[Firebug-cvs] firebug/project/java/src/org/firebug FireMsg.java,1.4,1.5 ListenFB.java,1.22,1.23 Rang
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2004-08-09 19:47:48
|
Update of /cvsroot/firebug/firebug/project/java/src/org/firebug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9641/src/org/firebug Modified Files: FireMsg.java ListenFB.java RangeMsg.java XBowLogger.java Log Message: Working java code. Index: XBowLogger.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/XBowLogger.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XBowLogger.java 5 Jul 2004 20:44:21 -0000 1.4 --- XBowLogger.java 9 Aug 2004 19:47:37 -0000 1.5 *************** *** 196,200 **** public void parse_packet_2(byte [] packet) { ! print_packet_raw(packet); } --- 196,254 ---- public void parse_packet_2(byte [] packet) { ! //print_packet_raw(packet); ! ! XBow4Msg msg = new XBow4Msg(packet,9); ! Connection conn = dbh.getConnection(); ! ! int mote_id = packet[7]; ! System.out.println("Mote id: " + packet[7]); ! ! int hours = msg.get_hours(); ! int minutes = msg.get_minutes(); ! int Lat_deg = msg.get_Lat_deg(); ! int Long_deg = msg.get_Long_deg(); ! int num_sats = msg.get_num_sats(); ! int NSEWind = 17; ! double Lat_dec_min = msg.get_Lat_dec_min(); ! double Long_dec_min = msg.get_Long_dec_min(); ! double dec_sec = msg.get_dec_sec(); ! ! ! /** 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(); ! ! ! String insertquery = "INSERT INTO location VALUES (" ! + mote_id + ", " ! + hours + ", " ! + minutes + ", " ! + dec_sec + ", " ! + Lat_deg + ", " ! + Lat_dec_min + ", " ! + Long_deg + ", " ! + Long_dec_min + ", " ! + NSEWind + "," ! + num_sats + ")"; ! ! ! try { ! rs = stmt.executeQuery(insertquery); ! } catch (SQLException sqle) { ! System.out.println("Problem with insert statement: " + insertquery); ! sqle.printStackTrace(); ! } ! stmt.close(); ! } catch (SQLException sqle) { ! System.out.println("Problem with statement"); ! sqle.printStackTrace(); ! } ! ! ! ! dbh.return_connection(conn); } Index: FireMsg.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/FireMsg.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FireMsg.java 2 Jul 2004 00:08:30 -0000 1.4 --- FireMsg.java 9 Aug 2004 19:47:37 -0000 1.5 *************** *** 88,91 **** --- 88,94 ---- String s = "Message <FireMsg> \n"; try { + s += " [magic=0x"+Long.toHexString(get_magic())+"]\n"; + } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } + try { s += " [mote_id=0x"+Long.toHexString(get_mote_id())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } *************** *** 105,111 **** s += " [lux="+Float.toString(get_lux())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } - try { - s += " [magic=0x"+Long.toHexString(get_magic())+"]\n"; - } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } return s; } --- 108,111 ---- *************** *** 114,128 **** ///////////////////////////////////////////////////////// ! // Accessor methods for field: mote_id ! // Field type: int, unsigned // Offset (bits): 0 // Size (bits): 16 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'mote_id' is signed (false). */ public static boolean isSigned_mote_id() { ! return false; } --- 114,191 ---- ///////////////////////////////////////////////////////// ! // Accessor methods for field: magic ! // Field type: short // Offset (bits): 0 + // Size (bits): 8 + ///////////////////////////////////////////////////////// + + /** + * Return whether the field 'magic' is signed (true). + */ + public static boolean isSigned_magic() { + return true; + } + + /** + * Return whether the field 'magic' is an array (false). + */ + public static boolean isArray_magic() { + return false; + } + + /** + * Return the offset (in bytes) of the field 'magic' + */ + public static int offset_magic() { + return (0 / 8); + } + + /** + * Return the offset (in bits) of the field 'magic' + */ + public static int offsetBits_magic() { + return 0; + } + + /** + * Return the value (as a short) of the field 'magic' + */ + public short get_magic() { + return (short)getUIntElement(offsetBits_magic(), 8); + } + + /** + * Set the value of the field 'magic' + */ + public void set_magic(short value) { + setUIntElement(offsetBits_magic(), 8, value); + } + + /** + * Return the size, in bytes, of the field 'magic' + */ + public static int size_magic() { + return (8 / 8); + } + + /** + * Return the size, in bits, of the field 'magic' + */ + public static int sizeBits_magic() { + return 8; + } + + ///////////////////////////////////////////////////////// + // Accessor methods for field: mote_id + // Field type: int + // Offset (bits): 8 // Size (bits): 16 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'mote_id' is signed (true). */ public static boolean isSigned_mote_id() { ! return true; } *************** *** 138,142 **** */ public static int offset_mote_id() { ! return (0 / 8); } --- 201,205 ---- */ public static int offset_mote_id() { ! return (8 / 8); } *************** *** 145,149 **** */ public static int offsetBits_mote_id() { ! return 0; } --- 208,212 ---- */ public static int offsetBits_mote_id() { ! return 8; } *************** *** 178,191 **** ///////////////////////////////////////////////////////// // Accessor methods for field: cnt ! // Field type: int, unsigned ! // Offset (bits): 16 // Size (bits): 16 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'cnt' is signed (false). */ public static boolean isSigned_cnt() { ! return false; } --- 241,254 ---- ///////////////////////////////////////////////////////// // Accessor methods for field: cnt ! // Field type: int ! // Offset (bits): 24 // Size (bits): 16 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'cnt' is signed (true). */ public static boolean isSigned_cnt() { ! return true; } *************** *** 201,205 **** */ public static int offset_cnt() { ! return (16 / 8); } --- 264,268 ---- */ public static int offset_cnt() { ! return (24 / 8); } *************** *** 208,212 **** */ public static int offsetBits_cnt() { ! return 16; } --- 271,275 ---- */ public static int offsetBits_cnt() { ! return 24; } *************** *** 241,254 **** ///////////////////////////////////////////////////////// // Accessor methods for field: temp ! // Field type: float, unsigned ! // Offset (bits): 32 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'temp' is signed (false). */ public static boolean isSigned_temp() { ! return false; } --- 304,317 ---- ///////////////////////////////////////////////////////// // Accessor methods for field: temp ! // Field type: float ! // Offset (bits): 40 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'temp' is signed (true). */ public static boolean isSigned_temp() { ! return true; } *************** *** 264,268 **** */ public static int offset_temp() { ! return (32 / 8); } --- 327,331 ---- */ public static int offset_temp() { ! return (40 / 8); } *************** *** 271,275 **** */ public static int offsetBits_temp() { ! return 32; } --- 334,338 ---- */ public static int offsetBits_temp() { ! return 40; } *************** *** 304,317 **** ///////////////////////////////////////////////////////// // Accessor methods for field: rel_hum ! // Field type: float, unsigned ! // Offset (bits): 64 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'rel_hum' is signed (false). */ public static boolean isSigned_rel_hum() { ! return false; } --- 367,380 ---- ///////////////////////////////////////////////////////// // Accessor methods for field: rel_hum ! // Field type: float ! // Offset (bits): 72 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'rel_hum' is signed (true). */ public static boolean isSigned_rel_hum() { ! return true; } *************** *** 327,331 **** */ public static int offset_rel_hum() { ! return (64 / 8); } --- 390,394 ---- */ public static int offset_rel_hum() { ! return (72 / 8); } *************** *** 334,338 **** */ public static int offsetBits_rel_hum() { ! return 64; } --- 397,401 ---- */ public static int offsetBits_rel_hum() { ! return 72; } *************** *** 367,380 **** ///////////////////////////////////////////////////////// // Accessor methods for field: baro_pres ! // Field type: float, unsigned ! // Offset (bits): 96 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'baro_pres' is signed (false). */ public static boolean isSigned_baro_pres() { ! return false; } --- 430,443 ---- ///////////////////////////////////////////////////////// // Accessor methods for field: baro_pres ! // Field type: float ! // Offset (bits): 104 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'baro_pres' is signed (true). */ public static boolean isSigned_baro_pres() { ! return true; } *************** *** 390,394 **** */ public static int offset_baro_pres() { ! return (96 / 8); } --- 453,457 ---- */ public static int offset_baro_pres() { ! return (104 / 8); } *************** *** 397,401 **** */ public static int offsetBits_baro_pres() { ! return 96; } --- 460,464 ---- */ public static int offsetBits_baro_pres() { ! return 104; } *************** *** 430,443 **** ///////////////////////////////////////////////////////// // Accessor methods for field: lux ! // Field type: float, unsigned ! // Offset (bits): 128 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'lux' is signed (false). */ public static boolean isSigned_lux() { ! return false; } --- 493,506 ---- ///////////////////////////////////////////////////////// // Accessor methods for field: lux ! // Field type: float ! // Offset (bits): 136 // Size (bits): 32 ///////////////////////////////////////////////////////// /** ! * Return whether the field 'lux' is signed (true). */ public static boolean isSigned_lux() { ! return true; } *************** *** 453,457 **** */ public static int offset_lux() { ! return (128 / 8); } --- 516,520 ---- */ public static int offset_lux() { ! return (136 / 8); } *************** *** 460,464 **** */ public static int offsetBits_lux() { ! return 128; } --- 523,527 ---- */ public static int offsetBits_lux() { ! return 136; } *************** *** 491,556 **** } - ///////////////////////////////////////////////////////// - // Accessor methods for field: magic - // Field type: short, unsigned - // Offset (bits): 160 - // Size (bits): 8 - ///////////////////////////////////////////////////////// - - /** - * Return whether the field 'magic' is signed (false). - */ - public static boolean isSigned_magic() { - return false; - } - - /** - * Return whether the field 'magic' is an array (false). - */ - public static boolean isArray_magic() { - return false; - } - - /** - * Return the offset (in bytes) of the field 'magic' - */ - public static int offset_magic() { - return (160 / 8); - } - - /** - * Return the offset (in bits) of the field 'magic' - */ - public static int offsetBits_magic() { - return 160; - } - - /** - * Return the value (as a short) of the field 'magic' - */ - public short get_magic() { - return (short)getUIntElement(offsetBits_magic(), 8); - } - - /** - * Set the value of the field 'magic' - */ - public void set_magic(short value) { - setUIntElement(offsetBits_magic(), 8, value); - } - - /** - * Return the size, in bytes, of the field 'magic' - */ - public static int size_magic() { - return (8 / 8); - } - - /** - * Return the size, in bits, of the field 'magic' - */ - public static int sizeBits_magic() { - return 8; - } - } --- 554,556 ---- Index: ListenFB.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/ListenFB.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ListenFB.java 2 Jul 2004 00:08:30 -0000 1.22 --- ListenFB.java 9 Aug 2004 19:47:37 -0000 1.23 *************** *** 66,69 **** --- 66,74 ---- private XBowLogger xbowlogger; + private dispatch [] da = { + new dispatch(128,firelogger), + new dispatch(129,rangelogger), + new dispatch(0,null) + }; /** Use this interface when changing the output *************** *** 173,176 **** --- 178,182 ---- static int extract_am_type(byte [] packet) { + System.out.println("Packet[5]: " + packet[5]); return (int)(packet[5]&0xFF); } *************** *** 210,215 **** * payload to determine which kind of payload it is. */ ! //int am_type = extract_am_type(packet); ! int am_type = get_xbow_packet_id(packet); System.out.println("AM type number: " + am_type); PacketPrinter printer = GetPrinter(am_type); --- 216,221 ---- * payload to determine which kind of payload it is. */ ! int am_type = extract_am_type(packet); ! //int am_type = get_xbow_packet_id(packet); System.out.println("AM type number: " + am_type); PacketPrinter printer = GetPrinter(am_type); *************** *** 269,277 **** // at the base station level. ! //listener.firelogger = new FireLogger(dbname); ! //listener.rangelogger = new RangeLogger(dbname); ! //listener.gpslogger = new GPSLogger(dbname); ! listener.xbowlogger = new XBowLogger(dbname); try { --- 275,283 ---- // at the base station level. ! listener.firelogger = new FireLogger(dbname); ! listener.rangelogger = new RangeLogger(dbname); ! listener.gpslogger = new GPSLogger(dbname); ! //listener.xbowlogger = new XBowLogger(dbname); try { *************** *** 283,284 **** --- 289,302 ---- } + + class dispatch { + + public int type; + public ListenFB.PacketPrinter pp; + + public dispatch(int type, ListenFB.PacketPrinter pp) { + this.type = type; + this.pp = pp; + } + + } Index: RangeMsg.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/RangeMsg.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RangeMsg.java 27 Mar 2004 00:04:47 -0000 1.2 --- RangeMsg.java 9 Aug 2004 19:47:37 -0000 1.3 *************** *** 10,19 **** /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 9; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 129; ! /** Create a new RangeMsg of size 9. */ public RangeMsg() { super(DEFAULT_MESSAGE_SIZE); --- 10,19 ---- /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 11; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 129; ! /** Create a new RangeMsg of size 11. */ public RangeMsg() { super(DEFAULT_MESSAGE_SIZE); *************** *** 102,105 **** --- 102,114 ---- s += " [voltage=0x"+Long.toHexString(get_voltage())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } + try { + s += " [NS=0x"+Long.toHexString(get_NS())+"]\n"; + } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } + try { + s += " [EW=0x"+Long.toHexString(get_EW())+"]\n"; + } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } + try { + s += " [numsats=0x"+Long.toHexString(get_numsats())+"]\n"; + } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } return s; } *************** *** 422,424 **** --- 431,627 ---- } + ///////////////////////////////////////////////////////// + // Accessor methods for field: NS + // Field type: byte, unsigned + // Offset (bits): 72 + // Size (bits): 1 + ///////////////////////////////////////////////////////// + + /** + * Return whether the field 'NS' is signed (false). + */ + public static boolean isSigned_NS() { + return false; + } + + /** + * Return whether the field 'NS' is an array (false). + */ + public static boolean isArray_NS() { + return false; + } + + /** + * Return the offset (in bytes) of the field 'NS' + */ + public static int offset_NS() { + return (72 / 8); + } + + /** + * Return the offset (in bits) of the field 'NS' + */ + public static int offsetBits_NS() { + return 72; + } + + /** + * Return the value (as a byte) of the field 'NS' + */ + public byte get_NS() { + return (byte)getUIntElement(offsetBits_NS(), 1); + } + + /** + * Set the value of the field 'NS' + */ + public void set_NS(byte value) { + setUIntElement(offsetBits_NS(), 1, value); + } + + /** + * Return the size, in bytes, of the field 'NS' + * WARNING: This field is not an even-sized number of bytes (1 bits). + */ + public static int size_NS() { + return (1 / 8) + 1; + } + + /** + * Return the size, in bits, of the field 'NS' + */ + public static int sizeBits_NS() { + return 1; + } + + ///////////////////////////////////////////////////////// + // Accessor methods for field: EW + // Field type: byte, unsigned + // Offset (bits): 73 + // Size (bits): 1 + ///////////////////////////////////////////////////////// + + /** + * Return whether the field 'EW' is signed (false). + */ + public static boolean isSigned_EW() { + return false; + } + + /** + * Return whether the field 'EW' is an array (false). + */ + public static boolean isArray_EW() { + return false; + } + + /** + * Return the offset (in bytes) of the field 'EW' + * WARNING: This field is not byte-aligned (bit offset 73). + */ + public static int offset_EW() { + return (73 / 8); + } + + /** + * Return the offset (in bits) of the field 'EW' + */ + public static int offsetBits_EW() { + return 73; + } + + /** + * Return the value (as a byte) of the field 'EW' + */ + public byte get_EW() { + return (byte)getUIntElement(offsetBits_EW(), 1); + } + + /** + * Set the value of the field 'EW' + */ + public void set_EW(byte value) { + setUIntElement(offsetBits_EW(), 1, value); + } + + /** + * Return the size, in bytes, of the field 'EW' + * WARNING: This field is not an even-sized number of bytes (1 bits). + */ + public static int size_EW() { + return (1 / 8) + 1; + } + + /** + * Return the size, in bits, of the field 'EW' + */ + public static int sizeBits_EW() { + return 1; + } + + ///////////////////////////////////////////////////////// + // Accessor methods for field: numsats + // Field type: byte, unsigned + // Offset (bits): 74 + // Size (bits): 4 + ///////////////////////////////////////////////////////// + + /** + * Return whether the field 'numsats' is signed (false). + */ + public static boolean isSigned_numsats() { + return false; + } + + /** + * Return whether the field 'numsats' is an array (false). + */ + public static boolean isArray_numsats() { + return false; + } + + /** + * Return the offset (in bytes) of the field 'numsats' + * WARNING: This field is not byte-aligned (bit offset 74). + */ + public static int offset_numsats() { + return (74 / 8); + } + + /** + * Return the offset (in bits) of the field 'numsats' + */ + public static int offsetBits_numsats() { + return 74; + } + + /** + * Return the value (as a byte) of the field 'numsats' + */ + public byte get_numsats() { + return (byte)getUIntElement(offsetBits_numsats(), 4); + } + + /** + * Set the value of the field 'numsats' + */ + public void set_numsats(byte value) { + setUIntElement(offsetBits_numsats(), 4, value); + } + + /** + * Return the size, in bytes, of the field 'numsats' + * WARNING: This field is not an even-sized number of bytes (4 bits). + */ + public static int size_numsats() { + return (4 / 8) + 1; + } + + /** + * Return the size, in bits, of the field 'numsats' + */ + public static int sizeBits_numsats() { + return 4; + } + } |