tracitestclient_main.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include <iostream>
00031 #include <string>
00032 #include <cstdlib>
00033 #include "TraCITestClient.h"
00034 
00035 
00036 // ===========================================================================
00037 // used namespaces
00038 // ===========================================================================
00039 using namespace testclient;
00040 
00041 
00042 // ===========================================================================
00043 // method definitions
00044 // ===========================================================================
00045 int main(int argc, char* argv[]) {
00046     std::string defFile = "";
00047     std::string outFileName = "testclient_out.txt";
00048     int port = -1;
00049     std::string host = "localhost";
00050     TraCITestClient* client;
00051 
00052     if ((argc == 1) || (argc % 2 == 0)) {
00053         std::cout << "Usage: TraciTestClient -def <definition_file>  -p <remote port>"
00054                   << "[-h <remote host>] [-o <outputfile name>]" << std::endl;
00055         return 0;
00056     }
00057 
00058     for (int i=1; i < argc; i++) {
00059         std::string arg = argv[i];
00060         if (arg.compare("-def") == 0) {
00061             defFile = argv[i+1];
00062             i++;
00063         } else if (arg.compare("-o") == 0) {
00064             outFileName = argv[i+1];
00065             i++;
00066         } else if (arg.compare("-p") == 0) {
00067             port = atoi(argv[i+1]);
00068             i++;
00069         } else if (arg.compare("-h") == 0) {
00070             host = argv[i+1];
00071             i++;
00072         } else {
00073             std::cout << "unknown parameter: " << argv[i] << std::endl;
00074             return 1;
00075         }
00076     }
00077 
00078     if (port == -1) {
00079         std::cout << "Missing port" << std::endl;
00080         return 1;
00081     }
00082     if (defFile.compare("") == 0) {
00083         std::cout << "Missing definition file" << std::endl;
00084         return 1;
00085     }
00086 
00087     client = new TraCITestClient(outFileName);
00088     bool success = client->run(defFile, port, host);
00089     delete client;
00090 
00091     return !success;
00092 }

Generated on Wed May 5 00:06:37 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6