EasyManua.ls Logo

Cognex DataMan - Generic Use Case: Real Time Timestamp

Cognex DataMan
76 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
onTimer: function () {
today = new Date();
var msg = today.getSeconds() * 1000 + today.getMilliseconds();
num_send = this.send(peer_name + ': time is: ' + msg + '\r\n');
this.resetHeartBeat(); // schedule next timer event [sec]
},
resetHeartBeat: function () {
this.setTimer(beat_timer); // schedule next timer event [sec]
}
};
}
Generic use case: Real time timestamp
Implements a custom DMCC command to set the real time (send current time in seconds starting Jan 1 1970, as output
by date +”%s” command). Prepend output with real time timestamp.
// communication script
var time_offset=0;
function CommHandler()
{
var peer_name;
return {
onConnect: function (peerName)
{
peer_name = peerName;
this.expectFramed("||;1>SET TIME.NOW ", "\r\n", 128); //
some pattern unlikely to happen
// enable the handler for this connection:
return true;
},
onDisconnect: function ()
{
},
onError: function (errorMsg)
{
},
onExpectedData: function (inputString) {
realTime = parseInt(inputString)*1000;
localTime = (new Date()).getTime();
time_offset = realTime - localTime;
this.send("||[0]\r\n");
return true;
},
59
DataMan Application Development

Table of Contents

Other manuals for Cognex DataMan

Related product manuals