44std::vector<std::string>
45Calibrator::getIDList() {
47 std::vector<std::string> ids;
49 ids.push_back(item.first);
55Calibrator::getIDCount() {
56 return (
int)getIDList().size();
60Calibrator::getEdgeID(
const std::string& calibratorID) {
61 return getCalibrator(calibratorID)->getEdge()->getID();
65Calibrator::getLaneID(
const std::string& calibratorID) {
66 const MSLane* lane = getCalibrator(calibratorID)->getLane();
67 if (lane ==
nullptr) {
75Calibrator::getVehsPerHour(
const std::string& calibratorID) {
80Calibrator::getSpeed(
const std::string& calibratorID) {
85Calibrator::getTypeID(
const std::string& calibratorID) {
90Calibrator::getBegin(
const std::string& calibratorID) {
95Calibrator::getEnd(
const std::string& calibratorID) {
100Calibrator::getRouteID(
const std::string& calibratorID) {
105Calibrator::getRouteProbeID(
const std::string& calibratorID) {
106 const MSRouteProbe* rp = getCalibrator(calibratorID)->getRouteProbe();
114std::vector<std::string>
115Calibrator::getVTypes(
const std::string& calibratorID) {
116 std::vector<std::string> result;
117 const std::set<std::string>& vTypes = getCalibrator(calibratorID)->getVehicleTypes();
118 result.insert(result.begin(), vTypes.begin(), vTypes.end());
119 std::sort(result.begin(), result.end());
125Calibrator::getPassed(
const std::string& calibratorID) {
126 return getCalibrator(calibratorID)->passed();
130Calibrator::getInserted(
const std::string& calibratorID) {
131 return getCalibrator(calibratorID)->getInserted();
135Calibrator::getRemoved(
const std::string& calibratorID) {
136 return getCalibrator(calibratorID)->getRemoved();
140Calibrator::getParameter(
const std::string& calibratorID,
const std::string& param) {
148Calibrator::setParameter(
const std::string& calibratorID,
const std::string& key,
const std::string& value) {
154Calibrator::setFlow(
const std::string& calibratorID,
double begin,
double end,
double vehsPerHour,
double speed,
const std::string& typeID,
155 const std::string& routeID,
156 const std::string& departLane,
157 const std::string& departSpeed) {
160 vehicleParams.
vtypeid = typeID;
161 vehicleParams.
routeid = routeID;
164 throw TraCIException(
"Vehicle type '" + typeID +
"' is not known");
167 throw TraCIException(error);
170 throw TraCIException(error);
172 getCalibrator(calibratorID)->setFlow(
TIME2STEPS(begin),
TIME2STEPS(end), vehsPerHour, speed, vehicleParams);
180Calibrator::getCalibrator(
const std::string&
id) {
182 auto it = dict.find(
id);
183 if (it == dict.end()) {
184 throw TraCIException(
"Calibrator '" +
id +
"' is not known");
190std::shared_ptr<VariableWrapper>
191Calibrator::makeWrapper() {
192 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
197Calibrator::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
200 return wrapper->wrapStringList(objID, variable, getIDList());
202 return wrapper->wrapInt(objID, variable, getIDCount());
204 return wrapper->wrapString(objID, variable, getEdgeID(objID));
206 return wrapper->wrapString(objID, variable, getLaneID(objID));
208 return wrapper->wrapDouble(objID, variable, getVehsPerHour(objID));
210 return wrapper->wrapDouble(objID, variable, getSpeed(objID));
212 return wrapper->wrapString(objID, variable, getTypeID(objID));
214 return wrapper->wrapDouble(objID, variable, getBegin(objID));
216 return wrapper->wrapDouble(objID, variable, getEnd(objID));
218 return wrapper->wrapString(objID, variable, getRouteID(objID));
220 return wrapper->wrapString(objID, variable, getRouteProbeID(objID));
222 return wrapper->wrapStringList(objID, variable, getVTypes(objID));
224 return wrapper->wrapInt(objID, variable, getPassed(objID));
226 return wrapper->wrapInt(objID, variable, getInserted(objID));
228 return wrapper->wrapInt(objID, variable, getRemoved(objID));
231 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
234 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
C++ TraCI client API implementation.
Calibrates the flow on a segment to a specified one.
static const std::map< std::string, MSCalibrator * > & getInstances()
return all calibrator instances
Representation of a lane in the micro simulation.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Writes routes of vehicles passing a certain edge.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
The car-following model and parameter.
const std::string & getID() const
Returns the id.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Structure representing possible vehicle parameter.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double departSpeed
(optional) The initial speed of the vehicle
std::string vtypeid
The vehicle's type id.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string routeid
The vehicle's route id.
static MSCalibrator::AspiredState getCalibratorState(const MSCalibrator *c)
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_VEHSPERHOUR
TRACI_CONST int VAR_BEGIN
TRACI_CONST int VAR_ROUTE_PROBE
TRACI_CONST int TRACI_ID_LIST
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_REMOVED
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int VAR_VTYPES
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_INSERTED
TRACI_CONST int VAR_PASSED
TRACI_CONST int VAR_ROUTE_ID
SUMOVehicleParameter * vehicleParameter