From: Sam Moore Date: Tue, 29 Oct 2013 04:56:41 +0000 (+0800) Subject: Add dilatometer as sensor X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d0b1d76f88063c93aa66c5dc9b5a48e2aa4dcfe3;p=matches%2FMCTX3420.git Add dilatometer as sensor Changed type of functions as needed and called Sensor_Add appropriately. --- diff --git a/server/sensor.c b/server/sensor.c index 53b3f03..a87a4d8 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -75,6 +75,7 @@ int Sensor_Add(const char * name, int user_id, ReadFn read, InitFn init, CleanFn #include "sensors/resource.h" #include "sensors/strain.h" #include "sensors/pressure.h" +#include "sensors/dilatometer.h" void Sensor_Init() { //Sensor_Add("cpu_stime", RESOURCE_CPU_SYS, Resource_Read, NULL, NULL, NULL); @@ -91,7 +92,7 @@ void Sensor_Init() //Sensor_Add("pressure1", PRESSURE1, Pressure_Read, Pressure_Init, 5000,0,5000,0); //Sensor_Add("pressure_feedback", PRESSURE_FEEDBACK, Pressure_Read, Pressure_Init, 5000,0,5000,0); //Sensor_Add("enclosure", ENCLOSURE, Enclosure_Read, Enclosure_Init, 1,1,1,1); - //Sensor_Add("dilatometer", DILATOMETER, Dilatometer_Read, Dilatometer_Init, -1,-1,-1,-1); + Sensor_Add("dilatometer", 0, Dilatometer_Read, Dilatometer_Init, Dilatometer_Cleanup, NULL); } /** diff --git a/server/sensors/dilatometer.c b/server/sensors/dilatometer.c index 684a425..0bbda6b 100644 --- a/server/sensors/dilatometer.c +++ b/server/sensors/dilatometer.c @@ -68,7 +68,7 @@ void Dilatometer_TestImage() /** * Cleanup Dilatometer pointers */ -void Dilatometer_Cleanup() +bool Dilatometer_Cleanup(int id) { if (g_capture != NULL) cvReleaseCapture(&g_capture); @@ -80,6 +80,7 @@ void Dilatometer_Cleanup() cvReleaseMat(&g_srcGray); if (g_edges != NULL) cvReleaseMat(&g_edges); + return true; } /** @@ -224,7 +225,7 @@ bool Dilatometer_GetEdge( double * value, int samples) * @param val - Will store the read value if successful * @returns true on successful read */ -bool Dilatometer_Read( double * value) +bool Dilatometer_Read(int id, double * value) { bool result = Dilatometer_GetEdge(value, SAMPLES); return result; @@ -233,11 +234,12 @@ bool Dilatometer_Read( double * value) /** * Initialise the dilatometer */ -void Dilatometer_Init() +bool Dilatometer_Init(const char * name, int id) { // Make an initial reading (will allocate memory the first time only). double val; Dilatometer_GetEdge(&val, 1); + return true; } // Overlays a line over the given edge position diff --git a/server/sensors/dilatometer.h b/server/sensors/dilatometer.h index 7bb9447..2c683d6 100644 --- a/server/sensors/dilatometer.h +++ b/server/sensors/dilatometer.h @@ -3,7 +3,7 @@ * @brief Declarations for functions to deal with dilatometer */ -#include "common.h" +#include "../common.h" //Threshold to determine the edge of the can #define THRES 230 @@ -11,7 +11,7 @@ //Number of samples of the image to take #define SAMPLES 600 -extern void Dilatometer_Init(); // Initialise the dilatometer -extern void Dilatometer_Cleanup(); // Cleanup -extern bool Dilatometer_Read( double * value); // Read the Dilatometer +extern bool Dilatometer_Init(const char * name, int id); // Initialise the dilatometer +extern bool Dilatometer_Cleanup(int id); // Cleanup +extern bool Dilatometer_Read(int id, double * value); // Read the Dilatometer