small optimizations and cleanups
This commit is contained in:
parent
63c685c852
commit
67c76649d9
5 changed files with 29 additions and 61 deletions
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MicaZMote.java,v 1.14 2010/02/03 16:04:44 fros4943 Exp $
|
||||
* $Id: MicaZMote.java,v 1.15 2010/10/04 12:54:01 joxe Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.avrmote;
|
||||
|
@ -64,7 +64,6 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote {
|
|||
/* 8 MHz according to Contiki config */
|
||||
public static long NR_CYCLES_PER_MSEC = 8000;
|
||||
|
||||
private Simulation mySimulation = null;
|
||||
private MoteInterfaceHandler myMoteInterfaceHandler;
|
||||
private AtmelMicrocontroller myCpu = null;
|
||||
private MicaZ micaZ = null;
|
||||
|
@ -81,14 +80,13 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote {
|
|||
|
||||
public MicaZMote() {
|
||||
myMoteType = null;
|
||||
mySimulation = null;
|
||||
myCpu = null;
|
||||
/* TODO myMemory = null; */
|
||||
myMoteInterfaceHandler = null;
|
||||
}
|
||||
|
||||
public MicaZMote(Simulation simulation, MicaZMoteType type) {
|
||||
mySimulation = simulation;
|
||||
setSimulation(simulation);
|
||||
myMoteType = type;
|
||||
|
||||
/* Schedule us immediately */
|
||||
|
@ -128,14 +126,6 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote {
|
|||
}
|
||||
}
|
||||
|
||||
public Simulation getSimulation() {
|
||||
return mySimulation;
|
||||
}
|
||||
|
||||
public void setSimulation(Simulation simulation) {
|
||||
mySimulation = simulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares CPU, memory and ELF module.
|
||||
*
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MspMote.java,v 1.47 2010/08/13 10:18:54 fros4943 Exp $
|
||||
* $Id: MspMote.java,v 1.48 2010/10/04 12:54:01 joxe Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote;
|
||||
|
@ -82,7 +82,6 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
|||
Visualizer.registerVisualizerSkin(CodeVisualizerSkin.class);
|
||||
}
|
||||
|
||||
private Simulation simulation;
|
||||
private CommandHandler commandHandler;
|
||||
private ArrayList<LineListener> commandListeners = new ArrayList<LineListener>();
|
||||
private MSP430 myCpu = null;
|
||||
|
@ -101,7 +100,6 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
|||
private MspBreakpointContainer breakpointsContainer;
|
||||
|
||||
public MspMote() {
|
||||
simulation = null;
|
||||
myMoteType = null;
|
||||
myCpu = null;
|
||||
myMemory = null;
|
||||
|
@ -184,14 +182,6 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
|||
myMemory = (MspMoteMemory) memory;
|
||||
}
|
||||
|
||||
public Simulation getSimulation() {
|
||||
return simulation;
|
||||
}
|
||||
|
||||
public void setSimulation(Simulation simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
/* Stack monitoring variables */
|
||||
public class StackOverflowObservable extends Observable {
|
||||
public void signalStackOverflow() {
|
||||
|
|
|
@ -26,14 +26,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ContikiMote.java,v 1.17 2010/02/03 16:06:21 fros4943 Exp $
|
||||
* $Id: ContikiMote.java,v 1.18 2010/10/04 12:54:01 joxe Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.contikimote;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdom.Element;
|
||||
|
@ -68,7 +67,6 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
|
|||
private ContikiMoteType myType = null;
|
||||
private SectionMoteMemory myMemory = null;
|
||||
private MoteInterfaceHandler myInterfaceHandler = null;
|
||||
private Simulation simulation = null;
|
||||
|
||||
/**
|
||||
* Creates a new uninitialized Contiki mote.
|
||||
|
@ -88,7 +86,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
|
|||
* @param sim Mote's simulation
|
||||
*/
|
||||
public ContikiMote(ContikiMoteType moteType, Simulation sim) {
|
||||
this.simulation = sim;
|
||||
setSimulation(sim);
|
||||
this.myType = moteType;
|
||||
this.myMemory = moteType.createInitialMemory();
|
||||
this.myInterfaceHandler = new MoteInterfaceHandler(this, moteType.getMoteInterfaceClasses());
|
||||
|
@ -124,14 +122,6 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
|
|||
myType = (ContikiMoteType) type;
|
||||
}
|
||||
|
||||
public Simulation getSimulation() {
|
||||
return simulation;
|
||||
}
|
||||
|
||||
public void setSimulation(Simulation simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks mote once. This is done by first polling all interfaces
|
||||
* and letting them act on the stored memory before the memory is set. Then
|
||||
|
@ -194,7 +184,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
|
|||
}
|
||||
|
||||
public boolean setConfigXML(Simulation simulation, Collection<Element> configXML, boolean visAvailable) {
|
||||
this.simulation = simulation;
|
||||
setSimulation(simulation);
|
||||
myMemory = myType.createInitialMemory();
|
||||
myInterfaceHandler = new MoteInterfaceHandler(this, myType.getMoteInterfaceClasses());
|
||||
|
||||
|
|
|
@ -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.11 2010/07/05 16:48:55 fros4943 Exp $
|
||||
* $Id: AbstractApplicationMote.java,v 1.12 2010/10/04 12:54:01 joxe Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.motes;
|
||||
|
@ -66,8 +66,6 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
|||
|
||||
protected MoteInterfaceHandler moteInterfaces = null;
|
||||
|
||||
private Simulation simulation = null;
|
||||
|
||||
/* Observe our own radio for incoming radio packets */
|
||||
private Observer radioDataObserver = new Observer() {
|
||||
public void update(Observable obs, Object obj) {
|
||||
|
@ -90,7 +88,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
|||
}
|
||||
|
||||
public AbstractApplicationMote(MoteType moteType, Simulation sim) {
|
||||
this.simulation = sim;
|
||||
setSimulation(sim);
|
||||
this.moteType = moteType;
|
||||
this.memory = new SectionMoteMemory(new Properties());
|
||||
this.moteInterfaces = new MoteInterfaceHandler(this, moteType.getMoteInterfaceClasses());
|
||||
|
@ -126,14 +124,6 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
|||
moteType = type;
|
||||
}
|
||||
|
||||
public Simulation getSimulation() {
|
||||
return simulation;
|
||||
}
|
||||
|
||||
public void setSimulation(Simulation simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
ArrayList<Element> config = new ArrayList<Element>();
|
||||
Element element;
|
||||
|
@ -154,7 +144,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
|||
|
||||
public boolean setConfigXML(Simulation simulation,
|
||||
Collection<Element> configXML, boolean visAvailable) {
|
||||
this.simulation = simulation;
|
||||
setSimulation(simulation);
|
||||
this.memory = new SectionMoteMemory(new Properties());
|
||||
moteInterfaces.getRadio().addObserver(radioDataObserver);
|
||||
|
||||
|
|
|
@ -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: AbstractWakeupMote.java,v 1.1 2009/10/27 10:07:56 fros4943 Exp $
|
||||
* $Id: AbstractWakeupMote.java,v 1.2 2010/10/04 12:54:01 joxe Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.motes;
|
||||
|
@ -38,7 +38,8 @@ import se.sics.cooja.TimeEvent;
|
|||
|
||||
public abstract class AbstractWakeupMote implements Mote {
|
||||
private static Logger logger = Logger.getLogger(AbstractWakeupMote.class);
|
||||
private Simulation simulation = null;
|
||||
|
||||
protected Simulation simulation = null;
|
||||
|
||||
private TimeEvent executeMoteEvent = new MoteTimeEvent(this, 0) {
|
||||
public void execute(long t) {
|
||||
|
@ -49,6 +50,15 @@ public abstract class AbstractWakeupMote implements Mote {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
public Simulation getSimulation() {
|
||||
return simulation;
|
||||
}
|
||||
|
||||
public void setSimulation(Simulation simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute mote software.
|
||||
* This method is only called from the simulation thread.
|
||||
|
@ -67,9 +77,9 @@ public abstract class AbstractWakeupMote implements Mote {
|
|||
* the mote software will execute as soon as possible.
|
||||
*/
|
||||
public void requestImmediateWakeup() {
|
||||
if (simulation == null) {
|
||||
simulation = getSimulation();
|
||||
}
|
||||
// if (simulation == null) {
|
||||
// simulation = getSimulation();
|
||||
// }
|
||||
|
||||
if (simulation.isSimulationThread()) {
|
||||
/* Schedule wakeup immediately */
|
||||
|
@ -97,13 +107,11 @@ public abstract class AbstractWakeupMote implements Mote {
|
|||
* @return True iff wakeup request rescheduled the wakeup time.
|
||||
*/
|
||||
public boolean scheduleNextWakeup(long time) {
|
||||
if (simulation == null) {
|
||||
simulation = getSimulation();
|
||||
}
|
||||
// if (simulation == null) {
|
||||
// simulation = getSimulation();
|
||||
// }
|
||||
|
||||
if (!simulation.isSimulationThread()) {
|
||||
throw new IllegalStateException("Scheduling wakeup from non-simulation thread");
|
||||
}
|
||||
assert simulation.isSimulationThread() : "Scheduling event from non-simulation thread";
|
||||
|
||||
if (executeMoteEvent.isScheduled() &&
|
||||
executeMoteEvent.getTime() <= time) {
|
||||
|
|
Loading…
Reference in a new issue