55 #include <mesosim/METriggeredCalibrator.h>
58 #ifdef CHECK_MEMORY_LEAKS
60 #endif // CHECK_MEMORY_LEAKS
88 WRITE_ERROR(
"Unknown edge ('" +
id +
"') referenced in a vaporizer.");
97 WRITE_ERROR(
"A vaporization begin time is negative (edge id='" +
id +
"').");
101 WRITE_ERROR(
"A vaporization ends before it starts (edge id='" +
id +
"').");
116 const std::string& base) {
128 throw InvalidArgument(
"The lanes to use within MSLaneSpeedTrigger '" +
id +
"' are not known.");
130 std::vector<MSLane*> lanes;
131 std::vector<std::string> laneIDs;
133 for (std::vector<std::string>::iterator i = laneIDs.begin(); i != laneIDs.end(); ++i) {
136 throw InvalidArgument(
"The lane to use within MSLaneSpeedTrigger '" +
id +
"' is not known.");
138 lanes.push_back(lane);
140 if (lanes.size() == 0) {
141 throw InvalidArgument(
"No lane defined for MSLaneSpeedTrigger '" +
id +
"'.");
172 std::vector<std::string> lines;
181 const std::string& base) {
196 METriggeredCalibrator* trigger = buildMECalibrator(net,
id, &lane->
getEdge(), pos, file, outfile, freq);
212 const std::string& base) {
223 throw InvalidArgument(
"The edge to use within MSTriggeredRerouter '" +
id +
"' is not known.");
225 std::vector<MSEdge*> edges;
226 std::vector<std::string> edgeIDs;
228 for (std::vector<std::string>::iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
231 throw InvalidArgument(
"The edge to use within MSTriggeredRerouter '" +
id +
"' is not known.");
233 edges.push_back(edge);
235 if (edges.size() == 0) {
236 throw InvalidArgument(
"No edges found for MSTriggeredRerouter '" +
id +
"'.");
241 throw InvalidArgument(
"Could not parse MSTriggeredRerouter '" +
id +
"'.");
255 const std::vector<MSLane*>& destLanes,
256 const std::string& file) {
262 METriggeredCalibrator*
263 NLTriggerBuilder::buildMECalibrator(
MSNet& ,
const std::string&
id,
265 const std::string& file,
266 const std::string& outfile,
268 return new METriggeredCalibrator(
id, edge, pos, file, outfile, freq);
276 const std::string& file,
277 const std::string& outfile,
279 return new MSCalibrator(
id, edge, pos, file, outfile, freq);
285 std::vector<MSEdge*>& edges,
286 SUMOReal prob,
const std::string& file,
bool off) {
293 const std::vector<std::string>& lines,
298 throw InvalidArgument(
"Could not build bus stop '" +
id +
"'; probably declared twice.");
307 const std::string& base,
308 const bool allowEmpty) {
328 const std::string& tt,
329 const std::string& tid) {
334 throw InvalidArgument(
"The lane " + objectid +
" to use within the " + tt +
" '" + tid +
"' is not known.");
343 const std::string& tt,
const std::string& tid) {
357 throw InvalidArgument(
"The position of " + tt +
" '" + tid +
"' lies beyond the lane's '" + lane->
getID() +
"' length.");
void setHandler(NLHandler *handler)
Sets the parent handler to use for nested parsing.
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
virtual void buildBusStop(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos)
Builds a bus stop.
MSEdge & getEdge() const
Returns the lane's edge.
virtual MSCalibrator * buildCalibrator(MSNet &net, const std::string &id, MSEdge *edge, SUMOReal pos, const std::string &file, const std::string &outfile, const SUMOTime freq)
builds a microscopic calibrator
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
static bool dictionary(std::string id, MSLane *lane)
Inserts a MSLane into the static dictionary Returns true if the key id isn't already in the dictionar...
SUMOReal getLength() const
Returns the lane's length.
void parseAndBuildRerouter(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a rerouter.
bool checkStopPos(SUMOReal &startPos, SUMOReal &endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos)
check start and end position of a stop
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
void parseAndBuildBusStop(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a bus stop.
NLTriggerBuilder()
Constructor.
Base (microsim) event class.
virtual ~NLTriggerBuilder()
Destructor.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
The simulated network and simulation perfomer.
static OptionsCont & getOptions()
Retrieves the options.
bool addBusStop(MSBusStop *busStop)
Adds a bus stop.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
Changes the speed allowed on a set of lanes.
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
virtual MSTriggeredRerouter * buildRerouter(MSNet &net, const std::string &id, std::vector< MSEdge * > &edges, SUMOReal prob, const std::string &file, bool off)
builds an rerouter
SUMOReal getPosition(const SUMOSAXAttributes &attrs, MSLane *lane, const std::string &tt, const std::string &tid)
returns the position on the lane checking it
Encapsulated SAX-Attributes.
NLHandler * myHandler
The parent handler to set for subhandlers.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
A lane area vehicles can halt at.
A wrapper for a Command function.
void parseAndBuildLaneSpeedTrigger(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a lane speed trigger.
void registerParent(const int tag, GenericSAXHandler *handler)
Assigning a parent handler which is enabled when the specified tag is closed.
SUMOTime string2time(const std::string &r)
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
std::string getFileName(const SUMOSAXAttributes &attrs, const std::string &base, const bool allowEmpty=false)
Helper method to obtain the filename.
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
Reroutes vehicles passing an edge.
Calibrates the flow on a segment to a specified one.
Patch the time in a way that it is at least as high as the simulation begin time. ...
static const bool gUseMesoSim
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual MSLaneSpeedTrigger * buildLaneSpeedTrigger(MSNet &net, const std::string &id, const std::vector< MSLane * > &destLanes, const std::string &file)
Builds a lane speed trigger.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
MSEventControl & getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Representation of a lane in the micro simulation.
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
MSLane * getLane(const SUMOSAXAttributes &attrs, const std::string &tt, const std::string &tid)
Returns the lane defined by attribute "lane".