Skip to content

Commit

Permalink
introducing new vClasses refs #12335 (sumo part)
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Apr 2, 2024
1 parent 65cf0e1 commit 8aaf8f0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/microsim/MSEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ MSEdge::rebuildAllowedLanes(const bool onInit) {
myAllowed.clear();
if (myCombinedPermissions != myMinimumPermissions) {
myAllowed.push_back(std::make_pair(SVC_IGNORING, myLanes));
for (int vclass = SVC_PRIVATE; vclass <= SUMOVehicleClass_MAX; vclass *= 2) {
for (SVCPermissions vclass = SVC_PRIVATE; vclass <= SUMOVehicleClass_MAX; vclass *= 2) {
if ((myCombinedPermissions & vclass) == vclass) {
std::shared_ptr<std::vector<MSLane*> > allowedLanes = std::make_shared<std::vector<MSLane*> >();
for (MSLane* const lane : *myLanes) {
Expand Down Expand Up @@ -377,7 +377,7 @@ MSEdge::rebuildAllowedTargets(const bool updateVehicles) {
} else {
addToAllowed(SVC_IGNORING, allLanes, myAllowedTargets[target]);
// compute the vclass specific mapping
for (int vclass = SVC_PRIVATE; vclass <= SUMOVehicleClass_MAX; vclass *= 2) {
for (SVCPermissions vclass = SVC_PRIVATE; vclass <= SUMOVehicleClass_MAX; vclass *= 2) {
if ((myCombinedPermissions & vclass) == vclass) {
std::shared_ptr<std::vector<MSLane*> > allowedLanes = std::make_shared<std::vector<MSLane*> >();
for (MSLane* const lane : *myLanes) {
Expand Down
17 changes: 12 additions & 5 deletions src/utils/common/SUMOVehicleClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ static StringBijection<SUMOVehicleClass>::Entry sumoVehicleClassStringInitialize
{"pedestrian", SVC_PEDESTRIAN},
{"evehicle", SVC_E_VEHICLE},
{"ship", SVC_SHIP},
{"container", SVC_CONTAINER},
{"cable_car", SVC_CABLE_CAR},
{"subway", SVC_SUBWAY},
{"aircraft", SVC_AIRCRAFT},
{"wheelchair", SVC_WHEELCHAIR},
{"scooter", SVC_SCOOTER},
{"drone", SVC_DRONE},
{"custom1", SVC_CUSTOM1},
{"custom2", SVC_CUSTOM2}
};
Expand Down Expand Up @@ -148,7 +155,7 @@ static std::string VehicleClassNameAll = "all";

const SUMOVehicleClass SUMOVehicleClass_MAX = SVC_CUSTOM2;

const SVCPermissions SVCAll = 2 * (int)SUMOVehicleClass_MAX - 1; // all relevant bits set to 1
const SVCPermissions SVCAll = 2 * (long long int)SUMOVehicleClass_MAX - 1; // all relevant bits set to 1

const SVCPermissions SVC_UNSPECIFIED = -1;

Expand Down Expand Up @@ -318,13 +325,13 @@ getVehicleClassID(const std::string& name) {
}


int
SVCPermissions
getVehicleClassCompoundID(const std::string& name) {
int ret = SVC_IGNORING;
SVCPermissions ret = SVC_IGNORING;
const std::vector<std::string> names = SumoVehicleClassStrings.getStrings();
for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
if (name.find(*it) != std::string::npos) {
ret = ret | (int) SumoVehicleClassStrings.get(*it);
ret = ret | (SVCPermissions) SumoVehicleClassStrings.get(*it);
}
}
return ret;
Expand Down Expand Up @@ -389,7 +396,7 @@ parseVehicleClasses(const std::string& allowedS, const std::string& disallowedS,
} else if (allowedS.size() > 0) {
return parseVehicleClasses(allowedS);
} else {
return invertPermissions(parseVehicleClasses(disallowedS) | (networkVersion < MMVersion(1, 3) ? SVC_RAIL_FAST : 0));
return invertPermissions(parseVehicleClasses(disallowedS) | (networkVersion < MMVersion(1, 3) ? SVC_RAIL_FAST : SVC_IGNORING));
}
}

Expand Down
18 changes: 13 additions & 5 deletions src/utils/common/SUMOVehicleClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,18 @@ enum SUMOVehicleClass {
/// @brief is an arbitrary ship
SVC_SHIP = 1 << 23,

SVC_CONTAINER = 1 << 24,
SVC_CABLE_CAR = 1 << 25,
SVC_SUBWAY = 1 << 26,
SVC_AIRCRAFT = 1 << 27,
SVC_WHEELCHAIR = 1 << 28,
SVC_SCOOTER = 1 << 29,
SVC_DRONE = 1 << 30,

/// @brief is a user-defined type
SVC_CUSTOM1 = 1 << 24,
SVC_CUSTOM1 = (long long int)1 << 31,
/// @brief is a user-defined type
SVC_CUSTOM2 = 1 << 25,
SVC_CUSTOM2 = (long long int)1 << 32,
//@}

/// @brief classes which drive on tracks
Expand All @@ -221,7 +229,7 @@ extern std::set<std::string> deprecatedVehicleClassesSeen;
extern StringBijection<SUMOVehicleShape> SumoVehicleShapeStrings;

/// @brief bitset where each bit declares whether a certain SVC may use this edge/lane
typedef int SVCPermissions;
typedef long long int SVCPermissions;

/// @brief all VClasses are allowed
extern const SVCPermissions SVCAll;
Expand All @@ -237,7 +245,7 @@ extern const SVCPermissions SVC_UNSPECIFIED;
typedef int SUMOEmissionClass;

/// @brief emission class not specified
extern const SVCPermissions EMISSION_CLASS_UNSPECIFIED;
extern const SUMOEmissionClass EMISSION_CLASS_UNSPECIFIED;

// ===========================================================================
// Stop Offsets
Expand Down Expand Up @@ -323,7 +331,7 @@ extern SUMOVehicleClass getVehicleClassID(const std::string& name);
* @param[in] name The name of the abstract vehicle class
* @return The OR'ed combination of base enum values
*/
extern int getVehicleClassCompoundID(const std::string& name);
extern SVCPermissions getVehicleClassCompoundID(const std::string& name);

/** @brief Parses the given definition of allowed vehicle classes into the given containers
* Deprecated classes go into a separate container.
Expand Down

0 comments on commit 8aaf8f0

Please sign in to comment.