From 990edbe32d3b7d76edf986ee3792bbe1ece50cd0 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Tue, 22 Feb 2011 20:23:43 +0100 Subject: [PATCH] moved radio interface visualizer code to shared abstract radio --- .../mspmote/interfaces/SkyByteRadio.java | 78 ------------------ .../cooja/mspmote/interfaces/TR1001Radio.java | 80 ------------------- .../contikimote/interfaces/ContikiRadio.java | 78 ------------------ 3 files changed, 236 deletions(-) mode change 100755 => 100644 tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java old mode 100755 new mode 100644 index 26043cf48..ad0eb65e4 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java @@ -385,84 +385,6 @@ public class SkyByteRadio extends Radio implements CustomDataRadio { rssiLastCounter = 8; } - public JPanel getInterfaceVisualizer() { - // Location - JPanel wrapperPanel = new JPanel(new BorderLayout()); - JPanel panel = new JPanel(new GridLayout(5, 2)); - - final JLabel statusLabel = new JLabel(""); - final JLabel lastEventLabel = new JLabel(""); - final JLabel channelLabel = new JLabel(""); - final JLabel powerLabel = new JLabel(""); - final JLabel ssLabel = new JLabel(""); - final JButton updateButton = new JButton("Update"); - - panel.add(new JLabel("STATE:")); - panel.add(statusLabel); - - panel.add(new JLabel("LAST EVENT:")); - panel.add(lastEventLabel); - - panel.add(new JLabel("CHANNEL:")); - panel.add(channelLabel); - - panel.add(new JLabel("OUTPUT POWER:")); - panel.add(powerLabel); - - panel.add(new JLabel("SIGNAL STRENGTH:")); - JPanel smallPanel = new JPanel(new GridLayout(1, 2)); - smallPanel.add(ssLabel); - smallPanel.add(updateButton); - panel.add(smallPanel); - - updateButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)"); - powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); - ssLabel.setText(getCurrentSignalStrength() + " dBm"); - } - }); - - Observer observer; - this.addObserver(observer = new Observer() { - public void update(Observable obs, Object obj) { - if (isTransmitting()) { - statusLabel.setText("transmitting"); - } else if (isReceiving()) { - statusLabel.setText("receiving"); - } else if (isReceiverOn()) { - statusLabel.setText("listening for traffic"); - } else { - statusLabel.setText("HW off"); - } - - lastEventLabel.setText(lastEvent + " @ time=" + lastEventTime); - - channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)"); - powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); - ssLabel.setText(getCurrentSignalStrength() + " dBm"); - } - }); - - observer.update(null, null); - - wrapperPanel.add(BorderLayout.NORTH, panel); - - // Saving observer reference for releaseInterfaceVisualizer - wrapperPanel.putClientProperty("intf_obs", observer); - return wrapperPanel; - } - - public void releaseInterfaceVisualizer(JPanel panel) { - Observer observer = (Observer) panel.getClientProperty("intf_obs"); - if (observer == null) { - logger.fatal("Error when releasing panel, observer is null"); - return; - } - - this.deleteObserver(observer); - } - public Mote getMote() { return mote; } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java index 6d71a9ae2..03d7cbe1e 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java @@ -355,86 +355,6 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio } }; - public JPanel getInterfaceVisualizer() { - // Location - JPanel wrapperPanel = new JPanel(new BorderLayout()); - JPanel panel = new JPanel(new GridLayout(5, 2)); - - final JLabel statusLabel = new JLabel(""); - final JLabel lastEventLabel = new JLabel(""); - final JLabel channelLabel = new JLabel("ALL CHANNELS (-1)"); - final JLabel powerLabel = new JLabel(""); - final JLabel ssLabel = new JLabel(""); - final JButton updateButton = new JButton("Update"); - - panel.add(new JLabel("STATE:")); - panel.add(statusLabel); - - panel.add(new JLabel("LAST EVENT:")); - panel.add(lastEventLabel); - - panel.add(new JLabel("CHANNEL:")); - panel.add(channelLabel); - - panel.add(new JLabel("OUTPUT POWER:")); - panel.add(powerLabel); - - panel.add(new JLabel("SIGNAL STRENGTH:")); - JPanel smallPanel = new JPanel(new GridLayout(1, 2)); - smallPanel.add(ssLabel); - smallPanel.add(updateButton); - panel.add(smallPanel); - - updateButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" - + getCurrentOutputPowerIndicator() + "/" - + getOutputPowerIndicatorMax() + ")"); - ssLabel.setText(getCurrentSignalStrength() + " dBm"); - } - }); - - Observer observer; - this.addObserver(observer = new Observer() { - public void update(Observable obs, Object obj) { - if (isTransmitting()) { - statusLabel.setText("transmitting"); - } else if (isReceiving()) { - statusLabel.setText("receiving"); - } else if (radioOn) { - statusLabel.setText("listening for traffic"); - } else { - statusLabel.setText("HW off"); - } - - lastEventLabel.setText(lastEvent + " @ time=" + lastEventTime); - - powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" - + getCurrentOutputPowerIndicator() + "/" - + getOutputPowerIndicatorMax() + ")"); - ssLabel.setText(getCurrentSignalStrength() + " dBm"); - } - }); - - observer.update(null, null); - - // Saving observer reference for releaseInterfaceVisualizer - panel.putClientProperty("intf_obs", observer); - - wrapperPanel.add(BorderLayout.NORTH, panel); - return wrapperPanel; - } - - public void releaseInterfaceVisualizer(JPanel panel) { - Observer observer = (Observer) panel.getClientProperty("intf_obs"); - if (observer == null) { - logger.fatal("Error when releasing panel, observer is null"); - return; - } - - this.deleteObserver(observer); - } - public Collection getConfigXML() { return null; } diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java index ca756bec7..b301c2114 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java @@ -345,84 +345,6 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA } } - public JPanel getInterfaceVisualizer() { - // Location - JPanel wrapperPanel = new JPanel(new BorderLayout()); - JPanel panel = new JPanel(new GridLayout(5, 2)); - - final JLabel statusLabel = new JLabel(""); - final JLabel lastEventLabel = new JLabel(""); - final JLabel channelLabel = new JLabel(""); - final JLabel powerLabel = new JLabel(""); - final JLabel ssLabel = new JLabel(""); - final JButton updateButton = new JButton("Update"); - - panel.add(new JLabel("STATE:")); - panel.add(statusLabel); - - panel.add(new JLabel("LAST EVENT:")); - panel.add(lastEventLabel); - - panel.add(new JLabel("CHANNEL:")); - panel.add(channelLabel); - - panel.add(new JLabel("OUTPUT POWER:")); - panel.add(powerLabel); - - panel.add(new JLabel("SIGNAL STRENGTH:")); - JPanel smallPanel = new JPanel(new GridLayout(1, 2)); - smallPanel.add(ssLabel); - smallPanel.add(updateButton); - panel.add(smallPanel); - - updateButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - channelLabel.setText("" + getChannel()); - powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); - ssLabel.setText(getCurrentSignalStrength() + " dBm"); - } - }); - - Observer observer; - this.addObserver(observer = new Observer() { - public void update(Observable obs, Object obj) { - if (isTransmitting()) { - statusLabel.setText("transmitting"); - } else if (isReceiving()) { - statusLabel.setText("receiving"); - } else if (radioOn) { - statusLabel.setText("listening for traffic"); - } else { - statusLabel.setText("HW off"); - } - - lastEventLabel.setText(lastEvent + " @ time=" + lastEventTime); - - channelLabel.setText("" + getChannel()); - powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); - ssLabel.setText(getCurrentSignalStrength() + " dBm"); - } - }); - - observer.update(null, null); - - wrapperPanel.add(BorderLayout.NORTH, panel); - - // Saving observer reference for releaseInterfaceVisualizer - wrapperPanel.putClientProperty("intf_obs", observer); - return wrapperPanel; - } - - public void releaseInterfaceVisualizer(JPanel panel) { - Observer observer = (Observer) panel.getClientProperty("intf_obs"); - if (observer == null) { - logger.fatal("Error when releasing panel, observer is null"); - return; - } - - this.deleteObserver(observer); - } - public Collection getConfigXML() { return null; }