48std::vector<std::string>
49InductionLoop::getIDList() {
50 std::vector<std::string> ids;
57InductionLoop::getIDCount() {
58 std::vector<std::string> ids;
64InductionLoop::getPosition(
const std::string& loopID) {
65 return getDetector(loopID)->getPosition();
70InductionLoop::getLaneID(
const std::string& loopID) {
71 return getDetector(loopID)->getLane()->getID();
76InductionLoop::getLastStepVehicleNumber(
const std::string& loopID) {
77 return (
int)getDetector(loopID)->getEnteredNumber((
int)
DELTA_T);
82InductionLoop::getLastStepMeanSpeed(
const std::string& loopID) {
83 return getDetector(loopID)->getSpeed((
int)
DELTA_T);
87std::vector<std::string>
88InductionLoop::getLastStepVehicleIDs(
const std::string& loopID) {
89 return getDetector(loopID)->getVehicleIDs((
int)
DELTA_T);
94InductionLoop::getLastStepOccupancy(
const std::string& loopID) {
95 return getDetector(loopID)->getOccupancy();
100InductionLoop::getLastStepMeanLength(
const std::string& loopID) {
101 return getDetector(loopID)->getVehicleLength((
int)
DELTA_T);
106InductionLoop::getTimeSinceDetection(
const std::string& loopID) {
107 return getDetector(loopID)->getTimeSinceLastDetection();
110std::vector<libsumo::TraCIVehicleData>
111InductionLoop::getVehicleData(
const std::string& loopID) {
112 const std::vector<MSInductLoop::VehicleData> vd = getDetector(loopID)->collectVehiclesOnDet(
SIMSTEP -
DELTA_T,
true,
true);
113 std::vector<libsumo::TraCIVehicleData> tvd;
116 tvd.back().id = vdi.idM;
117 tvd.back().length = vdi.lengthM;
118 tvd.back().entryTime = vdi.entryTimeM;
119 tvd.back().leaveTime = vdi.leaveTimeM;
120 tvd.back().typeID = vdi.typeIDM;
127InductionLoop::getIntervalOccupancy(
const std::string& loopID) {
133 return getDetector(loopID)->getIntervalOccupancy();
139InductionLoop::getIntervalMeanSpeed(
const std::string& loopID) {
143 if (meanData.getSamples() != 0) {
147 return meanData.getLaneLength() / defaultTravelTime;
150 return getDetector(loopID)->getIntervalMeanSpeed();
156InductionLoop::getIntervalVehicleNumber(
const std::string& loopID) {
158 const auto& meanData = getMEDetector(loopID)->getMeanData();
159 return meanData.nVehDeparted + meanData.nVehEntered;
161 return getDetector(loopID)->getIntervalVehicleNumber();
166std::vector<std::string>
167InductionLoop::getIntervalVehicleIDs(
const std::string& loopID) {
169 WRITE_ERROR(
"getIntervalVehicleIDs not applicable for meso");
170 return std::vector<std::string>();
172 return getDetector(loopID)->getIntervalVehicleIDs();
177InductionLoop::getLastIntervalOccupancy(
const std::string& loopID) {
179 WRITE_ERROR(
"getLastIntervalOccupancy not applicable for meso");
182 return getDetector(loopID)->getIntervalOccupancy(
true);
187InductionLoop::getLastIntervalMeanSpeed(
const std::string& loopID) {
189 WRITE_ERROR(
"getLastIntervalMeanSpeed not applicable for meso");
192 return getDetector(loopID)->getIntervalMeanSpeed(
true);
197InductionLoop::getLastIntervalVehicleNumber(
const std::string& loopID) {
199 WRITE_ERROR(
"getLastIntervalVehicleNumber not applicable for meso");
202 return getDetector(loopID)->getIntervalVehicleNumber(
true);
206std::vector<std::string>
207InductionLoop::getLastIntervalVehicleIDs(
const std::string& loopID) {
209 WRITE_ERROR(
"getLastIntervalVehicleIDs not applicable for meso");
210 return std::vector<std::string>();
212 return getDetector(loopID)->getIntervalVehicleIDs(
true);
217InductionLoop::overrideTimeSinceDetection(
const std::string& loopID,
double time) {
218 getDetector(loopID)->overrideTimeSinceDetection(time);
223InductionLoop::getDetector(
const std::string&
id) {
226 throw TraCIException(
"Induction loop '" +
id +
"' is not known");
233InductionLoop::getMEDetector(
const std::string&
id) {
236 throw TraCIException(
"Induction loop '" +
id +
"' is not known");
244InductionLoop::getParameter(
const std::string& loopID,
const std::string& param) {
253InductionLoop::setParameter(
const std::string& loopID,
const std::string& name,
const std::string& value) {
254 getDetector(loopID)->setParameter(name, value);
262InductionLoop::getTree() {
263 if (myTree ==
nullptr) {
268 const float cmin[2] = {(float) p.
x(), (float) p.
y()};
269 const float cmax[2] = {(float) p.
x(), (float) p.
y()};
270 myTree->Insert(cmin, cmax, il);
277InductionLoop::cleanup() {
289std::shared_ptr<VariableWrapper>
290InductionLoop::makeWrapper() {
291 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
296InductionLoop::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
299 return wrapper->wrapStringList(objID, variable, getIDList());
301 return wrapper->wrapInt(objID, variable, getIDCount());
303 return wrapper->wrapDouble(objID, variable, getPosition(objID));
305 return wrapper->wrapString(objID, variable, getLaneID(objID));
307 return wrapper->wrapInt(objID, variable, getLastStepVehicleNumber(objID));
309 return wrapper->wrapDouble(objID, variable, getLastStepMeanSpeed(objID));
311 return wrapper->wrapStringList(objID, variable, getLastStepVehicleIDs(objID));
313 return wrapper->wrapDouble(objID, variable, getLastStepOccupancy(objID));
315 return wrapper->wrapDouble(objID, variable, getLastStepMeanLength(objID));
317 return wrapper->wrapDouble(objID, variable, getTimeSinceDetection(objID));
319 return wrapper->wrapDouble(objID, variable, getIntervalOccupancy(objID));
321 return wrapper->wrapDouble(objID, variable, getIntervalMeanSpeed(objID));
323 return wrapper->wrapInt(objID, variable, getIntervalVehicleNumber(objID));
325 return wrapper->wrapStringList(objID, variable, getIntervalVehicleIDs(objID));
327 return wrapper->wrapDouble(objID, variable, getLastIntervalOccupancy(objID));
329 return wrapper->wrapDouble(objID, variable, getLastIntervalMeanSpeed(objID));
331 return wrapper->wrapInt(objID, variable, getLastIntervalVehicleNumber(objID));
333 return wrapper->wrapStringList(objID, variable, getLastIntervalVehicleIDs(objID));
336 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
339 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
C++ TraCI client API implementation.
An induction loop for mesoscopic simulation.
const MSMeanData_Net::MSLaneMeanDataValues & getMeanData() const
const MSEdge & getEdge() const
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
double getLength() const
return the length of the edge
An unextended detector measuring at a fixed position on a fixed lane.
double getPosition() const
Returns the position of the detector on the lane.
virtual const PositionVector & getShape(bool) const
double getTravelledDistance() const
Returns the total travelled distance.
double getOccupancy(SUMOTime period, int numLanes) const
const MSLane * getLane() const
Returns the lane the reminder works on.
MSDetectorControl & getDetectorControl()
Returns the detector control.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
T get(const std::string &id) const
Retrieves an item.
void insertIDs(std::vector< std::string > &into) const
int size() const
Returns the number of stored items within the container.
A RT-tree for efficient storing of SUMO's Named objects.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
double y() const
Returns the y-position.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int VAR_INTERVAL_NUMBER
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_LAST_INTERVAL_IDS
TRACI_CONST int VAR_LAST_INTERVAL_NUMBER
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int LAST_STEP_LENGTH
TRACI_CONST int VAR_POSITION
TRACI_CONST int LAST_STEP_MEAN_SPEED
TRACI_CONST int VAR_LAST_INTERVAL_OCCUPANCY
TRACI_CONST int VAR_INTERVAL_IDS
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int LAST_STEP_OCCUPANCY
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int VAR_INTERVAL_SPEED
TRACI_CONST int VAR_LAST_INTERVAL_SPEED
TRACI_CONST int VAR_INTERVAL_OCCUPANCY
TRACI_CONST int LAST_STEP_TIME_SINCE_DETECTION
Struct to store the data of the counted vehicle internally.
mirrors MSInductLoop::VehicleData