Command_SaveTLSSwitchStates Class Reference

#include <Command_SaveTLSSwitchStates.h>

Inheritance diagram for Command_SaveTLSSwitchStates:

Command

Detailed Description

Writes the switch times of a tls into a file when the tls switches.

Todo:
Revalidate this - as tls are not seting the link information directly ater being switched, the computed information may be delayed

Definition at line 54 of file Command_SaveTLSSwitchStates.h.


Public Member Functions

 Command_SaveTLSSwitchStates (const MSTLLogicControl::TLSLogicVariants &logics, OutputDevice &od) throw ()
 Constructor.
 ~Command_SaveTLSSwitchStates () throw ()
 Destructor.
Derived from Command
SUMOTime execute (SUMOTime currentTime) throw (ProcessError)
 Writes the state of the tls if a change occured.

Private Member Functions

 Command_SaveTLSSwitchStates (const Command_SaveTLSSwitchStates &)
 Invalidated copy constructor.
Command_SaveTLSSwitchStatesoperator= (const Command_SaveTLSSwitchStates &)
 Invalidated assignment operator.

Private Attributes

const
MSTLLogicControl::TLSLogicVariants
myLogics
 The traffic light logic to use.
OutputDevicemyOutputDevice
 The device to write to.
std::string myPreviousState
 Storage for prior state.
std::string myPreviousSubID
 Storage for prior sub-id.

Constructor & Destructor Documentation

Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates ( const MSTLLogicControl::TLSLogicVariants logics,
OutputDevice od 
) throw ()

Constructor.

Parameters:
[in] tlls The logic to write state of
[in] od The output device to write the state into

Definition at line 44 of file Command_SaveTLSSwitchStates.cpp.

References MSEventControl::ADAPT_AFTER_EXECUTION, MSEventControl::addEvent(), MSNet::getEndOfTimestepEvents(), and MSNet::getInstance().

00046         : myOutputDevice(od), myLogics(logics) {
00047     MSNet::getInstance()->getEndOfTimestepEvents().addEvent(this,
00048             0, MSEventControl::ADAPT_AFTER_EXECUTION);
00049     myOutputDevice.writeXMLHeader("tls-switch-states");
00050 }

Command_SaveTLSSwitchStates::~Command_SaveTLSSwitchStates (  )  throw ()

Destructor.

Definition at line 53 of file Command_SaveTLSSwitchStates.cpp.

00053                                                                   {
00054 }

Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates ( const Command_SaveTLSSwitchStates  )  [private]

Invalidated copy constructor.


Member Function Documentation

SUMOTime Command_SaveTLSSwitchStates::execute ( SUMOTime  currentTime  )  throw (ProcessError) [virtual]

Writes the state of the tls if a change occured.

If the state or the active program has changed, the state is written to the output device.

Returns always 1.

Parameters:
[in] currentTime The current simulation time
Returns:
Always 1 (will be executed in next time step)
Exceptions:
ProcessError not here
See also:
Command
Todo:
Here, a discrete even (on switch / program change) would be appropriate

Implements Command.

Definition at line 58 of file Command_SaveTLSSwitchStates.cpp.

References DELTA_T, MSTLLogicControl::TLSLogicVariants::getActive(), MSTrafficLightLogic::getCurrentPhaseDef(), MSTrafficLightLogic::getCurrentPhaseIndex(), MSTrafficLightLogic::getID(), MSPhaseDefinition::getState(), MSTrafficLightLogic::getSubID(), myLogics, myOutputDevice, myPreviousState, myPreviousSubID, and time2string().

00058                                                                              {
00059     const std::string &state = myLogics.getActive()->getCurrentPhaseDef().getState();
00060     if (state!=myPreviousState||myLogics.getActive()->getSubID()!=myPreviousSubID) {
00061         myOutputDevice << "    <tlsstate time=\"" << time2string(currentTime)
00062         << "\" id=\"" << myLogics.getActive()->getID()
00063         << "\" subid=\"" << myLogics.getActive()->getSubID()
00064         << "\" phase=\"" << myLogics.getActive()->getCurrentPhaseIndex()
00065         << "\" state=\"" << state << "\"/>\n";
00066         myPreviousState = state;
00067         myPreviousSubID = myLogics.getActive()->getSubID();
00068     }
00069     return DELTA_T;
00070 }

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

Invalidated assignment operator.


Field Documentation

The traffic light logic to use.

Definition at line 94 of file Command_SaveTLSSwitchStates.h.

Referenced by execute().

The device to write to.

Definition at line 91 of file Command_SaveTLSSwitchStates.h.

Referenced by execute().

Storage for prior state.

Definition at line 97 of file Command_SaveTLSSwitchStates.h.

Referenced by execute().

Storage for prior sub-id.

Definition at line 100 of file Command_SaveTLSSwitchStates.h.

Referenced by execute().


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

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