56 if (s->getConstraints().size() > 0) {
59 for (
auto item : s->getConstraints()) {
61 c->write(out, item.first);
80 s->removeConstraints();
113 myFoeSignal(signal) {
114 for (
const auto& lv : signal->
getLinks()) {
115 for (
const MSLink* link : lv) {
116 MSLane* lane = link->getViaLaneOrLane();
142 item.second->saveState(out);
151 const std::vector<std::string>& tripIDs = attrs.
get<std::vector<std::string> >(
SUMO_ATTR_STATE,
nullptr, ok);
153 if (lane ==
nullptr) {
168 item.second->clearState();
192 if (veh !=
nullptr) {
193 vehID =
" (" + veh->
getID() +
")";
195 std::vector<std::string> passedIDs;
196 for (
const std::string& passedTripID :
myTrackers.front()->myPassed) {
197 if (passedTripID ==
"") {
201 if (passedVeh !=
nullptr) {
202 passedIDs.push_back(passedVeh->
getID());
205 std::string passedIDs2 =
"";
206 if (passedIDs.size() > 0) {
207 passedIDs2 =
" (" +
toString(passedIDs) +
")";
209 std::string params =
"";
211 params += (
"\n key=" + item.first +
" value=" + item.second);
244 myLastIndex = (myLastIndex + 1) % myPassed.size();
247 if (myLane->getID() == DEBUG_LANE) {
256 while (limit > (
int)myPassed.size()) {
257 myPassed.insert(myPassed.begin() + (myLastIndex + 1),
"");
260 if (myLane->getID() == DEBUG_LANE) {
261 std::cout <<
" raiseLimit=" << limit <<
"\n";
268 if (myLastIndex < 0) {
273 if (myPassed[i] == tripId) {
277 i = (int)myPassed.size() - 1;
288 myPassed = std::vector<std::string>(myPassed.size());
294 const std::string state =
toString(myPassed.back() ==
""
295 ? std::vector<std::string>(myPassed.begin(), myPassed.begin() + (myLastIndex + 1))
310 raiseLimit((
int)tripIDs.size());
311 for (
int i = 0; i < (int)tripIDs.size(); i++) {
312 myPassed[i] = tripIDs[i];
315 if (myLane->getID() == DEBUG_LANE) {
316 std::cout <<
" loadState limit=" << tripIDs.size() <<
" index=" << index <<
"\n";
317 for (
int i = 0; i < (int)myPassed.size(); i++) {
318 std::cout <<
" i=" << i <<
" passed=" << myPassed[i] <<
"\n";
#define WRITE_WARNINGF(...)
@ SUMO_TAG_RAILSIGNAL_CONSTRAINTS
Constraints on switching a rail signal.
@ SUMO_TAG_RAILSIGNAL_CONSTRAINT_TRACKER
Saved state for constraint tracker.
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_STATE
The state of a link.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Representation of a lane in the micro simulation.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
bool hasPassed(const std::string &tripId, int limit) const
void raiseLimit(int limit)
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
tracks vehicles that passed this link (entered the next lane)
void loadState(int index, const std::vector< std::string > &tripIDs)
loads the current passed states into the given stream
PassedTracker(MSLane *lane)
void clearState()
Clear all passed states before quick-loading state.
void saveState(OutputDevice &out)
Saves the current passed states into the given stream.
static std::map< const MSLane *, PassedTracker *, ComparatorNumericalIdLess > myTrackerLookup
MSRailSignalConstraint_Predecessor(ConstraintType type, const MSRailSignal *signal, const std::string &tripId, int limit, bool active)
Constructor.
const MSRailSignal * myFoeSignal
store the foe signal (for TraCI access)
bool cleared() const
whether the constraint has been met
bool myAmActive
Whether this constraint is currently active.
static void loadState(const SUMOSAXAttributes &attrs)
loads the constraint state from the given attrs
static void saveState(OutputDevice &out)
Saves the current constraint states into the given stream.
const std::string myTripId
id of the predecessor that must already have passed
std::string getDescription() const
static void clearState()
Clear all constraint states before quick-loading state.
static void cleanup()
clean up state
std::vector< PassedTracker * > myTrackers
the tracker object for this constraint
void write(OutputDevice &out, const std::string &tripId) const
const int myLimit
the number of passed vehicles within which tripId must have occured
const SUMOVehicle * getFoe() const
A base class for constraints.
static const SUMOVehicle * getVeh(const std::string &tripID, bool checkID=false)
static void saveState(OutputDevice &out)
Saves the current constraint states into the given stream.
static std::map< std::string, std::string > myTripIdLookup
static void clearState()
Clear all constraint states before quick-loading state.
static void clearAll()
Remove all constraints before quick-loading state.
SumoXMLTag getTag() const
static void cleanup()
clean up state
static void storeTripId(const std::string &tripId, const std::string &vehID)
static const std::string & lookupVehId(const std::string &tripId)
static MSRailSignalControl & getInstance()
const std::vector< MSRailSignal * > & getSignals() const
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
The class responsible for building and deletion of vehicles.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
const std::string & getID() const
Returns the id.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
Representation of a vehicle, person, or container.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
Representation of a vehicle.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.