[Firebug-cvs] firebug/project/java/src/org/firebug XBow3Msg.java,1.1,1.2 XBowLogger.java,1.2,1.3
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2004-07-05 18:13:50
|
Update of /cvsroot/firebug/firebug/project/java/src/org/firebug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4573/project/java/src/org/firebug Modified Files: XBow3Msg.java XBowLogger.java Log Message: Database fix xbow logger. Index: XBowLogger.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/XBowLogger.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XBowLogger.java 2 Jul 2004 00:08:30 -0000 1.2 --- XBowLogger.java 5 Jul 2004 18:13:38 -0000 1.3 *************** *** 107,166 **** */ - public int mts400_convert_intersemapressure(byte [] packet) - { - - float UT1,dT; - float OFF,SENS,X,Press; - //uint16_t PressureData, TempData; - //uint16_t calibration[4]; //intersema calibration words - //uint16_t C1,C2,C3,C4,C5,C6; //intersema calibration coefficients - - short PressureData, TempData; - short [] calibration = new short[4]; //intersema calibration words - short C1,C2,C3,C4,C5,C6; //intersema calibration coefficients - - - //XSensorMTS400Data1 *data = (XSensorMTS400Data1 *)packet->data; - - calibration[0] = packet[15]; //data->cal_word1; - calibration[0] = (short)(packet[16] << 8); //data->cal_word1; - - calibration[1] = packet[17]; //data->cal_word2; - calibration[1] = (short)(packet[18] << 8); //data->cal_word2; - - calibration[2] = packet[19]; //data->cal_word3; - calibration[2] = (short)(packet[20] << 8); //data->cal_word3; - - calibration[3] = packet[21]; //data->cal_word4; - calibration[3] = (short)(packet[22] << 8); //data->cal_word4; - - PressureData = packet[23]; //data->intersemapressure; - PressureData = (short)(packet[24] << 8); //data->intersemapressure; - - TempData = packet[25]; //data->intersematemp; - TempData = (short)(packet[26] << 8); //data->intersematemp; - - C1 = (short)(calibration[0] >> 1); - C2 = (short)(((calibration[2] & 0x3f) << 6) | (calibration[3] & 0x3f)); - C3 = (short)(calibration[3] >> 6); - C4 = (short)(calibration[2] >> 6); - C5 = (short)(((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-(float)512.0)*dT)/(float)(1024); - SENS = (float)C1 + ((float)C3*dT)/(float)1024 + 24576; - X = (SENS*((float)PressureData-(float)7168.0))/16384 - OFF; - Press = X/(float)32.0 + (float)250.0; - System.out.println("Press: " + Press); - - return (int)Press; - } - public void parse_packet_1(byte [] packet) { XBow3Msg msg = new XBow3Msg(packet,9); int mote_id = packet[7]; --- 107,115 ---- */ public void parse_packet_1(byte [] packet) { XBow3Msg msg = new XBow3Msg(packet,9); + Connection conn = dbh.getConnection(); int mote_id = packet[7]; *************** *** 180,190 **** int intersematemp = (int)msg.get_fintersematemp(); //System.out.println("fintersematemp: " + intersematemp); ! float fintersematemp = (float)intersematemp;///(float)100000.0; System.out.println("fintersematemp: " + fintersematemp); int intersemapress = (int)msg.get_fintersemapressure(); //System.out.println("fintersematemp: " + intersemapress); ! float fintersemapress = (float)intersemapress;///(float)1000000.0; System.out.println("fintersemapressure: " + fintersemapress); } --- 129,193 ---- int intersematemp = (int)msg.get_fintersematemp(); //System.out.println("fintersematemp: " + intersematemp); ! float fintersematemp = (float)intersematemp/(float)100.0; System.out.println("fintersematemp: " + fintersematemp); int intersemapress = (int)msg.get_fintersemapressure(); //System.out.println("fintersematemp: " + intersemapress); ! float fintersemapress = (float)intersemapress/(float)10.0; System.out.println("fintersemapressure: " + fintersemapress); + + int ilux = (int)msg.get_lux(); + float lux = (float)ilux; + System.out.println("Lux: " + lux); + + /** FIXME: Ugly flow control using exception logic to + * to track down a bbad statement, needs to be cleaned up. + */ + try { + ResultSet rs; + Statement stmt = conn.createStatement(); + int cnt = 0; + + String updatequery = "UPDATE current " + + "SET " + //+ "time=" + time + ", " + + "cnt=" + cnt + "," + + "rel_hum=" + fHumidity + ", " + + "baro_pres=" + fintersemapress + ", " + + "temp=" + fintersematemp + "," + + "lux=" + lux + + " WHERE mote_id=" + mote_id; + + String insertquery = "INSERT INTO cumulative VALUES (" + + mote_id + ", " + + "NULL," // NULL lets timestamp do its thing. //time + ", " + + cnt + ", " + + fintersematemp + ", " + + fHumidity + ", " + + fintersemapress + ", " + + lux + ")"; + + + try { + rs = stmt.executeQuery(insertquery); + } catch (SQLException sqle) { + System.out.println("Problem with insert statement: " + insertquery); + sqle.printStackTrace(); + } + + try { + rs = stmt.executeQuery(updatequery); + } catch (SQLException sqle) { + System.out.println("Problem with update statement: " + updatequery); + sqle.printStackTrace(); + } + stmt.close(); + } catch (SQLException sqle) { + System.out.println("Problem with statement"); + sqle.printStackTrace(); + } + + dbh.return_connection(conn); + } *************** *** 193,206 **** public void parse_packet_2(byte [] packet) { ! } /** Put everything in print for now. */ public void print(byte [] packet) { - - - // Ugh what a kludge. The GPS date/time format // is not compatible with java. The date/time --- 196,207 ---- public void parse_packet_2(byte [] packet) { ! print_packet_raw(packet); } + /** Put everything in print for now. */ public void print(byte [] packet) { // Ugh what a kludge. The GPS date/time format // is not compatible with java. The date/time Index: XBow3Msg.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/XBow3Msg.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XBow3Msg.java 2 Jul 2004 00:08:30 -0000 1.1 --- XBow3Msg.java 5 Jul 2004 18:13:38 -0000 1.2 *************** *** 106,116 **** } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { ! s += " [intersemapressure=0x"+Long.toHexString(get_intersemapressure())+"]\n"; ! } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } ! try { ! s += " [taosch0=0x"+Long.toHexString(get_taosch0())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { ! s += " [taosch1=0x"+Long.toHexString(get_taosch1())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { --- 106,113 ---- } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { ! s += " [lux=0x"+Long.toHexString(get_lux())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { ! s += " [intersemapressure=0x"+Long.toHexString(get_intersemapressure())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { *************** *** 501,631 **** ///////////////////////////////////////////////////////// ! // Accessor methods for field: intersemapressure ! // Field type: int, unsigned // Offset (bits): 128 ! // Size (bits): 16 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'intersemapressure' is signed (false). */ ! public static boolean isSigned_intersemapressure() { return false; } /** ! * Return whether the field 'intersemapressure' is an array (false). */ ! public static boolean isArray_intersemapressure() { return false; } /** ! * Return the offset (in bytes) of the field 'intersemapressure' */ ! public static int offset_intersemapressure() { return (128 / 8); } /** ! * Return the offset (in bits) of the field 'intersemapressure' */ ! public static int offsetBits_intersemapressure() { return 128; } /** ! * Return the value (as a int) of the field 'intersemapressure' ! */ ! public int get_intersemapressure() { ! return (int)getUIntElement(offsetBits_intersemapressure(), 16); ! } ! ! /** ! * Set the value of the field 'intersemapressure' ! */ ! public void set_intersemapressure(int value) { ! setUIntElement(offsetBits_intersemapressure(), 16, value); ! } ! ! /** ! * Return the size, in bytes, of the field 'intersemapressure' ! */ ! public static int size_intersemapressure() { ! return (16 / 8); ! } ! ! /** ! * Return the size, in bits, of the field 'intersemapressure' ! */ ! public static int sizeBits_intersemapressure() { ! return 16; ! } ! ! ///////////////////////////////////////////////////////// ! // Accessor methods for field: taosch0 ! // Field type: int, unsigned ! // Offset (bits): 144 ! // Size (bits): 16 ! ///////////////////////////////////////////////////////// ! ! /** ! * Return whether the field 'taosch0' is signed (false). ! */ ! public static boolean isSigned_taosch0() { ! return false; ! } ! ! /** ! * Return whether the field 'taosch0' is an array (false). ! */ ! public static boolean isArray_taosch0() { ! return false; ! } ! ! /** ! * Return the offset (in bytes) of the field 'taosch0' ! */ ! public static int offset_taosch0() { ! return (144 / 8); ! } ! ! /** ! * Return the offset (in bits) of the field 'taosch0' ! */ ! public static int offsetBits_taosch0() { ! return 144; ! } ! ! /** ! * Return the value (as a int) of the field 'taosch0' */ ! public int get_taosch0() { ! return (int)getUIntElement(offsetBits_taosch0(), 16); } /** ! * Set the value of the field 'taosch0' */ ! public void set_taosch0(int value) { ! setUIntElement(offsetBits_taosch0(), 16, value); } /** ! * Return the size, in bytes, of the field 'taosch0' */ ! public static int size_taosch0() { ! return (16 / 8); } /** ! * Return the size, in bits, of the field 'taosch0' */ ! public static int sizeBits_taosch0() { ! return 16; } ///////////////////////////////////////////////////////// ! // Accessor methods for field: taosch1 // Field type: int, unsigned // Offset (bits): 160 --- 498,565 ---- ///////////////////////////////////////////////////////// ! // Accessor methods for field: lux ! // Field type: long, unsigned // Offset (bits): 128 ! // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'lux' is signed (false). */ ! public static boolean isSigned_lux() { return false; } /** ! * Return whether the field 'lux' is an array (false). */ ! public static boolean isArray_lux() { return false; } /** ! * Return the offset (in bytes) of the field 'lux' */ ! public static int offset_lux() { return (128 / 8); } /** ! * Return the offset (in bits) of the field 'lux' */ ! public static int offsetBits_lux() { return 128; } /** ! * Return the value (as a long) of the field 'lux' */ ! public long get_lux() { ! return (long)getUIntElement(offsetBits_lux(), 32); } /** ! * Set the value of the field 'lux' */ ! public void set_lux(long value) { ! setUIntElement(offsetBits_lux(), 32, value); } /** ! * Return the size, in bytes, of the field 'lux' */ ! public static int size_lux() { ! return (32 / 8); } /** ! * Return the size, in bits, of the field 'lux' */ ! public static int sizeBits_lux() { ! return 32; } ///////////////////////////////////////////////////////// ! // Accessor methods for field: intersemapressure // Field type: int, unsigned // Offset (bits): 160 *************** *** 634,689 **** /** ! * Return whether the field 'taosch1' is signed (false). */ ! public static boolean isSigned_taosch1() { return false; } /** ! * Return whether the field 'taosch1' is an array (false). */ ! public static boolean isArray_taosch1() { return false; } /** ! * Return the offset (in bytes) of the field 'taosch1' */ ! public static int offset_taosch1() { return (160 / 8); } /** ! * Return the offset (in bits) of the field 'taosch1' */ ! public static int offsetBits_taosch1() { return 160; } /** ! * Return the value (as a int) of the field 'taosch1' */ ! public int get_taosch1() { ! return (int)getUIntElement(offsetBits_taosch1(), 16); } /** ! * Set the value of the field 'taosch1' */ ! public void set_taosch1(int value) { ! setUIntElement(offsetBits_taosch1(), 16, value); } /** ! * Return the size, in bytes, of the field 'taosch1' */ ! public static int size_taosch1() { return (16 / 8); } /** ! * Return the size, in bits, of the field 'taosch1' */ ! public static int sizeBits_taosch1() { return 16; } --- 568,623 ---- /** ! * Return whether the field 'intersemapressure' is signed (false). */ ! public static boolean isSigned_intersemapressure() { return false; } /** ! * Return whether the field 'intersemapressure' is an array (false). */ ! public static boolean isArray_intersemapressure() { return false; } /** ! * Return the offset (in bytes) of the field 'intersemapressure' */ ! public static int offset_intersemapressure() { return (160 / 8); } /** ! * Return the offset (in bits) of the field 'intersemapressure' */ ! public static int offsetBits_intersemapressure() { return 160; } /** ! * Return the value (as a int) of the field 'intersemapressure' */ ! public int get_intersemapressure() { ! return (int)getUIntElement(offsetBits_intersemapressure(), 16); } /** ! * Set the value of the field 'intersemapressure' */ ! public void set_intersemapressure(int value) { ! setUIntElement(offsetBits_intersemapressure(), 16, value); } /** ! * Return the size, in bytes, of the field 'intersemapressure' */ ! public static int size_intersemapressure() { return (16 / 8); } /** ! * Return the size, in bits, of the field 'intersemapressure' */ ! public static int sizeBits_intersemapressure() { return 16; } |