#include <Command_SaveTLSSwitchStates.h>

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_SaveTLSSwitchStates & | operator= (const Command_SaveTLSSwitchStates &) |
| Invalidated assignment operator. | |
Private Attributes | |
| const MSTLLogicControl::TLSLogicVariants & | myLogics |
| The traffic light logic to use. | |
| OutputDevice & | myOutputDevice |
| The device to write to. | |
| std::string | myPreviousState |
| Storage for prior state. | |
| std::string | myPreviousSubID |
| Storage for prior sub-id. | |
| Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates | ( | const MSTLLogicControl::TLSLogicVariants & | logics, | |
| OutputDevice & | od | |||
| ) | throw () |
Constructor.
| [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 () |
| Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates | ( | const Command_SaveTLSSwitchStates & | ) | [private] |
Invalidated copy constructor.
| 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.
| [in] | currentTime | The current simulation time |
| ProcessError | not here |
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.
const MSTLLogicControl::TLSLogicVariants& Command_SaveTLSSwitchStates::myLogics [private] |
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().
std::string Command_SaveTLSSwitchStates::myPreviousState [private] |
Storage for prior state.
Definition at line 97 of file Command_SaveTLSSwitchStates.h.
Referenced by execute().
std::string Command_SaveTLSSwitchStates::myPreviousSubID [private] |
Storage for prior sub-id.
Definition at line 100 of file Command_SaveTLSSwitchStates.h.
Referenced by execute().
1.5.6