removed passive/active interfaces notion.

This commit is contained in:
fros4943 2008-10-28 13:38:55 +00:00
parent 4231e5f41a
commit bbf88f3723
4 changed files with 21 additions and 45 deletions

View file

@ -24,7 +24,7 @@
* (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: AbstractApplicationMote.java,v 1.2 2008/03/18 13:05:23 fros4943 Exp $
* $Id: AbstractApplicationMote.java,v 1.3 2008/10/28 13:38:55 fros4943 Exp $
*/
package se.sics.cooja.motes;
@ -93,12 +93,12 @@ public abstract class AbstractApplicationMote implements Mote {
// Create position
myInterfaceHandler = new MoteInterfaceHandler();
Position myPosition = new Position(this);
myInterfaceHandler.addPassiveInterface(myPosition);
myInterfaceHandler.addInterface(myPosition);
// Create radio
myApplicationRadio = new ApplicationRadio(this);
myApplicationRadio.addObserver(radioDataObserver);
myInterfaceHandler.addActiveInterface(myApplicationRadio);
myInterfaceHandler.addInterface(myApplicationRadio);
}
public void setState(State newState) {
@ -161,20 +161,8 @@ public abstract class AbstractApplicationMote implements Mote {
element = new Element("interface_config");
element.setText(myInterfaceHandler.getPosition().getClass().getName());
// Active interface configs (if any)
for (MoteInterface moteInterface: getInterfaces().getAllActiveInterfaces()) {
element = new Element("interface_config");
element.setText(moteInterface.getClass().getName());
Collection interfaceXML = moteInterface.getConfigXML();
if (interfaceXML != null) {
element.addContent(interfaceXML);
config.add(element);
}
}
// Passive interface configs (if any)
for (MoteInterface moteInterface: getInterfaces().getAllPassiveInterfaces()) {
// Interfaces
for (MoteInterface moteInterface: getInterfaces().getInterfaces()) {
element = new Element("interface_config");
element.setText(moteInterface.getClass().getName());
@ -196,10 +184,10 @@ public abstract class AbstractApplicationMote implements Mote {
myMemory = new SectionMoteMemory(new Properties());
myInterfaceHandler = new MoteInterfaceHandler();
Position myPosition = new Position(this);
myInterfaceHandler.addPassiveInterface(myPosition);
myInterfaceHandler.addInterface(myPosition);
myApplicationRadio = new ApplicationRadio(this);
myApplicationRadio.addObserver(radioDataObserver);
myInterfaceHandler.addActiveInterface(myApplicationRadio);
myInterfaceHandler.addInterface(myApplicationRadio);
for (Element element : configXML) {
String name = element.getName();
@ -207,8 +195,8 @@ public abstract class AbstractApplicationMote implements Mote {
if (name.equals("motetype_identifier")) {
myType = simulation.getMoteType(element.getText());
} else if (name.equals("interface_config")) {
Class<? extends MoteInterface> moteInterfaceClass = simulation.getGUI()
.tryLoadClass(this, MoteInterface.class, element.getText().trim());
Class<? extends MoteInterface> moteInterfaceClass =
simulation.getGUI().tryLoadClass(this, MoteInterface.class, element.getText().trim());
if (moteInterfaceClass == null) {
logger.warn("Can't find mote interface class: " + element.getText());

View file

@ -24,7 +24,7 @@
* (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: DisturberMote.java,v 1.3 2008/03/31 15:22:42 fros4943 Exp $
* $Id: DisturberMote.java,v 1.4 2008/10/28 13:39:24 fros4943 Exp $
*/
package se.sics.cooja.motes;
@ -88,11 +88,11 @@ public class DisturberMote implements Mote {
Position myPosition = new Position(this);
myPosition.setCoordinates(myRandom.nextDouble() * 100, myRandom
.nextDouble() * 100, myRandom.nextDouble() * 100);
myInterfaceHandler.addPassiveInterface(myPosition);
myInterfaceHandler.addInterface(myPosition);
// create interface handler for radio
myDisturberRadio = new DisturberRadio(this);
myInterfaceHandler.addActiveInterface(myDisturberRadio);
myInterfaceHandler.addInterface(myDisturberRadio);
}
public void setState(State newState) {
@ -163,20 +163,8 @@ public class DisturberMote implements Mote {
element = new Element("interface_config");
element.setText(myInterfaceHandler.getPosition().getClass().getName());
// Active interface configs (if any)
for (MoteInterface moteInterface: getInterfaces().getAllActiveInterfaces()) {
element = new Element("interface_config");
element.setText(moteInterface.getClass().getName());
Collection interfaceXML = moteInterface.getConfigXML();
if (interfaceXML != null) {
element.addContent(interfaceXML);
config.add(element);
}
}
// Passive interface configs (if any)
for (MoteInterface moteInterface: getInterfaces().getAllPassiveInterfaces()) {
// Interfaces
for (MoteInterface moteInterface: getInterfaces().getInterfaces()) {
element = new Element("interface_config");
element.setText(moteInterface.getClass().getName());
@ -198,9 +186,9 @@ public class DisturberMote implements Mote {
myMemory = new SectionMoteMemory(new Properties());
myInterfaceHandler = new MoteInterfaceHandler();
Position myPosition = new Position(this);
myInterfaceHandler.addPassiveInterface(myPosition);
myInterfaceHandler.addInterface(myPosition);
myDisturberRadio = new DisturberRadio(this);
myInterfaceHandler.addActiveInterface(myDisturberRadio);
myInterfaceHandler.addInterface(myDisturberRadio);
for (Element element : configXML) {

View file

@ -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.7 2008/03/18 13:55:46 fros4943 Exp $
* $Id: DisturberRadio.java,v 1.8 2008/10/28 13:39:24 fros4943 Exp $
*/
package se.sics.cooja.motes;
@ -236,7 +236,7 @@ public class DisturberRadio extends Radio {
this.deleteObserver(observer);
}
public double energyConsumptionPerTick() {
public double energyConsumption() {
return 0;
}

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: DummyMote.java,v 1.4 2008/03/31 15:22:41 fros4943 Exp $
* $Id: DummyMote.java,v 1.5 2008/10/28 13:39:24 fros4943 Exp $
*/
package se.sics.cooja.motes;
@ -97,7 +97,7 @@ public class DummyMote implements Mote {
Position myPosition = new Position(this);
myPosition.setCoordinates(myRandom.nextDouble() * 100, myRandom
.nextDouble() * 100, myRandom.nextDouble() * 100);
myInterfaceHandler.addPassiveInterface(myPosition);
myInterfaceHandler.addInterface(myPosition);
}
public void setState(State newState) {
@ -188,7 +188,7 @@ public class DummyMote implements Mote {
mySim = simulation;
myMemory = new SectionMoteMemory(new Properties());
myInterfaceHandler = new MoteInterfaceHandler();
myInterfaceHandler.addPassiveInterface(new Position(this));
myInterfaceHandler.addInterface(new Position(this));
for (Element element : configXML) {
String name = element.getName();