Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Accept default only for attributes according to VSS spec #241

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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