From 40aa63f285b9a2ed67aac67055a205de1a8d95ba Mon Sep 17 00:00:00 2001 From: Jeremy Tan Date: Fri, 1 Nov 2013 12:45:02 +0800 Subject: [PATCH] Final commit from marbles Not the dilatometer mods though --- server/image.c | 17 +++++++++++------ server/sensor.c | 19 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/server/image.c b/server/image.c index a32ac2c..dcc122d 100644 --- a/server/image.c +++ b/server/image.c @@ -10,6 +10,7 @@ static int g_captureID = -1; void Image_Handler(FCGIContext * context, char * params) { + int num = 0, width = 1600, height = 1200; // Set Default values FCGIValue val[] = { {"num", &num, FCGI_INT_T}, @@ -74,18 +75,22 @@ void Image_Handler(FCGIContext * context, char * params) g_captureID = num; } - cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_WIDTH, width); - cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_HEIGHT, height); + if (g_capture != NULL) + { + + cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_WIDTH, width); + cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_HEIGHT, height); - *frame = cvQueryFrame(g_capture); - result = (*frame != NULL); + *frame = cvQueryFrame(g_capture); + result = (*frame != NULL); //cvShowImage("display", *image); //cvWaitKey(0); //cvSaveImage("test.jpg",*image,0); - Log(LOGDEBUG, "At end of mutex"); - + Log(LOGDEBUG, "At end of mutex"); + } + pthread_mutex_unlock(&mutex); //Close the mutex //NOTE: Never have a "return" statement before the mutex is unlocked; it causes deadlocks! diff --git a/server/sensor.c b/server/sensor.c index b934e8f..4e8ac7f 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -76,6 +76,7 @@ int Sensor_Add(const char * name, int user_id, ReadFn read, InitFn init, CleanFn #include "sensors/strain.h" #include "sensors/pressure.h" #include "sensors/dilatometer.h" +#include "sensors/microphone.h" void Sensor_Init() { //Sensor_Add("cpu_stime", RESOURCE_CPU_SYS, Resource_Read, NULL, NULL, NULL); @@ -84,16 +85,20 @@ void Sensor_Init() Sensor_Add("pressure_high1", PRES_HIGH1, Pressure_Read, Pressure_Init, Pressure_Cleanup, NULL); Sensor_Add("pressure_low0", PRES_LOW0, Pressure_Read, Pressure_Init, Pressure_Cleanup, NULL); //Sensor_Add("../testing/count.py", 0, Piped_Read, Piped_Init, Piped_Cleanup, 1e50,-1e50,1e50,-1e50); - Sensor_Add("strain0_endhoop", STRAIN0, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); - Sensor_Add("strain1_endlong", STRAIN1, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); - Sensor_Add("strain2_midhoop", STRAIN2, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); - Sensor_Add("strain3_midlong", STRAIN3, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); + //Sensor_Add("strain0_endhoop", STRAIN0, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); + //Sensor_Add("strain1_endlong", STRAIN1, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); + //Sensor_Add("strain2_midhoop", STRAIN2, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); + //Sensor_Add("strain3_midlong", STRAIN3, Strain_Read, Strain_Init, Strain_Cleanup, Strain_Sanity); + + //Sensor_Add("microphone", 0, Microphone_Read, Microphone_Init, Microphone_Cleanup, Microphone_Sanity); //Sensor_Add("pressure0", PRESSURE0, Pressure_Read, Pressure_Init, 5000,0,5000,0); //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_pos", DIL_POS, Dilatometer_Read, Dilatometer_Init, Dilatometer_Cleanup, NULL); - //Sensor_Add("dilatometer_diff",DIL_DIFF, Dilatometer_Read, Dilatometer_Init, Dilatometer_Cleanup, NULL); + //Sensor_Add("enclosure", ENCLOSURE, Enclosure_Read, Enclosure_Init, 1,1,1,1); // Does not exist... + + //NOTE: DO NOT ENABLE DILATOMETER WITHOUT FURTHER TESTING; CAUSES SEGFAULTS + //Sensor_Add("dilatometer0", 0, Dilatometer_Read, Dilatometer_Init, Dilatometer_Cleanup, NULL); + //Sensor_Add("dilatometer1",1, Dilatometer_Read, Dilatometer_Init, Dilatometer_Cleanup, NULL); } /** -- 2.20.1