From: Callum Date: Sun, 8 Sep 2013 11:43:41 +0000 (+0800) Subject: Added safety check mechanism (needs some work) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;ds=inline;h=b0c5df604d8a200e92755e33f5c95ea3591c74fd;p=matches%2FMCTX3420.git Added safety check mechanism (needs some work) --- diff --git a/server/sensor.c b/server/sensor.c index c0c3ab1..1e27b4f 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -45,6 +45,8 @@ DataPoint * GetData(SensorId sensor_id, DataPoint * d) { case ANALOG_TEST0: { + //CheckSensor( sensor_id, *sensor value*); + static int count = 0; d->value = count++; break; @@ -69,6 +71,33 @@ DataPoint * GetData(SensorId sensor_id, DataPoint * d) return d; } +/** + * Checks the sensor data for unsafe or unexpected results + * @param sensor_id - The ID of the sensor + * +* +void CheckSensor( SensorId sensor_id) +{ + switch (sensor_id) + { + case ANALOG_TEST0: + { + if( *sensor value* > ANALOG_TEST0_SAFETY) + { + LogEx(LOGERR, GetData, Sensor analog_test0 is above the safe value); + //new log function that stops actuators? + } + //Also include a warning level? + else if( *sensor value* > ANALOG_TEST0_WARN) + { + LogEx(LOGWARN, GetData, Sensor analog_test0); + } + } + } + + +*/ + /** * Destroy a sensor