45 std::vector<std::string>
46 InductionLoop::getIDList() {
47 std::vector<std::string> ids;
54 InductionLoop::getIDCount() {
55 std::vector<std::string> ids;
61 InductionLoop::getPosition(
const std::string& detID) {
62 return getDetector(detID)->getPosition();
67 InductionLoop::getLaneID(
const std::string& detID) {
68 return getDetector(detID)->getLane()->getID();
73 InductionLoop::getLastStepVehicleNumber(
const std::string& detID) {
74 return (
int)getDetector(detID)->getEnteredNumber((
int)
DELTA_T);
79 InductionLoop::getLastStepMeanSpeed(
const std::string& detID) {
80 return getDetector(detID)->getSpeed((
int)
DELTA_T);
84 std::vector<std::string>
85 InductionLoop::getLastStepVehicleIDs(
const std::string& detID) {
86 return getDetector(detID)->getVehicleIDs((
int)
DELTA_T);
91 InductionLoop::getLastStepOccupancy(
const std::string& detID) {
92 return getDetector(detID)->getOccupancy();
97 InductionLoop::getLastStepMeanLength(
const std::string& detID) {
98 return getDetector(detID)->getVehicleLength((
int)
DELTA_T);
103 InductionLoop::getTimeSinceDetection(
const std::string& detID) {
104 return getDetector(detID)->getTimeSinceLastDetection();
108 std::vector<libsumo::TraCIVehicleData>
109 InductionLoop::getVehicleData(
const std::string& detID) {
110 const std::vector<MSInductLoop::VehicleData> vd = getDetector(detID)->collectVehiclesOnDet(
SIMSTEP -
DELTA_T,
true,
true);
111 std::vector<libsumo::TraCIVehicleData> tvd;
114 tvd.back().id = vdi.idM;
115 tvd.back().length = vdi.lengthM;
116 tvd.back().entryTime = vdi.entryTimeM;
117 tvd.back().leaveTime = vdi.leaveTimeM;
118 tvd.back().typeID = vdi.typeIDM;
125 InductionLoop::getDetector(
const std::string&
id) {
128 throw TraCIException(
"Induction loop '" +
id +
"' is not known");
135 InductionLoop::getParameter(
const std::string& detID,
const std::string& param) {
144 InductionLoop::setParameter(
const std::string& detID,
const std::string& name,
const std::string& value) {
145 getDetector(detID)->setParameter(name, value);
153 InductionLoop::getTree() {
154 if (myTree ==
nullptr) {
159 const float cmin[2] = {(float) p.
x(), (float) p.
y()};
160 const float cmax[2] = {(float) p.
x(), (float) p.
y()};
161 myTree->Insert(cmin, cmax, il);
168 InductionLoop::cleanup() {
180 std::shared_ptr<VariableWrapper>
181 InductionLoop::makeWrapper() {
182 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
187 InductionLoop::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
190 return wrapper->wrapStringList(objID, variable, getIDList());
192 return wrapper->wrapInt(objID, variable, getIDCount());
194 return wrapper->wrapDouble(objID, variable, getPosition(objID));
196 return wrapper->wrapString(objID, variable, getLaneID(objID));
198 return wrapper->wrapInt(objID, variable, getLastStepVehicleNumber(objID));
200 return wrapper->wrapDouble(objID, variable, getLastStepMeanSpeed(objID));
202 return wrapper->wrapStringList(objID, variable, getLastStepVehicleIDs(objID));
204 return wrapper->wrapDouble(objID, variable, getLastStepOccupancy(objID));
206 return wrapper->wrapDouble(objID, variable, getLastStepMeanLength(objID));
208 return wrapper->wrapDouble(objID, variable, getTimeSinceDetection(objID));
211 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
214 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
C++ TraCI client API implementation.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
An unextended detector measuring at a fixed position on a fixed lane.
double getPosition() const
Returns the position of the detector on the lane.
const PositionVector & getShape() const
Returns this lane's shape.
const MSLane * getLane() const
Returns the lane the reminder works on.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSDetectorControl & getDetectorControl()
Returns the detector control.
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 int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int TRACI_ID_LIST
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
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 LAST_STEP_TIME_SINCE_DETECTION
Struct to store the data of the counted vehicle internally.
mirrors MSInductLoop::VehicleData