SUMO - Simulation of Urban MObility
|
Builder of microsim-junctions and tls. More...
#include <NLJunctionControlBuilder.h>
Data Structures | |
struct | TLInitInfo |
A definition of junction initialisation. More... | |
Public Member Functions | |
void | addLogicItem (int request, const std::string &response, const std::string &foes, bool cont) throw (InvalidArgument) |
Adds a logic item. More... | |
void | addParam (const std::string &key, const std::string &value) |
Adds a parameter. More... | |
void | addPhase (SUMOTime duration, const std::string &state, int min, int max) |
Adds a phase to the currently built traffic lights logic. More... | |
MSJunctionControl * | build () const |
Builds the MSJunctionControl which holds all of the simulations junctions. More... | |
MSTLLogicControl * | buildTLLogics () const |
Returns the built tls-logic control. More... | |
void | closeJunction () throw (InvalidArgument, ProcessError) |
Closes (ends) the processing of the current junction. More... | |
void | closeJunctionLogic () throw (InvalidArgument) |
Ends the building of a junction logic (row-logic) More... | |
virtual void | closeTrafficLightLogic () throw (InvalidArgument, ProcessError) |
Ends the building of a traffic lights logic. More... | |
const std::string & | getActiveKey () const |
Returns the active key. More... | |
const std::string & | getActiveSubKey () const |
Returns the active sub key. More... | |
MSTLLogicControl::TLSLogicVariants & | getTLLogic (const std::string &id) const throw (InvalidArgument) |
Returns a previously build tls logic. More... | |
MSTLLogicControl & | getTLLogicControlToUse () const |
Returns the used tls control. More... | |
void | initJunctionLogic (const std::string &id) |
Initialises a junction logic. More... | |
void | initTrafficLightLogic (const std::string &id, const std::string &programID, TrafficLightType type, SUMOTime offset) |
Begins the reading of a traffic lights logic. More... | |
NLJunctionControlBuilder (MSNet &net, NLDetectorBuilder &db) | |
Constructor. More... | |
void | openJunction (const std::string &id, const std::string &key, const SumoXMLNodeType type, SUMOReal x, SUMOReal y, const PositionVector &shape, const std::vector< MSLane * > &incomingLanes, const std::vector< MSLane * > &internalLanes) throw (InvalidArgument) |
Begins the processing of the named junction. More... | |
virtual | ~NLJunctionControlBuilder () |
Destructor. More... | |
Protected Types | |
typedef std::map< std::string, std::string > | StringParameterMap |
Definition of a parameter map (key->value) More... | |
Protected Member Functions | |
MSJunctionLogic * | getJunctionLogicSecure () throw (InvalidArgument) |
Returns the current junction logic. More... | |
Factory methods, virtual so that other versions of the structures can be built | |
virtual MSJunction * | buildNoLogicJunction () |
Builds a junction that does not use a logic. More... | |
virtual MSJunction * | buildLogicJunction () throw (InvalidArgument) |
Builds a junction with a logic. More... | |
Protected Attributes | |
SUMOTime | myAbsDuration |
The absolute duration of a tls-control loop. More... | |
std::bitset< 64 > | myActiveConts |
The description about which lanes have an internal follower. More... | |
MSBitsetLogic::Foes | myActiveFoes |
The description about which lanes disallow other passing the junction simultaneously. More... | |
std::string | myActiveID |
The id of the currently chosen junction. More... | |
LaneVector | myActiveIncomingLanes |
The list of the incoming lanes of the currently chosen junction. More... | |
std::string | myActiveKey |
The key of the currently chosen junction. More... | |
MSBitsetLogic::Logic | myActiveLogic |
The right-of-way-logic of the currently chosen bitset-logic. More... | |
MSSimpleTrafficLightLogic::Phases | myActivePhases |
The current phase definitions for a simple traffic light. More... | |
std::string | myActiveProgram |
StringParameterMap | myAdditionalParameter |
Parameter map (key->value) More... | |
bool | myCurrentHasError |
Information whether the current logic had an error. More... | |
NLDetectorBuilder & | myDetectorBuilder |
The detector builder to use. More... | |
MSJunctionControl * | myJunctions |
The junctions controls. More... | |
std::vector< TLInitInfo > | myJunctions2PostLoadInit |
The container for information which junctions shall be initialised using which values. More... | |
MSTLLogicControl * | myLogicControl |
The tls control to use (0 if net's tls control shall be used) More... | |
std::map< std::string, MSJunctionLogic * > | myLogics |
Map of loaded junction logics. More... | |
TrafficLightType | myLogicType |
The current logic type. More... | |
MSNet & | myNet |
The net to use. More... | |
SUMOTime | myOffset |
The switch offset within the tls. More... | |
Position | myPosition |
The position of the junction. More... | |
int | myRequestItemNumber |
Counter for the inserted items. More... | |
int | myRequestSize |
The size of the request. More... | |
PositionVector | myShape |
The shape of the current junction. More... | |
SumoXMLNodeType | myType |
The type of the currently chosen junction. More... | |
Private Types | |
typedef std::vector< MSLane * > | LaneVector |
Definition of a lane vector. More... | |
Private Member Functions | |
NLJunctionControlBuilder (const NLJunctionControlBuilder &s) | |
invalidated copy operator More... | |
NLJunctionControlBuilder & | operator= (const NLJunctionControlBuilder &s) |
invalidated assignment operator More... | |
Static Private Attributes | |
static const int | NO_REQUEST_SIZE = -1 |
Builder of microsim-junctions and tls.
NLJunctionControlBuilder is a factory for MSJunction, MSJunctionLogic, WAUT, and MSTRafficLightLogic-instances.
Refactor this class - it's too large
Resort method by one of the topics.
Definition at line 69 of file NLJunctionControlBuilder.h.
|
private |
Definition of a lane vector.
Definition at line 72 of file NLJunctionControlBuilder.h.
|
protected |
Definition of a parameter map (key->value)
Definition at line 390 of file NLJunctionControlBuilder.h.
NLJunctionControlBuilder::NLJunctionControlBuilder | ( | MSNet & | net, |
NLDetectorBuilder & | db | ||
) |
Constructor.
Stores default values for extended tls reading them from the given options. Builds a MSTLLogicControl instance for myLogicControl.
[in] | net | The network to fill |
[in] | db | The detector builder to use |
Definition at line 71 of file NLJunctionControlBuilder.cpp.
References myJunctions, and myLogicControl.
|
virtual |
Destructor.
Deletes previously allocated "myLogicControl" and "myJunctions" if they were not previously returned (this may happen if an error occured).
Definition at line 78 of file NLJunctionControlBuilder.cpp.
References myJunctions, and myLogicControl.
|
private |
invalidated copy operator
void NLJunctionControlBuilder::addLogicItem | ( | int | request, |
const std::string & | response, | ||
const std::string & | foes, | ||
bool | cont | ||
) | throw (InvalidArgument) |
Adds a logic item.
Adds a logic item to the current processed logic. Throws an InvalidArgument if the current request size (myRequestSize) is 0 or lower.
[in] | request | The request (~link) index |
[in] | response | The response (list of higher priorised links) |
[in] | foes | List of foes to the request |
[in] | cont | Whether the request is followed by an internal end |
Definition at line 290 of file NLJunctionControlBuilder.cpp.
References toString().
Referenced by NLHandler::addRequest().
void NLJunctionControlBuilder::addParam | ( | const std::string & | key, |
const std::string & | value | ||
) |
Adds a parameter.
[in] | key | The key of the parameter |
[in] | value | The value of the parameter |
Where are these parameter used? Describe!
Can a parameter be overwritten?
Definition at line 391 of file NLJunctionControlBuilder.cpp.
References myAdditionalParameter.
Referenced by NLHandler::addParam().
void NLJunctionControlBuilder::addPhase | ( | SUMOTime | duration, |
const std::string & | state, | ||
int | min, | ||
int | max | ||
) |
Adds a phase to the currently built traffic lights logic.
[in] | duration | The duration of the phase |
[in] | state | The state of the tls |
[in] | min | The minimum duration of the phase |
[in] | max | The maximum duration of the phase |
min/max is used only by one junction type. Recheck
min/max: maybe only one type of a phase definition should be built
Definition at line 346 of file NLJunctionControlBuilder.cpp.
References myAbsDuration, and myActivePhases.
Referenced by NLHandler::addPhase().
MSJunctionControl * NLJunctionControlBuilder::build | ( | ) | const |
Builds the MSJunctionControl which holds all of the simulations junctions.
Returns the previously built junction control ("myJunctions"). "myJunctions" is set to 0, so that it will not be destroyed by the destructor.
Definition at line 143 of file NLJunctionControlBuilder.cpp.
References myJunctions.
Referenced by NLBuilder::buildNet().
|
protectedvirtual |
Builds a junction with a logic.
Builds a MSRightOfWayJunction. Throws an exception if the logic was not built (see getJunctionLogicSecure).
InvalidArgument | If the logic of the junction was not built before |
Definition at line 161 of file NLJunctionControlBuilder.cpp.
References getJunctionLogicSecure(), HAVE_INTERNAL_LANES, myActiveID, myActiveIncomingLanes, myPosition, and myShape.
Referenced by closeJunction().
|
protectedvirtual |
Builds a junction that does not use a logic.
Builds a MSNoLogicJunction
Definition at line 151 of file NLJunctionControlBuilder.cpp.
References HAVE_INTERNAL_LANES, myActiveID, myActiveIncomingLanes, myPosition, and myShape.
Referenced by closeJunction().
MSTLLogicControl * NLJunctionControlBuilder::buildTLLogics | ( | ) | const |
Returns the built tls-logic control.
Returns the junction control ("myLogicControl") built using MSTLLogicControl::closeNetworkReading. "myLogicControl" is set to 0, so that it will not be destroyed by the destructor.
ProcessError | If the traffic lights were not correct |
Definition at line 380 of file NLJunctionControlBuilder.cpp.
References MSTLLogicControl::closeNetworkReading(), and myLogicControl.
Referenced by NLBuilder::buildNet().
void NLJunctionControlBuilder::closeJunction | ( | ) | throw (InvalidArgument, ProcessError) |
Closes (ends) the processing of the current junction.
This method throws an InvalidArgument when a junction with the same id as the current was already added or if the junction type stored in "myType" is invalid. It throws a ProcessError if the container to store the junction in was not built before.
InvalidArgument | If the current id is already used or the junction type was invalid |
ProcessError | If the container to store the junction in was not built before |
Throwing ProcessError would get unneeded if the container would be built by default (see prepare)
The type of the junctions shoould probably be checked when supprted (in openJunction)
Definition at line 107 of file NLJunctionControlBuilder.cpp.
References NamedObjectCont< T >::add(), buildLogicJunction(), buildNoLogicJunction(), MSGlobals::gUsingInternalLanes, myActiveID, myJunctions, myType, NODETYPE_DEAD_END, NODETYPE_DEAD_END_DEPRECATED, NODETYPE_DISTRICT, NODETYPE_INTERNAL, NODETYPE_NOJUNCTION, NODETYPE_PRIORITY_JUNCTION, NODETYPE_RIGHT_BEFORE_LEFT, and NODETYPE_TRAFFIC_LIGHT.
Referenced by NLHandler::myEndElement().
void NLJunctionControlBuilder::closeJunctionLogic | ( | ) | throw (InvalidArgument) |
Ends the building of a junction logic (row-logic)
Rechecks values for the request and builds a MSJunctionLogic using these values. Throws and InvalidArgument if the values are invalid (error message is included). Tries to add the built logic to the internal container "myLogics". If another logic with the same id exists, an InvalidArgument is thrown.
InvalidArgument | If the logic's values are false or another logic with the same id was built before |
Definition at line 356 of file NLJunctionControlBuilder.cpp.
References myActiveConts, myActiveFoes, myActiveKey, myActiveLogic, myCurrentHasError, myLogics, myRequestItemNumber, myRequestSize, and NO_REQUEST_SIZE.
Referenced by NLHandler::myEndElement().
|
virtual |
Ends the building of a traffic lights logic.
Builds the correct type of a MSTrafficLightLogic using the stored information. Tries to add it to the used tls control. Throws an InvalidArgument if this is not possible (another tls logic with the same name exists).
InvalidArgument | If another tls logic with the same name as the currently built was loaded before |
Definition at line 199 of file NLJunctionControlBuilder.cpp.
References MSNet::getCurrentTimeStep(), getTLLogicControlToUse(), MSTrafficLightLogic::init(), NLJunctionControlBuilder::TLInitInfo::logic, myAbsDuration, myActiveKey, myActivePhases, myActiveProgram, myAdditionalParameter, myDetectorBuilder, myJunctions2PostLoadInit, myLogicType, myNet, myOffset, NLJunctionControlBuilder::TLInitInfo::params, MSTrafficLightLogic::setParameter(), TLTYPE_ACTUATED, TLTYPE_AGENT, and TLTYPE_STATIC.
Referenced by NLHandler::myEndElement().
const std::string & NLJunctionControlBuilder::getActiveKey | ( | ) | const |
Returns the active key.
Definition at line 407 of file NLJunctionControlBuilder.cpp.
References myActiveKey.
Referenced by NLHandler::addPhase().
const std::string & NLJunctionControlBuilder::getActiveSubKey | ( | ) | const |
Returns the active sub key.
Definition at line 413 of file NLJunctionControlBuilder.cpp.
References myActiveProgram.
Referenced by NLHandler::addPhase().
|
protected |
Returns the current junction logic.
"Current" means the one with "myActiveID". If it is not built yet (not within "myLogics") an InvalidArgument is thrown.
InvalidArgument | If the logic was not built before |
Definition at line 183 of file NLJunctionControlBuilder.cpp.
References myActiveID, and myLogics.
Referenced by buildLogicJunction().
MSTLLogicControl::TLSLogicVariants & NLJunctionControlBuilder::getTLLogic | ( | const std::string & | id | ) | const throw (InvalidArgument) |
Returns a previously build tls logic.
[in] | id | The ID of the tls logic to return |
InvalidArgument | If the named tls logic was not built before |
Definition at line 193 of file NLJunctionControlBuilder.cpp.
Referenced by NLHandler::addConnection(), and NLHandler::addE2Detector().
MSTLLogicControl & NLJunctionControlBuilder::getTLLogicControlToUse | ( | ) | const |
Returns the used tls control.
This may be either the internal one ("myLogicControl"), or, if the network has been already loaded and we are loading additional tls programs, the net's logic control.
Definition at line 398 of file NLJunctionControlBuilder.cpp.
References MSNet::getTLSControl(), myLogicControl, and myNet.
Referenced by NLHandler::addWAUTJunction(), NLHandler::addWAUTSwitch(), closeTrafficLightLogic(), NLHandler::closeWAUT(), and NLHandler::openWAUT().
void NLJunctionControlBuilder::initJunctionLogic | ( | const std::string & | id | ) |
Initialises a junction logic.
[in] | id | The id of the row-logic |
Definition at line 277 of file NLJunctionControlBuilder.cpp.
References myActiveConts, myActiveFoes, myActiveKey, myActiveLogic, myActiveProgram, myCurrentHasError, myRequestItemNumber, myRequestSize, and NO_REQUEST_SIZE.
Referenced by NLHandler::initJunctionLogic().
void NLJunctionControlBuilder::initTrafficLightLogic | ( | const std::string & | id, |
const std::string & | programID, | ||
TrafficLightType | type, | ||
SUMOTime | offset | ||
) |
Begins the reading of a traffic lights logic.
[in] | id | The id of the tls |
[in] | programID | The id of the currently loaded program |
[in] | type | The type of the tls |
[in] | offset | The offset to start with |
Why is the type not verified?
Recheck, describe usage of detectorOffset (where does the information come from?)
Definition at line 332 of file NLJunctionControlBuilder.cpp.
References myAbsDuration, myActiveKey, myActivePhases, myActiveProgram, myAdditionalParameter, myLogicType, myOffset, myRequestSize, and NO_REQUEST_SIZE.
Referenced by NLHandler::initTrafficLightLogic().
void NLJunctionControlBuilder::openJunction | ( | const std::string & | id, |
const std::string & | key, | ||
const SumoXMLNodeType | type, | ||
SUMOReal | x, | ||
SUMOReal | y, | ||
const PositionVector & | shape, | ||
const std::vector< MSLane * > & | incomingLanes, | ||
const std::vector< MSLane * > & | internalLanes | ||
) | throw (InvalidArgument) |
Begins the processing of the named junction.
[in] | id | The ID of the junction |
[in] | key | unused?! |
[in] | type | The type of the junction |
[in] | x | x-position of the junction |
[in] | y | y-position of the junction |
[in] | shape | The shape of the junction |
[in] | incomingLanes | List of lanes which end at this intersection |
[in] | internalLanes | List of internal lanes across this intersection |
InvalidArgument | If the junction type is not known |
Definition at line 85 of file NLJunctionControlBuilder.cpp.
References UNUSED_PARAMETER.
Referenced by NLHandler::openJunction().
|
private |
invalidated assignment operator
|
protected |
The absolute duration of a tls-control loop.
Definition at line 367 of file NLJunctionControlBuilder.h.
Referenced by addPhase(), closeTrafficLightLogic(), and initTrafficLightLogic().
|
protected |
The description about which lanes have an internal follower.
Definition at line 332 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), and initJunctionLogic().
|
protected |
The description about which lanes disallow other passing the junction simultaneously.
Definition at line 329 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), and initJunctionLogic().
|
protected |
The id of the currently chosen junction.
Definition at line 355 of file NLJunctionControlBuilder.h.
Referenced by buildLogicJunction(), buildNoLogicJunction(), closeJunction(), and getJunctionLogicSecure().
|
protected |
The list of the incoming lanes of the currently chosen junction.
Definition at line 347 of file NLJunctionControlBuilder.h.
Referenced by buildLogicJunction(), and buildNoLogicJunction().
|
protected |
The key of the currently chosen junction.
Definition at line 358 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), closeTrafficLightLogic(), getActiveKey(), initJunctionLogic(), and initTrafficLightLogic().
|
protected |
The right-of-way-logic of the currently chosen bitset-logic.
Definition at line 326 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), and initJunctionLogic().
|
protected |
The current phase definitions for a simple traffic light.
Definition at line 335 of file NLJunctionControlBuilder.h.
Referenced by addPhase(), closeTrafficLightLogic(), and initTrafficLightLogic().
|
protected |
Definition at line 358 of file NLJunctionControlBuilder.h.
Referenced by closeTrafficLightLogic(), getActiveSubKey(), initJunctionLogic(), and initTrafficLightLogic().
|
protected |
Parameter map (key->value)
Definition at line 393 of file NLJunctionControlBuilder.h.
Referenced by addParam(), closeTrafficLightLogic(), and initTrafficLightLogic().
|
protected |
Information whether the current logic had an error.
Definition at line 400 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), and initJunctionLogic().
|
protected |
The detector builder to use.
Definition at line 317 of file NLJunctionControlBuilder.h.
Referenced by closeTrafficLightLogic().
|
mutableprotected |
The junctions controls.
Definition at line 344 of file NLJunctionControlBuilder.h.
Referenced by build(), closeJunction(), NLJunctionControlBuilder(), and ~NLJunctionControlBuilder().
|
protected |
The container for information which junctions shall be initialised using which values.
Definition at line 382 of file NLJunctionControlBuilder.h.
Referenced by closeTrafficLightLogic().
|
mutableprotected |
The tls control to use (0 if net's tls control shall be used)
Definition at line 386 of file NLJunctionControlBuilder.h.
Referenced by buildTLLogics(), getTLLogicControlToUse(), NLJunctionControlBuilder(), and ~NLJunctionControlBuilder().
|
protected |
Map of loaded junction logics.
Definition at line 397 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), and getJunctionLogicSecure().
|
protected |
The current logic type.
Definition at line 323 of file NLJunctionControlBuilder.h.
Referenced by closeTrafficLightLogic(), and initTrafficLightLogic().
|
protected |
The net to use.
Definition at line 314 of file NLJunctionControlBuilder.h.
Referenced by closeTrafficLightLogic(), and getTLLogicControlToUse().
|
protected |
The switch offset within the tls.
Definition at line 320 of file NLJunctionControlBuilder.h.
Referenced by closeTrafficLightLogic(), and initTrafficLightLogic().
|
protected |
The position of the junction.
Definition at line 364 of file NLJunctionControlBuilder.h.
Referenced by buildLogicJunction(), and buildNoLogicJunction().
|
protected |
Counter for the inserted items.
Definition at line 341 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), and initJunctionLogic().
|
protected |
The size of the request.
Definition at line 338 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), initJunctionLogic(), and initTrafficLightLogic().
|
protected |
The shape of the current junction.
Definition at line 370 of file NLJunctionControlBuilder.h.
Referenced by buildLogicJunction(), and buildNoLogicJunction().
|
protected |
The type of the currently chosen junction.
Definition at line 361 of file NLJunctionControlBuilder.h.
Referenced by closeJunction().
|
staticprivate |
Definition at line 410 of file NLJunctionControlBuilder.h.
Referenced by closeJunctionLogic(), initJunctionLogic(), and initTrafficLightLogic().