27 lines
546 B
Plaintext
27 lines
546 B
Plaintext
|
|
||
|
// 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 {
|
||
|
sList:add(s:type, s).
|
||
|
}
|
||
|
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...
|
||
|
}
|
||
|
return sList[s].
|
||
|
}
|