Revision: 9831
http://sumo.svn.sourceforge.net/sumo/?rev=9831&view=rev
Author: dkrajzew
Date: 2011-03-02 11:49:04 +0000 (Wed, 02 Mar 2011)
Log Message:
-----------
catching and reporting occupied port, refs#309
Modified Paths:
--------------
trunk/sumo/src/gui/GUIApplicationWindow.cpp
trunk/sumo/src/gui/GUIApplicationWindow.h
trunk/sumo/src/traci-server/TraCIServer.cpp
trunk/sumo/src/traci-server/TraCIServer.h
Modified: trunk/sumo/src/gui/GUIApplicationWindow.cpp
===================================================================
--- trunk/sumo/src/gui/GUIApplicationWindow.cpp 2011-03-02 07:45:39 UTC (rev 9830)
+++ trunk/sumo/src/gui/GUIApplicationWindow.cpp 2011-03-02 11:49:04 UTC (rev 9831)
@@ -832,6 +832,22 @@
GUIApplicationWindow::handleEvent_SimulationLoaded(GUIEvent *e) {
myAmLoading = false;
GUIEvent_SimulationLoaded *ec = static_cast<GUIEvent_SimulationLoaded*>(e);
+ if (ec->myNet!=0) {
+#ifndef NO_TRACI
+ std::map<int, traci::TraCIServer::CmdExecutor> execs;
+ execs[CMD_GET_GUI_VARIABLE] = &TraCIServerAPI_GUI::processGet;
+ execs[CMD_SET_GUI_VARIABLE] = &TraCIServerAPI_GUI::processSet;
+ try {
+ traci::TraCIServer::openSocket(execs);
+ } catch (ProcessError &e) {
+ myMessageWindow->appendText(EVENT_ERROR_OCCURED, e.what());
+ MsgHandler::getErrorInstance()->inform(e.what());
+ delete ec->myNet;
+ ec->myNet = 0;
+ }
+#endif
+ }
+
// check whether the loading was successfull
if (ec->myNet==0) {
// report failure
@@ -843,12 +859,6 @@
} else {
// report success
setStatusBarText("'" + ec->myFile + "' loaded.");
-#ifndef NO_TRACI
- std::map<int, traci::TraCIServer::CmdExecutor> execs;
- execs[CMD_GET_GUI_VARIABLE] = &TraCIServerAPI_GUI::processGet;
- execs[CMD_SET_GUI_VARIABLE] = &TraCIServerAPI_GUI::processSet;
- traci::TraCIServer::jt(execs);
-#endif
// initialise simulation thread
myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd);
myWasStarted = false;
@@ -1068,7 +1078,7 @@
bool
-GUIApplicationWindow::loadSelection(const std::string &file, std::string &msg) throw() {
+GUIApplicationWindow::loadSelection(const std::string &file, std::string &msg) {
return GUISelectionLoader::loadSelection(file, msg);
}
Modified: trunk/sumo/src/gui/GUIApplicationWindow.h
===================================================================
--- trunk/sumo/src/gui/GUIApplicationWindow.h 2011-03-02 07:45:39 UTC (rev 9830)
+++ trunk/sumo/src/gui/GUIApplicationWindow.h 2011-03-02 11:49:04 UTC (rev 9831)
@@ -172,7 +172,7 @@
* @return Whether the selection could be loaded (fills the error message if not)
* @see GUIMainWindow::loadSelection
*/
- bool loadSelection(const std::string &file, std::string &msg) throw();
+ bool loadSelection(const std::string &file, std::string &msg);
protected:
virtual void addToWindowsMenu(FXMenuPane *) { }
Modified: trunk/sumo/src/traci-server/TraCIServer.cpp
===================================================================
--- trunk/sumo/src/traci-server/TraCIServer.cpp 2011-03-02 07:45:39 UTC (rev 9830)
+++ trunk/sumo/src/traci-server/TraCIServer.cpp 2011-03-02 11:49:04 UTC (rev 9831)
@@ -115,7 +115,7 @@
// ===========================================================================
void
-TraCIServer::jt(const std::map<int, CmdExecutor> &execs) throw() {
+TraCIServer::openSocket(const std::map<int, CmdExecutor> &execs) {
if (instance_ == 0) {
if (!closeConnection_ && OptionsCont::getOptions().getInt("remote-port") != 0) {
instance_ = new traci::TraCIServer();
@@ -267,12 +267,11 @@
} catch (SocketException &e) {
throw ProcessError(e.what());
}
-
}
/*****************************************************************************/
-TraCIServer::~TraCIServer() throw() {
+TraCIServer::~TraCIServer() {
MSNet::getInstance()->removeVehicleStateListener(this);
if (socket_ != NULL) {
socket_->close();
@@ -295,7 +294,7 @@
/*****************************************************************************/
void
-TraCIServer::vehicleStateChanged(const SUMOVehicle * const vehicle, MSNet::VehicleState to) throw() {
+TraCIServer::vehicleStateChanged(const SUMOVehicle * const vehicle, MSNet::VehicleState to) {
if (closeConnection_ || OptionsCont::getOptions().getInt("remote-port") == 0) {
return;
}
@@ -304,7 +303,7 @@
/*****************************************************************************/
void
-TraCIServer::processCommandsUntilSimStep(SUMOTime step) throw(ProcessError) {
+TraCIServer::processCommandsUntilSimStep(SUMOTime step) {
try {
if (instance_ == 0) {
if (!closeConnection_ && OptionsCont::getOptions().getInt("remote-port") != 0) {
@@ -384,8 +383,7 @@
/*****************************************************************************/
int
-TraCIServer::dispatchCommand()
-throw(TraCIException, std::invalid_argument) {
+TraCIServer::dispatchCommand() {
unsigned int commandStart = myInputStorage.position();
unsigned int commandLength = myInputStorage.readUnsignedByte();
if (commandLength==0) {
@@ -485,7 +483,7 @@
/*****************************************************************************/
void
-TraCIServer::postProcessSimulationStep() throw(TraCIException, std::invalid_argument) {
+TraCIServer::postProcessSimulationStep() {
// Position representation
int resType = myInputStorage.readUnsignedByte();
if (resType != POSITION_NONE && resType != POSITION_2D && resType != POSITION_ROADMAP
@@ -629,7 +627,7 @@
void
-TraCIServer::postProcessSimulationStep2() throw(TraCIException, std::invalid_argument) {
+TraCIServer::postProcessSimulationStep2() {
SUMOTime t = MSNet::getInstance()->getCurrentTimeStep();
writeStatusCmd(CMD_SIMSTEP2, RTYPE_OK, "");
int noActive = 0;
@@ -668,7 +666,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandGetVersion() throw(TraCIException) {
+TraCIServer::commandGetVersion() {
int apiVersion = 1;
std::string sumoVersion = VERSION_STRING;
@@ -694,7 +692,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandCloseConnection() throw(TraCIException) {
+TraCIServer::commandCloseConnection() {
closeConnection_ = true;
// write answer
writeStatusCmd(CMD_CLOSE, RTYPE_OK, "Goodbye");
@@ -704,7 +702,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandSimulationParameter() throw(TraCIException) {
+TraCIServer::commandSimulationParameter() {
bool setParameter = (myInputStorage.readByte() != 0);
std::string parameter = myInputStorage.readString();
@@ -792,7 +790,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandUpdateCalibrator() throw(TraCIException) {
+TraCIServer::commandUpdateCalibrator() {
myOutputStorage.reset();
int countTime = myInputStorage.readInt();
@@ -809,7 +807,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandPositionConversion() throw(TraCIException) {
+TraCIServer::commandPositionConversion() {
tcpip::Storage tmpResult;
RoadMapPos roadPos;
Position2D cartesianPos;
@@ -913,7 +911,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandScenario() throw(TraCIException) {
+TraCIServer::commandScenario() {
Storage tmpResult;
std::string warning = ""; // additional description for response
@@ -970,7 +968,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandAddVehicle() throw(TraCIException) {
+TraCIServer::commandAddVehicle() {
// read parameters
std::string vehicleId = myInputStorage.readString();
@@ -1058,7 +1056,7 @@
/*****************************************************************************/
bool
-TraCIServer::commandDistanceRequest() throw(TraCIException) {
+TraCIServer::commandDistanceRequest() {
Position2D pos1;
Position2D pos2;
RoadMapPos roadPos1;
@@ -1405,8 +1403,7 @@
/*****************************************************************************/
Position2D
-TraCIServer::convertRoadMapToCartesian(traci::TraCIServer::RoadMapPos roadPos)
-throw(TraCIException) {
+TraCIServer::convertRoadMapToCartesian(traci::TraCIServer::RoadMapPos roadPos) {
if (roadPos.pos < 0) {
throw TraCIException("Position on lane must not be negative");
}
@@ -1430,8 +1427,7 @@
/*****************************************************************************/
std::string
-TraCIServer::handleRoadMapDomain(bool isWriteCommand, tcpip::Storage& response)
-throw(TraCIException) {
+TraCIServer::handleRoadMapDomain(bool isWriteCommand, tcpip::Storage& response) {
std::string name = "";
std::string warning = ""; // additional description for response
DataTypeContainer dataCont;
@@ -1551,8 +1547,7 @@
/*****************************************************************************/
std::string
-TraCIServer::handleVehicleDomain(bool isWriteCommand, tcpip::Storage& response)
-throw(TraCIException) {
+TraCIServer::handleVehicleDomain(bool isWriteCommand, tcpip::Storage& response) {
std::string name;
int count = 0;
MSVehicleControl* vehControl = NULL;
@@ -1929,8 +1924,7 @@
/*****************************************************************************/
std::string
-TraCIServer::handleTrafficLightDomain(bool isWriteCommand, tcpip::Storage& response)
-throw(TraCIException) {
+TraCIServer::handleTrafficLightDomain(bool isWriteCommand, tcpip::Storage& response) {
int count = 0;
std::string name;
std::string warning = ""; // additional description for response
@@ -2151,8 +2145,7 @@
/*****************************************************************************/
std::string
-TraCIServer::handlePoiDomain(bool isWriteCommand, tcpip::Storage& response)
-throw(TraCIException) {
+TraCIServer::handlePoiDomain(bool isWriteCommand, tcpip::Storage& response) {
std::string name;
std::string warning = ""; // additional description for response
DataTypeContainer dataCont;
@@ -2276,8 +2269,7 @@
/*****************************************************************************/
std::string
-TraCIServer::handlePolygonDomain(bool isWriteCommand, tcpip::Storage& response)
-throw(TraCIException) {
+TraCIServer::handlePolygonDomain(bool isWriteCommand, tcpip::Storage& response) {
std::string name;
std::string warning = ""; // additional description for response
DataTypeContainer dataCont;
@@ -2418,8 +2410,7 @@
/*****************************************************************************/
void
-TraCIServer::handleLifecycleSubscriptions()
-throw(TraCIException) {
+TraCIServer::handleLifecycleSubscriptions() {
if (myLifecycleSubscriptions.count(DOM_VEHICLE) != 0) {
@@ -2449,8 +2440,7 @@
/*****************************************************************************/
void
-TraCIServer::handleDomainSubscriptions(const SUMOTime& currentTime, const map<int, const SUMOVehicle*>& activeEquippedVehicles)
-throw(TraCIException) {
+TraCIServer::handleDomainSubscriptions(const SUMOTime& currentTime, const map<int, const SUMOVehicle*>& activeEquippedVehicles) {
if (myDomainSubscriptions.count(DOM_VEHICLE) != 0) {
@@ -2507,7 +2497,7 @@
bool
-TraCIServer::addSubscription(int commandId) throw(TraCIException) {
+TraCIServer::addSubscription(int commandId) {
SUMOTime beginTime = myInputStorage.readInt();
SUMOTime endTime = myInputStorage.readInt();
std::string id = myInputStorage.readString();
@@ -2558,7 +2548,7 @@
bool
TraCIServer::processSingleSubscription(const Subscription &s, tcpip::Storage &writeInto,
- std::string &errors) throw(TraCIException) {
+ std::string &errors) {
bool ok = true;
tcpip::Storage outputStorage;
for (std::vector<int>::const_iterator i=s.variables.begin(); i!=s.variables.end(); ++i) {
Modified: trunk/sumo/src/traci-server/TraCIServer.h
===================================================================
--- trunk/sumo/src/traci-server/TraCIServer.h 2011-03-02 07:45:39 UTC (rev 9830)
+++ trunk/sumo/src/traci-server/TraCIServer.h 2011-03-02 11:49:04 UTC (rev 9831)
@@ -73,6 +73,13 @@
typedef bool(*CmdExecutor)(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage);
+ /** @brief Initialises the server
+ * @param[in] execs The (additional) command executors to use
+ */
+ static void openSocket(const std::map<int, CmdExecutor> &execs);
+
+
+
struct RoadMapPos {
std::string roadId;
float pos;
@@ -82,7 +89,7 @@
};
// process all commands until a simulation step is wanted
- static void processCommandsUntilSimStep(SUMOTime step) throw(ProcessError);
+ static void processCommandsUntilSimStep(SUMOTime step);
// check whether close was requested
static bool wasClosed();
@@ -90,7 +97,7 @@
// check whether close was requested
static void close();
- void vehicleStateChanged(const SUMOVehicle * const vehicle, MSNet::VehicleState to) throw();
+ void vehicleStateChanged(const SUMOVehicle * const vehicle, MSNet::VehicleState to);
// return vehicle that is referenced by the given external id
MSVehicle* getVehicleByExtId(int extId);
@@ -114,7 +121,7 @@
*/
TraCIServer::RoadMapPos convertCartesianToRoadMap(Position2D pos);
- const std::map<MSNet::VehicleState, std::vector<std::string> > &getVehicleStateChanges() const throw() {
+ const std::map<MSNet::VehicleState, std::vector<std::string> > &getVehicleStateChanges() const {
return myVehicleStateChanges;
}
@@ -125,13 +132,13 @@
* than within this container
* @return Mapped command executors
*/
- std::map<int, CmdExecutor> &getExecutors() throw() {
+ std::map<int, CmdExecutor> &getExecutors() {
return myExecutors;
}
- static void jt(const std::map<int, CmdExecutor> &execs) throw();
+
private:
// Constructor
@@ -140,9 +147,9 @@
// Destructor
// final cleanup
- virtual ~TraCIServer(void) throw();
+ virtual ~TraCIServer(void);
- int dispatchCommand() throw(TraCIException, std::invalid_argument);
+ int dispatchCommand();
// process command simStep
// This is the basic comman that encourage the mobility generator to simulate up to the given TargetTime.
@@ -151,16 +158,16 @@
// But node positions can be represented in many more ways, e.g. 2.5D, 3D or as points on a road network.
// The desired representation of positions is given by the entry ResultType.
// If more than one representation is needed, the command simulation step can be sent several times with the same Target Time and different ResultTypes.
- void postProcessSimulationStep() throw(TraCIException, std::invalid_argument);
- void postProcessSimulationStep2() throw(TraCIException, std::invalid_argument);
+ void postProcessSimulationStep();
+ void postProcessSimulationStep2();
- bool commandGetVersion() throw(TraCIException);
+ bool commandGetVersion();
- bool commandCloseConnection() throw(TraCIException);
+ bool commandCloseConnection();
- bool commandSimulationParameter() throw(TraCIException);
+ bool commandSimulationParameter();
// process command slowDown
@@ -168,18 +175,18 @@
// given by duration. This simulates different methods of slowing down, like instant braking, coasting...
// It's assumed that the speed reduction is linear
// @param in contains nodeID(integer), speed (float), duration(double)
- bool commandSlowDown() throw(TraCIException);
+ bool commandSlowDown();
- bool commandUpdateCalibrator() throw(TraCIException);
+ bool commandUpdateCalibrator();
- bool commandPositionConversion() throw(TraCIException);
+ bool commandPositionConversion();
- bool commandScenario() throw(TraCIException);
+ bool commandScenario();
- bool commandAddVehicle() throw(TraCIException);
+ bool commandAddVehicle();
- bool commandDistanceRequest() throw(TraCIException);
+ bool commandDistanceRequest();
@@ -196,44 +203,44 @@
* @return string containing an optional warning (to be added to the response command) if
* the requested variable type could not be used
*/
- std::string handleRoadMapDomain(bool isWriteCommand, tcpip::Storage& response) throw(TraCIException);
+ std::string handleRoadMapDomain(bool isWriteCommand, tcpip::Storage& response);
/**
* Handles the request of a Scenario Command for obtaining information on
* the vehicle domain.
*/
- std::string handleVehicleDomain(bool isWriteCommand, tcpip::Storage& response) throw(TraCIException);
+ std::string handleVehicleDomain(bool isWriteCommand, tcpip::Storage& response);
/**
* Handles the request of a Scenario Command for obtaining information on
* the traffic light domain.
*/
- std::string handleTrafficLightDomain(bool isWriteCommand, tcpip::Storage& response) throw(TraCIException);
+ std::string handleTrafficLightDomain(bool isWriteCommand, tcpip::Storage& response);
/**
* Handles the request of a Scenario Command for obtaining information on
* the point of interest domain.
*/
- std::string handlePoiDomain(bool isWriteCommand, tcpip::Storage& response) throw(TraCIException);
+ std::string handlePoiDomain(bool isWriteCommand, tcpip::Storage& response);
/**
* Handles the request of a Scenario Command for obtaining information on
* the polygon domain.
*/
- std::string handlePolygonDomain(bool isWriteCommand, tcpip::Storage& response) throw(TraCIException);
+ std::string handlePolygonDomain(bool isWriteCommand, tcpip::Storage& response);
/**
* Notifies client of all lifecycle events it is subscribed to
*/
- void handleLifecycleSubscriptions() throw(TraCIException);
+ void handleLifecycleSubscriptions();
/**
* Notifies client of all domain object update events it is subscribed to
*/
- void handleDomainSubscriptions(const SUMOTime& currentTime, const std::map<int, const SUMOVehicle*>& activeEquippedVehicles) throw(TraCIException);
+ void handleDomainSubscriptions(const SUMOTime& currentTime, const std::map<int, const SUMOVehicle*>& activeEquippedVehicles);
- bool addSubscription(int commandId) throw(TraCIException);
+ bool addSubscription(int commandId);
/**
* Converts a road map position to a cartesian position
@@ -241,7 +248,7 @@
* @param pos road map position that is to be convertes
* @return closest 2D position
*/
- Position2D convertRoadMapToCartesian(TraCIServer::RoadMapPos pos) throw(TraCIException);
+ Position2D convertRoadMapToCartesian(TraCIServer::RoadMapPos pos);
// singleton instance of the server
static TraCIServer* instance_;
@@ -335,7 +342,7 @@
std::vector<Subscription> mySubscriptions;
bool processSingleSubscription(const TraCIServer::Subscription &s, tcpip::Storage &writeInto,
- std::string &errors) throw(TraCIException);
+ std::string &errors);
std::map<MSNet::VehicleState, std::vector<std::string> > myVehicleStateChanges;
@@ -358,7 +365,7 @@
public:
DataTypeContainer() :lastValueRead(-1) {};
- void readValue(unsigned char dataType, tcpip::Storage& msg) throw(TraCIException) {
+ void readValue(unsigned char dataType, tcpip::Storage& msg) {
switch (dataType) {
case TYPE_UBYTE:
intValue = msg.readUnsignedByte();
@@ -408,7 +415,7 @@
return lastValueRead;
}
- unsigned char getUByte() throw(TraCIException) {
+ unsigned char getUByte() {
if (lastValueRead == TYPE_UBYTE) {
return static_cast<unsigned char>(intValue);
} else {
@@ -416,7 +423,7 @@
}
};
- char getByte() throw(TraCIException) {
+ char getByte() {
if (lastValueRead == TYPE_BYTE) {
return static_cast<char>(intValue);
} else {
@@ -424,7 +431,7 @@
}
};
- int getInteger() throw(TraCIException) {
+ int getInteger() {
if (lastValueRead == TYPE_INTEGER) {
return intValue;
} else {
@@ -432,7 +439,7 @@
}
};
- float getFloat() throw(TraCIException) {
+ float getFloat() {
if (lastValueRead == TYPE_FLOAT) {
return static_cast<float>(realValue);
} else {
@@ -440,7 +447,7 @@
}
};
- double getDouble() throw(TraCIException) {
+ double getDouble() {
if (lastValueRead == TYPE_DOUBLE) {
return intValue;
} else {
@@ -448,7 +455,7 @@
}
};
- void getBoundingBox(float& x1, float& y1, float& x2, float& y2) throw(TraCIException) {
+ void getBoundingBox(float& x1, float& y1, float& x2, float& y2) {
if (lastValueRead == TYPE_BOUNDINGBOX) {
x1 = boundingBox[0];
y1 = boundingBox[1];
@@ -459,7 +466,7 @@
}
};
- TraCIServer::RoadMapPos getRoadMapPosition() throw(TraCIException) {
+ TraCIServer::RoadMapPos getRoadMapPosition() {
if (lastValueRead == POSITION_ROADMAP) {
return roadPosValue;
} else {
@@ -467,7 +474,7 @@
}
};
- void get3DPosition(float& inX, float& inY, float& inZ) throw(TraCIException) {
+ void get3DPosition(float& inX, float& inY, float& inZ) {
if (lastValueRead == POSITION_3D || lastValueRead == POSITION_2_5D) {
inX = posXValue;
inY = posYValue;
@@ -477,7 +484,7 @@
}
};
- void get2DPosition(float& inX, float& inY) throw(TraCIException) {
+ void get2DPosition(float& inX, float& inY) {
if (lastValueRead == POSITION_2D) {
inX = posXValue;
inY = posYValue;
@@ -486,7 +493,7 @@
}
};
- Position2D getAnyPosition() throw(TraCIException) {
+ Position2D getAnyPosition() {
if (lastValueRead == POSITION_2D
|| lastValueRead == POSITION_3D
|| lastValueRead == POSITION_2_5D) {
@@ -498,7 +505,7 @@
}
};
- std::string getString() throw(TraCIException) {
+ std::string getString() {
if (lastValueRead == TYPE_STRING) {
return stringValue;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|