Specifications

AVIDdirector-M2M Technical Reference Guide
February 5, 2009 ©AVIDwireless 2004-2009 All Rights Reserved Page 38 of 55
/**
* Starts the M2Mlet for the Simulator board. This creates any initial devices and
* sets them to defined states.
*
* @param adApp Inistance of the AVIDdirectorMain application
*/
public final boolean start (AVIDdirectorMain adApp){
final String NAME = "Demo_M2Mlet.start";
started = false;
this.app = adApp;
try {
// boolean find out if we are in debug mode
boolean debugMode = Logger.isDebug();
// test if this is enabled or not, and if disable don't bother initializing
String configDemoM2mletEnabled = app.getConfigurationItem(CONFIG_FILE_DEMO_MODE);
if (configDemoM2mletEnabled != null) {
demoM2mletEnabled = AvidUtil.parseBoolean(configDemoM2mletEnabled);
} else {
// if no entry then assume it is enabled
demoM2mletEnabled = true;
}
// if enabled then continue the starting
if (demoM2mletEnabled) {
/** Populate our M2M_IODevice array with the sensors we have */
sensors = new M2M_IODevice[3];
// sensors[0] is TTL1 is analog input with a potentometer
sensors[0] = app.getM2M_IODeviceForAddress(M2M_IODevice.TTL1);
if (sensors[0] != null) {
if (debugMode) Logger.debugln(NAME,"Setting up "+sensors[0].getDeviceAddress()+
" as analog input with +/- 30 trigger");
// set this for analog input
sensors[0].setAnalogInput();
// trigger when changes +/- 30, no more than once every 10 seconds
sensors[0].setTriggerValueChange(30,30);
sensors[0].setMinTriggerInterval(10);
} else {
Logger.log(NAME,"No TTL1 Device specified");
}
// TTL5 is round pushbutton
sensors[1] = app.getM2M_IODeviceForAddress(M2M_IODevice.TTL5);
sensors[1].setDigitalInput();
// If low, then new simulation board.
// If high, then original board (the LED value was inverted on this one)
int value = sensors[1].readPinDig();
if (value == 1) {
oldDemoBoard = true;
if (debugMode) Logger.debugln(NAME,"Setting up "+sensors[1].getDeviceAddress()+
" for the round pushbutton trigger when 0 (pressed in) - old board");
sensors[1].setTriggerValueGoesLow(true); // trigger when low
sensors[1].setTriggerValueGoesHigh(false);
} else { // new demo board
if (debugMode) Logger.debugln(NAME,"Setting up "+sensors[1].getDeviceAddress()+
" for the round pushbutton trigger when 1 (pressed in)");
sensors[1].setTriggerValueGoesLow(false); // trigger when high
sensors[1].setTriggerValueGoesHigh(true);
}
// TTL6 is the toggle switch, notify on both high and low
sensors[2] = app.getM2M_IODeviceForAddress(M2M_IODevice.TTL6);
if (debugMode) Logger.debugln(NAME,"Setting up "+sensors[2].getDeviceAddress()+