#include <MSTLLogicControl.h>
This class holds all traffic light logics (programs) and their variants during the simulation. In addition, the schedule for switching between different tls programs are also stored.
When a WAUT is forced to switch, for each TLS, a switching procedure derived from WAUTSwitchProcedure is initialised and is asked repeatedly whether a switch could be done until it returns true.
Definition at line 55 of file MSTLLogicControl.h.
Public Member Functions | |
| bool | add (const std::string &id, const std::string &subID, MSTrafficLightLogic *logic, bool newDefault=true) throw (ProcessError) |
| Adds a tls program to the container. | |
| void | check2Switch (SUMOTime step) |
| Checks whether any WAUT is trying to switch a tls into another program. | |
| bool | closeNetworkReading () throw () |
| Lets MSTLLogicControl know that the network has been loaded. | |
| MSTrafficLightLogic *const | get (const std::string &id, const std::string &subid) const |
| Returns a single program (variant) defined by the tls id and the program subid. | |
| TLSLogicVariants & | get (const std::string &id) const throw (InvalidArgument) |
| Returns the variants of a named tls. | |
| MSTrafficLightLogic *const | getActive (const std::string &id) const |
| Returns the active program of a named tls. | |
| std::vector < MSTrafficLightLogic * > | getAllLogics () const |
| Returns a vector which contains all logics. | |
| std::vector< std::string > | getAllTLIds () const |
| std::pair< SUMOTime, MSPhaseDefinition > | getPhaseDef (const std::string &tlid) const |
| return the complete phase definition for a named traffic lights logic | |
| SUMOTime | initWautSwitch (SwitchInitCommand &cmd) |
| Initialises switching a WAUT. | |
| bool | isActive (const MSTrafficLightLogic *tl) const |
| Returns the information whether the given tls program is the currently active for his tls. | |
| bool | knows (const std::string &id) const |
| Returns the information whether the named tls is stored. | |
| MSTLLogicControl () throw () | |
| Constructor. | |
| void | setTrafficLightSignals () |
| For all traffic lights, the requests are masked away if they have red light (not yellow). | |
| bool | switchTo (const std::string &id, const std::string &subid) |
| Switches the named (id) tls to the named (subid) program. | |
| ~MSTLLogicControl () throw () | |
| Destructor. | |
WAUT definition methods | |
| void | addWAUT (SUMOTime refTime, const std::string &id, const std::string &startProg) throw (InvalidArgument) |
| Adds a WAUT definition. | |
| void | addWAUTJunction (const std::string &wautid, const std::string &tls, const std::string &proc, bool synchron) throw (InvalidArgument, ProcessError) |
| Adds a tls to the list of tls to be switched by the named WAUT. | |
| void | addWAUTSwitch (const std::string &wautid, SUMOTime when, const std::string &to) throw (InvalidArgument) |
| Adds a WAUT switch step to a previously built WAUT. | |
| void | closeWAUT (const std::string &wautid) throw (InvalidArgument) |
| Closes loading of a WAUT. | |
Protected Attributes | |
| std::vector< WAUTSwitchProcess > | myCurrentlySwitched |
| A list of currently running switching procedures. | |
| std::map< std::string, TLSLogicVariants * > | myLogics |
| A map from ids to the corresponding variants. | |
| bool | myNetWasLoaded |
| Information whether the net was completely loaded. | |
| std::map< std::string, WAUT * > | myWAUTs |
| A map of ids to corresponding WAUTs. | |
Private Member Functions | |
| MSTLLogicControl (const MSTLLogicControl &) | |
| Invalidated copy constructor. | |
| MSTLLogicControl & | operator= (const MSTLLogicControl &) |
| Invalidated assignment operator. | |
Data Structures | |
| class | OnSwitchAction |
| Base class for things to execute if a tls switches. More... | |
| class | SwitchInitCommand |
| This event-class is used to initialise a WAUT switch at a certain time. More... | |
| class | TLSLogicVariants |
| Storage for all programs of a single tls. More... | |
| struct | WAUT |
| A WAUT definition. More... | |
| struct | WAUTJunction |
| Storage for a junction assigned to a WAUT. More... | |
| struct | WAUTSwitch |
| Storage for a WAUTs switch point. More... | |
| class | WAUTSwitchProcedure |
| This is the abstract base class for switching from one tls program to another. More... | |
| class | WAUTSwitchProcedure_GSP |
| This class switches using the GSP algorithm. More... | |
| class | WAUTSwitchProcedure_JustSwitch |
| This class simply switches to the next program. More... | |
| class | WAUTSwitchProcedure_Stretch |
| This class switches using the Stretch algorithm. More... | |
| struct | WAUTSwitchProcess |
| An initialised switch process. More... | |
| MSTLLogicControl::MSTLLogicControl | ( | ) | throw () |
| MSTLLogicControl::~MSTLLogicControl | ( | ) | throw () |
Destructor.
Definition at line 582 of file MSTLLogicControl.cpp.
References myLogics, and myWAUTs.
00582 { 00583 // delete tls 00584 for (std::map<std::string, TLSLogicVariants*>::const_iterator i=myLogics.begin(); i!=myLogics.end(); ++i) { 00585 delete(*i).second; 00586 } 00587 // delete WAUTs 00588 for (std::map<std::string, WAUT*>::const_iterator i=myWAUTs.begin(); i!=myWAUTs.end(); ++i) { 00589 delete(*i).second; 00590 } 00591 }
| MSTLLogicControl::MSTLLogicControl | ( | const MSTLLogicControl & | ) | [private] |
Invalidated copy constructor.
| bool MSTLLogicControl::add | ( | const std::string & | id, | |
| const std::string & | subID, | |||
| MSTrafficLightLogic * | logic, | |||
| bool | newDefault = true | |||
| ) | throw (ProcessError) |
Adds a tls program to the container.
If a tls with the given id is not yet known, a TLSLogicVariants structure is built for this tls and added to the internal container and the tls program is used as the new default.
If the tls to add is loaded from an additional file (indicated by myNetWasLoaded, see closeNetworkReading), links from previously loaded tls are adapted to the logic. This may throw a ProcessError in the case no tls program was loaded for this tls before (was not defined in the network).
The parameter newDefault defines whether this program will be used as the new default program of this tls. This means that an existing tls program for this tls is replaced within the according TLSLogicVariants structure.
| [in] | id | The id of the tls (program) to add |
| [in] | subID | The program id of the tls (program) to add |
| [in] | logic | The tls logic to insert |
| ProcessError | In the case an additional tls program is loaded and no one for the tls existed in the network |
Definition at line 647 of file MSTLLogicControl.cpp.
References MSTLLogicControl::TLSLogicVariants::addLogic(), myLogics, and myNetWasLoaded.
00648 { 00649 if (myLogics.find(id)==myLogics.end()) { 00650 myLogics[id] = new TLSLogicVariants(); 00651 } 00652 std::map<std::string, TLSLogicVariants*>::iterator i = myLogics.find(id); 00653 TLSLogicVariants *tlmap = (*i).second; 00654 return tlmap->addLogic(subID, logic, myNetWasLoaded, newDefault); 00655 }
| void MSTLLogicControl::addWAUT | ( | SUMOTime | refTime, | |
| const std::string & | id, | |||
| const std::string & | startProg | |||
| ) | throw (InvalidArgument) |
Adds a WAUT definition.
Throws an InvalidArgument if the given id is already in use.
| [in] | refTime | The reference time of the WAUT |
| [in] | id | The ID of the WAUT |
| [in] | startProg | The begin program of the WAUT |
| InvalidArgument | If the id is already used by another WAUT |
Definition at line 713 of file MSTLLogicControl.cpp.
References MSTLLogicControl::WAUT::id, myWAUTs, MSTLLogicControl::WAUT::refTime, and MSTLLogicControl::WAUT::startProg.
Referenced by NLHandler::openWAUT().
00714 { 00715 // check whether the waut was already defined 00716 if (myWAUTs.find(id)!=myWAUTs.end()) { 00717 // report an error if so 00718 throw InvalidArgument("Waut '" + id + "' was already defined."); 00719 } 00720 WAUT *w = new WAUT; 00721 w->id = id; 00722 w->refTime = refTime; 00723 w->startProg = startProg; 00724 myWAUTs[id] = w; 00725 }
| void MSTLLogicControl::addWAUTJunction | ( | const std::string & | wautid, | |
| const std::string & | tls, | |||
| const std::string & | proc, | |||
| bool | synchron | |||
| ) | throw (InvalidArgument, ProcessError) |
Adds a tls to the list of tls to be switched by the named WAUT.
Passes the values directly to the used tls control. This throws an InvalidArgument if the given WAUT id or the given junction id is not known.
| [in] | wautid | The ID of the WAUT |
| [in] | tls | The id of the tls to be switched |
| [in] | proc | The switching procedure to use |
| [in] | synchron | Whether the switching shall be done in synchron mode |
| InvalidArgument | If the named WAUT or the named tls are not known | |
| ProcessError | If the initial switch fails |
Definition at line 745 of file MSTLLogicControl.cpp.
References MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSTLLogicControl::WAUTJunction::junction, myLogics, myWAUTs, MSTLLogicControl::WAUTJunction::procedure, switchTo(), and MSTLLogicControl::WAUTJunction::synchron.
Referenced by NLHandler::addWAUTJunction().
00748 { 00749 // try to get the waut 00750 if (myWAUTs.find(wautid)==myWAUTs.end()) { 00751 // report an error if the waut is not known 00752 throw InvalidArgument("Waut '" + wautid + "' was not yet defined."); 00753 } 00754 // try to get the tls to switch 00755 if (myLogics.find(tls)==myLogics.end()) { 00756 // report an error if the tls is not known 00757 throw InvalidArgument("TLS '" + tls + "' to switch in WAUT '" + wautid + "' was not yet defined."); 00758 } 00759 WAUTJunction j; 00760 j.junction = tls; 00761 j.procedure = proc; 00762 j.synchron = synchron; 00763 myWAUTs[wautid]->junctions.push_back(j); 00764 00765 std::string initProg = myWAUTs[wautid]->startProg; 00766 std::vector<WAUTSwitch>::const_iterator first = myWAUTs[wautid]->switches.end(); 00767 SUMOTime minExecTime = -1; 00768 int minIndex = -1; 00769 for (std::vector<WAUTSwitch>::const_iterator i=myWAUTs[wautid]->switches.begin(); i!=myWAUTs[wautid]->switches.end(); ++i) { 00770 if ((*i).when>MSNet::getInstance()->getCurrentTimeStep()&&(minExecTime==-1||(*i).when<minExecTime)) { 00771 minExecTime = (*i).when; 00772 first = i; 00773 } 00774 if (first!=myWAUTs[wautid]->switches.begin()) { 00775 initProg = (*(first-1)).to; 00776 } 00777 } 00778 // activate the first one 00779 switchTo(tls, initProg); 00780 }
| void MSTLLogicControl::addWAUTSwitch | ( | const std::string & | wautid, | |
| SUMOTime | when, | |||
| const std::string & | to | |||
| ) | throw (InvalidArgument) |
Adds a WAUT switch step to a previously built WAUT.
Throws an InvalidArgument if the given WAUT id is not known.
| [in] | wautid | The ID of the WAUT |
| [in] | when | The switch procedure begin |
| [in] | to | The program the WAUT shall start to switch to at the given time |
| InvalidArgument | If the named WAUT is not known |
Definition at line 729 of file MSTLLogicControl.cpp.
References myWAUTs, MSTLLogicControl::WAUTSwitch::to, and MSTLLogicControl::WAUTSwitch::when.
Referenced by NLHandler::addWAUTSwitch().
00730 { 00731 // try to get the waut 00732 if (myWAUTs.find(wautid)==myWAUTs.end()) { 00733 // report an error if the waut is not known 00734 throw InvalidArgument("Waut '" + wautid + "' was not yet defined."); 00735 } 00736 // build and save the waut switch definition 00737 WAUTSwitch s; 00738 s.to = to; 00739 s.when = (myWAUTs[wautid]->refTime + when) % 86400000; 00740 myWAUTs[wautid]->switches.push_back(s); 00741 }
| void MSTLLogicControl::check2Switch | ( | SUMOTime | step | ) |
Checks whether any WAUT is trying to switch a tls into another program.
Called from MSNet::simulationStep
Definition at line 854 of file MSTLLogicControl.cpp.
References myCurrentlySwitched, MSTLLogicControl::WAUTSwitchProcess::proc, switchTo(), and MSTLLogicControl::WAUTSwitchProcedure::trySwitch().
Referenced by MSNet::simulationStep().
00854 { 00855 for (std::vector<WAUTSwitchProcess>::iterator i=myCurrentlySwitched.begin(); i!=myCurrentlySwitched.end();) { 00856 const WAUTSwitchProcess &proc = *i; 00857 if (proc.proc->trySwitch(step)) { 00858 delete proc.proc; 00859 switchTo((*i).to->getID(), (*i).to->getSubID()); 00860 i = myCurrentlySwitched.erase(i); 00861 } else { 00862 ++i; 00863 } 00864 } 00865 }
| bool MSTLLogicControl::closeNetworkReading | ( | ) | throw () |
Lets MSTLLogicControl know that the network has been loaded.
This method must be called after the network (including the initial tls definitions) was loaded.
The originally loaded traffic lights are also verified herein by calling TLSLogicVariants::checkOriginalTLS, first.
The MSTLLogicControl is informed in order to know that link information is known for the tls programs loaded afterwards so that it may be adapted from the previously loaded tls (a net may only contain one program per tls).
The states of the links controlled by tls are saved for their potential later usage (if the tls is switched to off-mode).
Definition at line 669 of file MSTLLogicControl.cpp.
References myLogics, and myNetWasLoaded.
Referenced by NLJunctionControlBuilder::buildTLLogics().
00669 { 00670 bool hadErrors = false; 00671 for (std::map<std::string, TLSLogicVariants*>::iterator i=myLogics.begin(); i!=myLogics.end(); ++i) { 00672 hadErrors |= !(*i).second->checkOriginalTLS(); 00673 (*i).second->saveInitialStates(); 00674 } 00675 myNetWasLoaded = true; 00676 return !hadErrors; 00677 }
| void MSTLLogicControl::closeWAUT | ( | const std::string & | wautid | ) | throw (InvalidArgument) |
Closes loading of a WAUT.
Insatntiates the first switch ("SwitchInitCommand") for the WAUT into the network's simulation time step begin event control.
Throws an InvalidArgument if the given WAUT id is not known.
| [in] | wautid | The ID of the WAUT |
| InvalidArgument | If the named WAUT is not known |
Definition at line 784 of file MSTLLogicControl.cpp.
References MSEventControl::addEvent(), MSNet::getBeginOfTimestepEvents(), MSNet::getCurrentTimeStep(), MSNet::getInstance(), myWAUTs, MSEventControl::NO_CHANGE, and MSTLLogicControl::WAUT::switches.
Referenced by NLHandler::closeWAUT().
00784 { 00785 // try to get the waut 00786 if (myWAUTs.find(wautid)==myWAUTs.end()) { 00787 // report an error if the waut is not known 00788 throw InvalidArgument("Waut '" + wautid + "' was not yet defined."); 00789 } 00790 WAUT *w = myWAUTs.find(wautid)->second; 00791 std::string initProg = myWAUTs[wautid]->startProg; 00792 // get the switch to be performed as first 00793 std::vector<WAUTSwitch>::const_iterator first = w->switches.end(); 00794 SUMOTime minExecTime = -1; 00795 int minIndex = -1; 00796 for (std::vector<WAUTSwitch>::const_iterator i=w->switches.begin(); i!=w->switches.end(); ++i) { 00797 if ((*i).when>MSNet::getInstance()->getCurrentTimeStep()&&(minExecTime==-1||(*i).when<minExecTime)) { 00798 minExecTime = (*i).when; 00799 first = i; 00800 } 00801 } 00802 // activate the first one 00803 if (first!=w->switches.end()) { 00804 std::vector<WAUTSwitch>::const_iterator mbegin = w->switches.begin(); 00805 MSNet::getInstance()->getBeginOfTimestepEvents().addEvent( 00806 new SwitchInitCommand(*this, wautid, (unsigned int)distance(mbegin, first)), 00807 (*first).when, MSEventControl::NO_CHANGE); 00808 } 00809 /* 00810 // set the current program to all junctions 00811 for(std::vector<WAUTJunction>::const_iterator i=w->junctions.begin(); i!=w->junctions.end(); ++i) { 00812 switchTo((*i).junction, initProg); 00813 } 00814 */ 00815 }
| MSTrafficLightLogic *const MSTLLogicControl::get | ( | const std::string & | id, | |
| const std::string & | subid | |||
| ) | const |
Returns a single program (variant) defined by the tls id and the program subid.
| [in] | id | The id of the tls to get program of |
| [in] | subid | The program id of the tls program to get |
Definition at line 624 of file MSTLLogicControl.cpp.
References myLogics.
00624 { 00625 std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id); 00626 if (i==myLogics.end()) { 00627 return 0; 00628 } 00629 return (*i).second->getLogic(subid); 00630 }
| MSTLLogicControl::TLSLogicVariants & MSTLLogicControl::get | ( | const std::string & | id | ) | const throw (InvalidArgument) |
Returns the variants of a named tls.
| [in] | id | The id of the tls to get variants of |
Definition at line 614 of file MSTLLogicControl.cpp.
References myLogics.
Referenced by NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), MSTrafficLightLogic::SwitchCommand::execute(), GUITrafficLightLogicWrapper::getPopUpMenu(), NLJunctionControlBuilder::getTLLogic(), GUIViewTraffic::onGamingClick(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_TLS::processSet(), and GUITrafficLightLogicWrapper::switchTLSLogic().
00614 { 00615 std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id); 00616 if (i==myLogics.end()) { 00617 throw InvalidArgument("The tls '" + id + "' is not known."); 00618 } 00619 return *(*i).second; 00620 }
| MSTrafficLightLogic *const MSTLLogicControl::getActive | ( | const std::string & | id | ) | const |
Returns the active program of a named tls.
| [in] | id | The id of the tls to get the active program of |
Definition at line 691 of file MSTLLogicControl.cpp.
References myLogics.
Referenced by GUINet::getLinkTLID(), GUINet::getLinkTLIndex(), getPhaseDef(), and traci::TraCIServer::getTLLogicByExtId().
00691 { 00692 std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id); 00693 if (i==myLogics.end()) { 00694 return 0; 00695 } 00696 return (*i).second->getActive(); 00697 }
| std::vector< MSTrafficLightLogic * > MSTLLogicControl::getAllLogics | ( | ) | const |
Returns a vector which contains all logics.
All logics are included, active (current) and non-active
Definition at line 603 of file MSTLLogicControl.cpp.
References myLogics.
Referenced by GUINet::initTLMap(), and GUIViewTraffic::onGamingClick().
00603 { 00604 std::vector<MSTrafficLightLogic*> ret; 00605 std::map<std::string, TLSLogicVariants*>::const_iterator i; 00606 for (i=myLogics.begin(); i!=myLogics.end(); ++i) { 00607 std::vector<MSTrafficLightLogic*> s = (*i).second->getAllLogics(); 00608 copy(s.begin(), s.end(), back_inserter(ret)); 00609 } 00610 return ret; 00611 }
| std::vector< std::string > MSTLLogicControl::getAllTLIds | ( | ) | const |
Returns the ids of all existing variants-structures, wich are the ids of their contained tls logics (not the logic's programm-ids)
Definition at line 634 of file MSTLLogicControl.cpp.
References myLogics.
Referenced by NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), traci::TraCIServer::commandGetAllTLIds(), traci::TraCIServer::handleTrafficLightDomain(), TraCIServerAPI_TLS::processGet(), and traci::TraCIServer::TraCIServer().
00634 { 00635 std::vector<std::string> ret; 00636 00637 std::map<std::string, TLSLogicVariants*>::const_iterator i; 00638 for (i=myLogics.begin(); i!=myLogics.end(); ++i) { 00639 ret.push_back((*i).first); 00640 } 00641 00642 return ret; 00643 }
| std::pair< SUMOTime, MSPhaseDefinition > MSTLLogicControl::getPhaseDef | ( | const std::string & | tlid | ) | const |
return the complete phase definition for a named traffic lights logic
Definition at line 869 of file MSTLLogicControl.cpp.
References getActive(), MSTrafficLightLogic::getCurrentPhaseDef(), and MSNet::getInstance().
Referenced by GUITrafficLightLogicWrapper::begin2TrackPhases().
00869 { 00870 MSTrafficLightLogic *tl = getActive(tlid); 00871 return std::make_pair( 00872 MSNet::getInstance()->getCurrentTimeStep(), 00873 tl->getCurrentPhaseDef()); 00874 }
| SUMOTime MSTLLogicControl::initWautSwitch | ( | MSTLLogicControl::SwitchInitCommand & | cmd | ) |
Initialises switching a WAUT.
This method is called from a previously built SwitchInitCommand
Definition at line 819 of file MSTLLogicControl.cpp.
References MSTLLogicControl::WAUTSwitchProcess::from, MSTLLogicControl::TLSLogicVariants::getActive(), MSNet::getCurrentTimeStep(), MSTLLogicControl::SwitchInitCommand::getIndex(), MSNet::getInstance(), MSTLLogicControl::TLSLogicVariants::getLogicInstantiatingOff(), MSTLLogicControl::SwitchInitCommand::getWAUTID(), MSTLLogicControl::WAUTSwitchProcess::junction, myCurrentlySwitched, myLogics, myWAUTs, MSTLLogicControl::WAUTSwitchProcess::proc, MSTLLogicControl::WAUTSwitchProcess::to, and MSTLLogicControl::WAUTSwitch::to.
00819 { 00820 const std::string &wautid = cmd.getWAUTID(); 00821 unsigned int &index = cmd.getIndex(); 00822 WAUTSwitch s = myWAUTs[wautid]->switches[index]; 00823 for (std::vector<WAUTJunction>::iterator i=myWAUTs[wautid]->junctions.begin(); i!=myWAUTs[wautid]->junctions.end(); ++i) { 00824 // get the current program and the one to instantiate 00825 TLSLogicVariants *vars = myLogics.find((*i).junction)->second; 00826 MSTrafficLightLogic *from = vars->getActive(); 00827 MSTrafficLightLogic *to = vars->getLogicInstantiatingOff(*this, s.to); 00828 WAUTSwitchProcedure *proc = 0; 00829 if ((*i).procedure=="GSP") { 00830 proc = new WAUTSwitchProcedure_GSP(*this, *myWAUTs[wautid], from, to, (*i).synchron); 00831 } else if ((*i).procedure=="Stretch") { 00832 proc = new WAUTSwitchProcedure_Stretch(*this, *myWAUTs[wautid], from, to, (*i).synchron); 00833 } else { 00834 proc = new WAUTSwitchProcedure_JustSwitch(*this, *myWAUTs[wautid], from, to, (*i).synchron); 00835 } 00836 00837 WAUTSwitchProcess p; 00838 p.junction = (*i).junction; 00839 p.proc = proc; 00840 p.from = from; 00841 p.to = to; 00842 00843 myCurrentlySwitched.push_back(p); 00844 } 00845 index++; 00846 if (index==(int) myWAUTs[wautid]->switches.size()) { 00847 return 0; 00848 } 00849 return myWAUTs[wautid]->switches[index].when - MSNet::getInstance()->getCurrentTimeStep(); 00850 }
| bool MSTLLogicControl::isActive | ( | const MSTrafficLightLogic * | tl | ) | const |
Returns the information whether the given tls program is the currently active for his tls.
Definition at line 681 of file MSTLLogicControl.cpp.
References MSTrafficLightLogic::getID(), and myLogics.
Referenced by MSTrafficLightLogic::SwitchCommand::execute(), and GUIViewTraffic::onGamingClick().
00681 { 00682 std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(tl->getID()); 00683 if (i==myLogics.end()) { 00684 return false; 00685 } 00686 return (*i).second->isActive(tl); 00687 }
| bool MSTLLogicControl::knows | ( | const std::string & | id | ) | const |
Returns the information whether the named tls is stored.
Definition at line 659 of file MSTLLogicControl.cpp.
References myLogics.
Referenced by NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), and NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand().
00659 { 00660 std::map<std::string, TLSLogicVariants*>::const_iterator i = myLogics.find(id); 00661 if (i==myLogics.end()) { 00662 return false; 00663 } 00664 return true; 00665 }
| MSTLLogicControl& MSTLLogicControl::operator= | ( | const MSTLLogicControl & | ) | [private] |
Invalidated assignment operator.
| void MSTLLogicControl::setTrafficLightSignals | ( | ) |
For all traffic lights, the requests are masked away if they have red light (not yellow).
Definition at line 595 of file MSTLLogicControl.cpp.
References myLogics.
Referenced by MSNet::simulationStep().
00595 { 00596 for (std::map<std::string, TLSLogicVariants*>::iterator i=myLogics.begin(); i!=myLogics.end(); ++i) { 00597 (*i).second->setTrafficLightSignals(); 00598 } 00599 }
| bool MSTLLogicControl::switchTo | ( | const std::string & | id, | |
| const std::string & | subid | |||
| ) |
Switches the named (id) tls to the named (subid) program.
The program with the used subid must be previously added. If the tls itself or the program to switch to is not known, false is returned.
Definition at line 701 of file MSTLLogicControl.cpp.
References myLogics.
Referenced by addWAUTJunction(), check2Switch(), GUIViewTraffic::onGamingClick(), and GUITrafficLightLogicWrapper::switchTLSLogic().
00701 { 00702 // try to get the tls program definitions 00703 std::map<std::string, TLSLogicVariants*>::iterator i = myLogics.find(id); 00704 // handle problems 00705 if (i==myLogics.end()) { 00706 throw ProcessError("Could not switch tls '" + id + "' to program '" + subid + "':\n No such tls exists."); 00707 } 00708 return (*i).second->switchTo(*this, subid); 00709 }
std::vector<WAUTSwitchProcess> MSTLLogicControl::myCurrentlySwitched [protected] |
A list of currently running switching procedures.
Definition at line 658 of file MSTLLogicControl.h.
Referenced by check2Switch(), and initWautSwitch().
std::map<std::string, TLSLogicVariants*> MSTLLogicControl::myLogics [protected] |
A map from ids to the corresponding variants.
Definition at line 661 of file MSTLLogicControl.h.
Referenced by add(), addWAUTJunction(), closeNetworkReading(), get(), getActive(), getAllLogics(), getAllTLIds(), initWautSwitch(), isActive(), knows(), setTrafficLightSignals(), switchTo(), and ~MSTLLogicControl().
bool MSTLLogicControl::myNetWasLoaded [protected] |
Information whether the net was completely loaded.
Definition at line 664 of file MSTLLogicControl.h.
Referenced by add(), and closeNetworkReading().
std::map<std::string, WAUT*> MSTLLogicControl::myWAUTs [protected] |
A map of ids to corresponding WAUTs.
Definition at line 655 of file MSTLLogicControl.h.
Referenced by addWAUT(), addWAUTJunction(), addWAUTSwitch(), closeWAUT(), initWautSwitch(), and ~MSTLLogicControl().
1.5.6