X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fsensor.c;h=a3580b7793db4ced710fef483559ea4b497733cc;hb=466cbf5433adfc4fef7065164918201039159aff;hp=5115f990a214af4a927cda76bce8dddc19a0ab61;hpb=3a85bddfca280f46d675f4987615c65089c80f44;p=matches%2FMCTX3420.git diff --git a/server/sensor.c b/server/sensor.c index 5115f99..a3580b7 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -7,6 +7,7 @@ #include "common.h" #include "sensor.h" #include "options.h" +#include "gpio.h" #include /** Array of sensors, initialised by Sensor_Init **/ @@ -18,16 +19,19 @@ const SensorThreshold thresholds[NUMSENSORS]= { {1,-1,1,-1}, // ANALOG_TEST0 {500,0,499,0}, // ANALOG_TEST1 {5,-5,4,-4}, // ANALOG_FAIL0 + {500,0,499,0}, // ANALOG_REALTEST {1,0,1,0}, // DIGITAL_TEST0 {1,0,1,0}, // DIGITAL_TEST1 + {1,0,1,0}, // DIGITAL_REALTEST {1,0,1,0} // DIGITAL_FAIL0 }; /** Human readable names for the sensors **/ const char * g_sensor_names[NUMSENSORS] = { "analog_test0", "analog_test1", - "analog_fail0", "digital_test0", - "digital_test1", "digital_fail0" + "analog_realtest", "analog_fail0", + "digital_test0", "digital_test1", + "digital_realtest", "digital_fail0" }; /** @@ -154,8 +158,10 @@ bool Sensor_Read(Sensor * s, DataPoint * d) switch (s->id) { case ANALOG_TEST0: + { d->value = (double)(rand() % 100) / 100; break; + } case ANALOG_TEST1: { static int count = 0; @@ -163,8 +169,14 @@ bool Sensor_Read(Sensor * s, DataPoint * d) d->value = count++; break; } + case ANALOG_REALTEST: + { + //d->value = ADCRead(0); //ADC #0 on the Beaglebone + break; + } case ANALOG_FAIL0: - d->value = (double)(rand() % 6) * -( rand() % 2) / ( rand() % 100 + 1); + d->value = 250; + //d->value = (double)(rand() % 6) * -( rand() % 2) / ( rand() % 100 + 1); //Gives a value between -5 and 5 break; case DIGITAL_TEST0: @@ -173,6 +185,13 @@ bool Sensor_Read(Sensor * s, DataPoint * d) case DIGITAL_TEST1: d->value = (t.tv_sec+1)%2; break; + case DIGITAL_REALTEST: + { + // Can pass pin as argument, just using 20 as an example here + // Although since pins will be fixed, can just define it here if we need to + //d->value = pinRead(20); //Pin 20 on the Beaglebone + break; + } case DIGITAL_FAIL0: if( rand() % 100 > 98) d->value = 2;