diff --git a/plugins/posistagenet/main.js b/plugins/posistagenet/main.js index 07f3db9..dc11cfc 100644 --- a/plugins/posistagenet/main.js +++ b/plugins/posistagenet/main.js @@ -10,43 +10,50 @@ exports.config = { heartbeatTimeout: 15000, searchOptions: { type: 'multicast', - address: getMulticastGroup(1), + address: `236.10.10.10`, port: 56565, validateResponse(msg, info) { + // TODO(jwetzell): find a way to check that this is a posistagenet message return true; }, }, }; exports.ready = function ready(_device) { - console.log('posistagenet is ready'); const device = _device; - device.psn = new Decoder(); - + device.data = {}; const networkInterfaces = device.getNetworkInterfaces(); Object.keys(networkInterfaces).forEach((networkInterfaceID) => { const networkInterface = networkInterfaces[networkInterfaceID]; - device.connection.addMembership(getMulticastGroup(1), networkInterface[0].address); + device.connection.addMembership(`236.10.10.10`, networkInterface[0].address); }); }; -exports.data = function data(_device, buf) { +exports.data = function data(_device, buf, info) { const device = _device; - if (device.psn) { - device.psn.decode(buf); - device.data = { - data: device.psn.data, - info: device.psn.info, - }; - device.draw(); + + if (!device.decoders) { + device.decoders = {}; } + + if (!device.decoders[info.address]) { + device.decoders[info.address] = new Decoder(); + } + + device.decoders[info.address].decode(buf); + + Object.keys(device.decoders).forEach((address) => { + if (!device.data[address]) { + device.data[address] = { + data: device.decoders[address].data, + info: device.decoders[address].info, + }; + } + }); + device.draw(); }; exports.heartbeat = function heartbeat(device) {}; exports.update = function update(_device, doc, updateType, updateData) {}; - -function getMulticastGroup(universe) { - return `236.10.10.10`; -} diff --git a/plugins/posistagenet/template.ejs b/plugins/posistagenet/template.ejs index 9d2a410..819d156 100644 --- a/plugins/posistagenet/template.ejs +++ b/plugins/posistagenet/template.ejs @@ -3,7 +3,11 @@
| ACCEL | TRGTPOS | - -|||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ID | -Name | -x | -y | -z | - -x | -y | -z | - -x | -y | -z | - -validity | - -x | -y | -z | - -x | -y | -z | - -tracker_timestamp | -
| ID | +Name | +x | +y | +z | + +x | +y | +z | + +x | +y | +z | + +validity | + +x | +y | +z | + +x | +y | +z | + +tracker_timestamp | +
| <%= trackerId %> | <%= trackerInfo.name %> | @@ -84,12 +85,12 @@<%= trackerData.tracker_timestamp %> | - -||||||||||||||||