[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/vu/tools/java/net/tinyos/mcenter AllMSGDisplay.java, 1.1, 1.2 AppLoader.java, 1.1, 1.2 BigMSGDisplay.java, 1.1, 1.2 DiagMSGDisplay.java, 1.1, 1.2 MessageCenter.java, 1.1, 1.2 MessageCenterInternalFrame.java, 1.1, 1.2 MessageCenterOuterFrame.java, 1.1, 1.2 MessageTable.java, 1.1, 1.2 PacketDecoder.java, 1.1, 1.2 PhoenixSource.java, 1.1, 1.2 RemoteControl.java, 1.2, 1.3 SerialConnector.java, 1.1, 1.2 UniversalInterpreter.java, 1.1, 1.2

Brano Kusy kusyb at users.sourceforge.net
Thu Aug 3 18:52:29 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/net/tinyos/mcenter
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21474

Modified Files:
	AllMSGDisplay.java AppLoader.java BigMSGDisplay.java 
	DiagMSGDisplay.java MessageCenter.java 
	MessageCenterInternalFrame.java MessageCenterOuterFrame.java 
	MessageTable.java PacketDecoder.java PhoenixSource.java 
	RemoteControl.java SerialConnector.java 
	UniversalInterpreter.java 
Log Message:
updated serial connector, and messagecenter

Index: AllMSGDisplay.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/net/tinyos/mcenter/AllMSGDisplay.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AllMSGDisplay.java	17 Jun 2005 16:33:19 -0000	1.1
--- AllMSGDisplay.java	4 Aug 2006 01:52:24 -0000	1.2
***************
*** 1,181 ****
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  *
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  *
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! /**
!  * @author Andras Nadas, Miklos Maroti
!  * @last modified 12/04/2003
!  */
! 
! package net.tinyos.mcenter;
! 
! import net.tinyos.packet.*;
! 
! public class AllMSGDisplay extends MessageCenterInternalFrame implements PacketListenerIF {
!     
!     protected java.text.SimpleDateFormat timestamp = null;
!     protected boolean fullheader = false;
!     
!     
!     /** Creates new form AllMSGDisplay */
!     public AllMSGDisplay() {
!         super("Message Display");
!         initComponents();
!         SerialConnector.instance().registerPacketListener(this,SerialConnector.GET_ALL_MESSAGES);
!         
!         
!     }
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         jScrollPane1 = new javax.swing.JScrollPane();
!         jTextArea1 = new javax.swing.JTextArea();
!         subPanel = new javax.swing.JPanel();
!         timestampCheckBox = new javax.swing.JCheckBox();
!         fullHeaderCheckBox = new javax.swing.JCheckBox();
!         clearButton = new javax.swing.JButton();
! 
!         setTitle("Message Display");
!         jScrollPane1.setPreferredSize(new java.awt.Dimension(320, 240));
!         jScrollPane1.setViewportView(jTextArea1);
! 
!         getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
! 
!         timestampCheckBox.setText("print timestamp");
!         timestampCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 timestampCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         subPanel.add(timestampCheckBox);
! 
!         fullHeaderCheckBox.setText("print full header");
!         fullHeaderCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 fullHeaderCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         subPanel.add(fullHeaderCheckBox);
! 
!         clearButton.setText("Clear");
!         clearButton.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 clearButtonActionPerformed(evt);
!             }
!         });
! 
!         subPanel.add(clearButton);
! 
!         getContentPane().add(subPanel, java.awt.BorderLayout.SOUTH);
! 
!         pack();
!     }//GEN-END:initComponents
!     
!     private void fullHeaderCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fullHeaderCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             this.fullheader = true;
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             this.fullheader = false;
!         }
!         
!     }//GEN-LAST:event_fullHeaderCheckBoxItemStateChanged
!     
!     private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed
!         jTextArea1.setText("");
!     }//GEN-LAST:event_clearButtonActionPerformed
!     
!     private void timestampCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_timestampCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             this.timestamp = new java.text.SimpleDateFormat("HH:mm:ss.SSSS");
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             this.timestamp = null;
!         }
!     }//GEN-LAST:event_timestampCheckBoxItemStateChanged
!     
!     
!     protected String getTimeStamp() {
!         if( timestamp != null)
!             return timestamp.format(new java.util.Date()) + ' ';
!         
!         return "";
!     }
!     /**  .
!      */
!     public void packetReceived(byte[] packet) {
!         
!         
!         this.jTextArea1.append(getTimeStamp());
!         
!         if (packet.length < 5) {
!             this.jTextArea1.append("packet too short - " + packet.length +
!             " bytes");
!             return;
!         }
!         
!         int type = packet[2] & 0xFF;
!         int len = packet[4] & 0xFF;
!         
!         if (this.fullheader) {
!             this.jTextArea1.append("addr=" + ((packet[0] & 0xff) | (packet[1] & 0xff) << 8));
!             this.jTextArea1.append(" group=" + (packet[3] & 0xff) + " ");
!         }
!         
!         
!         
!         this.jTextArea1.append("type=" + type);
!         this.jTextArea1.append(" length=" + len);
!         
!         // first 5 bytes + 2 bytes for CRC
!         if( len > packet.length - 5 )
!             len = packet.length - 5;
!         
!         this.jTextArea1.append(" data:");
!         for(int i = 5; i < packet.length; ++i) {
!             int data = packet[i] & 0xFF;
!             this.jTextArea1.append(" " + data);
!         }
!         
!         if (len != packet.length - 5) {
!             this.jTextArea1.append(" -- length incorrect");
!         }
!         
!         this.jTextArea1.append("\n");
!         this.jTextArea1.setCaretPosition(this.jTextArea1.getDocument().getLength());
!         
!         
!     }
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JButton clearButton;
!     private javax.swing.JCheckBox fullHeaderCheckBox;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JTextArea jTextArea1;
!     private javax.swing.JPanel subPanel;
!     private javax.swing.JCheckBox timestampCheckBox;
!     // End of variables declaration//GEN-END:variables
!     
! }
--- 1,183 ----
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  *
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  *
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! /**
!  * @author Andras Nadas, Miklos Maroti
!  * @last modified 12/04/2003
!  */
! 
! package net.tinyos.mcenter;
! 
! import net.tinyos.packet.*;
! 
! public class AllMSGDisplay extends MessageCenterInternalFrame implements PacketListenerIF {
!     
!     protected java.text.SimpleDateFormat timestamp = null;
!     protected boolean fullheader = false;
!     
!     
!     /** Creates new form AllMSGDisplay */
!     public AllMSGDisplay() {
!         super("Message Display");
!         initComponents();
!         SerialConnector.instance().registerPacketListener(this,SerialConnector.GET_ALL_MESSAGES);
!         
!         
!     }
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         jScrollPane1 = new javax.swing.JScrollPane();
!         jTextArea1 = new javax.swing.JTextArea();
!         subPanel = new javax.swing.JPanel();
!         timestampCheckBox = new javax.swing.JCheckBox();
!         fullHeaderCheckBox = new javax.swing.JCheckBox();
!         clearButton = new javax.swing.JButton();
! 
!         setTitle("Message Display");
!         jScrollPane1.setPreferredSize(new java.awt.Dimension(320, 240));
!         jScrollPane1.setViewportView(jTextArea1);
! 
!         getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
! 
!         timestampCheckBox.setText("print timestamp");
!         timestampCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 timestampCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         subPanel.add(timestampCheckBox);
! 
!         fullHeaderCheckBox.setText("print full header");
!         fullHeaderCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 fullHeaderCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         subPanel.add(fullHeaderCheckBox);
! 
!         clearButton.setText("Clear");
!         clearButton.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 clearButtonActionPerformed(evt);
!             }
!         });
! 
!         subPanel.add(clearButton);
! 
!         getContentPane().add(subPanel, java.awt.BorderLayout.SOUTH);
! 
!         pack();
!     }//GEN-END:initComponents
!     
!     private void fullHeaderCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fullHeaderCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             this.fullheader = true;
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             this.fullheader = false;
!         }
!         
!     }//GEN-LAST:event_fullHeaderCheckBoxItemStateChanged
!     
!     private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed
!         jTextArea1.setText("");
!     }//GEN-LAST:event_clearButtonActionPerformed
!     
!     private void timestampCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_timestampCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             this.timestamp = new java.text.SimpleDateFormat("HH:mm:ss.SSSS");
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             this.timestamp = null;
!         }
!     }//GEN-LAST:event_timestampCheckBoxItemStateChanged
!     
!     
!     protected String getTimeStamp() {
!         if( timestamp != null)
!             return timestamp.format(new java.util.Date()) + ' ';
!         
!         return "";
!     }
!     /**  .
!      */
!     public void packetReceived(byte[] packet) {
!         
!     	MessageInterpreter interpreter = SerialConnector.instance().getMessageInterprter();
!         
!         this.jTextArea1.append(getTimeStamp());
!         
!         if (interpreter.isValidMessage(packet)) {
!             this.jTextArea1.append("packet too short - " + packet.length +
!             " bytes");
!             return;
!         }
!         
!         int type = interpreter.getType(packet);
!         int len = interpreter.getDataLength(packet);
!         
!         if (this.fullheader) {
!             this.jTextArea1.append("addr=" + interpreter.getAddress(packet));
!             this.jTextArea1.append(" group=" + interpreter.getGroup(packet) + " ");
!         }
!         
!         
!         
!         this.jTextArea1.append("type=" + type);
!         this.jTextArea1.append(" length=" + len);
!         
!         // first 5 bytes + 2 bytes for CRC
!         //if( len > packet.length - 5 )
!         //    len = packet.length - 5;
!         
!         this.jTextArea1.append(" data:");
!         
!         for(int i = interpreter.getDataStart(packet); i < packet.length; ++i) {
!             int data = packet[i] & 0xFF;
!             this.jTextArea1.append(" " + data);
!         }
!         
!         if (len != packet.length - interpreter.getDataStart(packet)) {
!             this.jTextArea1.append(" -- length incorrect");
!         }
!         
!         this.jTextArea1.append("\n");
!         this.jTextArea1.setCaretPosition(this.jTextArea1.getDocument().getLength());
!         
!         
!     }
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JButton clearButton;
!     private javax.swing.JCheckBox fullHeaderCheckBox;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JTextArea jTextArea1;
!     private javax.swing.JPanel subPanel;
!     private javax.swing.JCheckBox timestampCheckBox;
!     // End of variables declaration//GEN-END:variables
!     
! }

Index: AppLoader.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/net/tinyos/mcenter/AppLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AppLoader.java	17 Jun 2005 16:33:19 -0000	1.1
--- AppLoader.java	4 Aug 2006 01:52:24 -0000	1.2
***************
*** 1,392 ****
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! /**
!  * @author Andras Nadas
!  * @last modified 12/04/2003
!  */
! 
! package net.tinyos.mcenter;
! 
! public class AppLoader extends MessageCenterInternalFrame {
! 
!     private java.util.prefs.Preferences prefs  = java.util.prefs.Preferences.userNodeForPackage(this.getClass());
!     private java.util.prefs.Preferences permanentStorage;
!     private java.util.prefs.Preferences commentStorage;
!         
!     javax.swing.DefaultListModel moduleListModel = new javax.swing.DefaultListModel();
! 
!     
!     /** Creates new form AppLoader */
!     public AppLoader() {
!         super("App Loader");
!         initComponents();
!         setClosable(false);
!         moduleList.setCellRenderer(new ListItemRenderer());
!         permanentStorage = prefs.node(prefs.absolutePath()+"/AppLoader");
!         
!         loadModulList();
!         moduleList.addListSelectionListener(new AppLoader.ModuleListSelectionListener());
!         moduleList.addMouseListener(new java.awt.event.MouseAdapter(){
!             public void mouseClicked(java.awt.event.MouseEvent e){
!                 if(e.getClickCount() == 2){
!                     startModule(((ModuleListItem)moduleList.getSelectedValue()).className);
!                 }
!             }
!         });
!     }
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         java.awt.GridBagConstraints gridBagConstraints;
! 
!         jPanel1 = new javax.swing.JPanel();
!         jScrollPane1 = new javax.swing.JScrollPane();
!         moduleList = new javax.swing.JList(moduleListModel);
!         classTextField = new javax.swing.JTextField();
!         loadButton = new javax.swing.JButton();
!         removeButton = new javax.swing.JButton();
! 
!         getContentPane().setLayout(new java.awt.GridBagLayout());
! 
!         setTitle("App Loader");
!         jPanel1.setLayout(new java.awt.GridBagLayout());
! 
!         moduleList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
!         jScrollPane1.setViewportView(moduleList);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
!         gridBagConstraints.weighty = 1.0;
!         jPanel1.add(jScrollPane1, gridBagConstraints);
! 
!         classTextField.setText("net.tinyos.mcenter.");
!         classTextField.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 classTextFieldActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 0);
!         jPanel1.add(classTextField, gridBagConstraints);
! 
!         loadButton.setText("LoadApp");
!         loadButton.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 loadButtonActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.weightx = 1.0;
!         gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
!         jPanel1.add(loadButton, gridBagConstraints);
! 
!         removeButton.setText("Remove Form List");
!         removeButton.setEnabled(false);
!         removeButton.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 removeButtonActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.weightx = 1.0;
!         gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
!         jPanel1.add(removeButton, gridBagConstraints);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
!         gridBagConstraints.weightx = 1.0;
!         gridBagConstraints.weighty = 1.0;
!         getContentPane().add(jPanel1, gridBagConstraints);
! 
!         setSize(new java.awt.Dimension(320, 299));
!     }//GEN-END:initComponents
! 
!     private void classTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_classTextFieldActionPerformed
!         loadButtonActionPerformed(evt);
!     }//GEN-LAST:event_classTextFieldActionPerformed
!     
!     private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
!         int index = moduleList.getSelectedIndex();
!         ModuleListItem delItem = (ModuleListItem) moduleListModel.get(index);
!         moduleListModel.remove(index);
!         permanentStorage.remove(delItem.name);
!         //saveModulList();
!         
!         int size = moduleListModel.getSize();
!         
!         
!         if (size == 0) {
!             removeButton.setEnabled(false);
!             
!             //Adjust the selection
!         } else {
!             //removed item in last position
!             if (index == moduleListModel.getSize())
!                 index--;
!             //otherwise select same index
!             moduleList.setSelectedIndex(index);
!         }
!         
!     }//GEN-LAST:event_removeButtonActionPerformed
!     
!     private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed
!         /*Class module;
!         String className = this.classTextField.getText();*/
!         startModule(this.classTextField.getText());
!         /*String name;
!         
!         if(isModulInList(className))
!             return;
!         
!         try{
!             System.out.println("Loading Module...");
!             module = Class.forName(className);
!             Object instance = module.newInstance();
!             if(instance instanceof net.tinyos.mcenter.MessageCenterInternalFrame){
!                 ((MessageCenterInternalFrame)instance).focus();
!             }
!             System.out.println("\""+ module.getName()+ "\" has been Succefully loaded!" );
!             
!             name = module.getName().substring(module.getName().lastIndexOf('.')+1);
!             
!             
!             int index = moduleList.getSelectedIndex();
!             int size = moduleListModel.getSize();
!             
!             //If no selection or if item in last position is selected,
!             //add the line to end of list, and select it
!             if (index == -1 || (index+1 == size)) {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(size);
!                 
!                 //Otherwise insert the new line after the current selection,
!                 //and select it
!             } else {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(index+1);
!             }
!             removeButton.setEnabled(true);
!             permanentStorage.put(name,className.trim());
!             //saveModulList();
!             
!         }catch(LinkageError le){
!             System.err.println("Could not Link module: " + le.toString());
!         }catch(ClassNotFoundException cnfe){
!             System.err.println("Could not Found module: " + cnfe.toString());
!         }catch(IllegalAccessException iae){
!             System.err.println("Illegal Access in module: " + iae.toString());
!         }catch(InstantiationException ie){
!             System.err.println("Could not Instatiate module: " + ie.toString());
!         }catch(SecurityException se){
!             System.err.println("Security error in module: " + se.toString());
!         }
!         
!         */
!     }//GEN-LAST:event_loadButtonActionPerformed
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JTextField classTextField;
!     private javax.swing.JPanel jPanel1;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JButton loadButton;
!     private javax.swing.JList moduleList;
!     private javax.swing.JButton removeButton;
!     // End of variables declaration//GEN-END:variables
!     
!     protected Object startModule(String className){
!         Class module;
!         String name;
!         Object instance = null;
!         try{// Load The module
!             System.out.println("Loading Module...");
!             module = Class.forName(className);
!             instance = module.newInstance();
!             if(instance instanceof net.tinyos.mcenter.MessageCenterInternalFrame){
!                 ((MessageCenterInternalFrame)instance).focus();
!             }
!             System.out.println("\""+ module.getName()+ "\" has been Succefully loaded!" );
!         }catch(LinkageError le){
!             System.err.println("Could not Link module: " + le.toString());
!             return null;
!         }catch(ClassNotFoundException cnfe){
!             System.err.println("Could not Found module: " + cnfe.toString());
!             return null;
!         }catch(IllegalAccessException iae){
!             System.err.println("Illegal Access in module: " + iae.toString());
!             return null;
!         }catch(InstantiationException ie){
!             System.err.println("Could not Instatiate module: " + ie.toString());
!             return null;
!         }catch(SecurityException se){
!             System.err.println("Security error in module: " + se.toString());
!             return null;
!         }
!         // If we get here the module can be loaded and a new instance is created
!         // Check if the module has to be added to the modul list
!         if(!isModulInList(className)){
!             name = module.getName().substring(module.getName().lastIndexOf('.')+1);
!             
!             
!             int index = moduleList.getSelectedIndex();
!             int size = moduleListModel.getSize();
!             
!             //If no selection or if item in last position is selected,
!             //add the line to end of list, and select it
!             if (index == -1 || (index+1 == size)) {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(size);
!                 
!                 //Otherwise insert the new line after the current selection,
!                 //and select it
!             } else {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(index+1);
!             }
!             removeButton.setEnabled(true);
!             permanentStorage.put(name,className.trim());
!         }
!             
!         return instance;
!     }
!     
!     /*************************Persistency handling*********************************/
!     
!  
!     protected void loadModulList(){
!          try{
!             java.util.HashSet keySet = new java.util.HashSet();
!             keySet.addAll(java.util.Arrays.asList(permanentStorage.keys()));
!             
!             if(!keySet.isEmpty()){
!                 removeButton.setEnabled(true);
!                 java.util.Iterator keyIterator = keySet.iterator();
!                 while(keyIterator.hasNext()){
!                         String key = (String)keyIterator.next();
!                         String value = permanentStorage.get(key,"");
!                         ModuleListItem item = new ModuleListItem(key,value);
!                         moduleListModel.addElement(item);
!                         commentStorage = prefs.node(prefs.absolutePath()+"/Comments/"+value);
!                         item.loaderComment = commentStorage.get("loaderComment","");
!                     }
! 
!             }
!                 
!         }catch(Exception e){}
!          sortModuleList();
!     }
!         
! 
!     
!    
!     protected boolean isModulInList(String moduleClassName){
!         boolean retval = false;
!         try{
!             java.util.HashSet keySet = new java.util.HashSet();
!             keySet.addAll(java.util.Arrays.asList(permanentStorage.keys()));
!             retval = keySet.contains(moduleClassName.substring(moduleClassName.lastIndexOf('.')+1));
!         }catch(Exception e){}
!         return retval;
!     }
!     
!     /***************************Sorting the module list****************************/
!     
!     private void sortModuleList(){
!     // The Module List is not too long so a Bubble sort will do fine.
!     
!     for(int i =0; i<moduleListModel.size()-1; i++)
!         for(int j=0; j < moduleListModel.size()-(i+1); j++){
!             ModuleListItem first = (ModuleListItem)moduleListModel.get(j);
!             ModuleListItem second= (ModuleListItem)moduleListModel.get(j+1);
!             
!             if(first.name.compareTo(second.name) > 0){
!                 moduleListModel.set(j,second);
!                 moduleListModel.set(j+1,first);
!             }
!             
!         }
!         
!     }
!     
!     
!     /******************Inner classes to handle the module list*********************/
!     
!     private class ModuleListItem{
!         public String name;
!         public String className;
!         public String loaderComment = "";
!         
!         ModuleListItem(String name, String className){
!             this.name = name;
!             this. className = className;
!         }
!         
!         public String toString(){
!             return  this.name;
!         }
!     }
!     
!     private class ModuleListSelectionListener implements javax.swing.event.ListSelectionListener{
!         
!         public void valueChanged(javax.swing.event.ListSelectionEvent e) {
!             if(moduleList.getSelectedValue() != null)
!                 classTextField.setText(((ModuleListItem)moduleList.getSelectedValue()).className);
!         }
!         
!     }
!     
!     private class ListItemRenderer extends javax.swing.DefaultListCellRenderer{
!         public ListItemRenderer(){
!             super();
!         }
!         
!         public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
!             java.awt.Component cellComp = super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
!             if( cellComp instanceof javax.swing.JComponent ){
!                 String ttip = "";
!                 if(!((ModuleListItem)value).loaderComment.equalsIgnoreCase("")){
!                      ttip = new String(":   "+((ModuleListItem)value).loaderComment);
!                 }
!                ((javax.swing.JComponent)cellComp).setToolTipText(((ModuleListItem)value).className+ttip);
!             }
! 
!             return this;
!         }
!         
!     }
!     
!     
!     
!     
! }
! 
--- 1,398 ----
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! 
! 
! package net.tinyos.mcenter;
! 
! /**
!  * The AppLoasder is the application in the MessageCenter wich is capabale to load
!  * other applications. It also maintains a list of application loaded previously.
!  * @author Andras Nadas
!  */
! public class AppLoader extends MessageCenterInternalFrame {
! 
!     private java.util.prefs.Preferences prefs  = java.util.prefs.Preferences.userNodeForPackage(this.getClass());
!     private java.util.prefs.Preferences permanentStorage;
!     private java.util.prefs.Preferences commentStorage;
!         
!     javax.swing.DefaultListModel moduleListModel = new javax.swing.DefaultListModel();
! 
!     
!     /** Creates new form AppLoader */
!     public AppLoader(String[] args) {
!         super("App Loader");
!         initComponents();
!         setClosable(false);
!         moduleList.setCellRenderer(new ListItemRenderer());
!         permanentStorage = prefs.node(prefs.absolutePath()+"/AppLoader");
!         
!         loadModulList();
!         moduleList.addListSelectionListener(new AppLoader.ModuleListSelectionListener());
!         moduleList.addMouseListener(new java.awt.event.MouseAdapter(){
!             public void mouseClicked(java.awt.event.MouseEvent e){
!                 if(e.getClickCount() == 2){
!                     startModule(((ModuleListItem)moduleList.getSelectedValue()).className);
!                 }
!             }
!         });
!         
!         for(int i=0; i<args.length; i++) {
!         	startModule(args[i]);
!         }
!     }
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         java.awt.GridBagConstraints gridBagConstraints;
! 
!         jPanel1 = new javax.swing.JPanel();
!         jScrollPane1 = new javax.swing.JScrollPane();
!         moduleList = new javax.swing.JList(moduleListModel);
!         classTextField = new javax.swing.JTextField();
!         loadButton = new javax.swing.JButton();
!         removeButton = new javax.swing.JButton();
! 
!         getContentPane().setLayout(new java.awt.GridBagLayout());
! 
!         setTitle("App Loader");
!         jPanel1.setLayout(new java.awt.GridBagLayout());
! 
!         moduleList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
!         jScrollPane1.setViewportView(moduleList);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
!         gridBagConstraints.weighty = 1.0;
!         jPanel1.add(jScrollPane1, gridBagConstraints);
! 
!         classTextField.setText("net.tinyos.mcenter.");
!         classTextField.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 classTextFieldActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 0);
!         jPanel1.add(classTextField, gridBagConstraints);
! 
!         loadButton.setText("LoadApp");
!         loadButton.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 loadButtonActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.weightx = 1.0;
!         gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
!         jPanel1.add(loadButton, gridBagConstraints);
! 
!         removeButton.setText("Remove Form List");
!         removeButton.setEnabled(false);
!         removeButton.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 removeButtonActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.weightx = 1.0;
!         gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
!         jPanel1.add(removeButton, gridBagConstraints);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
!         gridBagConstraints.weightx = 1.0;
!         gridBagConstraints.weighty = 1.0;
!         getContentPane().add(jPanel1, gridBagConstraints);
! 
!         setSize(new java.awt.Dimension(320, 299));
!     }//GEN-END:initComponents
! 
!     private void classTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_classTextFieldActionPerformed
!         loadButtonActionPerformed(evt);
!     }//GEN-LAST:event_classTextFieldActionPerformed
!     
!     private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
!         int index = moduleList.getSelectedIndex();
!         ModuleListItem delItem = (ModuleListItem) moduleListModel.get(index);
!         moduleListModel.remove(index);
!         permanentStorage.remove(delItem.name);
!         //saveModulList();
!         
!         int size = moduleListModel.getSize();
!         
!         
!         if (size == 0) {
!             removeButton.setEnabled(false);
!             
!             //Adjust the selection
!         } else {
!             //removed item in last position
!             if (index == moduleListModel.getSize())
!                 index--;
!             //otherwise select same index
!             moduleList.setSelectedIndex(index);
!         }
!         
!     }//GEN-LAST:event_removeButtonActionPerformed
!     
!     private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed
!         /*Class module;
!         String className = this.classTextField.getText();*/
!         startModule(this.classTextField.getText());
!         /*String name;
!         
!         if(isModulInList(className))
!             return;
!         
!         try{
!             System.out.println("Loading Module...");
!             module = Class.forName(className);
!             Object instance = module.newInstance();
!             if(instance instanceof net.tinyos.mcenter.MessageCenterInternalFrame){
!                 ((MessageCenterInternalFrame)instance).focus();
!             }
!             System.out.println("\""+ module.getName()+ "\" has been Succefully loaded!" );
!             
!             name = module.getName().substring(module.getName().lastIndexOf('.')+1);
!             
!             
!             int index = moduleList.getSelectedIndex();
!             int size = moduleListModel.getSize();
!             
!             //If no selection or if item in last position is selected,
!             //add the line to end of list, and select it
!             if (index == -1 || (index+1 == size)) {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(size);
!                 
!                 //Otherwise insert the new line after the current selection,
!                 //and select it
!             } else {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(index+1);
!             }
!             removeButton.setEnabled(true);
!             permanentStorage.put(name,className.trim());
!             //saveModulList();
!             
!         }catch(LinkageError le){
!             System.err.println("Could not Link module: " + le.toString());
!         }catch(ClassNotFoundException cnfe){
!             System.err.println("Could not Found module: " + cnfe.toString());
!         }catch(IllegalAccessException iae){
!             System.err.println("Illegal Access in module: " + iae.toString());
!         }catch(InstantiationException ie){
!             System.err.println("Could not Instatiate module: " + ie.toString());
!         }catch(SecurityException se){
!             System.err.println("Security error in module: " + se.toString());
!         }
!         
!         */
!     }//GEN-LAST:event_loadButtonActionPerformed
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JTextField classTextField;
!     private javax.swing.JPanel jPanel1;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JButton loadButton;
!     private javax.swing.JList moduleList;
!     private javax.swing.JButton removeButton;
!     // End of variables declaration//GEN-END:variables
!     
!     protected Object startModule(String className){
!         Class module;
!         String name;
!         Object instance = null;
!         try{// Load The module
!             System.out.println("Loading Module...");
!             module = Class.forName(className);
!             instance = module.newInstance();
!             if(instance instanceof net.tinyos.mcenter.MessageCenterInternalFrame){
!                 ((MessageCenterInternalFrame)instance).focus();
!             }
!             System.out.println("\""+ module.getName()+ "\" has been Succefully loaded!" );
!         }catch(LinkageError le){
!             System.err.println("Could not Link module: " + le.toString());
!             return null;
!         }catch(ClassNotFoundException cnfe){
!             System.err.println("Could not Found module: " + cnfe.toString());
!             return null;
!         }catch(IllegalAccessException iae){
!             System.err.println("Illegal Access in module: " + iae.toString());
!             return null;
!         }catch(InstantiationException ie){
!             System.err.println("Could not Instatiate module: " + ie.toString());
!             return null;
!         }catch(SecurityException se){
!             System.err.println("Security error in module: " + se.toString());
!             return null;
!         }
!         // If we get here the module can be loaded and a new instance is created
!         // Check if the module has to be added to the modul list
!         if(!isModulInList(className)){
!             name = module.getName().substring(module.getName().lastIndexOf('.')+1);
!             
!             
!             int index = moduleList.getSelectedIndex();
!             int size = moduleListModel.getSize();
!             
!             //If no selection or if item in last position is selected,
!             //add the line to end of list, and select it
!             if (index == -1 || (index+1 == size)) {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(size);
!                 
!                 //Otherwise insert the new line after the current selection,
!                 //and select it
!             } else {
!                 moduleListModel.addElement(new ModuleListItem(name,className));
!                 moduleList.setSelectedIndex(index+1);
!             }
!             removeButton.setEnabled(true);
!             permanentStorage.put(name,className.trim());
!         }
!             
!         return instance;
!     }
!     
!     /*************************Persistency handling*********************************/
!     
!  
!     protected void loadModulList(){
!          try{
!             java.util.HashSet keySet = new java.util.HashSet();
!             keySet.addAll(java.util.Arrays.asList(permanentStorage.keys()));
!             
!             if(!keySet.isEmpty()){
!                 removeButton.setEnabled(true);
!                 java.util.Iterator keyIterator = keySet.iterator();
!                 while(keyIterator.hasNext()){
!                         String key = (String)keyIterator.next();
!                         String value = permanentStorage.get(key,"");
!                         ModuleListItem item = new ModuleListItem(key,value);
!                         moduleListModel.addElement(item);
!                         commentStorage = prefs.node(prefs.absolutePath()+"/Comments/"+value);
!                         item.loaderComment = commentStorage.get("loaderComment","");
!                     }
! 
!             }
!                 
!         }catch(Exception e){}
!          sortModuleList();
!     }
!         
! 
!     
!    
!     protected boolean isModulInList(String moduleClassName){
!         boolean retval = false;
!         try{
!             java.util.HashSet keySet = new java.util.HashSet();
!             keySet.addAll(java.util.Arrays.asList(permanentStorage.keys()));
!             retval = keySet.contains(moduleClassName.substring(moduleClassName.lastIndexOf('.')+1));
!         }catch(Exception e){}
!         return retval;
!     }
!     
!     /***************************Sorting the module list****************************/
!     
!     private void sortModuleList(){
!     // The Module List is not too long so a Bubble sort will do fine.
!     
!     for(int i =0; i<moduleListModel.size()-1; i++)
!         for(int j=0; j < moduleListModel.size()-(i+1); j++){
!             ModuleListItem first = (ModuleListItem)moduleListModel.get(j);
!             ModuleListItem second= (ModuleListItem)moduleListModel.get(j+1);
!             
!             if(first.name.compareTo(second.name) > 0){
!                 moduleListModel.set(j,second);
!                 moduleListModel.set(j+1,first);
!             }
!             
!         }
!         
!     }
!     
!     
!     /******************Inner classes to handle the module list*********************/
!     
!     private class ModuleListItem{
!         public String name;
!         public String className;
!         public String loaderComment = "";
!         
!         ModuleListItem(String name, String className){
!             this.name = name;
!             this. className = className;
!         }
!         
!         public String toString(){
!             return  this.name;
!         }
!     }
!     
!     private class ModuleListSelectionListener implements javax.swing.event.ListSelectionListener{
!         
!         public void valueChanged(javax.swing.event.ListSelectionEvent e) {
!             if(moduleList.getSelectedValue() != null)
!                 classTextField.setText(((ModuleListItem)moduleList.getSelectedValue()).className);
!         }
!         
!     }
!     
!     private class ListItemRenderer extends javax.swing.DefaultListCellRenderer{
!         public ListItemRenderer(){
!             super();
!         }
!         
!         public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
!             java.awt.Component cellComp = super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
!             if( cellComp instanceof javax.swing.JComponent ){
!                 String ttip = "";
!                 if(!((ModuleListItem)value).loaderComment.equalsIgnoreCase("")){
!                      ttip = new String(":   "+((ModuleListItem)value).loaderComment);
!                 }
!                ((javax.swing.JComponent)cellComp).setToolTipText(((ModuleListItem)value).className+ttip);
!             }
! 
!             return this;
!         }
!         
!     }
!     
!     
!     
!     
! }
! 

Index: BigMSGDisplay.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/net/tinyos/mcenter/BigMSGDisplay.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BigMSGDisplay.java	17 Jun 2005 16:33:19 -0000	1.1
--- BigMSGDisplay.java	4 Aug 2006 01:52:24 -0000	1.2
***************
*** 1,418 ****
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! /**
!  * @author Andras Nadas, Miklos Maroti
!  * @last modified 12/04/2003
!  */
! 
! package net.tinyos.mcenter;
! 
! import net.tinyos.packet.*;
! import java.util.*;
! 
! public class BigMSGDisplay extends MessageCenterInternalFrame implements PacketListenerIF{
!     
!     protected byte activeMessage = 0x6F;
!     protected boolean supressId = false;
!     protected boolean printBinary = false;
!     protected java.text.SimpleDateFormat timestamp = null;
!     
!     protected java.io.File saveFile = new java.io.File("standard.out");
!     protected java.io.FileOutputStream fileOut;
!     protected java.io.PrintWriter out;
!     
!     private BigMSGDisplay instance = null;
!     
!     private java.util.prefs.Preferences prefsRoot = java.util.prefs.Preferences.userNodeForPackage(this.getClass());
!     private java.util.prefs.Preferences prefs;
!     /** Creates new form BigMSGDisplay */
!     public BigMSGDisplay() {
!         super("Big Message Display");
!         instance = this;
!         prefs = prefsRoot.node(prefsRoot.absolutePath()+"/BigMSGDisplay");
!         initComponents();
!         SerialConnector.instance().registerPacketListener(this,activeMessage);
!         this.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter(){
!             public void internalFrameClosing(javax.swing.event.InternalFrameEvent e){
!                 SerialConnector.instance().removePacketListener(instance,activeMessage);
!                 //CenterFrame.instance().removeChildFrame(instance);
!             }
!         });
!     }
!     
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         java.awt.GridBagConstraints gridBagConstraints;
! 
!         jScrollPane1 = new javax.swing.JScrollPane();
!         jTextArea1 = new javax.swing.JTextArea();
!         subPanel = new javax.swing.JPanel();
!         stateLabel = new javax.swing.JLabel();
!         stateTextField = new javax.swing.JTextField();
!         jButton2 = new javax.swing.JButton();
!         jSeparator1 = new javax.swing.JSeparator();
!         timestampCheckBox = new javax.swing.JCheckBox();
!         noidCheckBox = new javax.swing.JCheckBox();
!         binaryCheckBox = new javax.swing.JCheckBox();
!         jSeparator2 = new javax.swing.JSeparator();
!         saveCheckBox = new javax.swing.JCheckBox();
!         jTextField1 = new javax.swing.JTextField();
!         jButton1 = new javax.swing.JButton();
! 
!         setTitle("Big Message Display");
!         jScrollPane1.setPreferredSize(new java.awt.Dimension(320, 240));
!         jScrollPane1.setViewportView(jTextArea1);
! 
!         getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
! 
!         subPanel.setLayout(new java.awt.GridBagLayout());
! 
!         stateLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
!         stateLabel.setText("state");
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.insets = new java.awt.Insets(0, 16, 0, 8);
!         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
!         subPanel.add(stateLabel, gridBagConstraints);
! 
!         stateTextField.setEditable(false);
!         stateTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
!         stateTextField.setText("mote:0/0");
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = 2;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
!         subPanel.add(stateTextField, gridBagConstraints);
! 
!         jButton2.setText("Clear");
!         jButton2.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 jButton2ActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.insets = new java.awt.Insets(0, 16, 0, 0);
!         subPanel.add(jButton2, gridBagConstraints);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         subPanel.add(jSeparator1, gridBagConstraints);
! 
!         timestampCheckBox.setText("print timestamp");
!         timestampCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 timestampCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = 2;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.insets = new java.awt.Insets(0, 64, 0, 0);
!         subPanel.add(timestampCheckBox, gridBagConstraints);
! 
!         noidCheckBox.setText("noid");
!         noidCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 noidCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
!         gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
!         subPanel.add(noidCheckBox, gridBagConstraints);
! 
!         binaryCheckBox.setText("binary");
!         binaryCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 binaryCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         subPanel.add(binaryCheckBox, gridBagConstraints);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.weightx = 1.0;
!         subPanel.add(jSeparator2, gridBagConstraints);
! 
!         saveCheckBox.setText("save");
!         saveCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 saveCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = 2;
!         gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
!         subPanel.add(saveCheckBox, gridBagConstraints);
! 
!         jTextField1.setEditable(false);
!         jTextField1.setText("standard.out");
!         jTextField1.setPreferredSize(new java.awt.Dimension(128, 20));
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         subPanel.add(jTextField1, gridBagConstraints);
! 
!         jButton1.setText("..");
!         jButton1.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 jButton1ActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.insets = new java.awt.Insets(1, 8, 2, 0);
!         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
!         subPanel.add(jButton1, gridBagConstraints);
! 
!         getContentPane().add(subPanel, java.awt.BorderLayout.SOUTH);
! 
!         pack();
!     }//GEN-END:initComponents
! 
!     private void binaryCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_binaryCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             printBinary = true;
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             printBinary = false;
!         }
!     }//GEN-LAST:event_binaryCheckBoxItemStateChanged
! 
!     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
!         jTextArea1.setText("");
!     }//GEN-LAST:event_jButton2ActionPerformed
!     
!     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
!         javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();
!         chooser.setDialogTitle("Choose File to save");
!         int returnVal = chooser.showSaveDialog(this);
!         if(returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
!             saveFile = chooser.getSelectedFile();
!             jTextField1.setText(saveFile.getName());
!         }
!         
!     }//GEN-LAST:event_jButton1ActionPerformed
!         
!     private void saveCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_saveCheckBoxItemStateChanged
!         try{
!             if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!                 jButton1.setEnabled(false);
!                 binaryCheckBox.setEnabled(false);
!                 fileOut = new java.io.FileOutputStream(saveFile);
!                 out = new java.io.PrintWriter(fileOut);
!                 
!             } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!                 jButton1.setEnabled(true);
!                 binaryCheckBox.setEnabled(true);
!                 fileOut=null;
!                 out = null;
!             }
!         }catch(java.io.FileNotFoundException fnfe){
!         }
!     }//GEN-LAST:event_saveCheckBoxItemStateChanged
!         
!     private void timestampCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_timestampCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             timestamp = new java.text.SimpleDateFormat("HH:mm:ss.SSSS");
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             timestamp = null;
!         }
!     }//GEN-LAST:event_timestampCheckBoxItemStateChanged
!     
!     private void noidCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_noidCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             supressId = true;
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             supressId = false;
!         }
!     }//GEN-LAST:event_noidCheckBoxItemStateChanged
!     
!     static protected class BigMsg {
!         int lastSeqNum;
!         int nextPosition;
!         byte[] packet;
!     }
!     
!     protected HashMap bigMsgs = new HashMap();
!     
!     static final int PACKET_TYPE_FIELD = 2;
!     static final int PACKET_LENGTH_FIELD = 4;
!     static final int PACKET_SOURCE = 5;
!     static final int PACKET_SEQNUM = 7;
!     static final int PACKET_DATA = 8;
! 
!     static final int MAX_SEQ_NUM = 127;
!     
!     // the first 5 bytes are: addr(2), type(1), group(1), length(1)
!     public void packetReceived(byte[] packet) {
!         if( packet[PACKET_TYPE_FIELD] != activeMessage )
!             return;
!         
!         byte len = packet[PACKET_LENGTH_FIELD];
!         int source = getShort(packet[PACKET_SOURCE], packet[PACKET_SOURCE+1]);
!         int seqNum = packet[PACKET_SEQNUM] & 0xFF;
! 
!         
!         // wrong format
!         if( len < 4 || PACKET_SOURCE + len > packet.length )
!             return;
!         len -= 3;	// omit the source and seqnum fields
!         
!         byte[] data = new byte[len];
!         System.arraycopy(packet, PACKET_DATA, data, 0, len);
!         
!         BigMsg bigMsg;
!         if( seqNum == 0xFF) {			//New Big MSG
!             bigMsgs.remove(new Integer(source));
!             
!             bigMsg = new BigMsg();
!             bigMsg.lastSeqNum = -1;
!             int blength = getInt(data,0);
!             
!             //bigMsg.packet = new byte[getShort(data[0], data[1])];
!             bigMsg.packet = new byte[blength];
!             bigMsg.nextPosition = data.length - 4;
!             System.arraycopy(data, 4, bigMsg.packet, 0, bigMsg.nextPosition);
!             
!             bigMsgs.put(new Integer(source), bigMsg);
!             
!         }
!         else {
!             bigMsg = (BigMsg)bigMsgs.get(new Integer(source));
!             
!             if( bigMsg == null || seqNum == bigMsg.lastSeqNum ){
!                 
!                 return;
!             }else if( seqNum != bigMsg.lastSeqNum+1 && (seqNum !=0 || bigMsg.lastSeqNum != MAX_SEQ_NUM) ){
!                 
!                 bigMsgs.remove(new Integer(source));
!             }
!             bigMsg.lastSeqNum = seqNum;
!             System.arraycopy(data, 0, bigMsg.packet, bigMsg.nextPosition, data.length);
!             bigMsg.nextPosition += data.length;
!             
!         }
!         
!         stateTextField.setText("mote"+source+":"+ bigMsg.nextPosition +"/" + bigMsg.packet.length );
!         //System.out.println("mote"+source+":"+ bigMsg.nextPosition +"/" + bigMsg.packet.length );
!         
!         if( bigMsg.nextPosition == bigMsg.packet.length ) {
!             bigMsgs.remove(new Integer(Integer.toString(source)));
!             
!             if( timestamp != null ){
!                 jTextArea1.append(timestamp.format(new java.util.Date()) + ' ');
!                 if(out != null && !printBinary)
!                     out.print(timestamp.format(new java.util.Date()) + ' ');
!             }
!             if( !supressId  ) {
!                 jTextArea1.append(Integer.toString(source));
!                 jTextArea1.append(" ");
!                 if(out != null  && !printBinary)
!                     out.print(Integer.toString(source)+" ");
!             }
! 
!             if(out != null  && printBinary){
! 
!                 try{                           
!                     fileOut.write(bigMsg.packet,0, bigMsg.packet.length );
!                 }catch(java.io.IOException ioe){}
!             }
!             
!             for(int i = 0; i < bigMsg.packet.length; ++i ) {
!                 if( i == 2048) {
!                     if(out == null){
!                         System.out.println("Line too long!! Save Message to File");
!                     }else{
!                         System.out.println("Line too long!! Displaying the truncated Message. Complete message saved to File.");
!                     }
!                     break;
!                 }
!                 jTextArea1.append(Integer.toString(bigMsg.packet[i] & 0xFF));
!                 jTextArea1.append(" ");
!                 if(out != null){
!                     if(!printBinary){
!                         out.print(Integer.toString(bigMsg.packet[i] & 0xFF) + " ");
!                     }
!                 }
!             }
!             
!             jTextArea1.append("\n");
!             this.jTextArea1.setCaretPosition(this.jTextArea1.getDocument().getLength());
!             
!             if(out != null && !printBinary)
!                     out.println("");
!             if(out != null){
!                     out.flush();
!                     try{
!                         fileOut.flush();
!                     }catch(java.io.IOException ioe){}
!             }
! 					
!         }
!     }
!     
!     protected int getShort(byte a, byte b) {
!         return (a & 0x00FF) + ((b << 8) & 0xFF00);
!     }
!     
!     protected int getInt(byte[] packet, int packetIndex )
! 	{
! 		return (packet[packetIndex++] & 0xFF) 
! 			+ ((packet[packetIndex++] & 0xFF) << 8)
! 			+ ((packet[packetIndex++] & 0xFF) << 16)
! 			+ ((packet[packetIndex] & 0xFF) << 24);
! 	}
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JCheckBox binaryCheckBox;
!     private javax.swing.JButton jButton1;
!     private javax.swing.JButton jButton2;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JSeparator jSeparator1;
!     private javax.swing.JSeparator jSeparator2;
!     private javax.swing.JTextArea jTextArea1;
!     private javax.swing.JTextField jTextField1;
!     private javax.swing.JCheckBox noidCheckBox;
!     private javax.swing.JCheckBox saveCheckBox;
!     private javax.swing.JLabel stateLabel;
!     private javax.swing.JTextField stateTextField;
!     private javax.swing.JPanel subPanel;
!     private javax.swing.JCheckBox timestampCheckBox;
!     // End of variables declaration//GEN-END:variables
!     
! }
--- 1,418 ----
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! /**
!  * @author Andras Nadas, Miklos Maroti
!  * @last modified 12/04/2003
!  */
! 
! package net.tinyos.mcenter;
! 
! import net.tinyos.packet.*;
! import java.util.*;
! 
! public class BigMSGDisplay extends MessageCenterInternalFrame implements PacketListenerIF{
!     
!     protected byte activeMessage = 0x6F;
!     protected boolean supressId = false;
!     protected boolean printBinary = false;
!     protected java.text.SimpleDateFormat timestamp = null;
!     
!     protected java.io.File saveFile = new java.io.File("standard.out");
!     protected java.io.FileOutputStream fileOut;
!     protected java.io.PrintWriter out;
!     
!     private BigMSGDisplay instance = null;
!     
!     private java.util.prefs.Preferences prefsRoot = java.util.prefs.Preferences.userNodeForPackage(this.getClass());
!     private java.util.prefs.Preferences prefs;
!     /** Creates new form BigMSGDisplay */
!     public BigMSGDisplay() {
!         super("Big Message Display");
!         instance = this;
!         prefs = prefsRoot.node(prefsRoot.absolutePath()+"/BigMSGDisplay");
!         initComponents();
!         SerialConnector.instance().registerPacketListener(this,activeMessage);
!         this.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter(){
!             public void internalFrameClosing(javax.swing.event.InternalFrameEvent e){
!                 SerialConnector.instance().removePacketListener(instance,activeMessage);
!                 //CenterFrame.instance().removeChildFrame(instance);
!             }
!         });
!     }
!     
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         java.awt.GridBagConstraints gridBagConstraints;
! 
!         jScrollPane1 = new javax.swing.JScrollPane();
!         jTextArea1 = new javax.swing.JTextArea();
!         subPanel = new javax.swing.JPanel();
!         stateLabel = new javax.swing.JLabel();
!         stateTextField = new javax.swing.JTextField();
!         jButton2 = new javax.swing.JButton();
!         jSeparator1 = new javax.swing.JSeparator();
!         timestampCheckBox = new javax.swing.JCheckBox();
!         noidCheckBox = new javax.swing.JCheckBox();
!         binaryCheckBox = new javax.swing.JCheckBox();
!         jSeparator2 = new javax.swing.JSeparator();
!         saveCheckBox = new javax.swing.JCheckBox();
!         jTextField1 = new javax.swing.JTextField();
!         jButton1 = new javax.swing.JButton();
! 
!         setTitle("Big Message Display");
!         jScrollPane1.setPreferredSize(new java.awt.Dimension(320, 240));
!         jScrollPane1.setViewportView(jTextArea1);
! 
!         getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
! 
!         subPanel.setLayout(new java.awt.GridBagLayout());
! 
!         stateLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
!         stateLabel.setText("state");
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.insets = new java.awt.Insets(0, 16, 0, 8);
!         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
!         subPanel.add(stateLabel, gridBagConstraints);
! 
!         stateTextField.setEditable(false);
!         stateTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
!         stateTextField.setText("mote:0/0");
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = 2;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
!         subPanel.add(stateTextField, gridBagConstraints);
! 
!         jButton2.setText("Clear");
!         jButton2.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 jButton2ActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.insets = new java.awt.Insets(0, 16, 0, 0);
!         subPanel.add(jButton2, gridBagConstraints);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         subPanel.add(jSeparator1, gridBagConstraints);
! 
!         timestampCheckBox.setText("print timestamp");
!         timestampCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 timestampCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = 2;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.insets = new java.awt.Insets(0, 64, 0, 0);
!         subPanel.add(timestampCheckBox, gridBagConstraints);
! 
!         noidCheckBox.setText("noid");
!         noidCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 noidCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
!         gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
!         subPanel.add(noidCheckBox, gridBagConstraints);
! 
!         binaryCheckBox.setText("binary");
!         binaryCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 binaryCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         subPanel.add(binaryCheckBox, gridBagConstraints);
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.weightx = 1.0;
!         subPanel.add(jSeparator2, gridBagConstraints);
! 
!         saveCheckBox.setText("save");
!         saveCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 saveCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = 2;
!         gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 8);
!         subPanel.add(saveCheckBox, gridBagConstraints);
! 
!         jTextField1.setEditable(false);
!         jTextField1.setText("standard.out");
!         jTextField1.setPreferredSize(new java.awt.Dimension(128, 20));
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         subPanel.add(jTextField1, gridBagConstraints);
! 
!         jButton1.setText("..");
!         jButton1.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 jButton1ActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
!         gridBagConstraints.insets = new java.awt.Insets(1, 8, 2, 0);
!         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
!         subPanel.add(jButton1, gridBagConstraints);
! 
!         getContentPane().add(subPanel, java.awt.BorderLayout.SOUTH);
! 
!         pack();
!     }//GEN-END:initComponents
! 
!     private void binaryCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_binaryCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             printBinary = true;
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             printBinary = false;
!         }
!     }//GEN-LAST:event_binaryCheckBoxItemStateChanged
! 
!     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
!         jTextArea1.setText("");
!     }//GEN-LAST:event_jButton2ActionPerformed
!     
!     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
!         javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();
!         chooser.setDialogTitle("Choose File to save");
!         int returnVal = chooser.showSaveDialog(this);
!         if(returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
!             saveFile = chooser.getSelectedFile();
!             jTextField1.setText(saveFile.getName());
!         }
!         
!     }//GEN-LAST:event_jButton1ActionPerformed
!         
!     private void saveCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_saveCheckBoxItemStateChanged
!         try{
!             if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!                 jButton1.setEnabled(false);
!                 binaryCheckBox.setEnabled(false);
!                 fileOut = new java.io.FileOutputStream(saveFile);
!                 out = new java.io.PrintWriter(fileOut);
!                 
!             } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!                 jButton1.setEnabled(true);
!                 binaryCheckBox.setEnabled(true);
!                 fileOut=null;
!                 out = null;
!             }
!         }catch(java.io.FileNotFoundException fnfe){
!         }
!     }//GEN-LAST:event_saveCheckBoxItemStateChanged
!         
!     private void timestampCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_timestampCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             timestamp = new java.text.SimpleDateFormat("HH:mm:ss.SSSS");
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             timestamp = null;
!         }
!     }//GEN-LAST:event_timestampCheckBoxItemStateChanged
!     
!     private void noidCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_noidCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             supressId = true;
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             supressId = false;
!         }
!     }//GEN-LAST:event_noidCheckBoxItemStateChanged
!     
!     static protected class BigMsg {
!         int lastSeqNum;
!         int nextPosition;
!         byte[] packet;
!     }
!     
!     protected HashMap bigMsgs = new HashMap();
!     
!     static final int PACKET_TYPE_FIELD = 2;
!     static final int PACKET_LENGTH_FIELD = 4;
!     static final int PACKET_SOURCE = 5;
!     static final int PACKET_SEQNUM = 7;
!     static final int PACKET_DATA = 8;
! 
!     static final int MAX_SEQ_NUM = 127;
!     
!     // the first 5 bytes are: addr(2), type(1), group(1), length(1)
!     public void packetReceived(byte[] packet) {
!         if( packet[PACKET_TYPE_FIELD] != activeMessage )
!             return;
!         
!         byte len = packet[PACKET_LENGTH_FIELD];
!         int source = getShort(packet[PACKET_SOURCE], packet[PACKET_SOURCE+1]);
!         int seqNum = packet[PACKET_SEQNUM] & 0xFF;
! 
!         
!         // wrong format
!         if( len < 4 || PACKET_SOURCE + len > packet.length )
!             return;
!         len -= 3;	// omit the source and seqnum fields
!         
!         byte[] data = new byte[len];
!         System.arraycopy(packet, PACKET_DATA, data, 0, len);
!         
!         BigMsg bigMsg;
!         if( seqNum == 0xFF) {			//New Big MSG
!             bigMsgs.remove(new Integer(source));
!             
!             bigMsg = new BigMsg();
!             bigMsg.lastSeqNum = -1;
!             int blength = getInt(data,0);
!             
!             //bigMsg.packet = new byte[getShort(data[0], data[1])];
!             bigMsg.packet = new byte[blength];
!             bigMsg.nextPosition = data.length - 4;
!             System.arraycopy(data, 4, bigMsg.packet, 0, bigMsg.nextPosition);
!             
!             bigMsgs.put(new Integer(source), bigMsg);
!             
!         }
!         else {
!             bigMsg = (BigMsg)bigMsgs.get(new Integer(source));
!             
!             if( bigMsg == null || seqNum == bigMsg.lastSeqNum ){
!                 
!                 return;
!             }else if( seqNum != bigMsg.lastSeqNum+1 && (seqNum !=0 || bigMsg.lastSeqNum != MAX_SEQ_NUM) ){
!                 
!                 bigMsgs.remove(new Integer(source));
!             }
!             bigMsg.lastSeqNum = seqNum;
!             System.arraycopy(data, 0, bigMsg.packet, bigMsg.nextPosition, data.length);
!             bigMsg.nextPosition += data.length;
!             
!         }
!         
!         stateTextField.setText("mote"+source+":"+ bigMsg.nextPosition +"/" + bigMsg.packet.length );
!         //System.out.println("mote"+source+":"+ bigMsg.nextPosition +"/" + bigMsg.packet.length );
!         
!         if( bigMsg.nextPosition == bigMsg.packet.length ) {
!             bigMsgs.remove(new Integer(Integer.toString(source)));
!             
!             if( timestamp != null ){
!                 jTextArea1.append(timestamp.format(new java.util.Date()) + ' ');
!                 if(out != null && !printBinary)
!                     out.print(timestamp.format(new java.util.Date()) + ' ');
!             }
!             if( !supressId  ) {
!                 jTextArea1.append(Integer.toString(source));
!                 jTextArea1.append(" ");
!                 if(out != null  && !printBinary)
!                     out.print(Integer.toString(source)+" ");
!             }
! 
!             if(out != null  && printBinary){
! 
!                 try{                           
!                     fileOut.write(bigMsg.packet,0, bigMsg.packet.length );
!                 }catch(java.io.IOException ioe){}
!             }
!             
!             for(int i = 0; i < bigMsg.packet.length; ++i ) {
!                 if( i == 2048) {
!                     if(out == null){
!                         System.out.println("Line too long!! Save Message to File");
!                     }else{
!                         System.out.println("Line too long!! Displaying the truncated Message. Complete message saved to File.");
!                     }
!                     break;
!                 }
!                 jTextArea1.append(Integer.toString(bigMsg.packet[i] & 0xFF));
!                 jTextArea1.append(" ");
!                 if(out != null){
!                     if(!printBinary){
!                         out.print(Integer.toString(bigMsg.packet[i] & 0xFF) + " ");
!                     }
!                 }
!             }
!             
!             jTextArea1.append("\n");
!             this.jTextArea1.setCaretPosition(this.jTextArea1.getDocument().getLength());
!             
!             if(out != null && !printBinary)
!                     out.println("");
!             if(out != null){
!                     out.flush();
!                     try{
!                         fileOut.flush();
!                     }catch(java.io.IOException ioe){}
!             }
! 					
!         }
!     }
!     
!     protected int getShort(byte a, byte b) {
!         return (a & 0x00FF) + ((b << 8) & 0xFF00);
!     }
!     
!     protected int getInt(byte[] packet, int packetIndex )
! 	{
! 		return (packet[packetIndex++] & 0xFF) 
! 			+ ((packet[packetIndex++] & 0xFF) << 8)
! 			+ ((packet[packetIndex++] & 0xFF) << 16)
! 			+ ((packet[packetIndex] & 0xFF) << 24);
! 	}
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JCheckBox binaryCheckBox;
!     private javax.swing.JButton jButton1;
!     private javax.swing.JButton jButton2;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JSeparator jSeparator1;
!     private javax.swing.JSeparator jSeparator2;
!     private javax.swing.JTextArea jTextArea1;
!     private javax.swing.JTextField jTextField1;
!     private javax.swing.JCheckBox noidCheckBox;
!     private javax.swing.JCheckBox saveCheckBox;
!     private javax.swing.JLabel stateLabel;
!     private javax.swing.JTextField stateTextField;
!     private javax.swing.JPanel subPanel;
!     private javax.swing.JCheckBox timestampCheckBox;
!     // End of variables declaration//GEN-END:variables
!     
! }

Index: DiagMSGDisplay.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/net/tinyos/mcenter/DiagMSGDisplay.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DiagMSGDisplay.java	17 Jun 2005 16:33:19 -0000	1.1
--- DiagMSGDisplay.java	4 Aug 2006 01:52:25 -0000	1.2
***************
*** 1,461 ****
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! package net.tinyos.mcenter;
! import net.tinyos.packet.*;
! /**
!  *
!  * @author  nadand
!  */
! public class DiagMSGDisplay extends MessageCenterInternalFrame implements PacketListenerIF {
!     
!     protected String delimiter = " ";
!     protected java.text.SimpleDateFormat timestamp = null;
!     
!     static final int PACKET_TYPE_FIELD = 2;
!     static final int PACKET_LENGTH_FIELD = 4;
!     static final int PACKET_DATA_FIELD = 5;
!     static final int PACKET_CRC_SIZE = 0;
!     
!     private int diagActiveMessage =0xB1;
!     
!     private java.util.prefs.Preferences prefsRoot = java.util.prefs.Preferences.userNodeForPackage(this.getClass());
!     private java.util.prefs.Preferences prefs;
!    
!     
!     /** Creates new form DiagMSGDisplay */
!     public DiagMSGDisplay() {
!         super("Diag Message Display");
!         prefs = prefsRoot.node(prefsRoot.absolutePath()+"/DiagMSGDisplay");
!         diagActiveMessage = prefs.getInt("DiagActiveMessage",0xB1);
!         initComponents();
!         SerialConnector.instance().registerPacketListener(this,diagActiveMessage & 0xFF);
!     }
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         java.awt.GridBagConstraints gridBagConstraints;
! 
!         jScrollPane1 = new javax.swing.JScrollPane();
!         jTextArea1 = new javax.swing.JTextArea();
!         subPanel = new javax.swing.JPanel();
!         timestampCheckBox = new javax.swing.JCheckBox();
!         jLabel1 = new javax.swing.JLabel();
!         jTextField1 = new javax.swing.JTextField();
! 
!         setTitle("Diag Message Display");
!         jScrollPane1.setPreferredSize(new java.awt.Dimension(320, 240));
!         jScrollPane1.setViewportView(jTextArea1);
! 
!         getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
! 
!         subPanel.setLayout(new java.awt.GridBagLayout());
! 
!         timestampCheckBox.setText("print timestamp");
!         timestampCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 timestampCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.weightx = 1.0;
!         subPanel.add(timestampCheckBox, gridBagConstraints);
! 
!         jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
!         jLabel1.setText("msg type");
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.weightx = 1.0;
!         subPanel.add(jLabel1, gridBagConstraints);
! 
!         jTextField1.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
!         jTextField1.setText("0XB1");
!         jTextField1.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 jTextField1ActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.weightx = 2.0;
!         subPanel.add(jTextField1, gridBagConstraints);
! 
!         getContentPane().add(subPanel, java.awt.BorderLayout.SOUTH);
! 
!         pack();
!     }//GEN-END:initComponents
! 
!     private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
!         /*String arg = jTextField1.getText();
!         arg.toUpperCase();
!         if( !arg.startsWith("0X") ) {
!             jTextField1.setText("0X"+Integer.toHexString(diagActiveMessage));
!         }
!         else{
!             
!             
!             SerialConnector.instance().removePacketListener(this,diagActiveMessage);
!             diagActiveMessage = (byte)Integer.parseInt(arg.substring(2), 16);
!             SerialConnector.instance().registerPacketListener(this,diagActiveMessage);
!             prefs.putInt("DiagActiveMessage",diagActiveMessage);
!         }*/
!     }//GEN-LAST:event_jTextField1ActionPerformed
!     
!     private void timestampCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_timestampCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             timestamp = new java.text.SimpleDateFormat("HH:mm:ss.SSSS");
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             timestamp = null;
!         }
!     }//GEN-LAST:event_timestampCheckBoxItemStateChanged
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JLabel jLabel1;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JTextArea jTextArea1;
!     private javax.swing.JTextField jTextField1;
!     private javax.swing.JPanel subPanel;
!     private javax.swing.JCheckBox timestampCheckBox;
!     // End of variables declaration//GEN-END:variables
!     protected String getTimeStamp() {
!         if( timestamp != null )
!             return timestamp.format(new java.util.Date()) + delimiter;
!         
!         return "";
!     }
!     
!     /**  .
!      */
!     public void packetReceived(byte[] packet) {
!     	if( packet[PACKET_TYPE_FIELD] == diagActiveMessage ) {
!             try {
!                 jTextArea1.append(getTimeStamp() + decode(packet)+ "\n");
!                 jTextArea1.setCaretPosition(this.jTextArea1.getDocument().getLength());
!                 
!             }
!             catch(DiagMsgException e) {
!                 System.out.println(e.getMessage());
!             }
!         }
!     }
!     
!     static protected class DiagMsgException extends Exception {
!         public DiagMsgException(String cause) {
!             super(cause);
!         }
!     }
!     
!     protected byte[] packet;
!     protected int end;
!     protected int head;
!     protected StringBuffer line;
!     
!     protected synchronized String decode(byte[] packet) throws DiagMsgException {
!         this.packet = packet;
!         
!         head = PACKET_DATA_FIELD;
!         end = PACKET_DATA_FIELD + packet[PACKET_LENGTH_FIELD];
!         if( end < head || end > packet.length - PACKET_CRC_SIZE )
!             throw new DiagMsgException("illegal message length");
!         
!         line = new StringBuffer();
!         
!         while(head < end) {
!             byte code = getByte();
!             
!             addSimple(code & 0xF);
!             addSimple((code >> 4) & 0xF);
!         }
!         
!         // delete the leading space
!         if( line.length() > 0 && line.substring(0, delimiter.length()).equals(delimiter) )
!             line.delete(0, delimiter.length());
!         
!         return new String(line);
!     }
!     
!     static final int TYPE_END = 0;
!     static final int TYPE_INT8 = 1;
!     static final int TYPE_UINT8 = 2;
!     static final int TYPE_HEX8 = 3;
!     static final int TYPE_INT16 = 4;
!     static final int TYPE_UINT16 = 5;
!     static final int TYPE_HEX16 = 6;
!     static final int TYPE_INT32 = 7;
!     static final int TYPE_UINT32 = 8;
!     static final int TYPE_HEX32 = 9;
!     static final int TYPE_FLOAT = 10;
!     static final int TYPE_CHAR = 11;
!     static final int TYPE_INT64 = 12;
!     static final int TYPE_UINT64 = 13;
!     static final int TYPE_TOKEN = 14;
!     static final int TYPE_ARRAY = 15;
!     
!     protected void addSimple(int type) throws DiagMsgException {
!         switch(type) {
!             case TYPE_END:                 break;
!             case TYPE_INT8:   addInt8();   break;
!             case TYPE_UINT8:  addUint8();  break;
!             case TYPE_HEX8:   addHex8();   break;
!             case TYPE_INT16:  addInt16();  break;
!             case TYPE_UINT16: addUint16(); break;
!             case TYPE_HEX16:  addHex16();  break;
!             case TYPE_INT32:  addInt32();  break;
!             case TYPE_UINT32: addUint32(); break;
!             case TYPE_HEX32:  addHex32();  break;
!             case TYPE_FLOAT:  addReal();   break;
!             case TYPE_CHAR:   addChar();   break;
!             case TYPE_INT64:  addInt64();  break;
!             case TYPE_UINT64: addUint64(); break;
!             case TYPE_TOKEN:  addToken();  break;
!             case TYPE_ARRAY:  addArray();  break;
!             
!             default:
!                 line.append(delimiter + "unknown");
!         }
!     }
!     
!     protected void addArray() throws DiagMsgException {
!         int len = getByte();
!         int type = (len >> 4) & 0xF;
!         len &= 0xF;
!         
!         if( type == TYPE_CHAR )
!             addStr(len);
!         else {
!             line.append(delimiter + "[");
!             
!             while( --len >= 0 )
!                 addSimple(type);
!             
!             line.append(" ]");
!         }
!     }
!     
!     protected void check(int len) throws DiagMsgException {
!         if( head + len > end )
!             throw new DiagMsgException("illegal message format");
!     }
!     
!     protected byte getByte() throws DiagMsgException {
!         check(1);
!         byte ret = packet[head];
!         head += 1;
!         return ret;
!     }
!     
!     protected short getShort() throws DiagMsgException {
!         short a,b;
!         check(2);
!         
!         a = packet[head];            a &= 0x00FF;
!         b = packet[head+1]; b <<= 8; b &= 0xFF00; a |= b;
!         
!         head += 2;
!         return a;
!     }
!     
!     protected int getInt() throws DiagMsgException {
!         int a,b;
!         check(4);
!         
!         a = packet[head];             a &= 0x000000FF;
!         b = packet[head+1]; b <<= 8;  b &= 0x0000FF00; a |= b;
!         b = packet[head+2]; b <<= 16; b &= 0x00FF0000; a |= b;
!         b = packet[head+3]; b <<= 24; b &= 0xFF000000; a |= b;
!         
!         head += 4;
!         return a;
!     }
!     
!     protected long getLong() throws DiagMsgException {
!         long a,b;
!         check(8);
!         
!         a = packet[head];             a &= 0x00000000000000FF;
!         b = packet[head+1]; b <<= 8;  b &= 0x000000000000FF00; a |= b;
!         b = packet[head+2]; b <<= 16; b &= 0x0000000000FF0000; a |= b;
!         b = packet[head+3]; b <<= 24; b &= 0x00000000FF000000; a |= b;
!         b = packet[head+4]; b &= 0x00000000000000FF; b <<= 32; a |= b;
!         b = packet[head+5]; b &= 0x00000000000000FF; b <<= 40; a |= b;
!         b = packet[head+6]; b &= 0x00000000000000FF; b <<= 48; a |= b;
!         b = packet[head+7]; b &= 0x00000000000000FF; b <<= 56; a |= b;
!         
!         head += 8;
!         return a;
!     }
!     
!     protected void addUint8() throws DiagMsgException {
!         String value = Integer.toString(getByte() & 0xFF);
!         line.append(delimiter + value);
!     }
!     
!     protected void addInt8() throws DiagMsgException {
!         String value = Byte.toString(getByte());
!         line.append(delimiter + value);
!     }
!     
!     protected void addHex8() throws DiagMsgException {
!         String value = Integer.toHexString(getByte() & 0xFF);
!         
!         line.append(delimiter + "0x");
!         for(int i = value.length(); i < 2; ++i)
!             line.append('0');
!         line.append(value);
!     }
!     
!     protected void addUint16() throws DiagMsgException {
!         String value = Integer.toString(getShort() & 0xFFFF);
!         line.append(delimiter + value);
!     }
!     
!     protected void addInt16() throws DiagMsgException {
!         String value = Short.toString(getShort());
!         line.append(delimiter + value);
!     }
!     
!     protected void addHex16() throws DiagMsgException {
!         String value = Integer.toHexString(getShort() & 0xFFFF);
!         
!         line.append(delimiter + "0x");
!         for(int i = value.length(); i < 4; ++i)
!             line.append('0');
!         line.append(value);
!     }
!     
!     protected void addUint32() throws DiagMsgException {
!         String value = Long.toString(getInt() & 0xFFFFFFFF);
!         line.append(delimiter + value);
!     }
!     
!     protected void addInt32() throws DiagMsgException {
!         String value = Integer.toString(getInt());
!         line.append(delimiter + value);
!     }
!     
!     protected void addHex32() throws DiagMsgException {
!         String value = Integer.toHexString(getInt());
!         
!         line.append(delimiter + "0x");
!         for(int i = value.length(); i < 8; ++i)
!             line.append('0');
!         line.append(value);
!     }
!     
!     protected void addInt64() throws DiagMsgException {
!         String value = Long.toString(getLong());
!         line.append(delimiter + value);
!     }
!     
!     protected void addUint64() throws DiagMsgException {
!         String value = Long.toString(getLong());
!         line.append(delimiter + value);
!     }
!     
!     protected void addReal() throws DiagMsgException {
!         float value = Float.intBitsToFloat(getInt());
!         line.append(delimiter + Float.toString(value));
!     }
!     
!     protected void addChar() throws DiagMsgException {
!         char value = (char)getByte();
!         line.append(delimiter + "'" + value + "'");
!     }
!     
!     protected void addStr(int len) throws DiagMsgException {
!         line.append(delimiter + "\"");
!         
!         while( --len >= 0 )
!             line.append((char)getByte());
!         
!         line.append('"');
!     }
!     
!     protected void addToken() throws DiagMsgException {
!         int token = getByte() & 0xFF;
!         
!         line.append(delimiter);
!         
!         switch(token) {
!             case 0 : line.append("false"); break;
!             case 1 : line.append("true"); break;
!             case 2 : line.append("node"); break;
!             case 3 : line.append("source"); break;
!             case 4 : line.append("destination"); break;
!             case 5 : line.append("target"); break;
!             case 6 : line.append("minimum"); break;
!             case 7 : line.append("maximum"); break;
!             case 8 : line.append("mean"); break;
!             case 9 : line.append("average"); break;
!             case 10 : line.append("time"); break;
!             case 11 : line.append("counter"); break;
!             case 12 : line.append("stamp"); break;
!             case 13 : line.append("sequence"); break;
!             case 14 : line.append("number"); break;
!             case 15 : line.append("config"); break;
!             case 16 : line.append("diameter"); break;
!             case 17 : line.append("fail"); break;
!             case 18 : line.append("success"); break;
!             case 19 : line.append("ack"); break;
!             case 20 : line.append("power"); break;
!             case 21 : line.append("local"); break;
!             case 22 : line.append("remote"); break;
!             case 23 : line.append("leader"); break;
!             case 24 : line.append("root"); break;
!             case 25 : line.append("first"); break;
!             case 26 : line.append("second"); break;
!             case 27 : line.append("third"); break;
!             case 28 : line.append("nodeid"); break;
!             case 29 : line.append("delta"); break;
!             case 30 : line.append("delay"); break;
!             case 31 : line.append("rate"); break;
!             case 32 : line.append("frequency"); break;
!             case 33 : line.append("coord"); break;
!             case 34 : line.append("coords"); break;
!             case 35 : line.append("angle"); break;
!             case 36 : line.append("temperature"); break;
!             case 37 : line.append("light"); break;
!             case 38 : line.append("next"); break;
!             case 39 : line.append("previous"); break;
!             case 40 : line.append("start"); break;
!             case 41 : line.append("end"); break;
!             case 42 : line.append("speed"); break;
!             case 43 : line.append("cpu"); break;
!             case 44 : line.append("beacon"); break;
!             case 45 : line.append("arrival"); break;
!             case 46 : line.append("senddone"); break;
!             case 47 : line.append("global"); break;
!             case 48 : line.append("clock"); break;
!             
!             default:
!                 line.append("token:" + token);
!         }
!     }
!     
!     
! }
--- 1,460 ----
! /*
!  * Copyright (c) 2003, Vanderbilt University
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and its
!  * documentation for any purpose, without fee, and without written agreement is
!  * hereby granted, provided that the above copyright notice, the following
!  * two paragraphs and the author appear in all copies of this software.
!  * 
!  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
!  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
!  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
!  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  * 
!  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
!  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
!  * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
!  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
!  */
! 
! package net.tinyos.mcenter;
! import net.tinyos.packet.*;
! /**
!  *
!  * @author  nadand
!  */
! public class DiagMSGDisplay extends MessageCenterInternalFrame implements PacketListenerIF {
!     
!     protected String delimiter = " ";
!     protected java.text.SimpleDateFormat timestamp = null;
!     
!     static final int PACKET_TYPE_FIELD = 2;
!     static final int PACKET_LENGTH_FIELD = 4;
!     static final int PACKET_DATA_FIELD = 5;
!     static final int PACKET_CRC_SIZE = 0;
!     
!     private int diagActiveMessage = 177;//0xB1;
!     private DiagMSGDisplay instance = null;
!     
!     private java.util.prefs.Preferences prefsRoot = java.util.prefs.Preferences.userNodeForPackage(this.getClass());
!     private java.util.prefs.Preferences prefs;
!    
!     
!     /** Creates new form DiagMSGDisplay */
!     public DiagMSGDisplay() {
!         super("Diag Message Display");
!         prefs = prefsRoot.node(prefsRoot.absolutePath()+"/DiagMSGDisplay");
!         initComponents();
!         instance = this;
!         
!         SerialConnector.instance().registerPacketListener(this,diagActiveMessage);
!         this.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter(){
!             public void internalFrameClosing(javax.swing.event.InternalFrameEvent e){
!                 SerialConnector.instance().removePacketListener(instance,diagActiveMessage);
!             }
!         });
!     }
!     
!     /** This method is called from within the constructor to
!      * initialize the form.
!      * WARNING: Do NOT modify this code. The content of this method is
!      * always regenerated by the Form Editor.
!      */
!     private void initComponents() {//GEN-BEGIN:initComponents
!         java.awt.GridBagConstraints gridBagConstraints;
! 
!         jScrollPane1 = new javax.swing.JScrollPane();
!         jTextArea1 = new javax.swing.JTextArea();
!         subPanel = new javax.swing.JPanel();
!         timestampCheckBox = new javax.swing.JCheckBox();
!         jLabel1 = new javax.swing.JLabel();
!         jTextField1 = new javax.swing.JTextField();
! 
!         setTitle("Diag Message Display");
!         jScrollPane1.setPreferredSize(new java.awt.Dimension(320, 240));
!         jScrollPane1.setViewportView(jTextArea1);
! 
!         getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
! 
!         subPanel.setLayout(new java.awt.GridBagLayout());
! 
!         timestampCheckBox.setText("print timestamp");
!         timestampCheckBox.addItemListener(new java.awt.event.ItemListener() {
!             public void itemStateChanged(java.awt.event.ItemEvent evt) {
!                 timestampCheckBoxItemStateChanged(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.weightx = 1.0;
!         subPanel.add(timestampCheckBox, gridBagConstraints);
! 
!         jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
!         jLabel1.setText("msg type");
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.weightx = 1.0;
!         subPanel.add(jLabel1, gridBagConstraints);
! 
!         jTextField1.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
!         jTextField1.setText("0XB1");
!         jTextField1.addActionListener(new java.awt.event.ActionListener() {
!             public void actionPerformed(java.awt.event.ActionEvent evt) {
!                 jTextField1ActionPerformed(evt);
!             }
!         });
! 
!         gridBagConstraints = new java.awt.GridBagConstraints();
!         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
!         gridBagConstraints.weightx = 2.0;
!         subPanel.add(jTextField1, gridBagConstraints);
! 
!         getContentPane().add(subPanel, java.awt.BorderLayout.SOUTH);
! 
!         pack();
!     }//GEN-END:initComponents
! 
!     private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
!     }//GEN-LAST:event_jTextField1ActionPerformed
!     
!     private void timestampCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_timestampCheckBoxItemStateChanged
!         if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
!             timestamp = new java.text.SimpleDateFormat("HH:mm:ss.SSSS");
!         } else if(evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
!             timestamp = null;
!         }
!     }//GEN-LAST:event_timestampCheckBoxItemStateChanged
!     
!     
!     // Variables declaration - do not modify//GEN-BEGIN:variables
!     private javax.swing.JLabel jLabel1;
!     private javax.swing.JScrollPane jScrollPane1;
!     private javax.swing.JTextArea jTextArea1;
!     private javax.swing.JTextField jTextField1;
!     private javax.swing.JPanel subPanel;
!     private javax.swing.JCheckBox timestampCheckBox;
!     // End of variables declaration//GEN-END:variables
!     protected String getTimeStamp() {
!         if( timestamp != null )
!             return timestamp.format(new java.util.Date()) + delimiter;
!         
!         return "";
!     }
!     
!     /**  .
!      */
!     public void packetReceived(byte[] packet) {
!     	MessageInterpreter mi = SerialConnector.instance().getMessageInterprter();
!     	if( mi.getType(packet) == diagActiveMessage ) {
!             try {
!                 jTextArea1.append(getTimeStamp() + decode(packet,mi)+ "\n");
!                 jTextArea1.setCaretPosition(this.jTextArea1.getDocument().getLength());
!                 
!             }
!             catch(DiagMsgException e) {
!                 System.out.println(e.getMessage());
!             }
!         }
!     }
!     
!     static protected class DiagMsgException extends Exception {
!         public DiagMsgException(String cause) {
!             super(cause);
!         }
!     }
!     
!     protected byte[] packet;
!     protected int end;
!     protected int head;
!     protected StringBuffer line;
!     
!     protected synchronized String decode(byte[] packet, MessageInterpreter mi) throws DiagMsgException {
!         this.packet = packet;
!         
!         
!         head = mi.getDataStart(packet);
!         end = head + mi.getDataLength(packet);
!         
!         //if( end < head || end > packet.length - PACKET_CRC_SIZE )
!         //    throw new DiagMsgException("illegal message length");
!         
!         line = new StringBuffer();
!         
!         while(head < end) {
!             byte code = getByte();
!             
!             addSimple(code & 0xF);
!             addSimple((code >> 4) & 0xF);
!         }
!         
!         // delete the leading space
!         if( line.length() > 0 && line.substring(0, delimiter.length()).equals(delimiter) )
!             line.delete(0, delimiter.length());
!         if( line.length() == 0)
!             line = new StringBuffer("Illegal message format!");
!         
!         return new String(line);
!     }
!     
!     static final int TYPE_END = 0;
!     static final int TYPE_INT8 = 1;
!     static final int TYPE_UINT8 = 2;
!     static final int TYPE_HEX8 = 3;
!     static final int TYPE_INT16 = 4;
!     static final int TYPE_UINT16 = 5;
!     static final int TYPE_HEX16 = 6;
!     static final int TYPE_INT32 = 7;
!     static final int TYPE_UINT32 = 8;
!     static final int TYPE_HEX32 = 9;
!     static final int TYPE_FLOAT = 10;
!     static final int TYPE_CHAR = 11;
!     static final int TYPE_INT64 = 12;
!     static final int TYPE_UINT64 = 13;
!     static final int TYPE_TOKEN = 14;
!     static final int TYPE_ARRAY = 15;
!     
!     protected void addSimple(int type) throws DiagMsgException {
!         switch(type) {
!             case TYPE_END:                 break;
!             case TYPE_INT8:   addInt8();   break;
!             case TYPE_UINT8:  addUint8();  break;
!             case TYPE_HEX8:   addHex8();   break;
!             case TYPE_INT16:  addInt16();  break;
!             case TYPE_UINT16: addUint16(); break;
!             case TYPE_HEX16:  addHex16();  break;
!             case TYPE_INT32:  addInt32();  break;
!             case TYPE_UINT32: addUint32(); break;
!             case TYPE_HEX32:  addHex32();  break;
!             case TYPE_FLOAT:  addReal();   break;
!             case TYPE_CHAR:   addChar();   break;
!             case TYPE_INT64:  addInt64();  break;
!             case TYPE_UINT64: addUint64(); break;
!             case TYPE_TOKEN:  addToken();  break;
!             case TYPE_ARRAY:  addArray();  break;
!             
!             default:
!                 line.append(delimiter + "unknown");
!         }
!     }
!     
!     protected void addArray() throws DiagMsgException {
!         int len = getByte();
!         int type = (len >> 4) & 0xF;
!         len &= 0xF;
!         
!         if( type == TYPE_CHAR )
!             addStr(len);
!         else {
!             line.append(delimiter + "[");
!             
!             while( --len >= 0 )
!                 addSimple(type);
!             
!             line.append(" ]");
!         }
!     }
!     
!     protected void check(int len) throws DiagMsgException {
!         if( head + len > end )
!             throw new DiagMsgException("illegal message format");
!     }
!     
!     protected byte getByte() throws DiagMsgException {
!         check(1);
!         byte ret = packet[head];
!         head += 1;
!         return ret;
!     }
!     
!     protected short getShort() throws DiagMsgException {
!         short a,b;
!         check(2);
!         
!         a = packet[head];            a &= 0x00FF;
!         b = packet[head+1]; b <<= 8; b &= 0xFF00; a |= b;
!         
!         head += 2;
!         return a;
!     }
!     
!     protected int getInt() throws DiagMsgException {
!         int a,b;
!         check(4);
!         
!         a = packet[head];             a &= 0x000000FF;
!         b = packet[head+1]; b <<= 8;  b &= 0x0000FF00; a |= b;
!         b = packet[head+2]; b <<= 16; b &= 0x00FF0000; a |= b;
!         b = packet[head+3]; b <<= 24; b &= 0xFF000000; a |= b;
!         
!         head += 4;
!         return a;
!     }
!     
!     protected long getLong() throws DiagMsgException {
!         long a,b;
!         check(8);
!         
!         a = packet[head];             a &= 0x00000000000000FF;
!         b = packet[head+1]; b <<= 8;  b &= 0x000000000000FF00; a |= b;
!         b = packet[head+2]; b <<= 16; b &= 0x0000000000FF0000; a |= b;
!         b = packet[head+3]; b <<= 24; b &= 0x00000000FF000000; a |= b;
!         b = packet[head+4]; b &= 0x00000000000000FF; b <<= 32; a |= b;
!         b = packet[head+5]; b &= 0x00000000000000FF; b <<= 40; a |= b;
!         b = packet[head+6]; b &= 0x00000000000000FF; b <<= 48; a |= b;
!         b = packet[head+7]; b &= 0x00000000000000FF; b <<= 56; a |= b;
!         
!         head += 8;
!         return a;
!     }
!     
!     protected void addUint8() throws DiagMsgException {
!         String value = Integer.toString(getByte() & 0xFF);
!         line.append(delimiter + value);
!     }
!     
!     protected void addInt8() throws DiagMsgException {
!         String value = Byte.toString(getByte());
!         line.append(delimiter + value);
!     }
!     
!     protected void addHex8() throws DiagMsgException {
!         String value = Integer.toHexString(getByte() & 0xFF);
!         
!         line.append(delimiter + "0x");
!         for(int i = value.length(); i < 2; ++i)
!             line.append('0');
!         line.append(value);
!     }
!     
!     protected void addUint16() throws DiagMsgException {
!         String value = Integer.toString(getShort() & 0xFFFF);
!         line.append(delimiter + value);
!     }
!     
!     protected void addInt16() throws DiagMsgException {
!         String value = Short.toString(getShort());
!         line.append(delimiter + value);
!     }
!     
!     protected void addHex16() throws DiagMsgException {
!         String value = Integer.toHexString(getShort() & 0xFFFF);
!         
!         line.append(delimiter + "0x");
!         for(int i = value.length(); i < 4; ++i)
!             line.append('0');
!         line.append(value);
!     }
!     
!     protected void addUint32() throws DiagMsgException {
!         String value = Long.toString(getInt() & 0xFFFFFFFF);
!         line.append(delimiter + value);
!     }
!     
!     protected void addInt32() throws DiagMsgException {
!         String value = Integer.toString(getInt());
!         line.append(delimiter + value);
!     }
!     
!     protected void addHex32() throws DiagMsgException {
!         String value = Integer.toHexString(getInt());
!         
!         line.append(delimiter + "0x");
!         for(int i = value.length(); i < 8; ++i)
!             line.append('0');
!         line.append(value);
!     }
!     
!     protected void addInt64() throws DiagMsgException {
!         String value = Long.toString(getLong());
!         line.append(delimiter + value);
!     }
!     
!     protected void addUint64() throws DiagMsgException {
!         String value = Long.toString(getLong());
!         line.append(delimiter + value);
!     }
!     
!     protected void addReal() throws DiagMsgException {
!         float value = Float.intBitsToFloat(getInt());
!         line.append(delimiter + Float.toString(value));
!     }
!     
!     protected void addChar() throws DiagMsgException {
!         char value = (char)getByte();
!         line.append(delimiter + "'" + value + "'");
!     }
!     
!     protected void addStr(int len) throws DiagMsgException {
!         line.append(delimiter + "\"");
!         
!         while( --len >= 0 )
!             line.append((char)getByte());
!         
!         line.append('"');
!     }
!     
!     protected void addToken() throws DiagMsgException {
!         int token = getByte() & 0xFF;
!         
!         line.append(delimiter);
!         
!         switch(token) {
!             case 0 : line.append("false"); break;
!             case 1 : line.append("true"); break;
!             case 2 : line.append("node"); break;
!             case 3 : line.append("source"); break;
!             case 4 : line.append("destination"); break;
!             case 5 : line.append("target"); break;
!             case 6 : line.append("minimum"); break;
!             case 7 : line.append("maximum"); break;
!             case 8 : line.append("mean"); break;
!             case 9 : line.append("average"); break;
!             case 10 : line.append("time"); break;
!             case 11 : line.append("counter"); break;
!             case 12 : line.append("stamp"); break;
!             case 13 : line.append("sequence"); break;
!             case 14 : line.append("number"); break;
!             case 15 : line.append("config"); break;
!             case 16 : line.append("diameter"); break;
!             case 17 : line.append("fail"); break;
!             case 18 : line.append("success"); break;
!             case 19 : line.append("ack"); break;
!             case 20 : line.append("power"); break;
!             case 21 : line.append("local"); break;
!             case 22 : line.append("remote"); break;
!             case 23 : line.append("leader"); break;
!             case 24 : line.append("root"); break;
!             case 25 : line.append("first"); break;
!             case 26 : line.append("second"); break;
!             case 27 : line.append("third"); break;
!             case 28 : line.append("nodeid"); break;
!             case 29 : line.append("delta"); break;
!             case 30 : line.append("delay"); break;
!             case 31 : line.append("rate"); break;
!             case 32 : line.append("frequency"); break;
!             case 33 : line.append("coord"); break;
!             case 34 : line.append("coords"); break;
!             case 35 : line.append("angle"); break;
!             case 36 : line.append("temperature"); break;
!             case 37 : line.append("light"); break;
!             case 38 : line.append("next"); break;
!             case 39 : line.append("previous"); break;
!             case 40 : line.append("start"); break;
!             case 41 : line.append("end"); break;
!             case 42 : line.append("speed"); break;
!             case 43 : line.append("cpu"); break;
!             case 44 : line.append("beacon"); break;
!