43std::vector<std::string>
44MeanData::getIDList() {
45 std::vector<std::string> ids;
46 for (
const auto& item :
MSNet::getInstance()->getDetectorControl().getMeanData()) {
47 ids.push_back(item.first);
49 std::sort(ids.begin(), ids.end());
54MeanData::getIDCount() {
55 return (
int)getIDList().size();
60MeanData::getAttributeValue(
const std::string& meanDataID,
const std::string& laneID,
const std::string& attr) {
62 throw TraCIException(
"Unknown Meandata attribute '" + attr +
"'.");
65 if (lane ==
nullptr) {
66 throw TraCIException(
"Lane '" + laneID +
"' is not known");
74std::vector<std::string>
75MeanData::getIDs(
const std::string&meanDataID) {
77 std::vector<std::string> result;
80 result.push_back(e->getID());
84 for (
const MSLane* lane : e->getLanes()) {
85 result.push_back(lane->getID());
94MeanData::getAttributeValues(
const std::string& meanDataID,
const std::string& attr) {
96 throw TraCIException(
"Unknown Meandata attribute '" + attr +
"'.");
100 std::vector<double> result;
107 for (
const MSLane* lane : e->getLanes()) {
117MeanData::getParameter(
const std::string& ,
const std::string& ) {
124MeanData::setParameter(
const std::string& ,
const std::string& ,
const std::string& ) {
134MeanData::getMeanData(
const std::string&
id) {
136 auto it = mdMap.find(
id);
137 if (it == mdMap.end() || it->second.size() == 0) {
138 throw TraCIException(
"MeanData '" +
id +
"' is not known");
140 if (it->second.size() > 1) {
143 return it->second.front();
147std::shared_ptr<VariableWrapper>
148MeanData::makeWrapper() {
149 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
154MeanData::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
157 return wrapper->wrapStringList(objID, variable, getIDList());
159 return wrapper->wrapInt(objID, variable, getIDCount());
162 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
165 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
170 return wrapper->wrapDouble(objID, variable, getAttributeValue(objID, laneID, attr));
173 return wrapper->wrapStringList(objID, variable, getIDs(objID));
#define WRITE_WARNINGF(...)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
const std::map< std::string, std::vector< MSMeanData * > > & getMeanData() const
A road/street connecting two junctions.
Representation of a lane in the micro simulation.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Data collector for edges/lanes.
const MSEdgeVector & getEdges() const
double getAttributeValue(const MSLane *lane, SumoXMLAttr a, double defaultValue) const
return attribute value for the given lane
The simulated network and simulation perfomer.
MSDetectorControl & getDetectorControl()
Returns the detector control.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
C++ TraCI client API implementation.
static SequentialStringBijection Attrs
The names of SUMO-XML attributes for use in netbuild.
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int TRACI_ID_LIST
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_MEANDATA_VALUES
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_MEANDATA_LANE
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_MEANDATA_IDS