Updated scheduling for user triggered events
This commit is contained in:
parent
67ae9fe26a
commit
bca8104a86
|
@ -26,18 +26,19 @@
|
||||||
* 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: ContikiPIR.java,v 1.8 2009/10/27 10:11:17 fros4943 Exp $
|
* $Id: ContikiPIR.java,v 1.9 2010/01/14 19:06:14 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.contikimote.interfaces;
|
package se.sics.cooja.contikimote.interfaces;
|
||||||
|
|
||||||
import java.awt.event.*;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.swing.*;
|
import javax.swing.JButton;
|
||||||
import org.apache.log4j.Logger;
|
import javax.swing.JPanel;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.SectionMoteMemory;
|
||||||
import se.sics.cooja.contikimote.ContikiMote;
|
import se.sics.cooja.contikimote.ContikiMote;
|
||||||
import se.sics.cooja.contikimote.ContikiMoteInterface;
|
import se.sics.cooja.contikimote.ContikiMoteInterface;
|
||||||
import se.sics.cooja.interfaces.PIR;
|
import se.sics.cooja.interfaces.PIR;
|
||||||
|
@ -63,7 +64,6 @@ import se.sics.cooja.interfaces.PIR;
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public class ContikiPIR extends PIR implements ContikiMoteInterface {
|
public class ContikiPIR extends PIR implements ContikiMoteInterface {
|
||||||
private static Logger logger = Logger.getLogger(ContikiPIR.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Approximate energy consumption of an active PIR sensor. ESB measured energy
|
* Approximate energy consumption of an active PIR sensor. ESB measured energy
|
||||||
|
@ -106,14 +106,12 @@ public class ContikiPIR extends PIR implements ContikiMoteInterface {
|
||||||
* Simulates a change in the PIR sensor.
|
* Simulates a change in the PIR sensor.
|
||||||
*/
|
*/
|
||||||
public void triggerChange() {
|
public void triggerChange() {
|
||||||
mote.getSimulation().scheduleEvent(pirEvent, mote.getSimulation().getSimulationTime());
|
mote.getSimulation().invokeSimulationThread(new Runnable() {
|
||||||
}
|
public void run() {
|
||||||
|
|
||||||
private TimeEvent pirEvent = new MoteTimeEvent(mote, 0) {
|
|
||||||
public void execute(long t) {
|
|
||||||
doTriggerChange();
|
doTriggerChange();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void doTriggerChange() {
|
public void doTriggerChange() {
|
||||||
if (moteMem.getByteValueOf("simPirIsActive") == 1) {
|
if (moteMem.getByteValueOf("simPirIsActive") == 1) {
|
||||||
|
|
|
@ -26,18 +26,21 @@
|
||||||
* 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: ContikiVib.java,v 1.8 2009/10/27 10:11:17 fros4943 Exp $
|
* $Id: ContikiVib.java,v 1.9 2010/01/14 19:06:14 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.contikimote.interfaces;
|
package se.sics.cooja.contikimote.interfaces;
|
||||||
|
|
||||||
import java.awt.event.*;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.swing.*;
|
import javax.swing.JButton;
|
||||||
import org.apache.log4j.Logger;
|
import javax.swing.JPanel;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
import se.sics.cooja.ClassDescription;
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.Mote;
|
||||||
|
import se.sics.cooja.MoteInterface;
|
||||||
|
import se.sics.cooja.SectionMoteMemory;
|
||||||
import se.sics.cooja.contikimote.ContikiMote;
|
import se.sics.cooja.contikimote.ContikiMote;
|
||||||
import se.sics.cooja.contikimote.ContikiMoteInterface;
|
import se.sics.cooja.contikimote.ContikiMoteInterface;
|
||||||
|
|
||||||
|
@ -63,7 +66,6 @@ import se.sics.cooja.contikimote.ContikiMoteInterface;
|
||||||
*/
|
*/
|
||||||
@ClassDescription("Vibration sensor")
|
@ClassDescription("Vibration sensor")
|
||||||
public class ContikiVib extends MoteInterface implements ContikiMoteInterface {
|
public class ContikiVib extends MoteInterface implements ContikiMoteInterface {
|
||||||
private static Logger logger = Logger.getLogger(ContikiVib.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Approximate energy consumption of an active vibration sensor. ESB measured
|
* Approximate energy consumption of an active vibration sensor. ESB measured
|
||||||
|
@ -106,14 +108,12 @@ public class ContikiVib extends MoteInterface implements ContikiMoteInterface {
|
||||||
* Simulates a change in the vibration sensor.
|
* Simulates a change in the vibration sensor.
|
||||||
*/
|
*/
|
||||||
public void triggerChange() {
|
public void triggerChange() {
|
||||||
mote.getSimulation().scheduleEvent(vibrateEvent, mote.getSimulation().getSimulationTime());
|
mote.getSimulation().invokeSimulationThread(new Runnable() {
|
||||||
}
|
public void run() {
|
||||||
|
|
||||||
private TimeEvent vibrateEvent = new MoteTimeEvent(mote, 0) {
|
|
||||||
public void execute(long t) {
|
|
||||||
doTriggerChange();
|
doTriggerChange();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void doTriggerChange() {
|
public void doTriggerChange() {
|
||||||
if (moteMem.getByteValueOf("simVibIsActive") == 1) {
|
if (moteMem.getByteValueOf("simVibIsActive") == 1) {
|
||||||
|
|
Loading…
Reference in a new issue