TraCIServerAPIHelper.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Some helper functions for communication
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 <utils/common/MsgHandler.h>
00031 #include <utils/common/ToString.h>
00032 #include "TraCIConstants.h"
00033 #include "TraCIServerAPIHelper.h"
00034 
00035 #ifdef CHECK_MEMORY_LEAKS
00036 #include <foreign/nvwa/debug_new.h>
00037 #endif // CHECK_MEMORY_LEAKS
00038 
00039 
00040 // ===========================================================================
00041 // used namespaces
00042 // ===========================================================================
00043 using namespace std;
00044 using namespace traci;
00045 using namespace tcpip;
00046 
00047 
00048 // ===========================================================================
00049 // method definitions
00050 // ===========================================================================
00051 void
00052 TraCIServerAPIHelper::writeStatusCmd(int commandId, int status,
00053                                      const std::string &description, tcpip::Storage &outputStorage) {
00054     if (status == RTYPE_ERR) {
00055         MsgHandler::getErrorInstance()->inform("Answered with error to command " + toString(commandId) +
00056                                                ": " + description);
00057     } else if (status == RTYPE_NOTIMPLEMENTED) {
00058         MsgHandler::getErrorInstance()->inform("Requested command not implemented (" + toString(commandId) +
00059                                                "): " + description);
00060     }
00061     // command length
00062     outputStorage.writeUnsignedByte(1 + 1 + 1 + 4 + static_cast<int>(description.length()));
00063     // command type
00064     outputStorage.writeUnsignedByte(commandId);
00065     // status
00066     outputStorage.writeUnsignedByte(status);
00067     // description
00068     outputStorage.writeString(description);
00069     return;
00070 }
00071 
00072 
00073 
00074 /****************************************************************************/
00075 

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