Specifications
AVIDdirector-M2M™ Technical Reference Guide
February 5, 2009 ©AVIDwireless 2004-2009 All Rights Reserved Page 39 of 55
" for the toggle switch and trigger on either");
sensors[2].setDigitalInput();
// have it send a percept reading on either trigger
sensors[2].setTriggerValueGoesLow(true);
sensors[2].setTriggerValueGoesHigh(true);
// TTL2 is the light bulb
lamp = app.getM2M_IODeviceForAddress(M2M_IODevice.TTL2);
if (debugMode) Logger.debugln(NAME,"Setting up "+lamp.getDeviceAddress()+
" as analog output for the lamp");
lamp.setAnalogOutput();
// TTL3 is the Green LED
greenLed = app.getM2M_IODeviceForAddress(M2M_IODevice.TTL3);
if (debugMode) Logger.debugln(NAME,"Setting up "+greenLed.getDeviceAddress()+
" for the Green LED");
greenLed.setDigitalOutput();
// TTL4 is the Red LED
redLed = app.getM2M_IODeviceForAddress(M2M_IODevice.TTL4);
if (debugMode) Logger.debugln(NAME,"Setting up "+redLed.getDeviceAddress()+
" for the Red LED");
redLed.setDigitalOutput();
// start this thread running
started = true;
thread = new Thread(this);
// Now wait for a signal that it has started
synchronized (this) {
try {
thread.start();
this.wait(30000); // 30 seconds to get going
} catch (InterruptedException e) {
Logger.log(NAME,"InterruptedException starting Thread");
}
}
} else {
Logger.log(NAME,"Demo M2MLet is not enabled");
}
} // try
catch (Exception e) {
Logger.log(NAME,e);
}
return started;
} // initialize
/**
* This thread monitors the test box's switches and dials and if something has
* changed it displays a message on the display and sends a message to the
* SensorLogic portal
*/
public final void run(){
final String NAME = "Demo_M2Mlet.run";
Thread.currentThread().setName("Demo_M2Mlet");
// notify out start method that we are running
threadRunning = true;
synchronized (this) {
this.notifyAll();
}
if (started) {
Logger.log(NAME,"Thread started");
//lcd.displayMessage("Monitoring...");
int value; // currently read value from a sensor
int lightIntensity; // value of the light (0-62)
String perceptMessage; // Percept reading to Portal