Skip to content

Commit

Permalink
fix #7631
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 23, 2021
1 parent 892e311 commit 87688ed
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/microsim/devices/MSDevice_FCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/****************************************************************************/
#include <config.h>

#include <bitset>
#include <utils/common/StringUtils.h>
#include <utils/options/OptionsCont.h>
#include <utils/iodevices/OutputDevice.h>
Expand All @@ -31,12 +32,15 @@
#include <microsim/MSVehicle.h>
#include "MSDevice_FCD.h"

// some attributes are not written by default and must be enabled via option fcd-output.attributes
#define DEFAULT_MASK (~((long long int)1 << SUMO_ATTR_VEHICLE))

// ===========================================================================
// static members
// ===========================================================================
std::set<const MSEdge*> MSDevice_FCD::myEdgeFilter;
bool MSDevice_FCD::myEdgeFilterInitialized(false);
long long int MSDevice_FCD::myWrittenAttributes(-1);
long long int MSDevice_FCD::myWrittenAttributes(DEFAULT_MASK);

// ===========================================================================
// method definitions
Expand Down Expand Up @@ -115,14 +119,15 @@ MSDevice_FCD::initOnce() {
myWrittenAttributes |= ((long long int)1 << attr);
}
}
//std::cout << "mask=" << myWrittenAttributes << " binary=" << std::bitset<64>(myWrittenAttributes) << "\n";
}


void
MSDevice_FCD::cleanup() {
myEdgeFilter.clear();
myEdgeFilterInitialized = false;
myWrittenAttributes = -1;
myWrittenAttributes = DEFAULT_MASK;
}


Expand Down
11 changes: 6 additions & 5 deletions src/microsim/output/MSFCDExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ MSFCDExport::write(OutputDevice& of, SUMOTime timestep, bool elevation) {

const std::vector<MSTransportable*>& persons = veh->getPersons();
for (MSTransportable* person : persons) {
writeTransportable(of, edge, person, true, SUMO_TAG_PERSON, useGeo, elevation, mask);
writeTransportable(of, edge, person, veh, true, SUMO_TAG_PERSON, useGeo, elevation, mask);
}
const std::vector<MSTransportable*>& containers = veh->getContainers();
for (MSTransportable* container : containers) {
writeTransportable(of, edge, container, true, SUMO_TAG_CONTAINER, useGeo, elevation, mask);
writeTransportable(of, edge, container, veh, true, SUMO_TAG_CONTAINER, useGeo, elevation, mask);
}
}
}
Expand All @@ -179,7 +179,7 @@ MSFCDExport::write(OutputDevice& of, SUMOTime timestep, bool elevation) {
}
const std::vector<MSTransportable*>& persons = (*e)->getSortedPersons(timestep);
for (MSTransportable* person : persons) {
writeTransportable(of, *e, person, inRadius.count(person) > 0, SUMO_TAG_PERSON, useGeo, elevation, mask);
writeTransportable(of, *e, person, nullptr, inRadius.count(person) > 0, SUMO_TAG_PERSON, useGeo, elevation, mask);
}
}
}
Expand All @@ -193,7 +193,7 @@ MSFCDExport::write(OutputDevice& of, SUMOTime timestep, bool elevation) {
}
const std::vector<MSTransportable*>& containers = (*e)->getSortedContainers(timestep);
for (MSTransportable* container : containers) {
writeTransportable(of, *e, container, inRadius.count(container) > 0, SUMO_TAG_CONTAINER, useGeo, elevation, mask);
writeTransportable(of, *e, container, nullptr, inRadius.count(container) > 0, SUMO_TAG_CONTAINER, useGeo, elevation, mask);
}
}
}
Expand All @@ -202,7 +202,7 @@ MSFCDExport::write(OutputDevice& of, SUMOTime timestep, bool elevation) {


void
MSFCDExport::writeTransportable(OutputDevice& of, const MSEdge* e, MSTransportable* p, bool inRadius, SumoXMLTag tag, bool useGeo, bool elevation, long long int mask) {
MSFCDExport::writeTransportable(OutputDevice& of, const MSEdge* e, MSTransportable* p, const SUMOVehicle* v, bool inRadius, SumoXMLTag tag, bool useGeo, bool elevation, long long int mask) {
if (p->getDevice(typeid(MSTransportableDevice_FCD)) == nullptr && !inRadius) {
return;
}
Expand All @@ -223,6 +223,7 @@ MSFCDExport::writeTransportable(OutputDevice& of, const MSEdge* e, MSTransportab
of.writeOptionalAttr(SUMO_ATTR_POSITION, p->getEdgePos(), mask);
of.writeOptionalAttr(SUMO_ATTR_EDGE, e->getID(), mask);
of.writeOptionalAttr(SUMO_ATTR_SLOPE, e->getLanes()[0]->getShape().slopeDegreeAtOffset(p->getEdgePos()), mask);
of.writeOptionalAttr(SUMO_ATTR_VEHICLE, v == nullptr ? "" : v->getID(), mask);
of.closeTag();
}

Expand Down
2 changes: 1 addition & 1 deletion src/microsim/output/MSFCDExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MSFCDExport {

private:
/// @brief write transportable
static void writeTransportable(OutputDevice& of, const MSEdge* e, MSTransportable* p, bool inRadius, SumoXMLTag tag, bool useGeo, bool elevation, long long int mask);
static void writeTransportable(OutputDevice& of, const MSEdge* e, MSTransportable* p, const SUMOVehicle* v, bool inRadius, SumoXMLTag tag, bool useGeo, bool elevation, long long int mask);

private:
/// @brief Invalidated copy constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xml/SUMOXMLDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ StringBijection<int>::Entry SUMOXMLDefinitions::attrs[] = {
{ "leaderID", SUMO_ATTR_LEADER_ID },
{ "leaderSpeed", SUMO_ATTR_LEADER_SPEED },
{ "leaderGap", SUMO_ATTR_LEADER_GAP },
{ "vehicle", SUMO_ATTR_VEHICLE },

// Edge
{ "id", SUMO_ATTR_ID },
Expand Down Expand Up @@ -776,7 +777,6 @@ StringBijection<int>::Entry SUMOXMLDefinitions::attrs[] = {
{ "avoidOverlap", SUMO_ATTR_AVOID_OVERLAP },

{ "actorConfig", SUMO_ATTR_ACTORCONFIG },
{ "vehicle", SUMO_ATTR_VEHICLE },
{ "startTime", SUMO_ATTR_STARTTIME },
{ "vehicleClass", SUMO_ATTR_VEHICLECLASS },
{ "fuel", SUMO_ATTR_FUEL },
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xml/SUMOXMLDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ enum SumoXMLAttr {
SUMO_ATTR_LEADER_ID = 55,
SUMO_ATTR_LEADER_SPEED = 56,
SUMO_ATTR_LEADER_GAP = 57,
SUMO_ATTR_VEHICLE = 58,
/// @}

/// @name common attributes
Expand Down Expand Up @@ -1098,7 +1099,6 @@ enum SumoXMLAttr {
SUMO_ATTR_COMMAND,

SUMO_ATTR_ACTORCONFIG,
SUMO_ATTR_VEHICLE,
SUMO_ATTR_STARTTIME,
SUMO_ATTR_VEHICLECLASS,
SUMO_ATTR_FUEL,
Expand Down

0 comments on commit 87688ed

Please sign in to comment.