this.sendTelegram(telegram_types.init_resp);
this.setTimer(0.0); // disable the
heartbeat timer
all_index = new Array(0);
break;
case 'S':
if (index) {
this.sendErrorTelegram(errorCodes.multi_index);
break;
}
index = data.substr(1, 4);
if (all_index.indexOf(index) >= 0)
this.sendErrorTelegram(errorCodes.index_in_use);
else
all_index.push(index);
break;
default:
break;
}
}
},
onConnect: function (peerName)
{
status = TelegramState.WAIT4CONTENT;
this.expectFramed('\x02', '\x03', 203);
this.setTimer(heartbeat_time_s);
index = null;
comm_handler.push(this);
all_index = new Array();
return true;
},
onDisconnect: function ()
{
var index = comm_handler.indexOf(this)
comm_handler.splice(index,1);
},
onExpectedData: function (inputString) {
switch (status)
{
case TelegramState.WAIT4CONTENT:
this.expectFramed('', '', 1); // actually, disable framing
telegram = inputString;
status = TelegramState.CHECKSUM;
break;
case TelegramState.CHECKSUM:
this.expectFramed('\x02', '\x03', 203); // enable framing
for the next telegram
this.checkTelegram(telegram, inputString.charCodeAt(0));
status = TelegramState.WAIT4CONTENT;
break;
72
DataMan Application Development