node-red-contrib-bacnet
Version:
The BACnet toolbox package for Node-RED from the P4NR B2B Community.
3 lines (2 loc) • 1.68 kB
JavaScript
;module.exports=function(t){var n=require("./core/bacnet-core"),i=require("node-bacnet");t.nodes.registerType("BACnet-Client",function(e){t.nodes.createNode(this,e),this.name=e.name,this.adpuTimeout=parseInt(e.adpuTimeout)||6e3,this.port=parseInt(e.port)||47808,this.IPAddress=e.IPAddress||"0.0.0.0",this.broadcastAddress=e.broadcastAddress||"0.0.0.255";var o=this;o.devices=[],o.IPAddress?(n.internalDebugLog("client with IP settings"),o.client=new i({adpuTimeout:o.adpuTimeout,port:o.port,interface:o.IPAddress,broadcastAddress:o.broadcastAddress})):(n.internalDebugLog("client without IP settings"),o.client=new i({adpuTimeout:o.adpuTimeout,port:o.port})),o.client&&(o.client.on("iAm",function(e){o.devices.push(e),n.internalDebugLog("iAm Event"),n.internalDebugLog("address: ",e.address),n.internalDebugLog("deviceId: ",e.deviceId),n.internalDebugLog("maxAdpu: ",e.maxAdpu),n.internalDebugLog("segmentation: ",e.segmentation),n.internalDebugLog("vendorId: ",e.vendorId)}),o.client.on("timeout",function(){n.internalDebugLog("timeout")}),o.client.whoIs(),o.client.on("error",function(e){o.error(e,{payload:"BACnet Client Error"}),o.client.close(),o.client=null,o.devices=[],o.client=new i({adpuTimeout:o.adpuTimeout,port:o.port,interface:o.IPAddress,broadcastAddress:o.broadcastAddress})})),o.on("input",function(e){e.devices=o.devices,o.send(e)}),o.on("close",function(e){o.client&&(o.client.close(),o.client=null),e()}),o.whoIsExplicit=function(e,t,n,i){o.devices=[],o.client.whoIs({lowLimit:e,highLimit:t,deviceIPAddress:n}),setTimeout(i,3e3)},o.whoIs=function(e){o.devices=[],o.client.whoIs(),setTimeout(e,3e3)}})};
//# sourceMappingURL=maps/bacnet-client.js.map