[Firebug-cvs] fireboard/beta/tools/src/xlisten/boards fireboard.c,1.11,1.12 pg_test.c,1.4,1.5
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2005-06-01 23:34:29
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv421/boards Modified Files: fireboard.c pg_test.c Log Message: Weather data is now stored in processed form in database table weather. Index: pg_test.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards/pg_test.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pg_test.c 1 Jun 2005 22:19:07 -0000 1.4 --- pg_test.c 1 Jun 2005 23:34:20 -0000 1.5 *************** *** 18,27 **** "CREATE TABLE %s%s ( " "result_time timestamp without time zone, " - "epoch integer, " "nodeid integer, " - "parent integer, " "voltage integer, " ! "humid integer, " ! "humtemp integer, " "intersemacal1 integer, " "intersemacal2 integer, " --- 18,27 ---- "CREATE TABLE %s%s ( " "result_time timestamp without time zone, " "nodeid integer, " "voltage integer, " ! "humidity float, " ! "temperature float, " ! "pressure float)"; ! #if 0 "intersemacal1 integer, " "intersemacal2 integer, " *************** *** 32,37 **** "taosch0 integer, " "taosch1 integer, " ! "accel_x integer, " ! "accel_y integer)"; // TODO: Remove the SQL command. --- 32,37 ---- "taosch0 integer, " "taosch1 integer, " ! #endif ! // TODO: Remove the SQL command. Index: fireboard.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards/fireboard.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** fireboard.c 1 Jun 2005 22:19:06 -0000 1.11 --- fireboard.c 1 Jun 2005 23:34:20 -0000 1.12 *************** *** 16,19 **** --- 16,20 ---- #include <math.h> #include <NMEA.h> + #include <sensorboardApp.h> #include "../xdb.h" *************** *** 164,173 **** * @version 2004/3/29 husiquan Initial revision */ ! int fireboard_convert_temp(uint16_t TempData) { ! float fTemp; - fTemp = -38.4 + 0.0098*(float)TempData; - return (int)fTemp; - } /** --- 165,185 ---- * @version 2004/3/29 husiquan Initial revision */ ! int fireboard_convert_temp(uint16_t TempData) { ! float fTemp; ! ! fTemp = -38.4 + 0.0098*(float)TempData; ! return (int)fTemp; ! } ! ! ! float ! fb_convert_temp(uint16_t TempData) { ! ! float fTemp; ! ! fTemp = -38.4 + 0.0098*(float)TempData; ! return fTemp; ! } /** *************** *** 188,192 **** * @version 2004/3/29 husiquan Initial revision */ ! int fireboard_convert_humidity( uint16_t HumData, uint16_t TempData){ float fTemp,fHumidity; --- 200,204 ---- * @version 2004/3/29 husiquan Initial revision */ ! int fireboard_convert_humidity(uint16_t HumData, uint16_t TempData){ float fTemp,fHumidity; *************** *** 199,202 **** --- 211,227 ---- } + + float + fb_convert_humidity(uint16_t HumData, uint16_t TempData){ + + float fTemp,fHumidity; + + fTemp = -38.4 + 0.0098*(float)TempData; + fHumidity = -4.0 + 0.0405 * HumData -0.0000028 * HumData * HumData; + fHumidity= (fTemp-25.0)* (0.01 + 0.00008 * HumData) + fHumidity; + + return fHumidity; + } + /** *************** *** 281,284 **** --- 306,341 ---- + float + fb_convert_intersemapressure(uint16_t cal_word1,uint16_t cal_word2,uint16_t cal_word3,uint16_t + cal_word4,uint16_t TempData,uint16_t PressureData) { + + float UT1,dT; + float OFF,SENS,X,Press; + uint16_t calibration[4]; //intersema calibration words + uint16_t C1,C2,C3,C4,C5;//,C6; //intersema calibration coefficients + + calibration[0] = cal_word1; + calibration[1] = cal_word2; + calibration[2] = cal_word3; + calibration[3] = cal_word4; + + C1 = calibration[0] >> 1; + C2 = ((calibration[2] & 0x3f) << 6) | (calibration[3] & 0x3f); + C3 = calibration[3] >> 6; + C4 = calibration[2] >> 6; + C5 = ((calibration[0] & 1) << 10) | (calibration[1] >> 6); + // C6 = calibration[1] & 0x3f; + + UT1=8*(float)C5+20224; + dT = (float)TempData-UT1; + OFF = (float)C2*4 + (((float)C4-512.0)*dT)/1024; + SENS = (float)C1 + ((float)C3*dT)/1024 + 24576; + X = (SENS*((float)PressureData-7168.0))/16384 - OFF; + Press = X/32.0 + 250.0; + + return Press; + } + + /** * Converts mica2 battery reading from raw ADC data to engineering units. *************** *** 546,551 **** } ! void fireboard_print_cooked_1(XbowSensorboardPacket *packet) ! { XSensorMTS400Data1 *pd; --- 603,609 ---- } ! void ! fireboard_print_cooked_1(XbowSensorboardPacket *packet) { ! XSensorMTS400Data1 *pd; *************** *** 775,778 **** --- 833,872 ---- + void + fb_pg_log_xbow_weather_cooked(XbowSensorboardPacket *packet) { + + Weather_Data * data; + + char command[512]; + data = (Weather_Data *) packet->data; + int voltage; + float humidity; + float temperature; + float pressure; + //float light = fireboard_convert_light(data->taosch0,data->taosch1); + + voltage = fireboard_convert_battery(data->vref); + humidity = fb_convert_humidity(data->humidity,data->temperature); + temperature = fb_convert_temp(data->temperature); + pressure = fireboard_convert_intersemapressure(data->cal_word1, + data->cal_word2, + data->cal_word3, + data->cal_word4, + data->intersematemp, + data->pressure); + + sprintf(command, "INSERT into %s (result_time,nodeid,voltage,humidity,temperature,pressure) values (now(),%u,%u,%f,%f,%f)", + "xbow_weather", + packet->node_id, + voltage, + humidity, + temperature, + pressure); + + xdb_execute(command); + } + + + // drop table fireboard_results; // drop table fireboard_results_l; *************** *** 836,841 **** case 1:{ #if 1 ! fb_pg_log_xbow_weather(packet); ! //fb_pg_log_xbow_weather_cooked(packet); return; #else --- 930,935 ---- case 1:{ #if 1 ! //fb_pg_log_xbow_weather(packet); ! fb_pg_log_xbow_weather_cooked(packet); return; #else |