mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
added output power indicator max value
This commit is contained in:
parent
7cf49fb57a
commit
223ded4595
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: TR1001Radio.java,v 1.1 2008/02/07 14:55:35 fros4943 Exp $
|
||||
* $Id: TR1001Radio.java,v 1.2 2008/03/17 09:52:03 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote.interfaces;
|
||||
@ -357,6 +357,10 @@ public class TR1001Radio extends Radio implements USARTListener, ByteRadio {
|
||||
return 1.5;
|
||||
}
|
||||
|
||||
public int getOutputPowerIndicatorMax() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
public int getCurrentOutputPowerIndicator() {
|
||||
// TODO Implement output power indicator
|
||||
return 100;
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ContikiRadio.java,v 1.17 2008/02/23 10:10:42 fros4943 Exp $
|
||||
* $Id: ContikiRadio.java,v 1.18 2008/03/17 09:50:27 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.contikimote.interfaces;
|
||||
@ -257,6 +257,10 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface,
|
||||
return 1.5;
|
||||
}
|
||||
|
||||
public int getOutputPowerIndicatorMax() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
public int getCurrentOutputPowerIndicator() {
|
||||
return myMoteMemory.getByteValueOf("simPower");
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ApplicationRadio.java,v 1.2 2007/05/30 10:52:57 fros4943 Exp $
|
||||
* $Id: ApplicationRadio.java,v 1.3 2008/03/17 09:50:27 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.interfaces;
|
||||
@ -44,7 +44,7 @@ import se.sics.cooja.*;
|
||||
* Application radio. May for example be used by Java-based mote to implement
|
||||
* radio functionality. Support radio channels and output power functionality.
|
||||
* The mote should observe the radio for incoming radio packet data.
|
||||
*
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
@ -68,15 +68,15 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
private byte[] outPacket = null;
|
||||
private int outPacketDuration = -1;
|
||||
|
||||
private double signalStrength = -200;
|
||||
private double signalStrength = -100;
|
||||
private int radioChannel = 1;
|
||||
private double outputPower = 0;
|
||||
private int outputPowerIndicator = 100;
|
||||
|
||||
|
||||
public ApplicationRadio(Mote mote) {
|
||||
this.myMote = mote;
|
||||
}
|
||||
|
||||
|
||||
/* Packet radio support */
|
||||
public byte[] getLastPacketTransmitted() {
|
||||
return packetFromMote;
|
||||
@ -141,7 +141,7 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
public Position getPosition() {
|
||||
return myMote.getInterfaces().getPosition();
|
||||
}
|
||||
|
||||
|
||||
public RadioEvent getLastEvent() {
|
||||
return lastEvent;
|
||||
}
|
||||
@ -165,10 +165,14 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
return outputPower;
|
||||
}
|
||||
|
||||
public int getOutputPowerIndicatorMax() {
|
||||
return outputPowerIndicator;
|
||||
}
|
||||
|
||||
public int getCurrentOutputPowerIndicator() {
|
||||
return outputPowerIndicator;
|
||||
}
|
||||
|
||||
|
||||
public double getCurrentSignalStrength() {
|
||||
return signalStrength;
|
||||
}
|
||||
@ -178,10 +182,10 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
}
|
||||
|
||||
/* Application radio support */
|
||||
|
||||
|
||||
/**
|
||||
* Start transmitting given packet.
|
||||
*
|
||||
*
|
||||
* @param packet Packet data
|
||||
* @param duration Duration to transmit
|
||||
*/
|
||||
@ -190,14 +194,14 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
outPacketDuration = duration;
|
||||
outPacket = packet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param i New output power indicator
|
||||
*/
|
||||
public void setOutputPowerIndicator(int i) {
|
||||
outputPowerIndicator = i;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param p New output power
|
||||
*/
|
||||
@ -211,7 +215,7 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
public void setChannel(int channel) {
|
||||
radioChannel = channel;
|
||||
}
|
||||
|
||||
|
||||
public void doActionsBeforeTick() {
|
||||
int currentTime = myMote.getSimulation().getSimulationTime();
|
||||
|
||||
@ -230,7 +234,7 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
this.setChanged();
|
||||
this.notifyObservers();
|
||||
}
|
||||
|
||||
|
||||
if (isTransmitting && currentTime >= transmissionEndTime) {
|
||||
isTransmitting = false;
|
||||
lastEvent = RadioEvent.TRANSMISSION_FINISHED;
|
||||
@ -261,7 +265,7 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
panel.add(Box.createVerticalStrut(3));
|
||||
panel.add(channelLabel);
|
||||
panel.add(Box.createVerticalGlue());
|
||||
|
||||
|
||||
updateButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ssLabel.setText("Signal strength (not auto-updated): "
|
||||
@ -271,12 +275,14 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
|
||||
final Observer observer = new Observer() {
|
||||
public void update(Observable obs, Object obj) {
|
||||
if (isTransmitting())
|
||||
if (isTransmitting()) {
|
||||
statusLabel.setText("Transmitting");
|
||||
if (isReceiving())
|
||||
}
|
||||
if (isReceiving()) {
|
||||
statusLabel.setText("Receiving");
|
||||
else
|
||||
} else {
|
||||
statusLabel.setText("Listening");
|
||||
}
|
||||
|
||||
lastEventLabel.setText("Last event (time=" + lastEventTime + "): " + lastEvent);
|
||||
ssLabel.setText("Signal strength (not auto-updated): "
|
||||
@ -313,7 +319,7 @@ public class ApplicationRadio extends Radio implements PacketRadio {
|
||||
|
||||
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||
}
|
||||
|
||||
|
||||
public Mote getMote() {
|
||||
return myMote;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science. All rights
|
||||
* reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@ -12,7 +12,7 @@
|
||||
* Institute nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -23,8 +23,8 @@
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 SUCH DAMAGE.
|
||||
*
|
||||
* $Id: Radio.java,v 1.7 2007/05/30 10:52:57 fros4943 Exp $
|
||||
*
|
||||
* $Id: Radio.java,v 1.8 2008/03/17 09:50:27 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.interfaces;
|
||||
@ -33,15 +33,15 @@ import se.sics.cooja.*;
|
||||
|
||||
/**
|
||||
* A Radio represents a mote radio transceiver.
|
||||
*
|
||||
*
|
||||
* A radio can support different abstraction levels such as transmitting and
|
||||
* receiving on a byte or packet-basis. In order to support communication
|
||||
* between different levels the general rule in COOJA is that all radios at a
|
||||
* lower abstraction level must also implement all higher levels.
|
||||
*
|
||||
*
|
||||
* @see PacketRadio
|
||||
* @see ByteRadio
|
||||
*
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
@ClassDescription("Packet Radio")
|
||||
@ -57,7 +57,7 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* Signal that a new reception just begun. This method should normally be
|
||||
* called from the radio medium.
|
||||
*
|
||||
*
|
||||
* @see #signalReceptionEnd()
|
||||
*/
|
||||
public abstract void signalReceptionStart();
|
||||
@ -65,7 +65,7 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* Signal that the current reception was ended. This method should normally be
|
||||
* called from the radio medium.
|
||||
*
|
||||
*
|
||||
* @see #signalReceptionStart()
|
||||
*/
|
||||
public abstract void signalReceptionEnd();
|
||||
@ -73,7 +73,7 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* Returns last event at this radio. This method should be used to learn the
|
||||
* reason when a radio notifies a change to observers.
|
||||
*
|
||||
*
|
||||
* @return Last radio event
|
||||
*/
|
||||
public abstract RadioEvent getLastEvent();
|
||||
@ -81,7 +81,7 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* Returns true if this radio is transmitting, or just finished transmitting,
|
||||
* data.
|
||||
*
|
||||
*
|
||||
* @see #isReceiving()
|
||||
* @return True if radio is transmitting data
|
||||
*/
|
||||
@ -89,7 +89,7 @@ public abstract class Radio extends MoteInterface {
|
||||
|
||||
/**
|
||||
* Returns true if this radio is receiving data.
|
||||
*
|
||||
*
|
||||
* @see #isTransmitting()
|
||||
* @return True if radio is receiving data
|
||||
*/
|
||||
@ -98,7 +98,7 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* Returns true if this radio had a connection that was dropped due to
|
||||
* interference.
|
||||
*
|
||||
*
|
||||
* @return True if this radio is interfered
|
||||
*/
|
||||
public abstract boolean isInterfered();
|
||||
@ -116,10 +116,15 @@ public abstract class Radio extends MoteInterface {
|
||||
public abstract double getCurrentOutputPower();
|
||||
|
||||
/**
|
||||
* @return Current output power indicator (1-100)
|
||||
* @return Current output power indicator
|
||||
*/
|
||||
public abstract int getCurrentOutputPowerIndicator();
|
||||
|
||||
/**
|
||||
* @return Maximum output power indicator
|
||||
*/
|
||||
public abstract int getOutputPowerIndicatorMax();
|
||||
|
||||
/**
|
||||
* @return Current surrounding signal strength
|
||||
*/
|
||||
@ -128,7 +133,7 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* Sets surrounding signal strength. This method should normally be called by
|
||||
* the radio medium.
|
||||
*
|
||||
*
|
||||
* @param signalStrength
|
||||
* Current surrounding signal strength
|
||||
*/
|
||||
@ -136,7 +141,7 @@ public abstract class Radio extends MoteInterface {
|
||||
|
||||
/**
|
||||
* Returns the current radio channel number.
|
||||
*
|
||||
*
|
||||
* @return Current channel number
|
||||
*/
|
||||
public abstract int getChannel();
|
||||
@ -144,7 +149,7 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* Returns the radio position.
|
||||
* This is typically the position of the mote.
|
||||
*
|
||||
*
|
||||
* @return Radio position
|
||||
*/
|
||||
public abstract Position getPosition();
|
||||
@ -152,9 +157,9 @@ public abstract class Radio extends MoteInterface {
|
||||
/**
|
||||
* This is a convenience function.
|
||||
* It returns the mote, if any, that holds this radio.
|
||||
*
|
||||
*
|
||||
* @return Mote
|
||||
*/
|
||||
public abstract Mote getMote();
|
||||
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: DisturberRadio.java,v 1.4 2007/05/30 10:53:18 fros4943 Exp $
|
||||
* $Id: DisturberRadio.java,v 1.5 2008/03/17 09:50:27 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.motes;
|
||||
@ -44,7 +44,7 @@ import se.sics.cooja.interfaces.*;
|
||||
|
||||
/**
|
||||
* This radio periodically transmits data on a configurable channel.
|
||||
*
|
||||
*
|
||||
* @author Fredrik Osterlind, Thiemo Voigt
|
||||
*/
|
||||
public class DisturberRadio extends Radio implements PacketRadio {
|
||||
@ -69,7 +69,7 @@ public class DisturberRadio extends Radio implements PacketRadio {
|
||||
|
||||
/**
|
||||
* Creates an interface to the radio at mote.
|
||||
*
|
||||
*
|
||||
* @param mote
|
||||
* Radio's mote.
|
||||
* @see Mote
|
||||
@ -78,7 +78,7 @@ public class DisturberRadio extends Radio implements PacketRadio {
|
||||
public DisturberRadio(Mote mote) {
|
||||
this.myMote = mote;
|
||||
}
|
||||
|
||||
|
||||
/* Packet radio support */
|
||||
public byte[] getLastPacketTransmitted() {
|
||||
return packetFromMote;
|
||||
@ -118,7 +118,7 @@ public class DisturberRadio extends Radio implements PacketRadio {
|
||||
public Position getPosition() {
|
||||
return myMote.getInterfaces().getPosition();
|
||||
}
|
||||
|
||||
|
||||
public RadioEvent getLastEvent() {
|
||||
return lastEvent;
|
||||
}
|
||||
@ -136,6 +136,10 @@ public class DisturberRadio extends Radio implements PacketRadio {
|
||||
return 1.5;
|
||||
}
|
||||
|
||||
public int getOutputPowerIndicatorMax() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
public int getCurrentOutputPowerIndicator() {
|
||||
return 100;
|
||||
}
|
||||
@ -185,17 +189,18 @@ public class DisturberRadio extends Radio implements PacketRadio {
|
||||
panel.add(channelLabel);
|
||||
panel.add(channelPicker);
|
||||
panel.add(Box.createVerticalGlue());
|
||||
|
||||
|
||||
channelPicker.setValue(distChannel);
|
||||
channelPicker.setColumns(3);
|
||||
channelPicker.setText(Integer.toString(distChannel));
|
||||
|
||||
final Observer observer = new Observer() {
|
||||
public void update(Observable obs, Object obj) {
|
||||
if (isTransmitting())
|
||||
if (isTransmitting()) {
|
||||
statusLabel.setText("Transmitting now!");
|
||||
else
|
||||
} else {
|
||||
statusLabel.setText("Disturber resting...");
|
||||
}
|
||||
|
||||
channelLabel.setText("Channel: " + getChannel());
|
||||
|
||||
@ -207,8 +212,9 @@ public class DisturberRadio extends Radio implements PacketRadio {
|
||||
channelPicker.addPropertyChangeListener("value", new PropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
distChannel = ((Number) channelPicker.getValue()).intValue();
|
||||
if (observer != null)
|
||||
if (observer != null) {
|
||||
observer.update(null, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -252,11 +258,12 @@ public class DisturberRadio extends Radio implements PacketRadio {
|
||||
|
||||
if (name.equals("channel")) {
|
||||
distChannel = Integer.parseInt(element.getText());
|
||||
} else
|
||||
} else {
|
||||
logger.fatal("Read unknown configuration: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Mote getMote() {
|
||||
return myMote;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user