[Firebug-cvs] fireboard/beta/tools/src/xlisten/boards fireboard.c,1.10,1.11 pg_test.c,1.3,1.4
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2005-06-01 22:19:16
|
Update of /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25276/boards Modified Files: fireboard.c pg_test.c Log Message: Reworked tables for cumulative and latest results. Index: pg_test.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards/pg_test.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pg_test.c 1 Jun 2005 18:06:08 -0000 1.3 --- pg_test.c 1 Jun 2005 22:19:07 -0000 1.4 *************** *** 10,13 **** --- 10,16 ---- #include "../xsensors.h" + // TODO: Condense tables down to gga, weather, etc. + + // TODO: Change these to cooked values. // TODO: Remove the SQL command. *************** *** 33,37 **** // TODO: Remove the SQL command. ! const char *fb_pg_location_schema = "CREATE TABLE %s%s ( " "nodeid integer, " --- 36,40 ---- // TODO: Remove the SQL command. ! const char *fb_pg_gga_schema = "CREATE TABLE %s%s ( " "nodeid integer, " *************** *** 46,85 **** ! /* ! * Want 4 tables for asset tracking: ! * cumulative_weather ! * current weather ! * cumulative_location ! * current_location ! */ static char pg_statement[512]; - void - fb_pg_create_cum_weather_table (void) { - - sprintf(pg_statement, fb_pg_weather_schema, "cumulative_weather", ""); - xdb_execute(pg_statement); - } - void - fb_pg_create_cur_weather_table (void) { - - sprintf(pg_statement, fb_pg_weather_schema, "current_weather", ""); - xdb_execute(pg_statement); - } void ! fb_pg_create_cum_location_table (void) { ! sprintf(pg_statement, fb_pg_location_schema, "cumulative_location", ""); xdb_execute(pg_statement); } void ! fb_pg_create_cur_location_table (void) { ! sprintf(pg_statement, fb_pg_location_schema, "current_location", ""); xdb_execute(pg_statement); } /** * Use this function for creating all of the tables --- 49,91 ---- ! const char *fb_pg_cache_rule = ! "CREATE RULE cache_%s AS ON INSERT TO %s DO ( " ! "DELETE FROM %s_L WHERE nodeid = NEW.nodeid; " ! "INSERT INTO %s_L VALUES (NEW.*); )"; ! ! static char pg_statement[512]; void ! fb_pg_create_xbow_weather_table (void) { ! ! const char * table = "xbow_weather"; ! sprintf(pg_statement, fb_pg_weather_schema, table, ""); ! xdb_execute(pg_statement); ! sprintf(pg_statement, fb_pg_weather_schema, table, "_L"); ! xdb_execute(pg_statement); ! // Add rule to update "latest results" table. ! sprintf(pg_statement, fb_pg_cache_rule, table, table, table, table); xdb_execute(pg_statement); } + void ! fb_pg_create_gga_table (void) { ! const char * table = "gga"; ! ! sprintf(pg_statement, fb_pg_gga_schema, table, ""); ! xdb_execute(pg_statement); ! sprintf(pg_statement, fb_pg_gga_schema, table, "_L"); ! xdb_execute(pg_statement); ! // Add rule to populate latest result table ! sprintf(pg_statement, fb_pg_cache_rule, table, table, table, table); xdb_execute(pg_statement); } + /** * Use this function for creating all of the tables *************** *** 89,96 **** fb_pg_create_tables(void) { ! fb_pg_create_cum_weather_table(); ! fb_pg_create_cur_weather_table(); ! fb_pg_create_cum_location_table(); ! fb_pg_create_cur_location_table(); } --- 95,100 ---- fb_pg_create_tables(void) { ! fb_pg_create_xbow_weather_table(); ! fb_pg_create_gga_table(); } *************** *** 111,118 **** fb_pg_delete_tables(void) { ! fb_pg_delete_table("cumulative_weather"); ! fb_pg_delete_table("current_weather"); ! fb_pg_delete_table("cumulative_location"); ! fb_pg_delete_table("current_location"); } --- 115,122 ---- fb_pg_delete_tables(void) { ! fb_pg_delete_table("xbow_weather"); ! fb_pg_delete_table("xbow_weather_L"); ! fb_pg_delete_table("gga"); ! fb_pg_delete_table("gga_L"); } *************** *** 131,134 **** --- 135,139 ---- + // TODO: Switch this to non-xbow specific packet. void *************** *** 142,146 **** "NSEWind) " "values (%u,%u,%u,%f,%u,%f,%u,%f,%u)", ! "cumulative_location", packet->node_id, data->hours, --- 147,151 ---- "NSEWind) " "values (%u,%u,%u,%f,%u,%f,%u,%f,%u)", ! "gga", packet->node_id, data->hours, *************** *** 153,177 **** data->NSEWind); - //printf("pg_statement: %s\n", pg_statement); - //printf("table: %s\n", xdb_get_table()); - xdb_execute(pg_statement); - - // TODO: Replace this with a rules cache statement. - #if 0 - // TODO: This needs to be changed to a REPLACE statement. - sprintf(pg_statement, - "INSERT into %s " - "(result_time,nodeid,parent,Hours,Minutes,seconds," - "Latitudedegree,Latitudeminutes,Longitudedegree,Longitudeminute," - "NSEWind)" - " values (now(),%u,%u,%u,%u,%f,%u,%f,%u,%f,%u)", - "current_location", - packet->node_id, packet->parent, - data->hours, data->minutes, data->dec_sec, - data->Lat_deg, data->Lat_dec_min, - data->Long_deg, data->Long_dec_min, data->NSEWind); - - xdb_execute(pg_statement); - #endif } --- 158,161 ---- Index: fireboard.c =================================================================== RCS file: /cvsroot/firebug/fireboard/beta/tools/src/xlisten/boards/fireboard.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** fireboard.c 1 Jun 2005 18:06:08 -0000 1.10 --- fireboard.c 1 Jun 2005 22:19:06 -0000 1.11 *************** *** 751,757 **** - void - fb_pg_log(XbowSensorboardPacket *packet) { } --- 751,775 ---- + void + fb_pg_log_xbow_weather(XbowSensorboardPacket *packet) { + + XSensorMTS400Data1 *data = (XSensorMTS400Data1 *)packet->data; + + char command[512]; + sprintf(command, + "INSERT into %s " + "(result_time,nodeid,parent,voltage,humid,humtemp," + "intersemacal1,intersemacal2,intersemacal3,intersemacal4," + "prtemp,press,taosch0,taosch1,accel_x,accel_y)" + " values (now(),%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u)", + "xbow_weather", + packet->node_id, packet->parent, + data->vref, data->humidity, data->temp, + data->cal_word1,data->cal_word2,data->cal_word3,data->cal_word4, + data->intersematemp, data->intersemapressure, + data->taosch0,data->taosch1, data->accel_x, GET_ACCEL_Y + ); + xdb_execute(command); } *************** *** 817,822 **** switch(packet->packet_id){ case 1:{ XSensorMTS400Data1 *data = (XSensorMTS400Data1 *)packet->data; - sprintf(command, "INSERT into %s " --- 835,844 ---- switch(packet->packet_id){ case 1:{ + #if 1 + fb_pg_log_xbow_weather(packet); + //fb_pg_log_xbow_weather_cooked(packet); + return; + #else XSensorMTS400Data1 *data = (XSensorMTS400Data1 *)packet->data; sprintf(command, "INSERT into %s " *************** *** 834,837 **** --- 856,860 ---- ); break; + #endif } case 2:{ |