MSNet Class Reference

#include <MSNet.h>

Inheritance diagram for MSNet:

GUINet

Detailed Description

The simulated network and simulation perfomer.

Definition at line 84 of file MSNet.h.


Notification about vehicle state changes

enum  VehicleState {
  VEHICLE_STATE_BUILT, VEHICLE_STATE_DEPARTED, VEHICLE_STATE_STARTING_TELEPORT, VEHICLE_STATE_ENDING_TELEPORT,
  VEHICLE_STATE_ARRIVED
}
 Definition of a vehicle state. More...
void addVehicleStateListener (VehicleStateListener *listener) throw ()
 Adds a vehicle states listener.
void informVehicleStateListener (const MSVehicle *const vehicle, VehicleState to) throw ()
 Informs all added listeners about a vehicle's state change.
void removeVehicleStateListener (VehicleStateListener *listener) throw ()
 Removes a vehicle states listener.

Public Types

enum  SimulationState {
  SIMSTATE_RUNNING, SIMSTATE_END_STEP_REACHED, SIMSTATE_NO_FURTHER_VEHICLES, SIMSTATE_CONNECTION_CLOSED,
  SIMSTATE_ERROR_IN_SIM, SIMSTATE_TOO_MANY_VEHICLES
}
 Possible states of a simulation - running or stopped with different reasons. More...

Public Member Functions

void closeBuilding (MSEdgeControl *edges, MSJunctionControl *junctions, MSRouteLoaderControl *routeLoaders, MSTLLogicControl *tlc, std::vector< SUMOTime > stateDumpTimes, std::vector< std::string > stateDumpFiles) throw ()
 Closes the network's building process.
void closeSimulation (SUMOTime start)
 Closes the simulation (all files, connections, etc.).
SUMOTime getCurrentTimeStep () const
 Returns the current simulation step (in s).
bool logSimulationDuration () const throw ()
 Returns whether duration shall be logged.
 MSNet (MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *emissionEvents, ShapeContainer *shapeCont=0) throw (ProcessError)
 Constructor.
int simulate (SUMOTime start, SUMOTime stop)
 Simulates from timestep start to stop.
SimulationState simulationState (SUMOTime stopTime) const throw ()
 Called after a simulation step, this method returns the current simulation state.
void simulationStep ()
 Performs a single simulation step.
void writeOutput ()
 Write netstate, emission and detector output.
virtual ~MSNet () throw ()
 Destructor.
Insertion and retrieval of bus stops
bool addBusStop (MSBusStop *busStop) throw ()
 Adds a bus stop.
MSBusStopgetBusStop (const std::string &id) throw ()
 Returns the named bus stop.
std::string getBusStopID (const MSLane *lane, const SUMOReal pos) throw ()
 Returns the bus stop close to the given position.
Retrieval of references to substructures
MSEventControlgetBeginOfTimestepEvents () throw ()
 Returns the event control for events executed at the begin of a time step.
MSDetectorControlgetDetectorControl () throw ()
 Returns the detector control.
MSEdgeControlgetEdgeControl () throw ()
 Returns the edge control.
MSEventControlgetEmissionEvents () throw ()
 Returns the event control for emission events.
MSEmitControlgetEmitControl () throw ()
 Returns the emission control.
MSEventControlgetEndOfTimestepEvents () throw ()
 Returns the event control for events executed at the end of a time step.
MSJunctionControlgetJunctionControl () throw ()
 Returns the junctions control.
MSPersonControlgetPersonControl () throw ()
 Returns the person control.
ShapeContainergetShapeContainer () throw ()
 Returns the shapes container.
MSTLLogicControlgetTLSControl () throw ()
 Returns the tls logics control.
MSVehicleControlgetVehicleControl () throw ()
 Returns the vehicle control.
MSEdgeWeightsStoragegetWeightsStorage () throw ()
 Returns the net's internal edge travel times/efforts container.
Output during the simulation
void postSimStepOutput () const throw ()
 Prints the statistics of the step at its end.
void preSimStepOutput () const throw ()
 Prints the current step number.

Static Public Member Functions

static void clearAll ()
 Clears all dictionaries.
static MSNetgetInstance () throw (ProcessError)
 Returns the pointer to the unique instance of MSNet (singleton).
static std::string getStateMessage (SimulationState state) throw ()
 Returns the message to show if a certain state occurs.

Protected Types

typedef std::map< std::string,
MSBusStop * > 
BusStopDictType
 Bus stop dictionary type.

Protected Attributes

BusStopDictType myBusStopDict
 Dictionary of bus stops.
MSRouteLoaderControlmyRouteLoaders
 Route loader for dynamic loading of routes.
SUMOTime myStep
 Current time step.
int myTooManyVehicles
 Storage for maximum vehicle number.
std::vector
< VehicleStateListener * > 
myVehicleStateListeners
 Container for vehicle state listener.
Substructures
MSEventControlmyBeginOfTimestepEvents
 Controls events executed at the begin of a time step;.
MSDetectorControlmyDetectorControl
 Controls detectors;.
MSEdgeControlmyEdges
 Controls edges, performs vehicle movement;.
MSEdgeWeightsStoragemyEdgeWeights
 The net's knowledge about edge efforts/travel times;.
MSEventControlmyEmissionEvents
 Controls emission events;.
MSEmitControlmyEmitter
 Controls vehicle emissions;.
MSEventControlmyEndOfTimestepEvents
 Controls events executed at the end of a time step;.
MSJunctionControlmyJunctions
 Controls junctions, realizes right-of-way rules;.
MSTLLogicControlmyLogics
 Controls tls logics, realizes waiting on tls rules;.
MSPersonControlmyPersonControl
 Controls person building and deletion;.
ShapeContainermyShapeContainer
 A container for geometrical shapes;.
MSVehicleControlmyVehicleControl
 Controls vehicle building and deletion;.
data needed for computing performance values
bool myLogExecutionTime
 Information whether the simulation duration shall be logged.
bool myLogStepNumber
 Information whether the number of the simulation step shall be logged.
long mySimBeginMillis
 The overall simulation duration.
long mySimStepBegin
 The last simulation step begin, end and duration.
long mySimStepDuration
long mySimStepEnd
long myVehiclesMoved
 The overall number of vehicle movements.
State output variables
std::vector< std::string > myStateDumpFiles
 The names for the state files.
std::vector< SUMOTimemyStateDumpTimes
 Times at which a state shall be written.

Static Protected Attributes

static MSNetmyInstance = 0
 Unique instance of MSNet.

Private Member Functions

 MSNet (const MSNet &)
 Invalidated copy constructor.
MSNetoperator= (const MSNet &)
 Invalidated assignment operator.

Data Structures

class  EdgeWeightsProxi
 A proxi for edge weights known by a vehicle/known globally. More...
class  VehicleStateListener
 Interface for objects listening to vehicle state changes. More...

Member Typedef Documentation

typedef std::map< std::string, MSBusStop* > MSNet::BusStopDictType [protected]

Bus stop dictionary type.

Definition at line 650 of file MSNet.h.


Member Enumeration Documentation

Possible states of a simulation - running or stopped with different reasons.

Enumerator:
SIMSTATE_RUNNING  The simulation is running.
SIMSTATE_END_STEP_REACHED  The final simulation step has been performed.
SIMSTATE_NO_FURTHER_VEHICLES  The simulation does not contain further vehicles.
SIMSTATE_CONNECTION_CLOSED  The connection to a client was closed by the client.
SIMSTATE_ERROR_IN_SIM  An error occured during the simulation step.
SIMSTATE_TOO_MANY_VEHICLES  The simulation contains too many vehicles (.

Deprecated:
)

Definition at line 89 of file MSNet.h.

Definition of a vehicle state.

Enumerator:
VEHICLE_STATE_BUILT  The vehicle was built, but has not yet departed.
VEHICLE_STATE_DEPARTED  The vehicle has departed (was inserted into the network).
VEHICLE_STATE_STARTING_TELEPORT  The vehicle started to teleport.
VEHICLE_STATE_ENDING_TELEPORT  The vehicle ended being teleported.
VEHICLE_STATE_ARRIVED  The vehicle arrived at his destination (is deleted).

Definition at line 436 of file MSNet.h.


Constructor & Destructor Documentation

MSNet::MSNet ( MSVehicleControl vc,
MSEventControl beginOfTimestepEvents,
MSEventControl endOfTimestepEvents,
MSEventControl emissionEvents,
ShapeContainer shapeCont = 0 
) throw (ProcessError)

Constructor.

This constructor builds a net of which only some basic structures are initialised. It prepares the network for being filled while loading. As soon as all edge/junction/traffic lights and other containers are build, they must be initialised using "closeBuilding".

Parameters:
[in] vc The vehicle control to use
[in] beginOfTimestepEvents The event control to use for simulation step begin events
[in] endOfTimestepEvents The event control to use for simulation step end events
[in] emissionEvents The event control to use for emission events
[in] shapeCont The shape container to use
Exceptions:
ProcessError If a network was already constructed
See also:
closeBuilding

Definition at line 152 of file MSNet.cpp.

References OptionsCont::getBool(), OptionsCont::getInt(), OptionsCont::getOptions(), OptionsCont::getString(), MSCORN::init(), myBeginOfTimestepEvents, myDetectorControl, myEdges, myEdgeWeights, myEmissionEvents, myEmitter, myEndOfTimestepEvents, myInstance, myJunctions, myLogExecutionTime, myLogics, myLogStepNumber, myPersonControl, myRouteLoaders, myShapeContainer, myStep, myTooManyVehicles, myVehicleControl, and string2time().

00154                                                             {
00155     if (myInstance!=0) {
00156         throw ProcessError("A network was already constructed.");
00157     }
00158     MSCORN::init();
00159     OptionsCont &oc = OptionsCont::getOptions();
00160     myStep = string2time(oc.getString("begin"));
00161     myLogExecutionTime = !oc.getBool("no-duration-log");
00162     myLogStepNumber = !oc.getBool("no-step-log");
00163     myTooManyVehicles = oc.getInt("too-many-vehicles");
00164     myEmitter = new MSEmitControl(*vc, (SUMOTime) oc.getInt("max-depart-delay"), oc.getBool("sloppy-emit"));// !!! SUMOTime-option
00165     myVehicleControl = vc;
00166     myDetectorControl = new MSDetectorControl();
00167     myEdges = 0;
00168     myJunctions = 0;
00169     myRouteLoaders = 0;
00170     myLogics = 0;
00171     myPersonControl = 0;
00172     myEdgeWeights = 0;
00173     myShapeContainer = shapeCont==0 ? new ShapeContainer() : shapeCont;
00174 
00175     myBeginOfTimestepEvents = beginOfTimestepEvents;
00176     myEndOfTimestepEvents = endOfTimestepEvents;
00177     myEmissionEvents = emissionEvents;
00178 
00179 #ifdef HAVE_MESOSIM
00180     if (MSGlobals::gUseMesoSim) {
00181         MSGlobals::gMesoNet = new MELoop();
00182     }
00183 #endif
00184     myInstance = this;
00185 }

MSNet::~MSNet (  )  throw () [virtual]

Destructor.

Definition at line 233 of file MSNet.cpp.

References clearAll(), GeoConvHelper::close(), myBeginOfTimestepEvents, myDetectorControl, myEdges, myEdgeWeights, myEmissionEvents, myEmitter, myEndOfTimestepEvents, myInstance, myJunctions, myLogics, myRouteLoaders, myShapeContainer, and myVehicleControl.

00233                       {
00234     // delete controls
00235     delete myJunctions;
00236     delete myDetectorControl;
00237     // delete mean data
00238     delete myEdges;
00239     delete myEmitter;
00240     delete myLogics;
00241     delete myRouteLoaders;
00242     delete myVehicleControl;
00243     delete myShapeContainer;
00244 #ifdef _MESSAGES
00245 #ifdef _DEBUG
00246     std::cout << "MSNet: clearing myMsgEmitter" << std::endl;
00247 #endif
00248     myMsgEmitter.clear();
00249 #ifdef _DEBUG
00250     std::cout << "MSNet: clearing msgEmitVec" << std::endl;
00251 #endif
00252     msgEmitVec.clear();
00253 #endif
00254 #ifdef HAVE_MESOSIM
00255     if (MSGlobals::gUseMesoSim) {
00256         delete MSGlobals::gMesoNet;
00257     }
00258 #endif
00259     delete myBeginOfTimestepEvents;
00260     delete myEndOfTimestepEvents;
00261     delete myEmissionEvents;
00262     delete myEdgeWeights;
00263     clearAll();
00264     GeoConvHelper::close();
00265     myInstance = 0;
00266 }

MSNet::MSNet ( const MSNet  )  [private]

Invalidated copy constructor.


Member Function Documentation

bool MSNet::addBusStop ( MSBusStop busStop  )  throw () [inline]

Adds a bus stop.

If another bus stop with the same id exists, false is returned. Otherwise, the bus stop is added to the internal bus stop container "myBusStopDict".

This control get responsible for deletion of the added bus stop.

Parameters:
[in] busStop The bus stop to add
Returns:
Whether the bus stop could be added

Definition at line 392 of file MSNet.h.

References myBusStopDict.

00392                                                 {
00393         if (myBusStopDict.find(busStop->getID()) == myBusStopDict.end()) {
00394             myBusStopDict[busStop->getID()] = busStop;
00395             return true;
00396         }
00397         return false;
00398     }

void MSNet::addVehicleStateListener ( VehicleStateListener listener  )  throw ()

Adds a vehicle states listener.

Parameters:
[in] listener The listener to add

Definition at line 617 of file MSNet.cpp.

References myVehicleStateListeners.

Referenced by traci::TraCIServer::TraCIServer().

00617                                                                      {
00618     if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener)==myVehicleStateListeners.end()) {
00619         myVehicleStateListeners.push_back(listener);
00620     }
00621 }

void MSNet::clearAll (  )  [static]

Clears all dictionaries.

Todo:
Try to move all this to the destructor

Definition at line 465 of file MSNet.cpp.

References MSRoute::clear(), MSLane::clear(), MSEdge::clear(), and MSVehicleTransfer::getInstance().

Referenced by GUILoadThread::run(), and ~MSNet().

00465                 {
00466     // clear container
00467     MSEdge::clear();
00468     MSLane::clear();
00469     MSRoute::clear();
00470     delete MSVehicleTransfer::getInstance();
00471 }

void MSNet::closeBuilding ( MSEdgeControl edges,
MSJunctionControl junctions,
MSRouteLoaderControl routeLoaders,
MSTLLogicControl tlc,
std::vector< SUMOTime stateDumpTimes,
std::vector< std::string >  stateDumpFiles 
) throw ()

Closes the network's building process.

Assigns the structures built while loading to this network.

Parameters:
[in] edges The control of edges which belong to this network
[in] junctions The control of junctions which belong to this network
[in] routeLoaders The route loaders used
[in] tlc The control of traffic lights which belong to this network
[in] stateDumpTimes List of time steps at which state shall be written
[in] stateDumpFiles Filenames for states
Todo:
Try to move all this to the constructor?

Definition at line 191 of file MSNet.cpp.

References MSCORN::CORN_OUT_EMISSIONS, MSCORN::CORN_OUT_OLDROUTES, MSCORN::CORN_OUT_TAZ, MSCORN::CORN_OUT_TRIPDURATIONS, MSCORN::CORN_OUT_VEHROUTES, MSCORN::CORN_VEH_SAVE_EDGE_EXIT, SysUtils::getCurrentMillis(), OptionsCont::getOptions(), myEdges, myJunctions, myLogExecutionTime, myLogics, myRouteLoaders, mySimBeginMillis, myStateDumpFiles, myStateDumpTimes, MSJunctionControl::postloadInitContainer(), and MSCORN::setWished().

Referenced by NLBuilder::buildNet().

00195                                                                   {
00196     myEdges = edges;
00197     myJunctions = junctions;
00198     myRouteLoaders = routeLoaders;
00199     myLogics = tlc;
00200     // save the time the network state shall be saved at
00201     myStateDumpTimes = stateDumpTimes;
00202     myStateDumpFiles = stateDumpFiles;
00203 
00204     // set requests/responses
00205     myJunctions->postloadInitContainer();
00206     // initialise outputs
00207     if (OptionsCont::getOptions().isSet("emissions-output")) {
00208         MSCORN::setWished(MSCORN::CORN_OUT_EMISSIONS);
00209     }
00210     if (OptionsCont::getOptions().isSet("tripinfo-output")) {
00211         MSCORN::setWished(MSCORN::CORN_OUT_TRIPDURATIONS);
00212     }
00213     if (OptionsCont::getOptions().isSet("vehroute-output")) {
00214         MSCORN::setWished(MSCORN::CORN_OUT_VEHROUTES);
00215         if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
00216             MSCORN::setWished(MSCORN::CORN_VEH_SAVE_EDGE_EXIT);
00217         }
00218         if (!OptionsCont::getOptions().getBool("vehroute-output.last-route")) {
00219             MSCORN::setWished(MSCORN::CORN_OUT_OLDROUTES);
00220         }
00221         if (OptionsCont::getOptions().getBool("device.routing.with-taz")) {
00222             MSCORN::setWished(MSCORN::CORN_OUT_TAZ);
00223         }
00224     }
00225 
00226     // initialise performance computation
00227     if (myLogExecutionTime) {
00228         mySimBeginMillis = SysUtils::getCurrentMillis();
00229     }
00230 }

void MSNet::closeSimulation ( SUMOTime  start  ) 

Closes the simulation (all files, connections, etc.).

Writes also performance output

Parameters:
[in] start The step the simulation was started with
Todo:
What exceptions may occure?

Definition at line 302 of file MSNet.cpp.

References traci::TraCIServer::close(), MSDetectorControl::close(), SysUtils::getCurrentMillis(), MSVehicleControl::getEmittedVehicleNo(), MSVehicleControl::getRunningVehicleNo(), MSEmitControl::getWaitingVehicleNo(), myDetectorControl, myEmitter, myLogExecutionTime, mySimBeginMillis, myStep, myVehicleControl, myVehiclesMoved, SUMOReal, and WRITE_MESSAGE.

Referenced by GUIRunThread::deleteSim(), and simulate().

00302                                      {
00303     if (myLogExecutionTime) {
00304         long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
00305         std::ostringstream msg;
00306         msg << "Performance: " << "\n" << " Duration: " << duration << " ms" << "\n";
00307         if (duration!=0) {
00308             msg << " Real time factor: " << ((SUMOReal)(myStep-start)*1000./(SUMOReal)duration) << "\n";
00309             msg.setf(std::ios::fixed , std::ios::floatfield);    // use decimal format
00310             msg.setf(std::ios::showpoint);    // print decimal point
00311             msg << " UPS: " << ((SUMOReal) myVehiclesMoved * 1000. / (SUMOReal) duration) << "\n";
00312         }
00313         msg << "Vehicles: " << "\n"
00314         << " Emitted: " << myVehicleControl->getEmittedVehicleNo() << "\n"
00315         << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
00316         << " Waiting: " << myEmitter->getWaitingVehicleNo() << "\n";
00317         WRITE_MESSAGE(msg.str());
00318     }
00319     myDetectorControl->close(myStep);
00320 #ifndef NO_TRACI
00321     traci::TraCIServer::close();
00322 #endif
00323 }

MSEventControl& MSNet::getBeginOfTimestepEvents (  )  throw () [inline]

Returns the event control for events executed at the begin of a time step.

Returns:
The control reponsible for events that are executed at the begin of a time step
See also:
MSEventControl

myBeginOfTimestepEvents

Definition at line 333 of file MSNet.h.

References myBeginOfTimestepEvents.

Referenced by NLTriggerBuilder::buildVaporizer(), MSSimpleTrafficLightLogic::changeStepAndDuration(), MSTLLogicControl::closeWAUT(), MSDevice_Routing::enterLaneAtEmit(), MSLaneSpeedTrigger::init(), and MSTrafficLightLogic::MSTrafficLightLogic().

00333                                                        {
00334         return *myBeginOfTimestepEvents;
00335     }

MSBusStop* MSNet::getBusStop ( const std::string &  id  )  throw () [inline]

Returns the named bus stop.

Parameters:
[in] id The id of the bus stop to return.
Returns:
The named bus stop, or 0 if no such stop exists

Definition at line 405 of file MSNet.h.

References myBusStopDict.

Referenced by MSVehicle::addStop(), and MSRouteHandler::myStartElement().

00405                                                        {
00406         BusStopDictType::iterator it = myBusStopDict.find(id);
00407         if (it == myBusStopDict.end()) {
00408             return 0;
00409         }
00410         return it->second;
00411     }

std::string MSNet::getBusStopID ( const MSLane lane,
const SUMOReal  pos 
) throw () [inline]

Returns the bus stop close to the given position.

Parameters:
[in] lane the lane of the bus stop to return.
[in] pos the position of the bus stop to return.
Returns:
The bus stop id on the location, or "" if no such stop exists

Definition at line 419 of file MSNet.h.

References MSBusStop::getEndLanePosition(), Named::getID(), MSBusStop::getLane(), myBusStopDict, and POSITION_EPS.

Referenced by MSVehicle::addTraciStop().

00419                                                                            {
00420         for (BusStopDictType::iterator it = myBusStopDict.begin(); it != myBusStopDict.end(); ++it) {
00421             MSBusStop *stop = it->second;
00422             if (&stop->getLane() == lane && fabs(stop->getEndLanePosition() - pos) < POSITION_EPS) {
00423                 return stop->getID();
00424             }
00425         }
00426         return "";
00427     }

SUMOTime MSNet::getCurrentTimeStep (  )  const

Returns the current simulation step (in s).

Returns:
the current simulation step

Definition at line 475 of file MSNet.cpp.

References myStep.

Referenced by MSVehicle::adaptSpeed(), traci::TraCIServer::addSubscription(), MSTLLogicControl::addWAUTJunction(), NLDetectorBuilder::buildE2Detector(), MSEmitter::childCheckEmit(), MSCalibrator::childCheckEmit(), NLJunctionControlBuilder::closeTrafficLightLogic(), MSTLLogicControl::closeWAUT(), MSInductLoop::collectVehiclesOnDet(), traci::TraCIServer::commandAddVehicle(), traci::TraCIServer::commandChangeRoute(), traci::TraCIServer::commandChangeTarget(), traci::TraCIServer::commandDistanceRequest(), traci::TraCIServer::commandSlowDown(), MSVehicle::enterLaneAtLaneChange(), MSPersonControl::erase(), Command_SaveTLCoupledLaneDet::execute(), Command_SaveTLCoupledDet::execute(), MSUnboundActuatedTrafficLightLogic::gapControl(), MSActuatedTrafficLightLogic::gapControl(), MSInductLoop::getCurrentOccupancy(), GUIApplicationWindow::getCurrentSimTime(), MSLaneSpeedTrigger::getCurrentSpeed(), MSEventControl::getCurrentTimeStep(), GUIApplicationWindow::handleEvent_SimulationLoaded(), GUIApplicationWindow::handleEvent_SimulationStep(), MSLaneSpeedTrigger::init(), MSTLLogicControl::initWautSwitch(), MSLane::isEmissionSuccess(), MSE3Collector::MSE3LeaveReminder::isStillActive(), MSE3Collector::MSE3EntryReminder::isStillActive(), main(), GUIRunThread::makeStep(), MSVehicle::moveFirstChecked(), MSVehicle::moveRegardingCritical(), MSTriggeredXMLReader::MSTriggeredXMLReader(), MSTriggeredXMLReader::myInit(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), MSVehicle::onDepart(), MSVehicle::onRemovalFromNet(), MSDevice_Routing::onTryEmit(), traci::TraCIServer::postProcessSimulationStep2(), TraCIServerAPI_Lane::processGet(), MSVehicle::processNextStop(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_TLS::processSet(), MSTriggeredRerouter::reroute(), GUIRunThread::run(), MSVehicleControl::scheduleVehicleRemoval(), MSVehicle::startLaneChange(), MSUnboundActuatedTrafficLightLogic::trySwitch(), MSSimpleTrafficLightLogic::trySwitch(), and MSActuatedTrafficLightLogic::trySwitch().

00475                                 {
00476     return myStep;
00477 }

MSDetectorControl& MSNet::getDetectorControl (  )  throw () [inline]

MSEdgeControl& MSNet::getEdgeControl (  )  throw () [inline]

Returns the edge control.

Returns:
The edge control
See also:
MSEdgeControl

myEdges

Definition at line 283 of file MSNet.h.

References myEdges.

Referenced by MSDevice_Routing::adaptEdgeEfforts(), MSDevice_Routing::buildVehicleDevices(), traci::TraCIServer::convertCartesianToRoadMap(), traci::TraCIServer::getNetBoundary(), and MSLane::isEmissionSuccess().

00283                                             {
00284         return *myEdges;
00285     }

MSEventControl& MSNet::getEmissionEvents (  )  throw () [inline]

MSEmitControl& MSNet::getEmitControl (  )  throw () [inline]

Returns the emission control.

Returns:
The emission control
See also:
MSEmitControl

myEmitter

Definition at line 293 of file MSNet.h.

References myEmitter.

Referenced by MSRouteHandler::closeFlow(), MSRouteHandler::closeVehicle(), GUINet::getParameterWindow(), and MSPerson::MSPersonStage_Driving::proceed().

00293                                             {
00294         return *myEmitter;
00295     }

MSEventControl& MSNet::getEndOfTimestepEvents (  )  throw () [inline]

Returns the event control for events executed at the end of a time step.

Returns:
The control reponsible for events that are executed at the end of a time step
See also:
MSEventControl

myEndOfTimestepEvents

Definition at line 343 of file MSNet.h.

References myEndOfTimestepEvents.

Referenced by MSDevice_Routing::buildVehicleDevices(), Command_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), MSDevice_HBEFA::enterLaneAtEmit(), and MSVTypeProbe::MSVTypeProbe().

00343                                                      {
00344         return *myEndOfTimestepEvents;
00345     }

MSNet * MSNet::getInstance ( void   )  throw (ProcessError) [static]

Returns the pointer to the unique instance of MSNet (singleton).

Returns:
Pointer to the unique MSNet-instance
Exceptions:
ProcessError If a network was not yet constructed

Definition at line 144 of file MSNet.cpp.

References myInstance.

Referenced by MSDevice_Routing::adaptEdgeEfforts(), MSVehicle::adaptSpeed(), MSEmitControl::add(), MSVehicle::addStop(), traci::TraCIServer::addSubscription(), MSVehicle::addTraciStop(), MSVehicleTransfer::addVeh(), MSTLLogicControl::addWAUTJunction(), GUITrafficLightLogicWrapper::begin2TrackPhases(), MSEmitter::MSEmitter_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSCalibrator::MSCalibrator_FileTriggeredChild::buildAndScheduleFlowVehicle(), NLTriggerBuilder::buildVaporizer(), MSVehicleControl::buildVehicle(), GUIVehicleControl::buildVehicle(), MSDevice_Routing::buildVehicleDevices(), MSSimpleTrafficLightLogic::changeStepAndDuration(), MSVehicleTransfer::checkEmissions(), MSEmitControl::checkFlows(), GUISUMOAbstractView::checkSnapshots(), MSEmitter::childCheckEmit(), MSRouteHandler::closeFlow(), MSRouteHandler::closePerson(), MSRouteHandler::closeRoute(), MSRouteHandler::closeVehicle(), MSRouteHandler::closeVehicleTypeDistribution(), MSTLLogicControl::closeWAUT(), MSInductLoop::collectVehiclesOnDet(), Command_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), traci::TraCIServer::commandAddVehicle(), traci::TraCIServer::commandChangeRoute(), traci::TraCIServer::commandChangeTarget(), traci::TraCIServer::commandDistanceRequest(), traci::TraCIServer::commandGetAllTLIds(), traci::TraCIServer::commandSlowDown(), traci::TraCIServer::convertCartesianToRoadMap(), NLDetectorBuilder::createEdgeLaneMeanData(), MSLane::detectCollisions(), GUITriggeredRerouter::drawGL(), GUILaneWrapper::drawGL(), MSDevice_Routing::enterLaneAtEmit(), MSDevice_HBEFA::enterLaneAtEmit(), MSVehicle::enterLaneAtLaneChange(), MSPersonControl::erase(), MSVTypeProbe::execute(), MSCalibrator::execute(), Command_SaveTLCoupledLaneDet::execute(), Command_SaveTLCoupledDet::execute(), FXIMPLEMENT(), MSUnboundActuatedTrafficLightLogic::gapControl(), MSActuatedTrafficLightLogic::gapControl(), MSInductLoop::getCurrentLength(), MSInductLoop::getCurrentOccupancy(), MSInductLoop::getCurrentPassedNumber(), MSLaneSpeedTrigger::getCurrentSpeed(), MSInductLoop::getCurrentSpeed(), MSEventControl::getCurrentTimeStep(), MSInductLoop::getCurrentVehicleIDs(), TraCIDijkstraRouter< E >::getEffort(), traci::TraCIServer::getNetBoundary(), MSInductLoop::getNVehContributed(), MSTLLogicControl::getPhaseDef(), traci::TraCIServer::getPoiByExtId(), traci::TraCIServer::getPolygonByExtId(), MSInductLoop::getTimestepsSinceLastDetection(), traci::TraCIServer::getTLLogicByExtId(), traci::TraCIServer::getVehicleByExtId(), GUINet::guiSimulationStep(), traci::TraCIServer::handlePoiDomain(), traci::TraCIServer::handlePolygonDomain(), traci::TraCIServer::handleRoadMapDomain(), traci::TraCIServer::handleTrafficLightDomain(), traci::TraCIServer::handleVehicleDomain(), MSLaneSpeedTrigger::init(), MSTLLogicControl::initWautSwitch(), MSEmitter::MSEmitter_FileTriggeredChild::inputEndReached(), MSCalibrator::MSCalibrator_FileTriggeredChild::inputEndReached(), MSLane::isEmissionSuccess(), MSInductLoop::isStillActive(), MSE3Collector::MSE3LeaveReminder::isStillActive(), MSE3Collector::MSE3EntryReminder::isStillActive(), MSLane::moveCritical(), MSVehicle::moveFirstChecked(), MSVehicle::moveRegardingCritical(), MSVehicle::moveRoutePointer(), MSCalibrator::MSCalibrator(), MSInductLoop::MSInductLoop(), MSMeanData_Harmonoise::MSMeanData_Harmonoise(), MSTrafficLightLogic::MSTrafficLightLogic(), MSTriggeredXMLReader::MSTriggeredXMLReader(), MSVehicle::MSVehicle(), MSVTypeProbe::MSVTypeProbe(), MSRouteHandler::myEndElement(), MSTriggeredXMLReader::myInit(), MSRouteHandler::myStartElement(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), MSVehicle::onDepart(), GUIViewTraffic::onGamingClick(), MSVehicle::onRemovalFromNet(), MSDevice_Routing::onTryEmit(), MSRouteHandler::openVehicleTypeDistribution(), traci::TraCIServer::postProcessSimulationStep(), traci::TraCIServer::postProcessSimulationStep2(), MSPerson::MSPersonStage_Driving::proceed(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_MeMeDetector::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_Edge::processGet(), MSVehicle::processNextStop(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_TLS::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Edge::processSet(), MSLane::push(), MSVehicle::reroute(), MSTriggeredRerouter::reroute(), MSVehicleControl::scheduleVehicleRemoval(), MSLane::setCritical(), GUIVehicle::Colorer::setFunctionalColor(), MSLaneSpeedTrigger::setOverriding(), MSLaneSpeedTrigger::setOverridingValue(), MSVehicle::startLaneChange(), traci::TraCIServer::TraCIServer(), MSUnboundActuatedTrafficLightLogic::trySwitch(), MSSimpleTrafficLightLogic::trySwitch(), MSActuatedTrafficLightLogic::trySwitch(), MSVehicleControl::vehicleEmitted(), GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute(), MSVehicle::~MSVehicle(), and traci::TraCIServer::~TraCIServer().

00144                                            {
00145     if (myInstance != 0) {
00146         return myInstance;
00147     }
00148     throw ProcessError("A network was not yet constructed.");
00149 }

MSJunctionControl& MSNet::getJunctionControl (  )  throw () [inline]

Returns the junctions control.

Returns:
The junctions control
See also:
MSJunctionControl

myJunctions

Definition at line 323 of file MSNet.h.

References myJunctions.

Referenced by traci::TraCIServer::handleTrafficLightDomain(), and TraCIServerAPI_Junction::processGet().

00323                                                     {
00324         return *myJunctions;
00325     }

MSPersonControl & MSNet::getPersonControl (  )  throw ()

Returns the person control.

If the person control does not exist, yet, it is created.

Returns:
The person control
See also:
MSPersonControl

myPersonControl

Definition at line 564 of file MSNet.cpp.

References myPersonControl.

Referenced by MSRouteHandler::closePerson(), MSPerson::proceed(), MSPerson::MSPersonStage_Waiting::proceed(), MSPerson::MSPersonStage_Driving::proceed(), MSPerson::MSPersonStage_Walking::proceed(), and MSVehicle::processNextStop().

00564                                 {
00565     if (myPersonControl==0) {
00566         myPersonControl = new MSPersonControl();
00567     }
00568     return *myPersonControl;
00569 }

ShapeContainer& MSNet::getShapeContainer (  )  throw () [inline]

std::string MSNet::getStateMessage ( MSNet::SimulationState  state  )  throw () [static]

Returns the message to show if a certain state occurs.

Returns:
Readable description of the state

Definition at line 444 of file MSNet.cpp.

References SIMSTATE_CONNECTION_CLOSED, SIMSTATE_END_STEP_REACHED, SIMSTATE_ERROR_IN_SIM, SIMSTATE_NO_FURTHER_VEHICLES, SIMSTATE_RUNNING, and SIMSTATE_TOO_MANY_VEHICLES.

Referenced by GUIApplicationWindow::handleEvent_SimulationEnded(), and simulate().

00444                                                          {
00445     switch (state) {
00446     case MSNet::SIMSTATE_RUNNING:
00447         return "";
00448     case MSNet::SIMSTATE_END_STEP_REACHED:
00449         return "The final simulation step has been reached.";
00450     case MSNet::SIMSTATE_NO_FURTHER_VEHICLES:
00451         return "All vehicles have left the simulation.";
00452     case MSNet::SIMSTATE_CONNECTION_CLOSED:
00453         return "TraCI requested termination.";
00454     case MSNet::SIMSTATE_ERROR_IN_SIM:
00455         return "Reason: An error occured (see log).";
00456     case MSNet::SIMSTATE_TOO_MANY_VEHICLES:
00457         return "Too many vehicles.";
00458     default:
00459         return "Unknown reason.";
00460     }
00461 }

MSTLLogicControl& MSNet::getTLSControl (  )  throw () [inline]

MSVehicleControl& MSNet::getVehicleControl (  )  throw () [inline]

MSEdgeWeightsStorage & MSNet::getWeightsStorage (  )  throw ()

Returns the net's internal edge travel times/efforts container.

If the net does not have such a container, it is built.

Returns:
The net's knowledge about edge weights

Definition at line 573 of file MSNet.cpp.

References myEdgeWeights.

Referenced by traci::TraCIServer::commandChangeRoute(), traci::TraCIServer::commandChangeTarget(), traci::TraCIServer::postProcessSimulationStep(), TraCIServerAPI_Vehicle::processSet(), and TraCIServerAPI_Edge::processSet().

00573                                  {
00574     if (myEdgeWeights==0) {
00575         myEdgeWeights = new MSEdgeWeightsStorage();
00576     }
00577     return *myEdgeWeights;
00578 }

void MSNet::informVehicleStateListener ( const MSVehicle *const   vehicle,
VehicleState  to 
) throw ()

Informs all added listeners about a vehicle's state change.

Parameters:
[in] vehicle The vehicle which changed its state
[in] to The state the vehicle has changed to
See also:
VehicleStateListener:vehicleStateChanged

Definition at line 634 of file MSNet.cpp.

References myVehicleStateListeners.

Referenced by MSVehicleTransfer::addVeh(), MSVehicleControl::buildVehicle(), GUIVehicleControl::buildVehicle(), MSVehicleTransfer::checkEmissions(), MSVehicleControl::scheduleVehicleRemoval(), and MSVehicleControl::vehicleEmitted().

00634                                                                                           {
00635     for (std::vector<VehicleStateListener*>::iterator i=myVehicleStateListeners.begin(); i!=myVehicleStateListeners.end(); ++i) {
00636         (*i)->vehicleStateChanged(vehicle, to);
00637     }
00638 }

bool MSNet::logSimulationDuration (  )  const throw ()

Returns whether duration shall be logged.

Returns:
Whether duration shall be logged

Definition at line 513 of file MSNet.cpp.

References myLogExecutionTime.

Referenced by GUINet::getParameterWindow().

00513                                            {
00514     return myLogExecutionTime;
00515 }

MSNet& MSNet::operator= ( const MSNet  )  [private]

Invalidated assignment operator.

void MSNet::postSimStepOutput (  )  const throw ()

Prints the statistics of the step at its end.

Called on the end of a simulation step

Definition at line 589 of file MSNet.cpp.

References DELTA_T, MSVehicleControl::getEmittedVehicleNo(), MSVehicleControl::getRunningVehicleNo(), myLogExecutionTime, mySimStepDuration, myStep, myVehicleControl, OUTPUT_ACCURACY, SUMOReal, and time2string().

Referenced by simulate().

00589                                        {
00590     if (myLogExecutionTime) {
00591         std::string msg;
00592         std::ostringstream oss;
00593         oss.setf(std::ios::fixed , std::ios::floatfield);    // use decimal format
00594         oss.setf(std::ios::showpoint);    // print decimal point
00595         oss << std::setprecision(OUTPUT_ACCURACY);
00596         if (mySimStepDuration!=0) {
00597             oss << " (" << mySimStepDuration << "ms ~= "
00598             << (1000./ (SUMOReal) mySimStepDuration) << "*RT, ~"
00599             << ((SUMOReal) myVehicleControl->getRunningVehicleNo()/(SUMOReal) mySimStepDuration*1000.);
00600         } else {
00601             oss << " (0ms ?*RT. ?";
00602         }
00603         oss << "UPS, vehicles"
00604         << " TOT " << myVehicleControl->getEmittedVehicleNo()
00605         << " ACT " << myVehicleControl->getRunningVehicleNo()
00606         << ")                                              ";
00607         msg = oss.str();
00608         std::string prev = "Step #" + time2string(myStep-DELTA_T);
00609         msg = msg.substr(0, 78 - prev.length());
00610         std::cout << msg;
00611     }
00612     std::cout << (char) 13;
00613 }

void MSNet::preSimStepOutput (  )  const throw ()

Prints the current step number.

Called on the begin of a simulation step

Definition at line 582 of file MSNet.cpp.

References myStep, OUTPUT_ACCURACY, and time2string().

Referenced by simulate().

00582                                       {
00583     std::cout << std::setprecision(OUTPUT_ACCURACY);
00584     std::cout << "Step #" << time2string(myStep);
00585 }

void MSNet::removeVehicleStateListener ( VehicleStateListener listener  )  throw ()

Removes a vehicle states listener.

Parameters:
[in] listener The listener to remove

Definition at line 625 of file MSNet.cpp.

References myVehicleStateListeners.

Referenced by traci::TraCIServer::~TraCIServer().

00625                                                                         {
00626     std::vector<VehicleStateListener*>::iterator i= find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener);
00627     if (i!=myVehicleStateListeners.end()) {
00628         myVehicleStateListeners.erase(i);
00629     }
00630 }

int MSNet::simulate ( SUMOTime  start,
SUMOTime  stop 
)

Simulates from timestep start to stop.

Parameters:
[in] start The begin time step of the simulation
[in] stop The end time step of the simulation
Returns:
Returns always 0
Todo:
Recheck return value
Todo:
What exceptions may occure?

Definition at line 270 of file MSNet.cpp.

References closeSimulation(), OptionsCont::getOptions(), getStateMessage(), myLogStepNumber, myStep, postSimStepOutput(), preSimStepOutput(), SIMSTATE_RUNNING, simulationState(), simulationStep(), traci::TraCIServer::wasClosed(), and WRITE_MESSAGE.

Referenced by main().

00270                                              {
00271     // the simulation loop
00272     std::string quitMessage = "";
00273     myStep = start;
00274     do {
00275         if (myLogStepNumber) {
00276             preSimStepOutput();
00277         }
00278         simulationStep();
00279         if (myLogStepNumber) {
00280             postSimStepOutput();
00281         }
00282         MSNet::SimulationState state = simulationState(stop);
00283 #ifndef NO_TRACI
00284         if (state!=SIMSTATE_RUNNING) {
00285             if (OptionsCont::getOptions().getInt("remote-port")!=0&&!traci::TraCIServer::wasClosed()) {
00286                 state = SIMSTATE_RUNNING;
00287             }
00288         }
00289 #endif
00290         if (state!=SIMSTATE_RUNNING) {
00291             quitMessage = "Simulation End: " + getStateMessage(state);
00292         }
00293     } while (quitMessage=="");
00294     WRITE_MESSAGE(quitMessage);
00295     // exit simulation loop
00296     closeSimulation(start);
00297     return 0;
00298 }

MSNet::SimulationState MSNet::simulationState ( SUMOTime  stopTime  )  const throw ()

Called after a simulation step, this method returns the current simulation state.

Parameters:
[in] stopTime The time the simulation shall stop at
Returns:
The current simulation state
See also:
SimulationState

Definition at line 420 of file MSNet.cpp.

References OptionsCont::getInt(), OptionsCont::getOptions(), MSVehicleControl::getRunningVehicleNo(), MSEmitControl::hasPendingFlows(), MSVehicleControl::haveAllVehiclesQuit(), MSEventControl::isEmpty(), myEmissionEvents, myEmitter, myStep, myTooManyVehicles, myVehicleControl, SIMSTATE_CONNECTION_CLOSED, SIMSTATE_END_STEP_REACHED, SIMSTATE_NO_FURTHER_VEHICLES, SIMSTATE_RUNNING, SIMSTATE_TOO_MANY_VEHICLES, and traci::TraCIServer::wasClosed().

Referenced by GUIRunThread::makeStep(), and simulate().

00420                                                       {
00421     if (myTooManyVehicles>0&&(int) myVehicleControl->getRunningVehicleNo()>myTooManyVehicles) {
00422         return SIMSTATE_TOO_MANY_VEHICLES;
00423     }
00424 #ifndef NO_TRACI
00425     if (traci::TraCIServer::wasClosed()) {
00426         return SIMSTATE_CONNECTION_CLOSED;
00427     }
00428     if (stopTime < 0 && OptionsCont::getOptions().getInt("remote-port") == 0 && myVehicleControl->haveAllVehiclesQuit() && !myEmitter->hasPendingFlows()) {
00429 #else
00430     if (stopTime < 0 && myVehicleControl->haveAllVehiclesQuit() && !myEmitter->hasPendingFlows()) {
00431 #endif
00432         if (myEmissionEvents->isEmpty()) {
00433             return SIMSTATE_NO_FURTHER_VEHICLES;
00434         }
00435     }
00436     if (stopTime >= 0 && myStep >= stopTime) {
00437         return SIMSTATE_END_STEP_REACHED;
00438     }
00439     return SIMSTATE_RUNNING;
00440 }

void MSNet::simulationStep (  ) 

Performs a single simulation step.

Todo:
Which exceptions may occur?

Definition at line 327 of file MSNet.cpp.

References MSEdgeControl::changeLanes(), MSTLLogicControl::check2Switch(), MSVehicleTransfer::checkEmissions(), DELTA_T, MSEdgeControl::detectCollisions(), MSEmitControl::emitVehicles(), MSEventControl::execute(), MSGlobals::gCheck4Accidents, SysUtils::getCurrentMillis(), MSVehicleTransfer::getInstance(), MSVehicleControl::getRunningVehicleNo(), MSPersonControl::hasArrivedPersons(), MSRouteLoaderControl::loadNext(), MSEdgeControl::moveCritical(), MSEdgeControl::moveFirst(), myBeginOfTimestepEvents, myEdges, myEmissionEvents, myEmitter, myEndOfTimestepEvents, myJunctions, myLogExecutionTime, myLogics, myPersonControl, myRouteLoaders, mySimStepBegin, mySimStepDuration, mySimStepEnd, myStateDumpFiles, myStateDumpTimes, myStep, myVehicleControl, myVehiclesMoved, MSEdgeControl::patchActiveLanes(), MSPersonControl::popArrivedPersons(), traci::TraCIServer::processCommandsUntilSimStep(), MSJunctionControl::setAllowed(), MSTLLogicControl::setTrafficLightSignals(), and writeOutput().

Referenced by GUIRunThread::makeStep(), and simulate().

00327                       {
00328 #ifndef NO_TRACI
00329     traci::TraCIServer::processCommandsUntilSimStep(myStep);
00330 #endif
00331     // execute beginOfTimestepEvents
00332     if (myLogExecutionTime) {
00333         mySimStepBegin = SysUtils::getCurrentMillis();
00334     }
00335 #ifdef HAVE_MESOSIM
00336     // netstate output
00337     std::vector<SUMOTime>::iterator timeIt = find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep);
00338     if (timeIt!=myStateDumpTimes.end()) {
00339         const int dist = distance(myStateDumpTimes.begin(), timeIt);
00340         std::ofstream strm(myStateDumpFiles[dist].c_str(), std::fstream::out|std::fstream::binary);
00341         saveState(strm);
00342     }
00343 #endif
00344     myBeginOfTimestepEvents->execute(myStep);
00345     if (MSGlobals::gCheck4Accidents) {
00346         myEdges->detectCollisions(myStep);
00347     }
00348 #ifdef HAVE_MESOSIM
00349     if (MSGlobals::gUseMesoSim) {
00350         myJunctions->setAllowed();
00351         MSGlobals::gMesoNet->simulate(myStep);
00352     } else {
00353 #endif
00354         // check whether the tls shall be switched
00355         myLogics->check2Switch(myStep);
00356         // set information about which vehicles may drive at all
00357         myLogics->setTrafficLightSignals();
00358 
00359 
00360         // assure all lanes with vehicles are 'active'
00361         myEdges->patchActiveLanes();
00362 
00363         // move vehicles
00364         //  precompute possible positions for vehicles that do interact with
00365         //   their lane's end
00366         myEdges->moveCritical(myStep);
00367 
00368         // move vehicles which do interact with their lane's end
00369         //  (it is now known whether they may drive
00370         myEdges->moveFirst(myStep);
00371         if (MSGlobals::gCheck4Accidents) {
00372             myEdges->detectCollisions(myStep);
00373         }
00374 
00375         // Vehicles change Lanes (maybe)
00376         myEdges->changeLanes(myStep);
00377 
00378         if (MSGlobals::gCheck4Accidents) {
00379             myEdges->detectCollisions(myStep);
00380         }
00381 #ifdef HAVE_MESOSIM
00382     }
00383 #endif
00384     // load routes
00385     myRouteLoaders->loadNext(myStep, myEmitter);
00386 
00387     // persons
00388     if (myPersonControl!=0) {
00389         while (myPersonControl->hasArrivedPersons(myStep)) {
00390             const MSPersonControl::PersonVector &persons = myPersonControl->popArrivedPersons(myStep);
00391             for (MSPersonControl::PersonVector::const_iterator i=persons.begin(); i!=persons.end(); ++i) {
00392                 (*i)->proceed(this, myStep);
00393             }
00394         }
00395     }
00396     // emit Vehicles
00397     myEmitter->emitVehicles(myStep);
00398     if (MSGlobals::gCheck4Accidents) {
00399         myEdges->detectCollisions(myStep);
00400     }
00401     MSVehicleTransfer::getInstance()->checkEmissions(myStep);
00402     myEmissionEvents->execute(myStep);
00403 
00404     // execute endOfTimestepEvents
00405     myEndOfTimestepEvents->execute(myStep);
00406 
00407     // update and write (if needed) detector values
00408     writeOutput();
00409 
00410     if (myLogExecutionTime) {
00411         mySimStepEnd = SysUtils::getCurrentMillis();
00412         mySimStepDuration = mySimStepEnd - mySimStepBegin;
00413         myVehiclesMoved += myVehicleControl->getRunningVehicleNo();
00414     }
00415     myStep += DELTA_T;
00416 }

void MSNet::writeOutput (  ) 

Write netstate, emission and detector output.

Todo:
Which exceptions may occur?

Definition at line 481 of file MSNet.cpp.

References DELTA_T, OutputDevice::getDeviceByOption(), MSVehicleControl::getEmittedVehicleNo(), MSVehicleControl::getEndedVehicleNo(), MSVehicleControl::getLoadedVehicleNo(), MSVehicleControl::getMeanTravelTime(), MSVehicleControl::getMeanWaitingTime(), OptionsCont::getOptions(), MSVehicleControl::getRunningVehicleNo(), MSEmitControl::getWaitingVehicleNo(), myDetectorControl, myEdges, myEmitter, myLogExecutionTime, mySimStepDuration, myStep, myVehicleControl, time2string(), MSDetectorControl::updateDetectors(), MSXMLRawOut::write(), and MSDetectorControl::writeOutput().

Referenced by simulationStep().

00481                    {
00482     // update detector values
00483     myDetectorControl->updateDetectors(myStep);
00484     // check state dumps
00485     if (OptionsCont::getOptions().isSet("netstate-dump")) {
00486         MSXMLRawOut::write(OutputDevice::getDeviceByOption("netstate-dump"), *myEdges, myStep);
00487     }
00488     // emission output
00489     if (OptionsCont::getOptions().isSet("emissions-output")) {
00490         std::string wt = myVehicleControl->getMeanWaitingTime() ? "-1.00" : time2string((SUMOTime) myVehicleControl->getMeanWaitingTime());
00491         std::string tt = myVehicleControl->getMeanTravelTime()<0 ? "-1.00" : time2string((SUMOTime) myVehicleControl->getMeanTravelTime());
00492         OutputDevice::getDeviceByOption("emissions-output")
00493         << "    <emission-state time=\"" << time2string(myStep) << "\" "
00494         << "loaded=\"" << myVehicleControl->getLoadedVehicleNo() << "\" "
00495         << "emitted=\"" << myVehicleControl->getEmittedVehicleNo() << "\" "
00496         << "running=\"" << myVehicleControl->getRunningVehicleNo() << "\" "
00497         << "waiting=\"" << myEmitter->getWaitingVehicleNo() << "\" "
00498         << "ended=\"" << myVehicleControl->getEndedVehicleNo() << "\" "
00499         << "meanWaitingTime=\"" << wt << "\" "
00500         << "meanTravelTime=\"" << tt << "\" ";
00501         if (myLogExecutionTime) {
00502             OutputDevice::getDeviceByOption("emissions-output")
00503             << "duration=\"" << mySimStepDuration << "\" ";
00504         }
00505         OutputDevice::getDeviceByOption("emissions-output") << "/>\n";
00506     }
00507     // write detector values
00508     myDetectorControl->writeOutput(myStep + DELTA_T, false);
00509 }


Field Documentation

Controls events executed at the begin of a time step;.

See also:
MSEventControl

Definition at line 601 of file MSNet.h.

Referenced by getBeginOfTimestepEvents(), MSNet(), simulationStep(), and ~MSNet().

Dictionary of bus stops.

Definition at line 652 of file MSNet.h.

Referenced by addBusStop(), getBusStop(), and getBusStopID().

Controls detectors;.

See also:
MSDetectorControl

Definition at line 599 of file MSNet.h.

Referenced by closeSimulation(), getDetectorControl(), GUINet::initDetectors(), MSNet(), writeOutput(), and ~MSNet().

Controls edges, performs vehicle movement;.

See also:
MSEdgeControl

Definition at line 591 of file MSNet.h.

Referenced by closeBuilding(), getEdgeControl(), MSNet(), simulationStep(), writeOutput(), and ~MSNet().

The net's knowledge about edge efforts/travel times;.

See also:
MSEdgeWeightsStorage

Definition at line 609 of file MSNet.h.

Referenced by getWeightsStorage(), MSNet(), and ~MSNet().

Controls emission events;.

See also:
MSEventControl

Definition at line 605 of file MSNet.h.

Referenced by getEmissionEvents(), MSNet(), simulationState(), simulationStep(), and ~MSNet().

Controls vehicle emissions;.

See also:
MSEmitControl

Definition at line 597 of file MSNet.h.

Referenced by closeSimulation(), getEmitControl(), MSNet(), simulationState(), simulationStep(), writeOutput(), and ~MSNet().

Controls events executed at the end of a time step;.

See also:
MSEventControl

Definition at line 603 of file MSNet.h.

Referenced by getEndOfTimestepEvents(), MSNet(), simulationStep(), and ~MSNet().

MSNet * MSNet::myInstance = 0 [static, protected]

Unique instance of MSNet.

Definition at line 573 of file MSNet.h.

Referenced by getInstance(), MSNet(), and ~MSNet().

Controls junctions, realizes right-of-way rules;.

See also:
MSJunctionControl

Definition at line 593 of file MSNet.h.

Referenced by closeBuilding(), getJunctionControl(), GUINet::getJunctionPosition(), GUINet::initGUIStructures(), MSNet(), simulationStep(), and ~MSNet().

Information whether the simulation duration shall be logged.

Definition at line 618 of file MSNet.h.

Referenced by closeBuilding(), closeSimulation(), logSimulationDuration(), MSNet(), postSimStepOutput(), simulationStep(), and writeOutput().

Controls tls logics, realizes waiting on tls rules;.

See also:
MSJunctionControl

Definition at line 595 of file MSNet.h.

Referenced by closeBuilding(), GUINet::getLinkTLID(), GUINet::getLinkTLIndex(), getTLSControl(), GUINet::initTLMap(), MSNet(), simulationStep(), and ~MSNet().

Information whether the number of the simulation step shall be logged.

Definition at line 621 of file MSNet.h.

Referenced by MSNet(), and simulate().

Controls person building and deletion;.

See also:
MSPersonControl

Definition at line 589 of file MSNet.h.

Referenced by getPersonControl(), MSNet(), and simulationStep().

Route loader for dynamic loading of routes.

Definition at line 576 of file MSNet.h.

Referenced by closeBuilding(), MSNet(), simulationStep(), and ~MSNet().

A container for geometrical shapes;.

See also:
ShapeContainer

Definition at line 607 of file MSNet.h.

Referenced by getShapeContainer(), GUINet::getShapeIDs(), MSNet(), and ~MSNet().

long MSNet::mySimBeginMillis [protected]

The overall simulation duration.

Definition at line 627 of file MSNet.h.

Referenced by closeBuilding(), and closeSimulation().

long MSNet::mySimStepBegin [protected]

The last simulation step begin, end and duration.

Definition at line 624 of file MSNet.h.

Referenced by simulationStep().

long MSNet::mySimStepDuration [protected]

Definition at line 624 of file MSNet.h.

Referenced by postSimStepOutput(), simulationStep(), and writeOutput().

long MSNet::mySimStepEnd [protected]

Definition at line 624 of file MSNet.h.

Referenced by simulationStep().

std::vector<std::string> MSNet::myStateDumpFiles [protected]

The names for the state files.

Definition at line 641 of file MSNet.h.

Referenced by closeBuilding(), and simulationStep().

std::vector<SUMOTime> MSNet::myStateDumpTimes [protected]

Times at which a state shall be written.

Definition at line 639 of file MSNet.h.

Referenced by closeBuilding(), and simulationStep().

SUMOTime MSNet::myStep [protected]

int MSNet::myTooManyVehicles [protected]

Storage for maximum vehicle number.

Definition at line 646 of file MSNet.h.

Referenced by MSNet(), and simulationState().

Controls vehicle building and deletion;.

See also:
MSVehicleControl

Definition at line 587 of file MSNet.h.

Referenced by closeSimulation(), getVehicleControl(), MSNet(), postSimStepOutput(), simulationState(), simulationStep(), GUINet::vehicleExists(), writeOutput(), and ~MSNet().

long MSNet::myVehiclesMoved [protected]

The overall number of vehicle movements.

Definition at line 630 of file MSNet.h.

Referenced by closeSimulation(), GUINet::getMeanUPS(), and simulationStep().

Container for vehicle state listener.

Definition at line 655 of file MSNet.h.

Referenced by addVehicleStateListener(), informVehicleStateListener(), and removeVehicleStateListener().


The documentation for this class was generated from the following files:

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