NLJunctionControlBuilder Class Reference

#include <NLJunctionControlBuilder.h>


Detailed Description

Builder of microsim-junctions and tls.

NLJunctionControlBuilder is a factory for MSJunction, MSJunctionLogic, WAUT, and MSTRafficLightLogic-instances.

Todo:
Refactor this class - it's too large
Todo:
Resort method by one of the topics.

Definition at line 65 of file NLJunctionControlBuilder.h.


Public Member Functions

void addIncomingLane (MSLane *lane) throw ()
 Adds an incoming lane to the previously chosen junction.
void addJunctionShape (const Position2DVector &shape) throw ()
 Stores the information about the current junction's shape.
void addLogicItem (int request, const std::string &response, const std::string &foes, bool cont) throw (InvalidArgument)
 Adds a logic item.
void addParam (const std::string &key, const std::string &value) throw ()
 Adds a parameter.
void addPhase (SUMOTime duration, const std::string &state, int min, int max) throw ()
 Adds a phase to the currently built traffic lights logic.
MSJunctionControlbuild () const throw ()
 Builds the MSJunctionControl which holds all of the simulations junctions.
MSTLLogicControlbuildTLLogics () const throw (ProcessError)
 Returns the built tls-logic control.
void closeJunction () throw (InvalidArgument, ProcessError)
 Closes (ends) the processing of the current junction.
void closeJunctionLogic () throw (InvalidArgument)
 Ends the building of a junction logic (row-logic).
void closeJunctions (NLDetectorBuilder &db) throw ()
 Closes the building of the junction control.
virtual void closeTrafficLightLogic () throw (InvalidArgument, ProcessError)
 Ends the building of a traffic lights logic.
const std::string & getActiveID () const throw ()
 Returns the active name.
const std::string & getActiveKey () const throw ()
 Returns the active key.
const std::string & getActiveSubKey () const throw ()
 Returns the active sub key.
MSTLLogicControl::TLSLogicVariantsgetTLLogic (const std::string &id) const throw (InvalidArgument)
 Returns a previously build tls logic.
MSTLLogicControlgetTLLogicControlToUse () const throw ()
 Returns the used tls control.
void initIncomingLanes () throw ()
 Clears the inlanes-container.
void initJunctionLogic (const std::string &id, int requestSize, int laneNumber) throw ()
 Initialises a junction logic.
void initTrafficLightLogic (const std::string &id, const std::string &programID, const std::string &type, int offset, SUMOReal detectorOffset) throw ()
 Begins the reading of a traffic lights logic.
 NLJunctionControlBuilder (MSNet &net, OptionsCont &oc) throw ()
 Constructor.
void openJunction (const std::string &id, const std::string &key, const std::string &type, SUMOReal x, SUMOReal y, const Position2DVector &shape) throw (InvalidArgument)
 Begins the processing of the named junction.
void setKey (const std::string &key) throw ()
 Set the key of the logic.
void setLaneNumber (int size) throw ()
 Sets the lane number the parsed logic will be responsible for.
void setOffset (int val) throw ()
 Set the offset with which the logic shall start.
void setRequestSize (int size) throw ()
 Sets the size of the request.
void setSubKey (const std::string &subkey) throw ()
 Set the subkey of the logic.
virtual ~NLJunctionControlBuilder () throw ()
 Destructor.

Protected Types

enum  JunctionType {
  TYPE_UNKNOWN = 0, TYPE_NOJUNCTION, TYPE_RIGHT_BEFORE_LEFT, TYPE_PRIORITY_JUNCTION,
  TYPE_DEAD_END, TYPE_INTERNAL
}
 numerical representations of junction types More...
typedef std::map< std::string,
std::string > 
StringParameterMap
 Definition of a parameter map (key->value).

Protected Member Functions

MSJunctionLogicgetJunctionLogicSecure () throw (InvalidArgument)
 Returns the current junction logic.
Factory methods, virtual so that other versions of the structures can be built
virtual MSJunctionbuildLogicJunction () throw (InvalidArgument)
 Builds a junction with a logic.
virtual MSJunctionbuildNoLogicJunction () throw ()
 Builds a junction that does not use a logic.

Protected Attributes

SUMOTime myAbsDuration
 The absolute duration of a tls-control loop.
std::bitset< 64 > myActiveConts
 The description about which lanes have an internal follower.
MSBitsetLogic::FoesmyActiveFoes
 The description about which lanes disallow other passing the junction simultaneously.
std::string myActiveID
 The id of the currently chosen junction.
LaneVector myActiveIncomingLanes
 The list of the incoming lanes of the currently chosen junction.
std::string myActiveKey
 The key of the currently chosen junction.
MSBitsetLogic::LogicmyActiveLogic
 The right-of-way-logic of the currently chosen bitset-logic.
MSSimpleTrafficLightLogic::Phases myActivePhases
 The current phase definitions for a simple traffic light.
std::string myActiveSubKey
StringParameterMap myAdditionalParameter
 Parameter map (key->value).
bool myCurrentHasError
 Information whether the current logic had an error.
MSJunctionControlmyJunctions
 The junctions controls.
std::vector< TLInitInfomyJunctions2PostLoadInit
 The container for information which junctions shall be initialised using which values.
int myLaneNumber
 The number of lanes.
MSTLLogicControlmyLogicControl
 The tls control to use (0 if net's tls control shall be used).
std::map< std::string,
MSJunctionLogic * > 
myLogics
 Map of loaded junction logics.
std::string myLogicType
 The current logic type.
MSNetmyNet
 The net to use.
SUMOTime myOffset
 The switch offset within the tls.
Position2D myPosition
 The position of the junction.
int myRequestItemNumber
 Counter for the inserted items.
int myRequestSize
 The size of the request.
Position2DVector myShape
 The shape of the current junction.
JunctionType myType
 The type of the currently chosen junction.
Default parameter for extended tls
Todo:
Recheck, move to somewhere else


SUMOReal myDetectorOffset
 Default detector offset.
SUMOReal myStdActuatedDetectorGap
SUMOReal myStdActuatedMaxGap
SUMOReal myStdActuatedPassingTime
int myStdDecisionHorizon
 Default decision horizon (agentbased).
SUMOReal myStdDeltaLimit
 Default difference minimum (agentbased).
SUMOReal myStdDetectorLengths
 Default detector lengths (agentbased).
SUMOReal myStdDetectorPositions
 Default detector positions.
int myStdLearnHorizon
 Default learning horizon (agentbased).
int myStdTCycle
 The loaded default cycle time.

Private Types

typedef std::vector< MSLane * > LaneVector
 Definition of a lane vector.

Private Member Functions

 NLJunctionControlBuilder (const NLJunctionControlBuilder &s)
 invalidated copy operator
NLJunctionControlBuilderoperator= (const NLJunctionControlBuilder &s)
 invalidated assignment operator

Data Structures

struct  TLInitInfo
 A definition of junction initialisation. More...

Member Typedef Documentation

typedef std::vector<MSLane*> NLJunctionControlBuilder::LaneVector [private]

Definition of a lane vector.

Definition at line 68 of file NLJunctionControlBuilder.h.

typedef std::map<std::string, std::string> NLJunctionControlBuilder::StringParameterMap [protected]

Definition of a parameter map (key->value).

Definition at line 530 of file NLJunctionControlBuilder.h.


Member Enumeration Documentation

numerical representations of junction types

Enumerator:
TYPE_UNKNOWN  A junction with an unkown type.
TYPE_NOJUNCTION  A not controlled junction.
TYPE_RIGHT_BEFORE_LEFT  A junction where vehicles coming from the right side may drive as first.
TYPE_PRIORITY_JUNCTION  A junction where one street has a higher priority.
TYPE_DEAD_END  A dead end (all roads end here).
TYPE_INTERNAL  An internal junction.

Definition at line 401 of file NLJunctionControlBuilder.h.

00401                       {
00403         TYPE_UNKNOWN = 0,
00405         TYPE_NOJUNCTION,
00407         TYPE_RIGHT_BEFORE_LEFT,
00409         TYPE_PRIORITY_JUNCTION,
00411         TYPE_DEAD_END,
00413         TYPE_INTERNAL
00414     };


Constructor & Destructor Documentation

NLJunctionControlBuilder::NLJunctionControlBuilder ( MSNet net,
OptionsCont oc 
) throw ()

Constructor.

Stores default values for extended tls reading them from the given options. Builds a MSTLLogicControl instance for myLogicControl.

Parameters:
[in] net The network to fill
[in] oc The options to use
Todo:
Why are options not const?

Definition at line 58 of file NLJunctionControlBuilder.cpp.

00060         : myNet(net), myOffset(0), myJunctions(0) {
00061     myStdDetectorPositions = oc.getFloat("actuated-tl.detector-pos");
00062     myStdDetectorLengths = oc.getFloat("agent-tl.detector-len");
00063     myStdLearnHorizon = oc.getInt("agent-tl.learn-horizon");
00064     myStdDecisionHorizon = oc.getInt("agent-tl.decision-horizon");
00065     myStdDeltaLimit = oc.getFloat("agent-tl.min-diff");
00066     myStdTCycle = oc.getInt("agent-tl.tcycle");
00067     myStdActuatedMaxGap = oc.getFloat("actuated-tl.max-gap");
00068     myStdActuatedPassingTime = oc.getFloat("actuated-tl.passing-time");
00069     myStdActuatedDetectorGap = oc.getFloat("actuated-tl.detector-gap");
00070     myLogicControl = new MSTLLogicControl();
00071     myJunctions = new MSJunctionControl();
00072 }

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

Destructor.

Deletes previously allocated "myLogicControl" and "myJunctions" if they were not previously returned (this may happen if an error occured).

Definition at line 75 of file NLJunctionControlBuilder.cpp.

References myJunctions, and myLogicControl.

00075                                                             {
00076     delete myLogicControl;
00077     delete myJunctions;
00078 }

NLJunctionControlBuilder::NLJunctionControlBuilder ( const NLJunctionControlBuilder s  )  [private]

invalidated copy operator


Member Function Documentation

void NLJunctionControlBuilder::addIncomingLane ( MSLane lane  )  throw ()

Adds an incoming lane to the previously chosen junction.

Parameters:
[in] lane The lane to add to the junction as being an incoming lane

Definition at line 121 of file NLJunctionControlBuilder.cpp.

References myActiveIncomingLanes.

Referenced by NLHandler::addIncomingLanes().

00121                                                               {
00122     myActiveIncomingLanes.push_back(lane);
00123 }

void NLJunctionControlBuilder::addJunctionShape ( const Position2DVector shape  )  throw ()

Stores the information about the current junction's shape.

Parameters:
[in] shape The shape of the current junction

Definition at line 127 of file NLJunctionControlBuilder.cpp.

References myShape.

Referenced by NLHandler::addJunctionShape().

00127                                                                                 {
00128     // @deprecated: at some time, all junctions should have a shape attribute (moved from characters)
00129     myShape = shape;
00130 }

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.

Parameters:
[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
Todo:
Recheck "cont"; is the description correct?

Definition at line 313 of file NLJunctionControlBuilder.cpp.

References myActiveConts, myActiveFoes, myActiveKey, myActiveLogic, myCurrentHasError, myRequestItemNumber, and myRequestSize.

Referenced by NLHandler::addLogicItem().

00316                                                                          {
00317     if (myCurrentHasError) {
00318         // had an error
00319         return;
00320     }
00321     if (request>63) {
00322         // bad request
00323         myCurrentHasError = true;
00324         throw InvalidArgument("Junction logic '" + myActiveKey + "' is larger than allowed; recheck the network.");
00325     }
00326     if (myRequestSize<=0) {
00327         throw InvalidArgument("The request size, the response size or the number of lanes is not given! Contact your net supplier");
00328     }
00329     // add the read response for the given request index
00330     std::bitset<64> use(response);
00331     assert(myActiveLogic->size()>(size_t) request);
00332     (*myActiveLogic)[request] = use;
00333     // add the read junction-internal foes for the given request index
00334     std::bitset<64> use2(foes);
00335     assert(myActiveFoes->size()>(size_t) request);
00336     (*myActiveFoes)[request] = use2;
00337     // add whether the vehicle may drive a little bit further
00338     myActiveConts.set(request, cont);
00339     // increse number of set information
00340     myRequestItemNumber++;
00341 }

void NLJunctionControlBuilder::addParam ( const std::string &  key,
const std::string &  value 
) throw ()

Adds a parameter.

Parameters:
[in] key The key of the parameter
[in] value The value of the parameter
Todo:
Where are these parameter used? Describe!
Todo:
Can a parameter be overwritten?

Definition at line 457 of file NLJunctionControlBuilder.cpp.

References myAdditionalParameter.

Referenced by NLHandler::addParam().

00458                                                                    {
00459     myAdditionalParameter[key] = value;
00460 }

void NLJunctionControlBuilder::addPhase ( SUMOTime  duration,
const std::string &  state,
int  min,
int  max 
) throw ()

Adds a phase to the currently built traffic lights logic.

Parameters:
[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
Todo:
min/max is used only by one junction type. Recheck
Todo:
min/max: maybe only one type of a phase definition should be built

Definition at line 371 of file NLJunctionControlBuilder.cpp.

References myAbsDuration, and myActivePhases.

Referenced by NLHandler::addPhase().

00372                                                                              {
00373     // build and add the phase definition to the list
00374     myActivePhases.push_back(new MSPhaseDefinition(duration, minDuration, maxDuration, state));
00375     // add phase duration to the absolute duration
00376     myAbsDuration += duration;
00377 }

MSJunctionControl * NLJunctionControlBuilder::build (  )  const throw ()

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.

Returns:
The built junction control

Definition at line 169 of file NLJunctionControlBuilder.cpp.

References myJunctions.

Referenced by NLBuilder::buildNet().

00169                                               {
00170     MSJunctionControl *js = myJunctions;
00171     myJunctions = 0;
00172     return js;
00173 }

MSJunction * NLJunctionControlBuilder::buildLogicJunction (  )  throw (InvalidArgument) [protected, virtual]

Builds a junction with a logic.

Builds a MSRightOfWayJunction. Throws an exception if the logic was not built (see getJunctionLogicSecure).

Returns:
The built junction
Exceptions:
InvalidArgument If the logic of the junction was not built before

Definition at line 187 of file NLJunctionControlBuilder.cpp.

References endif, getJunctionLogicSecure(), HAVE_INTERNAL_LANES, myActiveID, myActiveIncomingLanes, myPosition, and myShape.

Referenced by closeJunction().

00187                                                                     {
00188     MSJunctionLogic *jtype = getJunctionLogicSecure();
00189     // build the junction
00190     return new MSRightOfWayJunction(myActiveID, myPosition, myShape, myActiveIncomingLanes,
00191 #ifdef HAVE_INTERNAL_LANES
00192                                     myActiveInternalLanes,
00193 #endif
00194                                     jtype);
00195 }

MSJunction * NLJunctionControlBuilder::buildNoLogicJunction (  )  throw () [protected, virtual]

Builds a junction that does not use a logic.

Builds a MSNoLogicJunction

Returns:
The built junction

Definition at line 177 of file NLJunctionControlBuilder.cpp.

References endif, HAVE_INTERNAL_LANES, myActiveID, myActiveIncomingLanes, myPosition, and myShape.

Referenced by closeJunction().

00177                                                        {
00178     return new MSNoLogicJunction(myActiveID, myPosition, myShape, myActiveIncomingLanes
00179 #ifdef HAVE_INTERNAL_LANES
00180                                  , myActiveInternalLanes
00181 #endif
00182                                 );
00183 }

MSTLLogicControl * NLJunctionControlBuilder::buildTLLogics (  )  const throw (ProcessError)

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.

Returns:
The built tls-logic control
Exceptions:
ProcessError If the traffic lights were not correct
See also:
MSTLLogicControl::closeNetworkReading

Definition at line 446 of file NLJunctionControlBuilder.cpp.

References MSTLLogicControl::closeNetworkReading(), and myLogicControl.

Referenced by NLBuilder::buildNet().

00446                                                                   {
00447     if (!myLogicControl->closeNetworkReading()) {
00448         throw ProcessError("Traffic lights could not be built.");
00449     }
00450     MSTLLogicControl *ret = myLogicControl;
00451     myLogicControl = 0;
00452     return ret;
00453 }

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.

Exceptions:
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
Todo:
Throwing ProcessError would get unneeded if the container would be built by default (see prepare)
Todo:
The type of the junctions shoould probably be checked when supprted (in openJunction)

Definition at line 134 of file NLJunctionControlBuilder.cpp.

References NamedObjectCont< T >::add(), buildLogicJunction(), buildNoLogicJunction(), MSGlobals::gUsingInternalLanes, myActiveID, myJunctions, myType, TYPE_DEAD_END, TYPE_INTERNAL, TYPE_NOJUNCTION, TYPE_PRIORITY_JUNCTION, and TYPE_RIGHT_BEFORE_LEFT.

Referenced by NLHandler::closeJunction().

00134                                                                              {
00135     if (myJunctions==0) {
00136         throw ProcessError("Information about the number of nodes was missing.");
00137     }
00138     MSJunction *junction = 0;
00139     switch (myType) {
00140     case TYPE_NOJUNCTION:
00141         junction = buildNoLogicJunction();
00142         break;
00143     case TYPE_RIGHT_BEFORE_LEFT:
00144     case TYPE_PRIORITY_JUNCTION:
00145         junction = buildLogicJunction();
00146         break;
00147     case TYPE_DEAD_END:
00148         junction = buildNoLogicJunction();
00149         break;
00150     case TYPE_INTERNAL:
00151 #ifdef HAVE_INTERNAL_LANES
00152         if (MSGlobals::gUsingInternalLanes) {
00153             junction = buildInternalJunction();
00154         }
00155 #endif
00156         break;
00157     default:
00158         throw InvalidArgument("False junction logic type.");
00159     }
00160     if (junction!=0) {
00161         if (!myJunctions->add(myActiveID, junction)) {
00162             throw InvalidArgument("Another junction with the id '" + myActiveID + "' exists.");
00163         }
00164     }
00165 }

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.

Exceptions:
InvalidArgument If the logic's values are false or another logic with the same id was built before

Definition at line 419 of file NLJunctionControlBuilder.cpp.

References myActiveConts, myActiveFoes, myActiveKey, myActiveLogic, myCurrentHasError, myLaneNumber, myLogics, myRequestItemNumber, and myRequestSize.

Referenced by NLHandler::myEndElement().

00419                                                                     {
00420     if (myCurrentHasError) {
00421         // had an error before...
00422         return;
00423     }
00424     if (myRequestItemNumber!=myRequestSize) {
00425         throw InvalidArgument("The description for the junction logic '" + myActiveKey + "' is malicious.");
00426     }
00427     MSJunctionLogic *logic =
00428         new MSBitsetLogic(myRequestSize, myLaneNumber, myActiveLogic, myActiveFoes, myActiveConts);
00429     if (myLogics.find(myActiveKey)!=myLogics.end()) {
00430         throw InvalidArgument("Junction logic '" + myActiveKey + "' was defined twice.");
00431     }
00432     myLogics[myActiveKey] = logic;
00433 }

void NLJunctionControlBuilder::closeJunctions ( NLDetectorBuilder db  )  throw ()

Closes the building of the junction control.

Sets loaded junction parameter into all tls logics.

Parameters:
[in] db The detector builder to use (unused!)
Todo:
Really nasty! Both parameter are not used herein.
Todo:
Where do extended tl build their detectors, what value are set herein?
Todo:
May the called method throw something?

Definition at line 437 of file NLJunctionControlBuilder.cpp.

References myJunctions2PostLoadInit.

Referenced by NLBuilder::buildNet().

00437                                                                       {
00438     for (std::vector<TLInitInfo>::iterator i=myJunctions2PostLoadInit.begin(); i!=myJunctions2PostLoadInit.end(); i++) {
00439         (*i).logic->setParameter((*i).params);
00440         (*i).logic->init(db);
00441     }
00442 }

void NLJunctionControlBuilder::closeTrafficLightLogic (  )  throw (InvalidArgument, ProcessError) [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).

Exceptions:
InvalidArgument If another tls logic with the same name as the currently built was loaded before

Definition at line 231 of file NLJunctionControlBuilder.cpp.

References MSNet::getCurrentTimeStep(), getTLLogicControlToUse(), NLJunctionControlBuilder::TLInitInfo::logic, myAbsDuration, myActiveKey, myActivePhases, myActiveSubKey, myAdditionalParameter, myDetectorOffset, myJunctions2PostLoadInit, myLogicType, myNet, myOffset, myStdActuatedDetectorGap, myStdActuatedMaxGap, myStdActuatedPassingTime, myStdDecisionHorizon, myStdDeltaLimit, myStdLearnHorizon, myStdTCycle, NLJunctionControlBuilder::TLInitInfo::params, MSTrafficLightLogic::setParameter(), and toString().

Referenced by NLHandler::myEndElement().

00231                                                                                       {
00232     if (myAbsDuration==0) {
00233         throw InvalidArgument("TLS program '" + myActiveSubKey + "' for TLS '" + myActiveKey + "' has a duration of 0.");
00234     }
00235     // compute the initial step and first switch time of the tls-logic
00236     unsigned int step = 0;
00237     SUMOTime firstEventOffset = 0;
00238     SUMOTime offset = (myNet.getCurrentTimeStep() + myOffset % myAbsDuration) % myAbsDuration;
00239     MSSimpleTrafficLightLogic::Phases::const_iterator i = myActivePhases.begin();
00240     while (offset>=(*i)->duration) {
00241         step++;
00242         offset -= (*i)->duration;
00243         ++i;
00244     }
00245     firstEventOffset = (*i)->duration - offset + myNet.getCurrentTimeStep();
00246 
00247     //
00248     if (myActiveSubKey=="") {
00249         myActiveSubKey = "default";
00250     }
00251     MSTrafficLightLogic *tlLogic = 0;
00252     // build the tls-logic in dependance to its type
00253     if (myLogicType=="actuated") {
00254         // build an actuated logic
00255         tlLogic =
00256             new MSActuatedTrafficLightLogic(getTLLogicControlToUse(),
00257                                             myActiveKey, myActiveSubKey,
00258                                             myActivePhases, step, firstEventOffset, myStdActuatedMaxGap,
00259                                             myStdActuatedPassingTime, myStdActuatedDetectorGap);
00260     } else if (myLogicType=="agentbased") {
00261         // build an agentbased logic
00262         tlLogic =
00263             new MSAgentbasedTrafficLightLogic(getTLLogicControlToUse(),
00264                                               myActiveKey, myActiveSubKey,
00265                                               myActivePhases, step, firstEventOffset, myStdLearnHorizon,
00266                                               myStdDecisionHorizon, myStdDeltaLimit, myStdTCycle);
00267     } else {
00268         // build a fixed tls-logic
00269         tlLogic =
00270             new MSSimpleTrafficLightLogic(getTLLogicControlToUse(),
00271                                           myActiveKey, myActiveSubKey,
00272                                           myActivePhases, step, firstEventOffset);
00273         tlLogic->setParameter(myAdditionalParameter);
00274     }
00275     TLInitInfo ii;
00276     ii.logic = tlLogic;
00277     ii.params = myAdditionalParameter;
00278     ii.params["detector_offset"] = toString(myDetectorOffset);
00279     myJunctions2PostLoadInit.push_back(ii);
00280     myActivePhases.clear();
00281     if (tlLogic!=0) {
00282         try {
00283             if (!getTLLogicControlToUse().add(myActiveKey, myActiveSubKey, tlLogic)) {
00284                 throw InvalidArgument("Another logic with id '" + myActiveKey + "' and subid '" + myActiveSubKey + "' exists.");
00285             }
00286         } catch (InvalidArgument &) {
00287             delete tlLogic;
00288             throw;
00289         }
00290     }
00291 }

const std::string & NLJunctionControlBuilder::getActiveID (  )  const throw ()

Returns the active name.

Returns:
The active id

Definition at line 473 of file NLJunctionControlBuilder.cpp.

References myActiveID.

Referenced by NLHandler::addIncomingLanes(), and NLHandler::addJunctionShape().

00473                                                     {
00474     return myActiveID;
00475 }

const std::string & NLJunctionControlBuilder::getActiveKey (  )  const throw ()

Returns the active key.

Returns:
The active key

Definition at line 479 of file NLJunctionControlBuilder.cpp.

References myActiveKey.

Referenced by NLHandler::addPhase(), and NLHandler::myCharacters().

00479                                                      {
00480     return myActiveKey;
00481 }

const std::string & NLJunctionControlBuilder::getActiveSubKey (  )  const throw ()

Returns the active sub key.

Returns:
The active sub key

Definition at line 485 of file NLJunctionControlBuilder.cpp.

References myActiveSubKey.

Referenced by NLHandler::addPhase().

00485                                                         {
00486     return myActiveSubKey;
00487 }

MSJunctionLogic * NLJunctionControlBuilder::getJunctionLogicSecure (  )  throw (InvalidArgument) [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.

Returns:
The current tls logic
Exceptions:
InvalidArgument If the logic was not built before
Todo:
Where is this used?

Definition at line 209 of file NLJunctionControlBuilder.cpp.

References myActiveID, and myLogics.

Referenced by buildLogicJunction().

00209                                                                         {
00210     // get and check the junction logic
00211     if (myLogics.find(myActiveID)==myLogics.end()) {
00212         throw InvalidArgument("Missing junction logic '" + myActiveID + "'.");
00213     }
00214     return myLogics[myActiveID];
00215 }

MSTLLogicControl::TLSLogicVariants & NLJunctionControlBuilder::getTLLogic ( const std::string &  id  )  const throw (InvalidArgument)

Returns a previously build tls logic.

Parameters:
[in] id The ID of the tls logic to return
Returns:
The named logic
Exceptions:
InvalidArgument If the named tls logic was not built before

Definition at line 225 of file NLJunctionControlBuilder.cpp.

References MSTLLogicControl::get(), and getTLLogicControlToUse().

Referenced by NLHandler::addE2Detector(), and NLSucceedingLaneBuilder::addSuccLane().

00225                                                                                      {
00226     return getTLLogicControlToUse().get(id);
00227 }

MSTLLogicControl & NLJunctionControlBuilder::getTLLogicControlToUse (  )  const throw ()

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.

Returns:
The tls control to use

Definition at line 464 of file NLJunctionControlBuilder.cpp.

References MSNet::getTLSControl(), myLogicControl, and myNet.

Referenced by NLHandler::addWAUTJunction(), NLHandler::addWAUTSwitch(), closeTrafficLightLogic(), NLHandler::closeWAUT(), getTLLogic(), and NLHandler::openWAUT().

00464                                                                {
00465     if (myLogicControl!=0) {
00466         return *myLogicControl;
00467     }
00468     return myNet.getTLSControl();
00469 }

void NLJunctionControlBuilder::initIncomingLanes (  )  throw ()

Clears the inlanes-container.

Todo:
It seems as the container would be used in several ways; Recheck!

Definition at line 219 of file NLJunctionControlBuilder.cpp.

References myActiveIncomingLanes.

Referenced by initTrafficLightLogic(), and NLHandler::initTrafficLightLogic().

00219                                                     {
00220     myActiveIncomingLanes.clear();
00221 }

void NLJunctionControlBuilder::initJunctionLogic ( const std::string &  id,
int  requestSize,
int  laneNumber 
) throw ()

Initialises a junction logic.

Parameters:
[in] id The id of the row-logic
[in] requestSize The number of links participating in this row-logic
[in] laneNumber The number of lanes participating in this row-logic

Definition at line 295 of file NLJunctionControlBuilder.cpp.

References myActiveConts, myActiveFoes, myActiveKey, myActiveLogic, myActiveSubKey, myCurrentHasError, myLaneNumber, myRequestItemNumber, and myRequestSize.

Referenced by NLHandler::initJunctionLogic().

00295                                                                                                         {
00296     myActiveKey = id;
00297     myActiveSubKey = "";
00298     myActiveLogic = new MSBitsetLogic::Logic();
00299     myActiveFoes = new MSBitsetLogic::Foes();
00300     myActiveConts.reset();
00301     myRequestSize = requestSize;
00302     myLaneNumber = laneNumber;
00303     myRequestItemNumber = 0;
00304     myCurrentHasError = false;
00305     if (myRequestSize>0) {
00306         myActiveLogic->resize(myRequestSize);
00307         myActiveFoes->resize(myRequestSize);
00308     }
00309 }

void NLJunctionControlBuilder::initTrafficLightLogic ( const std::string &  id,
const std::string &  programID,
const std::string &  type,
int  offset,
SUMOReal  detectorOffset 
) throw ()

Begins the reading of a traffic lights logic.

Parameters:
[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
[in] detectorOffset The offset of the detectors to build
Todo:
Why is the type not verified?
Todo:
Recheck, describe usage of detectorOffset (where does the information come from?)
Todo:
detectorOffset is used only by one junction type. Is it not possible, to remove this from the call?

Definition at line 345 of file NLJunctionControlBuilder.cpp.

References initIncomingLanes(), myAbsDuration, myActiveKey, myActivePhases, myActiveSubKey, myAdditionalParameter, myDetectorOffset, myLogicType, myOffset, myRequestSize, myStdDetectorLengths, and myStdDetectorPositions.

Referenced by NLHandler::initTrafficLightLogic().

00346                                                                             {
00347     myActiveKey = id;
00348     myActiveSubKey = programID;
00349     myActivePhases.clear();
00350     myAbsDuration = 0;
00351     myRequestSize = -1;
00352     initIncomingLanes();
00353     myLogicType = type;
00354     myDetectorOffset = detectorOffset;
00355     myOffset = offset;
00356     myAdditionalParameter.clear();
00357     if (myDetectorOffset==-1) {
00358         // agentbased
00359         if (myLogicType=="agentbased") {
00360             myDetectorOffset = myStdDetectorLengths;
00361         }
00362         // actuated
00363         if (myLogicType=="actuated") {
00364             myDetectorOffset = myStdDetectorPositions;
00365         }
00366     }
00367 }

void NLJunctionControlBuilder::openJunction ( const std::string &  id,
const std::string &  key,
const std::string &  type,
SUMOReal  x,
SUMOReal  y,
const Position2DVector shape 
) throw (InvalidArgument)

Begins the processing of the named junction.

Parameters:
[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
Exceptions:
InvalidArgument If the junction type is not known
Todo:
Check why "key" is given

Definition at line 81 of file NLJunctionControlBuilder.cpp.

References myActiveID, myActiveIncomingLanes, myActiveKey, myPosition, myShape, myType, Position2D::set(), TYPE_DEAD_END, TYPE_INTERNAL, TYPE_NOJUNCTION, TYPE_PRIORITY_JUNCTION, TYPE_RIGHT_BEFORE_LEFT, and TYPE_UNKNOWN.

Referenced by NLHandler::openJunction().

00085                                                                                              {
00086 #ifdef HAVE_INTERNAL_LANES
00087     myActiveInternalLanes.clear();
00088 #endif
00089     myActiveIncomingLanes.clear();
00090     myActiveID = id;
00091     myActiveKey = key;
00092     myType = TYPE_UNKNOWN;
00093     if (type=="right_before_left") {
00094         myType = TYPE_RIGHT_BEFORE_LEFT;
00095     } else if (type=="priority") {
00096         myType = TYPE_PRIORITY_JUNCTION;
00097     } else if (type=="DEAD_END"||type=="district") {
00098         myType = TYPE_DEAD_END;
00099     } else if (type=="internal") {
00100         myType = TYPE_INTERNAL;
00101     } else if (type=="unregulated"||type=="none") {
00102         myType = TYPE_NOJUNCTION;
00103     }
00104     if (myType==TYPE_UNKNOWN) {
00105         throw InvalidArgument("An unknown or invalid junction type '" + type + "' occured in junction '" + id + "'.");
00106     }
00107     myPosition.set(x, y);
00108     myShape = shape;
00109 }

NLJunctionControlBuilder& NLJunctionControlBuilder::operator= ( const NLJunctionControlBuilder s  )  [private]

invalidated assignment operator

void NLJunctionControlBuilder::setKey ( const std::string &  key  )  throw ()

Set the key of the logic.

Parameters:
[in] key The key of the logic

Definition at line 405 of file NLJunctionControlBuilder.cpp.

References myActiveKey.

Referenced by NLHandler::setKey().

00405                                                              {
00406     // @deprecated: assuming a net could still use characters for the id
00407     myActiveKey = key;
00408 }

void NLJunctionControlBuilder::setLaneNumber ( int  size  )  throw ()

Sets the lane number the parsed logic will be responsible for.

Parameters:
[in] size The number of lanes controlled by the junction
Todo:
This information is not used anymore!

Definition at line 391 of file NLJunctionControlBuilder.cpp.

References myLaneNumber.

Referenced by NLHandler::setLaneNumber().

00391                                                        {
00392     // @deprecated: assuming a net could still use characters for the lane number
00393     myLaneNumber = val;
00394 }

void NLJunctionControlBuilder::setOffset ( int  val  )  throw ()

Set the offset with which the logic shall start.

Parameters:
[in] val The offset with which the logic shall start
Todo:
Check why the offset is not SUMOTime

Definition at line 398 of file NLJunctionControlBuilder.cpp.

References myOffset.

Referenced by NLHandler::setOffset().

00398                                                    {
00399     // @deprecated: assuming a net could still use characters for the offset
00400     myOffset = val;
00401 }

void NLJunctionControlBuilder::setRequestSize ( int  size  )  throw ()

Sets the size of the request.

Parameters:
[in] size The size of the request
Todo:
Where does this information come from?

Definition at line 381 of file NLJunctionControlBuilder.cpp.

References myActiveFoes, myActiveLogic, myRequestSize, and size.

Referenced by NLHandler::setRequestSize().

00381                                                          {
00382     // @deprecated: assuming a net could still use characters for the request size
00383     myRequestSize = size;
00384     myActiveLogic->resize(myRequestSize);
00385     myActiveFoes->resize(myRequestSize);
00386 }

void NLJunctionControlBuilder::setSubKey ( const std::string &  subkey  )  throw ()

Set the subkey of the logic.

Parameters:
[in] subkey The subkey of the logic

Definition at line 412 of file NLJunctionControlBuilder.cpp.

References myActiveSubKey.

Referenced by NLHandler::setSubKey().

00412                                                                    {
00413     // @deprecated: assuming a net could still use characters for the sub id
00414     myActiveSubKey = subkey;
00415 }


Field Documentation

The absolute duration of a tls-control loop.

Definition at line 472 of file NLJunctionControlBuilder.h.

Referenced by addPhase(), closeTrafficLightLogic(), and initTrafficLightLogic().

std::bitset<64> NLJunctionControlBuilder::myActiveConts [protected]

The description about which lanes have an internal follower.

Definition at line 434 of file NLJunctionControlBuilder.h.

Referenced by addLogicItem(), closeJunctionLogic(), and initJunctionLogic().

The description about which lanes disallow other passing the junction simultaneously.

Definition at line 431 of file NLJunctionControlBuilder.h.

Referenced by addLogicItem(), closeJunctionLogic(), initJunctionLogic(), and setRequestSize().

std::string NLJunctionControlBuilder::myActiveID [protected]

The id of the currently chosen junction.

Definition at line 460 of file NLJunctionControlBuilder.h.

Referenced by buildLogicJunction(), buildNoLogicJunction(), closeJunction(), getActiveID(), getJunctionLogicSecure(), and openJunction().

The list of the incoming lanes of the currently chosen junction.

Definition at line 452 of file NLJunctionControlBuilder.h.

Referenced by addIncomingLane(), buildLogicJunction(), buildNoLogicJunction(), initIncomingLanes(), and openJunction().

std::string NLJunctionControlBuilder::myActiveKey [protected]

The right-of-way-logic of the currently chosen bitset-logic.

Definition at line 428 of file NLJunctionControlBuilder.h.

Referenced by addLogicItem(), closeJunctionLogic(), initJunctionLogic(), and setRequestSize().

The current phase definitions for a simple traffic light.

Definition at line 437 of file NLJunctionControlBuilder.h.

Referenced by addPhase(), closeTrafficLightLogic(), and initTrafficLightLogic().

Parameter map (key->value).

Definition at line 533 of file NLJunctionControlBuilder.h.

Referenced by addParam(), closeTrafficLightLogic(), and initTrafficLightLogic().

Information whether the current logic had an error.

Definition at line 540 of file NLJunctionControlBuilder.h.

Referenced by addLogicItem(), closeJunctionLogic(), and initJunctionLogic().

Default detector offset.

Definition at line 494 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic(), and initTrafficLightLogic().

The junctions controls.

Definition at line 449 of file NLJunctionControlBuilder.h.

Referenced by build(), closeJunction(), and ~NLJunctionControlBuilder().

The container for information which junctions shall be initialised using which values.

Definition at line 487 of file NLJunctionControlBuilder.h.

Referenced by closeJunctions(), and closeTrafficLightLogic().

The number of lanes.

Definition at line 443 of file NLJunctionControlBuilder.h.

Referenced by closeJunctionLogic(), initJunctionLogic(), and setLaneNumber().

The tls control to use (0 if net's tls control shall be used).

Definition at line 526 of file NLJunctionControlBuilder.h.

Referenced by buildTLLogics(), getTLLogicControlToUse(), and ~NLJunctionControlBuilder().

std::map<std::string, MSJunctionLogic*> NLJunctionControlBuilder::myLogics [protected]

Map of loaded junction logics.

Definition at line 537 of file NLJunctionControlBuilder.h.

Referenced by closeJunctionLogic(), and getJunctionLogicSecure().

std::string NLJunctionControlBuilder::myLogicType [protected]

The current logic type.

Definition at line 425 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic(), and initTrafficLightLogic().

The net to use.

Definition at line 419 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic(), and getTLLogicControlToUse().

The switch offset within the tls.

Definition at line 422 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic(), initTrafficLightLogic(), and setOffset().

The position of the junction.

Definition at line 469 of file NLJunctionControlBuilder.h.

Referenced by buildLogicJunction(), buildNoLogicJunction(), and openJunction().

Counter for the inserted items.

Definition at line 446 of file NLJunctionControlBuilder.h.

Referenced by addLogicItem(), closeJunctionLogic(), and initJunctionLogic().

The size of the request.

Definition at line 440 of file NLJunctionControlBuilder.h.

Referenced by addLogicItem(), closeJunctionLogic(), initJunctionLogic(), initTrafficLightLogic(), and setRequestSize().

The shape of the current junction.

Definition at line 475 of file NLJunctionControlBuilder.h.

Referenced by addJunctionShape(), buildLogicJunction(), buildNoLogicJunction(), and openJunction().

Definition at line 521 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic().

Definition at line 515 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic().

Definition at line 518 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic().

Default decision horizon (agentbased).

Definition at line 506 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic().

Default difference minimum (agentbased).

Definition at line 509 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic().

Default detector lengths (agentbased).

Definition at line 500 of file NLJunctionControlBuilder.h.

Referenced by initTrafficLightLogic().

Default detector positions.

Definition at line 497 of file NLJunctionControlBuilder.h.

Referenced by initTrafficLightLogic().

Default learning horizon (agentbased).

Definition at line 503 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic().

The loaded default cycle time.

Definition at line 512 of file NLJunctionControlBuilder.h.

Referenced by closeTrafficLightLogic().

The type of the currently chosen junction.

Definition at line 466 of file NLJunctionControlBuilder.h.

Referenced by closeJunction(), and openJunction().


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

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