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