node-red-contrib-modbus
Advanced tools
Comparing version 5.11.0 to 5.12.0
@@ -0,1 +1,15 @@ | ||
# [5.12.0](https://github.com/biancoroyal/node-red-contrib-modbus/compare/v5.11.0...v5.12.0) (2020-05-17) | ||
### Bug Fixes | ||
* **reader:** issue [#200](https://github.com/biancoroyal/node-red-contrib-modbus/issues/200) missing topic in msg ([b099b1f](https://github.com/biancoroyal/node-red-contrib-modbus/commit/b099b1f6e95a60504658d3f9ce9945d719cba934)) | ||
### Features | ||
* **reader:** empty msg on error ([15a8e01](https://github.com/biancoroyal/node-red-contrib-modbus/commit/15a8e012f92e8df5d76223a4287f594b14a87881)) | ||
# [5.11.0](https://github.com/biancoroyal/node-red-contrib-modbus/compare/v5.10.1...v5.11.0) (2020-05-12) | ||
@@ -2,0 +16,0 @@ |
@@ -14,5 +14,5 @@ { | ||
"updateOnAllQueueChanges": "Show All Updates", | ||
"updateOnAllUnitQueues": "All Queues (1-255)" | ||
"updateOnAllUnitQueues": "All Queues (0-255)" | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
"use strict";module.exports=function(o){require("source-map-support").install();var a=require("./modbus-basics"),d=require("./core/modbus-core"),u=require("./core/modbus-io-core"),l=require("debug")("contribModbus:read");o.nodes.registerType("modbus-read",function(e){o.nodes.createNode(this,e),this.name=e.name,this.topic=e.topic,this.unitid=e.unitid,this.dataType=e.dataType,this.adr=e.adr,this.quantity=e.quantity||1,this.rate=e.rate,this.rateUnit=e.rateUnit,this.delayOnStart=e.delayOnStart,this.startDelayTime=parseInt(e.startDelayTime)||10,this.showStatusActivities=e.showStatusActivities,this.showErrors=e.showErrors,this.connection=null,this.useIOFile=e.useIOFile,this.ioFile=o.nodes.getNode(e.ioFile),this.useIOForPayload=e.useIOForPayload,this.logIOActivities=e.logIOActivities,this.internalDebugLog=l,this.verboseLogging=o.settings.verbose;var s=this,r=!1;function i(e){o.settings.verbose&&s.warn("Client -> "+e+s.serverInfo)}s.INPUT_TIMEOUT_MILLISECONDS=1e3,s.statusText="waiting",s.delayTimerReading=!1,s.intervalTimerIdReading=!1,n(s.statusText),i("open node "+s.id);var t=o.nodes.getNode(e.server);function n(e){var i,t,n,o;"polling"===e&&r||(i=a.setNodeStatusProperties(e,s.showStatusActivities),t=s.statusText,-1!==e.search("active")||"polling"===e?(n=i.status+(" ( "+s.rate+" "+a.get_timeUnit_name(s.rateUnit))+" ) ",r=!1,n!==t&&s.status({fill:i.fill,shape:i.shape,text:n})):(o=i.status)!==t&&s.status({fill:i.fill,shape:i.shape,text:o}))}t&&(s.onModbusInit=function(){n("initialized")},s.onModbusConnect=function(){n("connected"),s.resetAllReadingTimer(),s.initializeReadingTimer()},s.onModbusRegister=function(){s.showStatusActivities&&n("registered"),t.serialSendingAllowed&&(s.resetAllReadingTimer(),s.initializeReadingTimer(),n("connected"))},s.onModbusActive=function(){n("active")},s.onModbusQueue=function(){n("queue")},s.onModbusError=function(e){n("failure"),t.reconnectOnTimeout&&s.resetAllReadingTimer(),s.showErrors&&s.warn(e)},s.onModbusClose=function(){n("closed"),s.resetAllReadingTimer()},s.onModbusBroken=function(){n("broken"),t.reconnectOnTimeout&&(n("reconnecting after "+t.reconnectTimeout+" msec."),s.resetAllReadingTimer())},s.onModbusReadDone=function(e,i){s.showStatusActivities&&n("reading done"),function(e,i,t){{var n,o,r;s.useIOFile&&s.ioFile.lastUpdatedAt?(s.logIOActivities&&u.internalDebug("node.adr:"+s.adr+" node.quantity:"+s.quantity),n=u.nameValuesFromIOFile(s,t,e,i,s.adr),o=u.filterValueNames(s,n,d.functionCodeModbusRead(s.dataType),s.adr,s.quantity),r={topic:t.topic,responseBuffer:i,input:t,sendingNodeId:s.id},s.useIOForPayload?(r.payload=o,r.values=e):(r.payload=e,r.valueNames=o),s.send([r,{payload:i,values:e,input:t,valueNames:o,sendingNodeId:s.id}])):s.send([{payload:e,responseBuffer:i,input:t,sendingNodeId:s.id},{payload:i,values:e,input:t,sendingNodeId:s.id}])}}(e.data,e,i)},s.onModbusReadError=function(e,i){l(e.message),s.showErrors&&s.error(e,i),a.setModbusError(s,t,e,i)},s.modbusPollingRead=function(){var e;t.client?(e={topic:s.topic||"polling",from:s.name,payload:{unitid:s.unitid,fc:d.functionCodeModbusRead(s.dataType),address:s.adr,quantity:s.quantity,messageId:d.getObjectId()}},s.showStatusActivities&&n("polling"),t.emit("readModbus",e,s.onModbusReadDone,s.onModbusReadError)):n("waiting")},s.resetDelayTimerToRead=function(e){e.delayTimerReading&&(i("resetDelayTimerToRead node "+e.id),clearTimeout(e.delayTimerReading)),e.delayTimerReading=null},s.resetIntervalToRead=function(e){e.intervalTimerIdReading&&(i("resetIntervalToRead node "+e.id),clearInterval(e.intervalTimerIdReading)),e.intervalTimerIdReading=null},s.resetAllReadingTimer=function(){s.resetDelayTimerToRead(s),s.resetIntervalToRead(s)},s.resetAllReadingTimer(),s.startIntervalReading=function(){s.intervalTimerIdReading||(i("startIntervalReading node "+s.id),s.intervalTimerIdReading=setInterval(s.modbusPollingRead,a.calc_rateByUnit(s.rate,s.rateUnit)))},s.initializeReadingTimer=function(){s.resetAllReadingTimer(),s.delayOnStart?(i("initializeReadingTimer delay timer node "+s.id),s.delayTimerReading=setTimeout(s.startIntervalReading,s.INPUT_TIMEOUT_MILLISECONDS*s.startDelayTime)):s.startIntervalReading()},s.removeNodeListenerFromModbusClient=function(){t.removeListener("mbinit",s.onModbusInit),t.removeListener("mbqueue",s.onModbusQueue),t.removeListener("mbconnected",s.onModbusConnect),t.removeListener("mbactive",s.onModbusActive),t.removeListener("mberror",s.onModbusError),t.removeListener("mbclosed",s.onModbusClose),t.removeListener("mbbroken",s.onModbusBroken),t.removeListener("mbregister",s.onModbusRegister),t.removeListener("mbderegister",s.onModbusClose)},this.on("close",function(e){s.resetAllReadingTimer(),s.removeNodeListenerFromModbusClient(),n("closed"),i("close node "+s.id),t.deregisterForModbus(s.id,e)}),s.showStatusActivities&&(t.on("mbinit",s.onModbusInit),t.on("mbqueue",s.onModbusQueue)),t.on("mbconnected",s.onModbusConnect),t.on("mbactive",s.onModbusActive),t.on("mberror",s.onModbusError),t.on("mbclosed",s.onModbusClose),t.on("mbbroken",s.onModbusBroken),t.on("mbregister",s.onModbusRegister),t.on("mbderegister",s.onModbusClose),t.registerForModbus(s))}),o.httpAdmin.post("/modbus/read/inject/:id",o.auth.needsPermission("modbus.inject.write"),function(e,i){var t=o.nodes.getNode(e.params.id);if(t)try{t.modbusPollingRead(),i.sendStatus(200)}catch(e){i.sendStatus(500),t.error(o._("modbusinject.failed",{error:e.toString()}))}else i.sendStatus(404)})}; | ||
"use strict";module.exports=function(o){require("source-map-support").install();var s=require("./modbus-basics"),d=require("./core/modbus-core"),u=require("./core/modbus-io-core"),l=require("debug")("contribModbus:read");o.nodes.registerType("modbus-read",function(e){o.nodes.createNode(this,e),this.name=e.name,this.topic=e.topic,this.unitid=e.unitid,this.dataType=e.dataType,this.adr=e.adr,this.quantity=e.quantity||1,this.rate=e.rate,this.rateUnit=e.rateUnit,this.delayOnStart=e.delayOnStart,this.startDelayTime=parseInt(e.startDelayTime)||10,this.showStatusActivities=e.showStatusActivities,this.showErrors=e.showErrors,this.connection=null,this.useIOFile=e.useIOFile,this.ioFile=o.nodes.getNode(e.ioFile),this.useIOForPayload=e.useIOForPayload,this.logIOActivities=e.logIOActivities,this.emptyMsgOnFail=e.emptyMsgOnFail,this.internalDebugLog=l,this.verboseLogging=o.settings.verbose;var a=this,r=!1;function t(e){o.settings.verbose&&a.warn("Client -> "+e+a.serverInfo)}a.INPUT_TIMEOUT_MILLISECONDS=1e3,a.statusText="waiting",a.delayTimerReading=!1,a.intervalTimerIdReading=!1,n(a.statusText),t("open node "+a.id);var i=o.nodes.getNode(e.server);function n(e){var t,i,n,o;"polling"===e&&r||(t=s.setNodeStatusProperties(e,a.showStatusActivities),i=a.statusText,-1!==e.search("active")||"polling"===e?(n=t.status+(" ( "+a.rate+" "+s.get_timeUnit_name(a.rateUnit))+" ) ",r=!1,n!==i&&a.status({fill:t.fill,shape:t.shape,text:n})):(o=t.status)!==i&&a.status({fill:t.fill,shape:t.shape,text:o}))}i&&(a.onModbusInit=function(){n("initialized")},a.onModbusConnect=function(){n("connected"),a.resetAllReadingTimer(),a.initializeReadingTimer()},a.onModbusRegister=function(){a.showStatusActivities&&n("registered"),i.serialSendingAllowed&&(a.resetAllReadingTimer(),a.initializeReadingTimer(),n("connected"))},a.onModbusActive=function(){n("active")},a.onModbusQueue=function(){n("queue")},a.onModbusError=function(e){n("failure"),i.reconnectOnTimeout&&a.resetAllReadingTimer(),a.showErrors&&a.warn(e)},a.onModbusClose=function(){n("closed"),a.resetAllReadingTimer()},a.onModbusBroken=function(){n("broken"),i.reconnectOnTimeout&&(n("reconnecting after "+i.reconnectTimeout+" msec."),a.resetAllReadingTimer())},a.onModbusReadDone=function(e,t){a.showStatusActivities&&n("reading done"),function(e,t,i){var n=i.topic||a.topic;{var o,r,s;a.useIOFile&&a.ioFile.lastUpdatedAt?(a.logIOActivities&&u.internalDebug("node.adr:"+a.adr+" node.quantity:"+a.quantity),o=u.nameValuesFromIOFile(a,i,e,t,a.adr),r=u.filterValueNames(a,o,d.functionCodeModbusRead(a.dataType),a.adr,a.quantity),s={topic:n,responseBuffer:t,input:i,sendingNodeId:a.id},a.useIOForPayload?(s.payload=r,s.values=e):(s.payload=e,s.valueNames=r),a.send([s,{topic:n,payload:t,values:e,input:i,valueNames:r,sendingNodeId:a.id}])):a.send([{topic:n,payload:e,responseBuffer:t,input:i,sendingNodeId:a.id},{topic:n,payload:t,values:e,input:i,sendingNodeId:a.id}])}}(e.data,e,t)},a.errorProtocolMsg=function(e,t){s.logMsgError(a,e,t),s.sendEmptyMsgOnFail(a,e,t)},a.onModbusReadError=function(e,t){a.internalDebugLog(e.message),a.errorProtocolMsg(e,t),s.setModbusError(a,i,e,t)},a.modbusPollingRead=function(){var e;i.client?(e={topic:a.topic||"polling",from:a.name,payload:{unitid:a.unitid,fc:d.functionCodeModbusRead(a.dataType),address:a.adr,quantity:a.quantity,messageId:d.getObjectId()}},a.showStatusActivities&&n("polling"),i.emit("readModbus",e,a.onModbusReadDone,a.onModbusReadError)):n("waiting")},a.resetDelayTimerToRead=function(e){e.delayTimerReading&&(t("resetDelayTimerToRead node "+e.id),clearTimeout(e.delayTimerReading)),e.delayTimerReading=null},a.resetIntervalToRead=function(e){e.intervalTimerIdReading&&(t("resetIntervalToRead node "+e.id),clearInterval(e.intervalTimerIdReading)),e.intervalTimerIdReading=null},a.resetAllReadingTimer=function(){a.resetDelayTimerToRead(a),a.resetIntervalToRead(a)},a.resetAllReadingTimer(),a.startIntervalReading=function(){a.intervalTimerIdReading||(t("startIntervalReading node "+a.id),a.intervalTimerIdReading=setInterval(a.modbusPollingRead,s.calc_rateByUnit(a.rate,a.rateUnit)))},a.initializeReadingTimer=function(){a.resetAllReadingTimer(),a.delayOnStart?(t("initializeReadingTimer delay timer node "+a.id),a.delayTimerReading=setTimeout(a.startIntervalReading,a.INPUT_TIMEOUT_MILLISECONDS*a.startDelayTime)):a.startIntervalReading()},a.removeNodeListenerFromModbusClient=function(){i.removeListener("mbinit",a.onModbusInit),i.removeListener("mbqueue",a.onModbusQueue),i.removeListener("mbconnected",a.onModbusConnect),i.removeListener("mbactive",a.onModbusActive),i.removeListener("mberror",a.onModbusError),i.removeListener("mbclosed",a.onModbusClose),i.removeListener("mbbroken",a.onModbusBroken),i.removeListener("mbregister",a.onModbusRegister),i.removeListener("mbderegister",a.onModbusClose)},this.on("close",function(e){a.resetAllReadingTimer(),a.removeNodeListenerFromModbusClient(),n("closed"),t("close node "+a.id),i.deregisterForModbus(a.id,e)}),a.showStatusActivities&&(i.on("mbinit",a.onModbusInit),i.on("mbqueue",a.onModbusQueue)),i.on("mbconnected",a.onModbusConnect),i.on("mbactive",a.onModbusActive),i.on("mberror",a.onModbusError),i.on("mbclosed",a.onModbusClose),i.on("mbbroken",a.onModbusBroken),i.on("mbregister",a.onModbusRegister),i.on("mbderegister",a.onModbusClose),i.registerForModbus(a))}),o.httpAdmin.post("/modbus/read/inject/:id",o.auth.needsPermission("modbus.inject.write"),function(e,t){var i=o.nodes.getNode(e.params.id);if(i)try{i.modbusPollingRead(),t.sendStatus(200)}catch(e){t.sendStatus(500),i.error(o._("modbusinject.failed",{error:e.toString()}))}else t.sendStatus(404)})}; | ||
//# sourceMappingURL=maps/modbus-read.js.map |
{ | ||
"name": "node-red-contrib-modbus", | ||
"version": "5.11.0", | ||
"version": "5.12.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "The all in one Modbus TCP and Serial contribution package for Node-RED.", |
@@ -27,3 +27,3 @@ ![Platform Node-RED](http://b.repl.ca/v1/Platform-Node--RED-red.png) | ||
Node-RED v1.x versions: | ||
* Node.JS 13.x is beta supported with v5.x | ||
* Node.JS 14.x is beta supported with v5.x | ||
* Node.JS 12.x is supported with v5.x | ||
@@ -141,3 +141,4 @@ * Node.JS 10.x is supported with v5.x | ||
Report issues, share your experiences, write Wiki articles and Blogs to share more about this package, please! | ||
Report issues, share your experiences, record tutorials, | ||
write Wiki articles and Blogs to share more about this package, please! | ||
@@ -144,0 +145,0 @@ ## Authors |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8312954
197