function CommHandler()
{
// private properties and methods:
var num_trigger = 0;
var num_send;
// public properties and methods:
function onTimeout()
{
num_send = this.send(m ': timer callback\r\n');
this.setTimer(1.0);
}
function onTimeout2()
{
today = new Date();
var msg = today.getSeconds() * 1000 + today.getMilliseconds();
num_send = this.send(m ': time is: ' + msg + '\r\n');
dmccCommand("TRIGGER", true);
this.setTimer(1.0);
}
function replace_crlf(input_str)
{
return input_str.replace(/\r/g, '\\r').replace(/\n/g, '\\n');
}
return {
onConnect: function (peerName)
{
my_name = peerName;
// we may ignore the connection
if(my_name == "COM1")
return false;
num_send = this.send(m ": connected\r\n");
this.expectFramed("#", ";\r\n", 64);
return true;
},
onDisconnect: function ()
{
},
onExpectedData: function (inputString) {
var msg = 'ok';
this.expectFramed("#", ";\r\n", 64);
if (inputString == "name")
{
msg = dmccGet("DEVICE.NAME");
msg = msg.response;
}
else if(inputString == "trigger")
56
DataMan Application Development