Skip to content

Commit

Permalink
Merge pull request #241 from boschresearch/fix/default_only_for_attri…
Browse files Browse the repository at this point in the history
…butes

Accept default only for attributes according to VSS spec
  • Loading branch information
SebastianSchildt authored Nov 18, 2021
2 parents a93fd65 + 342e9d2 commit 5547726
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
7 changes: 3 additions & 4 deletions src/VssDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ bool VssDatabase::isAttribute(const json &element) {
}


/** Iterates over a given VSS tree and checks for sensors and actuators specifying the "default"
* metadata. If a default is present, it will be used as "value" (and thus returned upon get
* even if there has been no previous set)
/** Iterates over a given VSS tree and checks attributes specifying the "default"
* metadata. If a default is present, it will be used as "value" (and thus returned upon get)
*/
void VssDatabase::applyDefaultValues(json &tree, VSSPath path) {
//logger_->Log(LogLevel::VERBOSE, "Applying default values in "+path.to_string());

if ( isSensor(tree) || isActor(tree) || isAttribute(tree)) {
if ( isAttribute(tree)) {
if (tree.contains("default")) {
logger_->Log(LogLevel::INFO, "Setting default for "+path.to_string()+" to "+tree["default"].as<string>());
/** Not using setSignal, as that always operates on the complete tree. However applyDefaultValues shall also
Expand Down
23 changes: 0 additions & 23 deletions test/unit-test/VssDatabaseTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,6 @@ BOOST_AUTO_TEST_CASE(applyDefaultValues_Recurse) {
],
"type": "attribute",
"uuid": "0c4cf2b3979456928967e73b646bda05"
},
"ChargePortFlap": {
"datatype": "string",
"default": "closed",
"description": "Signal indicating if charge port cover is open or closed, can potentially be controlled manually.",
"enum": [
"open",
"closed"
],
"type": "actuator",
"uuid": "528e53ad98c1546b90bb48f24f04815a"
}
}
}
Expand All @@ -484,18 +473,6 @@ BOOST_AUTO_TEST_CASE(applyDefaultValues_Recurse) {
],
"type": "attribute",
"uuid": "0c4cf2b3979456928967e73b646bda05"
},
"ChargePortFlap": {
"datatype": "string",
"default": "closed",
"value": "closed",
"description": "Signal indicating if charge port cover is open or closed, can potentially be controlled manually.",
"enum": [
"open",
"closed"
],
"type": "actuator",
"uuid": "528e53ad98c1546b90bb48f24f04815a"
}
}
}
Expand Down

0 comments on commit 5547726

Please sign in to comment.