2021-08-06 08:57:07 +00:00
|
|
|
|
|
|
|
// we rebuild the sensor list with every invocation, because things change
|
|
|
|
function buildSensorList {
|
|
|
|
local sList is Lexicon().
|
|
|
|
list SENSORS in SensorList.
|
|
|
|
for s in SensorList {
|
2021-08-08 01:33:51 +00:00
|
|
|
if not sList:HasKey(s:type) {
|
|
|
|
sList:add(s:type, s).
|
|
|
|
}
|
2021-08-06 08:57:07 +00:00
|
|
|
}
|
|
|
|
return sList.
|
|
|
|
}
|
|
|
|
|
|
|
|
function HasSensor {
|
|
|
|
parameter s.
|
|
|
|
local sList is buildSensorList().
|
|
|
|
return sList:HasKey(s).
|
|
|
|
}
|
|
|
|
|
|
|
|
function ReadSensor {
|
|
|
|
parameter s.
|
|
|
|
|
|
|
|
local sList is buildSensorList().
|
|
|
|
if not sList:HasKey(s) {
|
|
|
|
return -1. // TODO: is -1 an impossible result for all sensors? I suspect not...
|
|
|
|
}
|
2021-08-08 01:33:51 +00:00
|
|
|
return s:DISPLAY:TOSCALAR.
|
2021-08-06 08:57:07 +00:00
|
|
|
}
|