removing obsolete method previously used for estimating contiki's energy consumption.

This commit is contained in:
fros4943 2010-02-05 09:07:58 +00:00
parent cdb1b93dc6
commit 4d7fe46561
7 changed files with 497 additions and 522 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: SerialUI.java,v 1.2 2009/06/02 09:34:12 fros4943 Exp $ * $Id: SerialUI.java,v 1.3 2010/02/05 09:07:58 fros4943 Exp $
*/ */
package se.sics.cooja.dialogs; package se.sics.cooja.dialogs;
@ -263,10 +263,6 @@ public abstract class SerialUI extends Log implements SerialPort {
this.deleteObserver(observer); this.deleteObserver(observer);
} }
public double energyConsumption() {
return 0;
}
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
return null; return null;
} }

View file

@ -1,347 +1,345 @@
/* /*
* Copyright (c) 2009, Swedish Institute of Computer Science. * Copyright (c) 2009, Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: Radio802154.java,v 1.1 2009/11/10 12:54:39 joxe Exp $ * $Id: Radio802154.java,v 1.2 2010/02/05 09:07:58 fros4943 Exp $
*/ */
package se.sics.cooja.emulatedmote; package se.sics.cooja.emulatedmote;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.*; import java.util.*;
import javax.swing.*; import javax.swing.*;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
import se.sics.cooja.*; import se.sics.cooja.*;
import se.sics.cooja.interfaces.CustomDataRadio; import se.sics.cooja.interfaces.CustomDataRadio;
import se.sics.cooja.interfaces.Position; import se.sics.cooja.interfaces.Position;
import se.sics.cooja.interfaces.Radio; import se.sics.cooja.interfaces.Radio;
/** /**
* 802.15.4 radio class for COOJA. * 802.15.4 radio class for COOJA.
* *
* @author Joakim Eriksson * @author Joakim Eriksson
*/ */
public abstract class Radio802154 extends Radio implements CustomDataRadio { public abstract class Radio802154 extends Radio implements CustomDataRadio {
private final static boolean DEBUG = false; private final static boolean DEBUG = false;
private static Logger logger = Logger.getLogger(Radio802154.class); private static Logger logger = Logger.getLogger(Radio802154.class);
protected long lastEventTime = 0; protected long lastEventTime = 0;
protected RadioEvent lastEvent = RadioEvent.UNKNOWN; protected RadioEvent lastEvent = RadioEvent.UNKNOWN;
protected boolean isInterfered = false; protected boolean isInterfered = false;
private boolean isTransmitting = false; private boolean isTransmitting = false;
protected boolean isReceiving = false; protected boolean isReceiving = false;
// private boolean hasFailedReception = false; // private boolean hasFailedReception = false;
private boolean radioOn = true; private boolean radioOn = true;
private RadioByte lastOutgoingByte = null; private RadioByte lastOutgoingByte = null;
private RadioByte lastIncomingByte = null; private RadioByte lastIncomingByte = null;
private RadioPacket lastOutgoingPacket = null; private RadioPacket lastOutgoingPacket = null;
private RadioPacket lastIncomingPacket = null; private RadioPacket lastIncomingPacket = null;
// private int mode; // private int mode;
protected Mote mote; protected Mote mote;
public Radio802154(Mote mote) { public Radio802154(Mote mote) {
this.mote = mote; this.mote = mote;
} }
int len = 0; int len = 0;
int expLen = 0; int expLen = 0;
byte[] buffer = new byte[127 + 15]; byte[] buffer = new byte[127 + 15];
protected void handleTransmit(byte val) { protected void handleTransmit(byte val) {
if (len == 0) { if (len == 0) {
lastEventTime = mote.getSimulation().getSimulationTime(); lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.TRANSMISSION_STARTED; lastEvent = RadioEvent.TRANSMISSION_STARTED;
if (DEBUG) logger.debug("----- 802.15.4 TRANSMISSION STARTED -----"); if (DEBUG) logger.debug("----- 802.15.4 TRANSMISSION STARTED -----");
setChanged(); setChanged();
notifyObservers(); notifyObservers();
} }
/* send this byte to all nodes */ /* send this byte to all nodes */
lastOutgoingByte = new RadioByte(val); lastOutgoingByte = new RadioByte(val);
lastEventTime = mote.getSimulation().getSimulationTime(); lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED; lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED;
setChanged(); setChanged();
notifyObservers(); notifyObservers();
buffer[len++] = val; buffer[len++] = val;
//System.out.println("## 802.15.4: " + (val&0xff) + " transmitted..."); //System.out.println("## 802.15.4: " + (val&0xff) + " transmitted...");
if (len == 6) { if (len == 6) {
//System.out.println("## CC2420 Packet of length: " + val + " expected..."); //System.out.println("## CC2420 Packet of length: " + val + " expected...");
expLen = val + 6; expLen = val + 6;
} }
if (len == expLen) { if (len == expLen) {
if (DEBUG) logger.debug("----- 802.15.4 CUSTOM DATA TRANSMITTED -----"); if (DEBUG) logger.debug("----- 802.15.4 CUSTOM DATA TRANSMITTED -----");
lastOutgoingPacket = Radio802154PacketConverter.fromCC2420ToCooja(buffer); lastOutgoingPacket = Radio802154PacketConverter.fromCC2420ToCooja(buffer);
lastEventTime = mote.getSimulation().getSimulationTime(); lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.PACKET_TRANSMITTED; lastEvent = RadioEvent.PACKET_TRANSMITTED;
if (DEBUG) logger.debug("----- 802.15.4 PACKET TRANSMITTED -----"); if (DEBUG) logger.debug("----- 802.15.4 PACKET TRANSMITTED -----");
setChanged(); setChanged();
notifyObservers(); notifyObservers();
// System.out.println("## CC2420 Transmission finished..."); // System.out.println("## CC2420 Transmission finished...");
lastEventTime = mote.getSimulation().getSimulationTime(); lastEventTime = mote.getSimulation().getSimulationTime();
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/ /*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
lastEvent = RadioEvent.TRANSMISSION_FINISHED; lastEvent = RadioEvent.TRANSMISSION_FINISHED;
setChanged(); setChanged();
notifyObservers(); notifyObservers();
len = 0; len = 0;
} }
} }
/* Packet radio support */ /* Packet radio support */
public RadioPacket getLastPacketTransmitted() { public RadioPacket getLastPacketTransmitted() {
return lastOutgoingPacket; return lastOutgoingPacket;
} }
public RadioPacket getLastPacketReceived() { public RadioPacket getLastPacketReceived() {
return lastIncomingPacket; return lastIncomingPacket;
} }
public void setReceivedPacket(RadioPacket packet) { public void setReceivedPacket(RadioPacket packet) {
} }
/* Custom data radio support */ /* Custom data radio support */
public Object getLastCustomDataTransmitted() { public Object getLastCustomDataTransmitted() {
return lastOutgoingByte; return lastOutgoingByte;
} }
public Object getLastCustomDataReceived() { public Object getLastCustomDataReceived() {
return lastIncomingByte; return lastIncomingByte;
} }
public void receiveCustomData(Object data) { public void receiveCustomData(Object data) {
if (data instanceof RadioByte) { if (data instanceof RadioByte) {
lastIncomingByte = (RadioByte) data; lastIncomingByte = (RadioByte) data;
handleReceive(lastIncomingByte.getPacketData()[0]); handleReceive(lastIncomingByte.getPacketData()[0]);
} }
} }
/* General radio support */ /* General radio support */
public boolean isTransmitting() { public boolean isTransmitting() {
return isTransmitting; return isTransmitting;
} }
public boolean isReceiving() { public boolean isReceiving() {
return isReceiving; return isReceiving;
} }
public boolean isInterfered() { public boolean isInterfered() {
return isInterfered; return isInterfered;
} }
protected abstract void handleReceive(byte b); protected abstract void handleReceive(byte b);
protected abstract void handleEndOfReception(); protected abstract void handleEndOfReception();
public abstract int getChannel(); public abstract int getChannel();
public abstract int getFrequency(); public abstract int getFrequency();
public abstract boolean isReceiverOn(); public abstract boolean isReceiverOn();
public abstract double getCurrentOutputPower(); public abstract double getCurrentOutputPower();
public abstract int getCurrentOutputPowerIndicator(); public abstract int getCurrentOutputPowerIndicator();
public abstract int getOutputPowerIndicatorMax(); public abstract int getOutputPowerIndicatorMax();
public abstract double getCurrentSignalStrength(); public abstract double getCurrentSignalStrength();
public abstract void setCurrentSignalStrength(double signalStrength); public abstract void setCurrentSignalStrength(double signalStrength);
public abstract double energyConsumption(); /* need to add a few more methods later??? */
public void signalReceptionStart() {
/* need to add a few more methods later??? */ isReceiving = true;
public void signalReceptionStart() {
isReceiving = true; // cc2420.setCCA(true);
// hasFailedReception = mode == CC2420.MODE_TXRX_OFF;
// cc2420.setCCA(true); /* TODO cc2420.setSFD(true); */
// hasFailedReception = mode == CC2420.MODE_TXRX_OFF;
/* TODO cc2420.setSFD(true); */ lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_STARTED;
lastEventTime = mote.getSimulation().getSimulationTime(); if (DEBUG) logger.debug("----- 802.15.4 RECEPTION STARTED -----");
lastEvent = RadioEvent.RECEPTION_STARTED; setChanged();
if (DEBUG) logger.debug("----- 802.15.4 RECEPTION STARTED -----"); notifyObservers();
setChanged(); }
notifyObservers();
} public void signalReceptionEnd() {
/* Deliver packet data */
public void signalReceptionEnd() { isReceiving = false;
/* Deliver packet data */ // hasFailedReception = false;
isReceiving = false; isInterfered = false;
// hasFailedReception = false; // cc2420.setCCA(false);
isInterfered = false;
// cc2420.setCCA(false); /* tell the receiver that the packet is ended */
handleEndOfReception();
/* tell the receiver that the packet is ended */
handleEndOfReception(); lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_FINISHED;
lastEventTime = mote.getSimulation().getSimulationTime(); if (DEBUG) logger.debug("----- 802.15.4 RECEPTION FINISHED -----");
lastEvent = RadioEvent.RECEPTION_FINISHED; // Exception e = new IllegalStateException("Why finished?");
if (DEBUG) logger.debug("----- 802.15.4 RECEPTION FINISHED -----"); // e.printStackTrace();
// Exception e = new IllegalStateException("Why finished?"); setChanged();
// e.printStackTrace(); notifyObservers();
setChanged(); }
notifyObservers();
} public RadioEvent getLastEvent() {
return lastEvent;
public RadioEvent getLastEvent() { }
return lastEvent;
} public void interfereAnyReception() {
isInterfered = true;
public void interfereAnyReception() { isReceiving = false;
isInterfered = true; // hasFailedReception = false;
isReceiving = false; lastIncomingPacket = null;
// hasFailedReception = false;
lastIncomingPacket = null; //cc2420.setCCA(true);
//cc2420.setCCA(true); /* is this ok ?? */
handleEndOfReception();
/* is this ok ?? */ //recv.nextByte(false, (byte)0);
handleEndOfReception();
//recv.nextByte(false, (byte)0); lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_INTERFERED;
lastEventTime = mote.getSimulation().getSimulationTime(); /*logger.debug("----- SKY RECEPTION INTERFERED -----");*/
lastEvent = RadioEvent.RECEPTION_INTERFERED; setChanged();
/*logger.debug("----- SKY RECEPTION INTERFERED -----");*/ notifyObservers();
setChanged(); }
notifyObservers();
} public JPanel getInterfaceVisualizer() {
// Location
public JPanel getInterfaceVisualizer() { JPanel wrapperPanel = new JPanel(new BorderLayout());
// Location JPanel panel = new JPanel(new GridLayout(5, 2));
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 statusLabel = new JLabel(""); final JLabel channelLabel = new JLabel("");
final JLabel lastEventLabel = new JLabel(""); final JLabel powerLabel = new JLabel("");
final JLabel channelLabel = new JLabel(""); final JLabel ssLabel = new JLabel("");
final JLabel powerLabel = new JLabel(""); final JButton updateButton = new JButton("Update");
final JLabel ssLabel = new JLabel("");
final JButton updateButton = new JButton("Update"); panel.add(new JLabel("STATE:"));
panel.add(statusLabel);
panel.add(new JLabel("STATE:"));
panel.add(statusLabel); panel.add(new JLabel("LAST EVENT:"));
panel.add(lastEventLabel);
panel.add(new JLabel("LAST EVENT:"));
panel.add(lastEventLabel); panel.add(new JLabel("CHANNEL:"));
panel.add(channelLabel);
panel.add(new JLabel("CHANNEL:"));
panel.add(channelLabel); panel.add(new JLabel("OUTPUT POWER:"));
panel.add(powerLabel);
panel.add(new JLabel("OUTPUT POWER:"));
panel.add(powerLabel); panel.add(new JLabel("SIGNAL STRENGTH:"));
JPanel smallPanel = new JPanel(new GridLayout(1, 2));
panel.add(new JLabel("SIGNAL STRENGTH:")); smallPanel.add(ssLabel);
JPanel smallPanel = new JPanel(new GridLayout(1, 2)); smallPanel.add(updateButton);
smallPanel.add(ssLabel); panel.add(smallPanel);
smallPanel.add(updateButton);
panel.add(smallPanel); updateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateButton.addActionListener(new ActionListener() { channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)");
public void actionPerformed(ActionEvent e) { powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")");
channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)"); ssLabel.setText(getCurrentSignalStrength() + " dBm");
powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); }
ssLabel.setText(getCurrentSignalStrength() + " dBm"); });
}
}); Observer observer;
this.addObserver(observer = new Observer() {
Observer observer; public void update(Observable obs, Object obj) {
this.addObserver(observer = new Observer() { if (isTransmitting()) {
public void update(Observable obs, Object obj) { statusLabel.setText("transmitting");
if (isTransmitting()) { } else if (isReceiving()) {
statusLabel.setText("transmitting"); statusLabel.setText("receiving");
} else if (isReceiving()) { } else if (radioOn /* mode != CC2420.MODE_TXRX_OFF */) {
statusLabel.setText("receiving"); statusLabel.setText("listening for traffic");
} else if (radioOn /* mode != CC2420.MODE_TXRX_OFF */) { } else {
statusLabel.setText("listening for traffic"); statusLabel.setText("HW off");
} else { }
statusLabel.setText("HW off");
} lastEventLabel.setText(lastEvent + " @ time=" + lastEventTime);
lastEventLabel.setText(lastEvent + " @ time=" + lastEventTime); channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)");
powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")");
channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)"); ssLabel.setText(getCurrentSignalStrength() + " dBm");
powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); }
ssLabel.setText(getCurrentSignalStrength() + " dBm"); });
}
}); observer.update(null, null);
observer.update(null, null); wrapperPanel.add(BorderLayout.NORTH, panel);
wrapperPanel.add(BorderLayout.NORTH, panel); // Saving observer reference for releaseInterfaceVisualizer
wrapperPanel.putClientProperty("intf_obs", observer);
// Saving observer reference for releaseInterfaceVisualizer return wrapperPanel;
wrapperPanel.putClientProperty("intf_obs", observer); }
return wrapperPanel;
} public void releaseInterfaceVisualizer(JPanel panel) {
Observer observer = (Observer) panel.getClientProperty("intf_obs");
public void releaseInterfaceVisualizer(JPanel panel) { if (observer == null) {
Observer observer = (Observer) panel.getClientProperty("intf_obs"); logger.fatal("Error when releasing panel, observer is null");
if (observer == null) { return;
logger.fatal("Error when releasing panel, observer is null"); }
return;
} this.deleteObserver(observer);
}
this.deleteObserver(observer);
} public Mote getMote() {
return mote;
public Mote getMote() { }
return mote;
} public Position getPosition() {
return mote.getInterfaces().getPosition();
public Position getPosition() { }
return mote.getInterfaces().getPosition();
} public Collection<Element> getConfigXML() {
return null;
public Collection<Element> getConfigXML() { }
return null;
} public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
}
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) { }
}
}

View file

@ -1,152 +1,148 @@
package se.sics.cooja.interfaces; package se.sics.cooja.interfaces;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.util.Collection; import java.util.Collection;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import javax.swing.JPanel; import javax.swing.JPanel;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
import se.sics.cooja.*; import se.sics.cooja.*;
import se.sics.cooja.contikimote.interfaces.ContikiLED; import se.sics.cooja.contikimote.interfaces.ContikiLED;
public class ApplicationLED extends LED { public class ApplicationLED extends LED {
private static Logger logger = Logger.getLogger(ContikiLED.class); private static Logger logger = Logger.getLogger(ContikiLED.class);
private Mote mote = null; private Mote mote = null;
private byte currentLedValue = 0; private byte currentLedValue = 0;
public static final byte LEDS_GREEN = 1; public static final byte LEDS_GREEN = 1;
public static final byte LEDS_YELLOW = 2; public static final byte LEDS_YELLOW = 2;
public static final byte LEDS_RED = 4; public static final byte LEDS_RED = 4;
private static final Color DARK_GREEN = new Color(0, 50, 0); private static final Color DARK_GREEN = new Color(0, 50, 0);
private static final Color DARK_YELLOW = new Color(50, 50, 0); private static final Color DARK_YELLOW = new Color(50, 50, 0);
private static final Color DARK_RED = new Color(50, 0, 0); private static final Color DARK_RED = new Color(50, 0, 0);
private static final Color GREEN = new Color(0, 255, 0); private static final Color GREEN = new Color(0, 255, 0);
private static final Color YELLOW = new Color(255, 255, 0); private static final Color YELLOW = new Color(255, 255, 0);
private static final Color RED = new Color(255, 0, 0); private static final Color RED = new Color(255, 0, 0);
public ApplicationLED(Mote mote) { public ApplicationLED(Mote mote) {
this.mote = mote; this.mote = mote;
} }
public static String[] getCoreInterfaceDependencies() { public static String[] getCoreInterfaceDependencies() {
return new String[]{"leds_interface"}; return new String[]{"leds_interface"};
} }
public boolean isAnyOn() { public boolean isAnyOn() {
return currentLedValue > 0; return currentLedValue > 0;
} }
public boolean isGreenOn() { public boolean isGreenOn() {
return (currentLedValue & LEDS_GREEN) > 0; return (currentLedValue & LEDS_GREEN) > 0;
} }
public boolean isYellowOn() { public boolean isYellowOn() {
return (currentLedValue & LEDS_YELLOW) > 0; return (currentLedValue & LEDS_YELLOW) > 0;
} }
public boolean isRedOn() { public boolean isRedOn() {
return (currentLedValue & LEDS_RED) > 0; return (currentLedValue & LEDS_RED) > 0;
} }
public void setLED(int led) { public void setLED(int led) {
boolean ledChanged; boolean ledChanged;
ledChanged = led != currentLedValue; ledChanged = led != currentLedValue;
currentLedValue = (byte) led; currentLedValue = (byte) led;
if (ledChanged) { if (ledChanged) {
this.setChanged(); this.setChanged();
this.notifyObservers(mote); this.notifyObservers(mote);
} }
} }
public JPanel getInterfaceVisualizer() { public JPanel getInterfaceVisualizer() {
final JPanel panel = new JPanel() { final JPanel panel = new JPanel() {
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
int x = 20; int x = 20;
int y = 25; int y = 25;
int d = 25; int d = 25;
if (isGreenOn()) { if (isGreenOn()) {
g.setColor(GREEN); g.setColor(GREEN);
g.fillOval(x, y, d, d); g.fillOval(x, y, d, d);
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.drawOval(x, y, d, d); g.drawOval(x, y, d, d);
} else { } else {
g.setColor(DARK_GREEN); g.setColor(DARK_GREEN);
g.fillOval(x + 5, y + 5, d-10, d-10); g.fillOval(x + 5, y + 5, d-10, d-10);
} }
x += 40; x += 40;
if (isRedOn()) { if (isRedOn()) {
g.setColor(RED); g.setColor(RED);
g.fillOval(x, y, d, d); g.fillOval(x, y, d, d);
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.drawOval(x, y, d, d); g.drawOval(x, y, d, d);
} else { } else {
g.setColor(DARK_RED); g.setColor(DARK_RED);
g.fillOval(x + 5, y + 5, d-10, d-10); g.fillOval(x + 5, y + 5, d-10, d-10);
} }
x += 40; x += 40;
if (isYellowOn()) { if (isYellowOn()) {
g.setColor(YELLOW); g.setColor(YELLOW);
g.fillOval(x, y, d, d); g.fillOval(x, y, d, d);
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.drawOval(x, y, d, d); g.drawOval(x, y, d, d);
} else { } else {
g.setColor(DARK_YELLOW); g.setColor(DARK_YELLOW);
g.fillOval(x + 5, y + 5, d-10, d-10); g.fillOval(x + 5, y + 5, d-10, d-10);
} }
} }
}; };
Observer observer; Observer observer;
this.addObserver(observer = new Observer() { this.addObserver(observer = new Observer() {
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
panel.repaint(); panel.repaint();
} }
}); });
// Saving observer reference for releaseInterfaceVisualizer // Saving observer reference for releaseInterfaceVisualizer
panel.putClientProperty("intf_obs", observer); panel.putClientProperty("intf_obs", observer);
panel.setMinimumSize(new Dimension(140, 60)); panel.setMinimumSize(new Dimension(140, 60));
panel.setPreferredSize(new Dimension(140, 60)); panel.setPreferredSize(new Dimension(140, 60));
return panel; return panel;
} }
public void releaseInterfaceVisualizer(JPanel panel) { public void releaseInterfaceVisualizer(JPanel panel) {
Observer observer = (Observer) panel.getClientProperty("intf_obs"); Observer observer = (Observer) panel.getClientProperty("intf_obs");
if (observer == null) { if (observer == null) {
logger.fatal("Error when releasing panel, observer is null"); logger.fatal("Error when releasing panel, observer is null");
return; return;
} }
this.deleteObserver(observer); this.deleteObserver(observer);
} }
public double energyConsumption() { public Collection<Element> getConfigXML() {
return 0; return null;
} }
public Collection<Element> getConfigXML() { @Override
return null; public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
} // TODO Auto-generated method stub
}
@Override
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
// TODO Auto-generated method stub
}
} }

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ApplicationRadio.java,v 1.11 2010/01/24 23:16:17 joxe Exp $ * $Id: ApplicationRadio.java,v 1.12 2010/02/05 09:07:58 fros4943 Exp $
*/ */
package se.sics.cooja.interfaces; package se.sics.cooja.interfaces;
@ -335,10 +335,6 @@ private int interfered;
this.deleteObserver(observer); this.deleteObserver(observer);
} }
public double energyConsumption() {
return 0;
}
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
return null; return null;
} }

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: Mote2MoteRelations.java,v 1.3 2010/01/12 09:36:10 fros4943 Exp $ * $Id: Mote2MoteRelations.java,v 1.4 2010/02/05 09:07:58 fros4943 Exp $
*/ */
package se.sics.cooja.interfaces; package se.sics.cooja.interfaces;
@ -225,10 +225,6 @@ public class Mote2MoteRelations extends MoteInterface {
this.deleteObserver(observer); this.deleteObserver(observer);
} }
public double energyConsumption() {
return 0;
}
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
return null; return null;
} }

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: Position.java,v 1.5 2009/03/09 14:08:54 fros4943 Exp $ * $Id: Position.java,v 1.6 2010/02/05 09:07:58 fros4943 Exp $
*/ */
package se.sics.cooja.interfaces; package se.sics.cooja.interfaces;
@ -168,10 +168,6 @@ public class Position extends MoteInterface {
this.deleteObserver(observer); this.deleteObserver(observer);
} }
public double energyConsumption() {
return 0.0;
}
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
Vector<Element> config = new Vector<Element>(); Vector<Element> config = new Vector<Element>();
Element element; Element element;

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: AbstractApplicationMoteType.java,v 1.8 2010/02/03 15:11:48 fros4943 Exp $ * $Id: AbstractApplicationMoteType.java,v 1.9 2010/02/05 09:08:07 fros4943 Exp $
*/ */
package se.sics.cooja.motes; package se.sics.cooja.motes;
@ -245,9 +245,6 @@ public abstract class AbstractApplicationMoteType implements MoteType {
public void setMoteID(int newID) { public void setMoteID(int newID) {
this.id = newID; this.id = newID;
} }
public double energyConsumption() {
return 0;
}
public JPanel getInterfaceVisualizer() { public JPanel getInterfaceVisualizer() {
return null; return null;
} }