Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add units into generated config #523

Merged
merged 4 commits into from
Dec 2, 2022
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
25 changes: 19 additions & 6 deletions bin/test_registrar
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,26 @@ echo

clean_devices=$(fgrep 'Z"' ${TEST_SITE}/registration_summary.json | wc -l)
EXPECTED_CLEAN=3 # AHU-1 has a bad site location, so does not match as clean.
exit_status=0
exit_status=clean

echo Found ${clean_devices} clean devices.
[ "${clean_devices}" == $EXPECTED_CLEAN ] || exit_status=1
[ "${clean_devices}" == $EXPECTED_CLEAN ] || exit_status=expected_clean

device_files=$(ls -d ${TEST_SITE}/devices/*)

# Individual tests for generated config values
echo
echo Testing generated_config...
error_file=`mktemp` && rm $error_file
generated_config=sites/udmi_site_model/devices/AHU-1/out/generated_config.json
[[ "Degrees-Celsius" == $(jq -r .pointset.points.filter_differential_pressure_sensor.units $generated_config) ]] || (echo Units mismatch; touch $error_file)
if [[ -f $error_file ]]; then
echo Errors found testing generated config.
exit_status=generated_config
fi
echo Done with generated_config test.
echo

# Test site_metadata settings for system.location.site.
site=$(jq -r .system.location.site < ${TEST_SITE}/site_metadata.json)

Expand All @@ -46,7 +59,7 @@ function check_norm {

sm_devices=$(check_norm)
echo Devices with correct site_metadata: ${sm_devices}
[ "${sm_devices}" == "${device_files}" ] || exit_status=2
[ "${sm_devices}" == "${device_files}" ] || exit_status=site_metadata

mv ${TEST_SITE}/site_metadata.json ${TEST_SITE}/_site_metadata.json

Expand All @@ -55,9 +68,9 @@ bin/registrar ${TEST_SITE}
base_devices=sites/udmi_site_model/devices/AHU-1
sm_devices=$(check_norm)
echo Devices with correct no-defaults site_metadata: ${sm_devices}
[ "${sm_devices}" == "${base_devices}" ] || exit_status=3
[ "${sm_devices}" == "${base_devices}" ] || exit_status=no_defaults

mv ${TEST_SITE}/_site_metadata.json ${TEST_SITE}/site_metadata.json

echo Done with registrar tests, exit code $exit_status
exit $exit_status
echo Done with registrar tests, results are $exit_status
[[ $exit_status == clean ]]
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
"pointset" : {
"points" : {
"filter_alarm_pressure_status" : {
"ref" : "BV11.present_value"
"ref" : "BV11.present_value",
"units" : "No-units"
},
"filter_differential_pressure" : {
"units" : "Bars"
},
"filter_differential_pressure" : { },
"filter_differential_pressure_sensor" : {
"ref" : "AV12.present_value"
"ref" : "AV12.present_value",
"units" : "Degrees-Celsius"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
"pointset" : {
"points" : {
"filter_alarm_pressure_status" : {
"ref" : "BV11.present_value"
"ref" : "BV11.present_value",
"units" : "No-units"
},
"filter_differential_pressure" : {
"units" : "Bars"
},
"filter_differential_pressure" : { },
"filter_differential_pressure_sensor" : {
"ref" : "AV12.present_value"
"ref" : "AV12.present_value",
"units" : "Degrees-Celsius"
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions tests/downgrade.site/devices/DWN-2/out/generated_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
"pointset" : {
"points" : {
"filter_alarm_pressure_status" : {
"ref" : "BV11.present_value"
"ref" : "BV11.present_value",
"units" : "No-units"
},
"filter_differential_pressure" : {
"units" : "Bars"
},
"filter_differential_pressure" : { },
"filter_differential_pressure_sensor" : {
"ref" : "AV12.present_value"
"ref" : "AV12.present_value",
"units" : "Degrees-Celsius"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/downgrade.site/registration_summary.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"DWN-2" : "devices/DWN-2"
},
"Version" : {
"main" : "1.3.14-92-g6b250906"
"main" : "1.3.14-104-gbc8bee55"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ private PointsetConfig getDevicePointsetConfig() {

PointPointsetConfig configFromMetadata(PointPointsetModel metadata) {
PointPointsetConfig pointConfig = new PointPointsetConfig();
pointConfig.units = metadata.units;
pointConfig.ref = metadata.ref;
if (Boolean.TRUE.equals(metadata.writable)) {
pointConfig.set_value = metadata.baseline_value;
Expand Down