node-red-contrib-modbus
Advanced tools
Comparing version 5.4.0-alpha.0 to 5.4.0-alpha.2
@@ -1,7 +0,23 @@ | ||
# [5.4.0-alpha.0](https://github.com/biancoroyal/node-red-contrib-modbus/compare/5.1.0-0...5.4.0-alpha.0) (2020-03-11) | ||
# Changelog | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
## [5.4.0-alpha.2](https://github.com/biancoroyal/node-red-contrib-modbus/compare/v4.1.3...v5.4.0-alpha.2) (2020-03-26) | ||
### Features | ||
* [#161](https://github.com/biancoroyal/node-red-contrib-modbus/issues/161) multiple RTU devices via UnitID ([b0b5011](https://github.com/biancoroyal/node-red-contrib-modbus/commit/b0b5011be4ab5e7c06ab44fd9df7b0ff5ddd0fd8)) | ||
* [#180](https://github.com/biancoroyal/node-red-contrib-modbus/issues/180) msg on fail pre-release alpha ([282a7c4](https://github.com/biancoroyal/node-red-contrib-modbus/commit/282a7c46a26c91f387b024ec1703f090a14f1816)) | ||
* msg or error on flex connector ([16a947b](https://github.com/biancoroyal/node-red-contrib-modbus/commit/16a947b9eed12a600b5315bf41e63606305ccbd4)) | ||
* new output for flex config ([f78e775](https://github.com/biancoroyal/node-red-contrib-modbus/commit/f78e775f2e84ae5d8ce406457a2b747daa3abd38)) | ||
* new state machine from xstate ([57aef99](https://github.com/biancoroyal/node-red-contrib-modbus/commit/57aef9956187ee9d70e862b226f3a3ef5e091528)) | ||
* set default on serial for queue by the type checkbox switch ([65edb52](https://github.com/biancoroyal/node-red-contrib-modbus/commit/65edb52b393a421d7c5db3dd8749a2a0da7d4393)) | ||
### Bug Fixes | ||
* [#160](https://github.com/biancoroyal/node-red-contrib-modbus/issues/160) error on show activities true ([af27fe6](https://github.com/biancoroyal/node-red-contrib-modbus/commit/af27fe616654eb074bb29f34a163d4ffabc742bd)) | ||
* [#178](https://github.com/biancoroyal/node-red-contrib-modbus/issues/178) debug per node to see where it is not correct or fallback core log ([ff69134](https://github.com/biancoroyal/node-red-contrib-modbus/commit/ff691343ab7c93451642922bf6fa237f777b934f)) | ||
* [#178](https://github.com/biancoroyal/node-red-contrib-modbus/issues/178) too get no crash on internal debug log ([a0389e7](https://github.com/biancoroyal/node-red-contrib-modbus/commit/a0389e7b051d736bc958fee4fbfeb1879cda99e3)), closes [#180](https://github.com/biancoroyal/node-red-contrib-modbus/issues/180) | ||
* serialport list call ([f401c58](https://github.com/biancoroyal/node-red-contrib-modbus/commit/f401c58cb384ce87489aecaa99a3000f18e4222b)) | ||
@@ -11,7 +27,26 @@ * supporter file missing ([d24fad6](https://github.com/biancoroyal/node-red-contrib-modbus/commit/d24fad66e8730f9535b8d9edc0512087e55b7d07)) | ||
* typo config node client ([9be8b16](https://github.com/biancoroyal/node-red-contrib-modbus/commit/9be8b1634469abfe6b8b6fb471a16f9387b6cee4)) | ||
* **client:** FSM message FSM Reset while failure handling and on unplanned state changes, now it raises only on failures ([944786c](https://github.com/biancoroyal/node-red-contrib-modbus/commit/944786cdd6f9e8322c3e3264cd1ef8aa4a244118)) | ||
# [5.4.0-alpha.1](https://github.com/biancoroyal/node-red-contrib-modbus/compare/5.1.0-0...5.4.0-alpha.1) (2020-03-26) | ||
### Bug Fixes | ||
* [#160](https://github.com/biancoroyal/node-red-contrib-modbus/issues/160) error on show activities true ([af27fe6](https://github.com/biancoroyal/node-red-contrib-modbus/commit/af27fe616654eb074bb29f34a163d4ffabc742bd)) | ||
* [#178](https://github.com/biancoroyal/node-red-contrib-modbus/issues/178) debug per node to see where it is not correct or fallback core log ([ff69134](https://github.com/biancoroyal/node-red-contrib-modbus/commit/ff691343ab7c93451642922bf6fa237f777b934f)) | ||
* [#178](https://github.com/biancoroyal/node-red-contrib-modbus/issues/178) too get no crash on internal debug log ([a0389e7](https://github.com/biancoroyal/node-red-contrib-modbus/commit/a0389e7b051d736bc958fee4fbfeb1879cda99e3)), closes [#180](https://github.com/biancoroyal/node-red-contrib-modbus/issues/180) | ||
* serialport list call ([f401c58](https://github.com/biancoroyal/node-red-contrib-modbus/commit/f401c58cb384ce87489aecaa99a3000f18e4222b)) | ||
* supporter file missing ([d24fad6](https://github.com/biancoroyal/node-red-contrib-modbus/commit/d24fad66e8730f9535b8d9edc0512087e55b7d07)) | ||
* travis build ([7a7294e](https://github.com/biancoroyal/node-red-contrib-modbus/commit/7a7294e9fd2fa14d54412586af8c81e25d5b30cd)) | ||
* typo config node client ([9be8b16](https://github.com/biancoroyal/node-red-contrib-modbus/commit/9be8b1634469abfe6b8b6fb471a16f9387b6cee4)) | ||
* **client:** FSM message FSM Reset while failure handling and on unplanned state changes, now it raises only on failures ([944786c](https://github.com/biancoroyal/node-red-contrib-modbus/commit/944786cdd6f9e8322c3e3264cd1ef8aa4a244118)) | ||
### Features | ||
* [#161](https://github.com/biancoroyal/node-red-contrib-modbus/issues/161) multiple RTU devices via UnitID ([b0b5011](https://github.com/biancoroyal/node-red-contrib-modbus/commit/b0b5011be4ab5e7c06ab44fd9df7b0ff5ddd0fd8)) | ||
* [#180](https://github.com/biancoroyal/node-red-contrib-modbus/issues/180) msg on fail pre-release alpha ([282a7c4](https://github.com/biancoroyal/node-red-contrib-modbus/commit/282a7c46a26c91f387b024ec1703f090a14f1816)) | ||
* msg or error on flex connector ([16a947b](https://github.com/biancoroyal/node-red-contrib-modbus/commit/16a947b9eed12a600b5315bf41e63606305ccbd4)) | ||
* new output for flex config ([f78e775](https://github.com/biancoroyal/node-red-contrib-modbus/commit/f78e775f2e84ae5d8ce406457a2b747daa3abd38)) | ||
* set default on serial for queue by the type checkbox switch ([65edb52](https://github.com/biancoroyal/node-red-contrib-modbus/commit/65edb52b393a421d7c5db3dd8749a2a0da7d4393)) | ||
@@ -140,4 +175,1 @@ | ||
# 1.0.0 (2017-01-18) | ||
@@ -1,2 +0,2 @@ | ||
"use strict";require("source-map-support").install();var de=de||{biancoroyal:{modbus:{core:{client:{}}}}};de.biancoroyal.modbus.core.client.internalDebug=de.biancoroyal.modbus.core.client.internalDebug||require("debug")("contribModbus:core:client"),de.biancoroyal.modbus.core.client.internalDebugFSM=de.biancoroyal.modbus.core.client.internalDebugFSM||require("debug")("contribModbus:core:client:fsm"),de.biancoroyal.modbus.core.client.modbusSerialDebug=de.biancoroyal.modbus.core.client.modbusSerialDebug||require("debug")("modbus-serial"),de.biancoroyal.modbus.core.client.XStateFSM=de.biancoroyal.modbus.core.client.XStateFSM||require("@xstate/fsm"),de.biancoroyal.modbus.core.client.stateLogEnabled=de.biancoroyal.modbus.core.client.stateLogEnabled||!1,de.biancoroyal.modbus.core.client.networkErrors=["ESOCKETTIMEDOUT","ETIMEDOUT","ECONNRESET","ENETRESET","ECONNABORTED","ECONNREFUSED","ENETUNREACH","ENOTCONN","ESHUTDOWN","EHOSTDOWN","ENETDOWN","EWOULDBLOCK","EAGAIN","EHOSTUNREACH"],de.biancoroyal.modbus.core.client.createStateMachineService=function(){return this.stateLogEnabled=!1,this.XStateFSM.createMachine({id:"modbus",initial:"new",states:{new:{on:{INIT:"init",STOP:"stopped"}},broken:{on:{INIT:"init",STOP:"stopped",FAILURE:"failed",CLOSE:"closed",ACTIVATE:"activated"}},init:{on:{OPENSERIAL:"opened",CONNECT:"connected",FAILURE:"failed"}},opened:{on:{CONNECT:"connected",FAILURE:"failed",CLOSE:"closed"}},connected:{on:{CLOSE:"closed",ACTIVATE:"activated",FAILURE:"failed"}},activated:{on:{CLOSE:"closed",READ:"reading",WRITE:"writing",QUEUE:"queueing",FAILURE:"failed"}},queueing:{on:{ACTIVATE:"activated",READ:"reading",WRITE:"writing",EMPTY:"empty",FAILURE:"failed",CLOSE:"closed"}},empty:{on:{QUEUE:"queueing",FAILURE:"failed",CLOSE:"closed"}},reading:{on:{ACTIVATE:"activated",FAILURE:"failed"}},writing:{on:{ACTIVATE:"activated",FAILURE:"failed"}},closed:{on:{FAILURE:"failed",BREAK:"broken",CONNECT:"connected"}},failed:{on:{CLOSE:"closed",BREAK:"broken",STOP:"stopped"}},stopped:{on:{NEW:"new",STOP:"stopped"}}}})},de.biancoroyal.modbus.core.client.startStateService=function(e){return this.XStateFSM.interpret(e).start()},de.biancoroyal.modbus.core.client.checkUnitId=function(e,a){return"tcp"===a?0<=e&&e<=255:1<=e&&e<=247},de.biancoroyal.modbus.core.client.getLogFunction=function(e){return e.internalDebugLog?e.internalDebugLog:de.biancoroyal.modbus.core.client.internalDebug},de.biancoroyal.modbus.core.client.readModbus=function(a,t,n,o){if(a.client){a.bufferCommands||a.stateService.send("READ"),a.setUnitIdFromPayload(t),a.client.setTimeout(a.clientTimeout);var i=de.biancoroyal.modbus.core.client.getLogFunction(a);a.queueLog(JSON.stringify({info:"read msg",message:t.payload,unitid:t.queueUnitId,timeout:a.client.getTimeout(),state:a.actualServiceState.value}));try{switch(parseInt(t.payload.fc)){case 1:a.client.readCoils(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 2:a.client.readDiscreteInputs(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 3:a.client.readHoldingRegisters(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 4:a.client.readInputRegisters(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;default:a.activateSending(t),o(new Error("Function Code Unknown"),t),i("Function Code Unknown %s",t.payload.fc)}}catch(e){i(e.message),a.modbusErrorHandling(e)}}},de.biancoroyal.modbus.core.client.writeModbus=function(a,t,n,o){if(a.client){a.bufferCommands||a.stateService.send("WRITE"),a.setUnitIdFromPayload(t),a.client.setTimeout(a.clientTimeout);var i=de.biancoroyal.modbus.core.client.getLogFunction(a);a.queueLog(JSON.stringify({info:"write msg",message:t.payload,unitid:t.queueUnitId,timeout:a.client.getTimeout(),state:a.actualServiceState.value}));try{switch(parseInt(t.payload.fc)){case 15:parseInt(t.payload.value.length)!==parseInt(t.payload.quantity)?(a.activateSending(t),o(new Error("Quantity should be less or equal to coil payload array length: "+t.payload.value.length+" Addr: "+t.payload.address+" Q: "+t.payload.quantity),t)):a.client.writeCoils(parseInt(t.payload.address),t.payload.value).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 5:t.payload.value?t.payload.value=!0:t.payload.value=!1,a.client.writeCoil(parseInt(t.payload.address),t.payload.value).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 16:parseInt(t.payload.value.length)!==parseInt(t.payload.quantity)?(a.activateSending(t),o(new Error("Quantity should be less or equal to register payload array length: "+t.payload.value.length+" Addr: "+t.payload.address+" Q: "+t.payload.quantity),t)):a.client.writeRegisters(parseInt(t.payload.address),t.payload.value).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 6:a.client.writeRegister(parseInt(t.payload.address),parseInt(t.payload.value)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;default:a.activateSending(t),o(new Error("Function Code Unknown"),t),i("Function Code Unknown %s",t.payload.fc)}}catch(e){i(e.message),a.modbusErrorHandling(e)}}},de.biancoroyal.modbus.core.client.setNewNodeSettings=function(e,a){var t=de.biancoroyal.modbus.core.client.getLogFunction(e);switch(a||t("New Connection message invalid."),a.payload.connectorType){case"TCP":e.tcpHost=a.payload.tcpHost||e.tcpHost,e.tcpPort=a.payload.tcpPort||e.tcpPort,e.tcpType=a.payload.tcpType||e.tcpType,t("New Connection Data "+e.tcpHost+" "+e.tcpPort+" "+e.tcpType);break;case"SERIAL":a.payload.serialPort&&(e.serialPort=a.payload.serialPort||e.serialPort),a.payload.serialBaudrate&&(e.serialBaudrate=parseInt(a.payload.serialBaudrate)||e.serialBaudrate),e.serialDatabits=a.payload.serialDatabits||e.serialDatabits,e.serialStopbits=a.payload.serialStopbits||e.serialStopbits,e.serialParity=a.payload.serialParity||e.serialParity,e.serialType=a.payload.serialType||e.serialType,a.payload.serialConnectionDelay&&(e.serialConnectionDelay=parseInt(a.payload.serialConnectionDelay)||e.serialConnectionDelay),t("New Connection Data "+e.serialPort+" "+e.serialBaudrate+" "+e.serialType);break;default:t("Unknown Dynamic Reconnect Type "+a.payload.connectorType)}a.payload.unitId&&(e.unit_id=parseInt(a.payload.unitId)||e.unit_id),a.payload.commandDelay&&(e.commandDelay=parseInt(a.payload.commandDelay)||e.commandDelay),a.payload.clientTimeout&&(e.clientTimeout=parseInt(a.payload.clientTimeout)||e.clientTimeout),a.payload.reconnectTimeout&&(e.reconnectTimeout=parseInt(a.payload.reconnectTimeout)||e.reconnectTimeout)},de.biancoroyal.modbus.core.client.messagesAllowedStates=["activated","queueing","empty"],module.exports=de.biancoroyal.modbus.core.client; | ||
"use strict";require("source-map-support").install();var de=de||{biancoroyal:{modbus:{core:{client:{}}}}};de.biancoroyal.modbus.core.client.internalDebug=de.biancoroyal.modbus.core.client.internalDebug||require("debug")("contribModbus:core:client"),de.biancoroyal.modbus.core.client.internalDebugFSM=de.biancoroyal.modbus.core.client.internalDebugFSM||require("debug")("contribModbus:core:client:fsm"),de.biancoroyal.modbus.core.client.modbusSerialDebug=de.biancoroyal.modbus.core.client.modbusSerialDebug||require("debug")("modbus-serial"),de.biancoroyal.modbus.core.client.XStateFSM=de.biancoroyal.modbus.core.client.XStateFSM||require("@xstate/fsm"),de.biancoroyal.modbus.core.client.stateLogEnabled=de.biancoroyal.modbus.core.client.stateLogEnabled||!1,de.biancoroyal.modbus.core.client.networkErrors=["ESOCKETTIMEDOUT","ETIMEDOUT","ECONNRESET","ENETRESET","ECONNABORTED","ECONNREFUSED","ENETUNREACH","ENOTCONN","ESHUTDOWN","EHOSTDOWN","ENETDOWN","EWOULDBLOCK","EAGAIN","EHOSTUNREACH"],de.biancoroyal.modbus.core.client.createStateMachineService=function(){return this.stateLogEnabled=!1,this.XStateFSM.createMachine({id:"modbus",initial:"new",states:{new:{on:{INIT:"init",BREAK:"broken",STOP:"stopped"}},broken:{on:{INIT:"init",STOP:"stopped",FAILURE:"failed",CLOSE:"closed",ACTIVATE:"activated"}},init:{on:{OPENSERIAL:"opened",CONNECT:"connected",BREAK:"broken",FAILURE:"failed"}},opened:{on:{CONNECT:"connected",BREAK:"broken",FAILURE:"failed",CLOSE:"closed"}},connected:{on:{CLOSE:"closed",ACTIVATE:"activated",BREAK:"broken",FAILURE:"failed"}},activated:{on:{CLOSE:"closed",READ:"reading",WRITE:"writing",QUEUE:"queueing",BREAK:"broken",FAILURE:"failed"}},queueing:{on:{ACTIVATE:"activated",READ:"reading",WRITE:"writing",EMPTY:"empty",FAILURE:"failed",BREAK:"broken",CLOSE:"closed"}},empty:{on:{QUEUE:"queueing",BREAK:"broken",FAILURE:"failed",CLOSE:"closed"}},reading:{on:{ACTIVATE:"activated",BREAK:"broken",FAILURE:"failed"}},writing:{on:{ACTIVATE:"activated",BREAK:"broken",FAILURE:"failed"}},closed:{on:{FAILURE:"failed",BREAK:"broken",CONNECT:"connected"}},failed:{on:{CLOSE:"closed",BREAK:"broken",STOP:"stopped"}},stopped:{on:{NEW:"new",STOP:"stopped"}}}})},de.biancoroyal.modbus.core.client.startStateService=function(e){return this.XStateFSM.interpret(e).start()},de.biancoroyal.modbus.core.client.checkUnitId=function(e,a){return"tcp"===a?0<=e&&e<=255:1<=e&&e<=247},de.biancoroyal.modbus.core.client.getLogFunction=function(e){return e.internalDebugLog?e.internalDebugLog:de.biancoroyal.modbus.core.client.internalDebug},de.biancoroyal.modbus.core.client.readModbus=function(a,t,n,o){if(a.client){a.bufferCommands||a.stateService.send("READ"),a.setUnitIdFromPayload(t),a.client.setTimeout(a.clientTimeout);var i=de.biancoroyal.modbus.core.client.getLogFunction(a);a.queueLog(JSON.stringify({info:"read msg",message:t.payload,unitid:t.queueUnitId,timeout:a.client.getTimeout(),state:a.actualServiceState.value}));try{switch(parseInt(t.payload.fc)){case 1:a.client.readCoils(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 2:a.client.readDiscreteInputs(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 3:a.client.readHoldingRegisters(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 4:a.client.readInputRegisters(parseInt(t.payload.address),parseInt(t.payload.quantity)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;default:a.activateSending(t),o(new Error("Function Code Unknown"),t),i("Function Code Unknown %s",t.payload.fc)}}catch(e){i(e.message),a.modbusErrorHandling(e)}}},de.biancoroyal.modbus.core.client.writeModbus=function(a,t,n,o){if(a.client){a.bufferCommands||a.stateService.send("WRITE"),a.setUnitIdFromPayload(t),a.client.setTimeout(a.clientTimeout);var i=de.biancoroyal.modbus.core.client.getLogFunction(a);a.queueLog(JSON.stringify({info:"write msg",message:t.payload,unitid:t.queueUnitId,timeout:a.client.getTimeout(),state:a.actualServiceState.value}));try{switch(parseInt(t.payload.fc)){case 15:parseInt(t.payload.value.length)!==parseInt(t.payload.quantity)?(a.activateSending(t),o(new Error("Quantity should be less or equal to coil payload array length: "+t.payload.value.length+" Addr: "+t.payload.address+" Q: "+t.payload.quantity),t)):a.client.writeCoils(parseInt(t.payload.address),t.payload.value).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 5:t.payload.value?t.payload.value=!0:t.payload.value=!1,a.client.writeCoil(parseInt(t.payload.address),t.payload.value).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 16:parseInt(t.payload.value.length)!==parseInt(t.payload.quantity)?(a.activateSending(t),o(new Error("Quantity should be less or equal to register payload array length: "+t.payload.value.length+" Addr: "+t.payload.address+" Q: "+t.payload.quantity),t)):a.client.writeRegisters(parseInt(t.payload.address),t.payload.value).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;case 6:a.client.writeRegister(parseInt(t.payload.address),parseInt(t.payload.value)).then(function(e){a.activateSending(t),n(e,t)}).catch(function(e){a.activateSending(t),o(e,t),a.modbusErrorHandling(e)});break;default:a.activateSending(t),o(new Error("Function Code Unknown"),t),i("Function Code Unknown %s",t.payload.fc)}}catch(e){i(e.message),a.modbusErrorHandling(e)}}},de.biancoroyal.modbus.core.client.setNewNodeSettings=function(e,a){var t=de.biancoroyal.modbus.core.client.getLogFunction(e);if(!a)return t("New Connection message invalid."),!1;switch(a.payload.connectorType){case"TCP":e.tcpHost=a.payload.tcpHost||e.tcpHost,e.tcpPort=a.payload.tcpPort||e.tcpPort,e.tcpType=a.payload.tcpType||e.tcpType,t("New Connection Data "+e.tcpHost+" "+e.tcpPort+" "+e.tcpType);break;case"SERIAL":a.payload.serialPort&&(e.serialPort=a.payload.serialPort||e.serialPort),a.payload.serialBaudrate&&(e.serialBaudrate=parseInt(a.payload.serialBaudrate)||e.serialBaudrate),e.serialDatabits=a.payload.serialDatabits||e.serialDatabits,e.serialStopbits=a.payload.serialStopbits||e.serialStopbits,e.serialParity=a.payload.serialParity||e.serialParity,e.serialType=a.payload.serialType||e.serialType,a.payload.serialConnectionDelay&&(e.serialConnectionDelay=parseInt(a.payload.serialConnectionDelay)||e.serialConnectionDelay),t("New Connection Data "+e.serialPort+" "+e.serialBaudrate+" "+e.serialType);break;default:t("Unknown Dynamic Reconnect Type "+a.payload.connectorType)}return a.payload.unitId&&(e.unit_id=parseInt(a.payload.unitId)||e.unit_id),a.payload.commandDelay&&(e.commandDelay=parseInt(a.payload.commandDelay)||e.commandDelay),a.payload.clientTimeout&&(e.clientTimeout=parseInt(a.payload.clientTimeout)||e.clientTimeout),a.payload.reconnectTimeout&&(e.reconnectTimeout=parseInt(a.payload.reconnectTimeout)||e.reconnectTimeout),!0},de.biancoroyal.modbus.core.client.messagesAllowedStates=["activated","queueing","empty"],module.exports=de.biancoroyal.modbus.core.client; | ||
//# sourceMappingURL=../maps/core/modbus-client-core.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";require("source-map-support").install();var de=de||{biancoroyal:{modbus:{queue:{core:{}}}}};de.biancoroyal.modbus.queue.core.internalDebug=de.biancoroyal.modbus.queue.core.internalDebug||require("debug")("contribModbus:queue:core"),de.biancoroyal.modbus.queue.core.core=de.biancoroyal.modbus.queue.core.core||require("./modbus-core"),de.biancoroyal.modbus.queue.core.initQueue=function(e){e.bufferCommandList.clear(),e.sendAllowed.clear(),e.sendToDeviceAllowed=[],e.unitSendingAllowed=[];for(var n=0;n<=255;n++)e.bufferCommandList.set(n,[]),e.sendAllowed.set(n,!0)},de.biancoroyal.modbus.queue.core.checkQueuesAreEmpty=function(e){for(var n=!0,u=0;u<=255;u++)n&=0<e.bufferCommandList.get(u).length;return n},de.biancoroyal.modbus.queue.core.sequentialDequeueCommand=function(e){var n=e.unitSendingAllowed.length,u=parseInt(e.unitSendingAllowed.shift()),t=!0;Number.isInteger(u)&&0<e.bufferCommandList.get(u).length?t=e.parallelUnitIdsAllowed?this.sendDataInParallel(e,u,n):this.sendDataPerDevice(e,u,n):e.queueLog(JSON.stringify({type:"queue check is not a unit",unitid:u})),t&&e.stateService.send("EMPTY")},de.biancoroyal.modbus.queue.core.sendDataInParallel=function(e,n,u){var t=null,i=!0;return e.queueLog(JSON.stringify({type:"queue check",unitid:n,sendAllowed:e.sendAllowed.get(n),queueLength:e.bufferCommandList.get(n).length})),e.sendAllowed.get(n)&&(t=e.bufferCommandList.get(n).shift())&&(e.sendAllowed.set(n,!1),e.queueLog(JSON.stringify({type:"serial sending and wait per unitid",unitid:n,queueLength:e.bufferCommandList.get(n).length,sendAllowedForNext:e.sendAllowed.get(n),delay:e.commandDelay})),0<e.bufferCommandList.get(n).length&&e.unitSendingAllowed.push(n),i=!1,t.callModbus(e,t.msg,t.cb,t.cberr)),i},de.biancoroyal.modbus.queue.core.sendDataPerDevice=function(e,n,u){var t=null,i=!0;return e.queueLog(JSON.stringify({type:"queue check",unitid:n,sendAllowed:e.sendAllowed.get(n),queueLength:e.bufferCommandList.get(n).length})),0===e.sendToDeviceAllowed.length&&(t=e.bufferCommandList.get(n).shift())&&(e.sendToDeviceAllowed.push(n),e.queueLog(JSON.stringify({type:"serial sending and wait",unitid:n,queueLength:e.bufferCommandList.get(n).length,sendAllowedForNext:e.sendToDeviceAllowed.length,delay:e.commandDelay})),0<e.bufferCommandList.get(n).length&&e.unitSendingAllowed.push(n),i=!1,t.callModbus(e,t.msg,t.cb,t.cberr)),i},de.biancoroyal.modbus.queue.core.dequeueCommand=function(e){var n=e.actualServiceState;-1===e.messageAllowedStates.indexOf(n.value)?e.queueLog(JSON.stringify({state:n.value,message:"dequeue command disallowed state",delay:e.commandDelay})):(e.queueLog(JSON.stringify({state:n.value,message:"dequeue command "+e.clienttype,delay:e.commandDelay})),this.sequentialDequeueCommand(e)),this.checkQueuesAreEmpty(e)&&e.stateService.send("EMPTY")},de.biancoroyal.modbus.queue.core.getQueueNumber=function(e,n){var u=parseInt(n.payload.unitid);return Number.isInteger(u)?e.bufferCommandList.get(u).length:e.bufferCommandList.get(e.unit_id).length},de.biancoroyal.modbus.queue.core.pushToQueueByUnitId=function(e,n,u,t,i){var d=parseInt(u.payload.unitid);Number.isInteger(d)?(u.queueUnit=d,e.queueLog(JSON.stringify({info:"push to Queue by Unit-Id",message:u.payload,unit:d,sendingListLength:e.unitSendingAllowed.length})),e.unitSendingAllowed.push(d),e.bufferCommandList.get(d).push({callModbus:n,msg:u,cb:t,cberr:i})):(u.queueUnit=e.unit_id,e.queueLog(JSON.stringify({info:"push to Queue by default Unit-Id",message:u.payload,unit:e.unit_id,sendingListLength:e.unitSendingAllowed.length})),-1===e.unitSendingAllowed.indexOf(e.unit_id)&&e.unitSendingAllowed.push(e.unit_id),e.bufferCommandList.get(e.unit_id).push({callModbus:n,msg:u,cb:t,cberr:i}))},module.exports=de.biancoroyal.modbus.queue.core; | ||
"use strict";require("source-map-support").install();var de=de||{biancoroyal:{modbus:{queue:{core:{}}}}};de.biancoroyal.modbus.queue.core.internalDebug=de.biancoroyal.modbus.queue.core.internalDebug||require("debug")("contribModbus:queue:core"),de.biancoroyal.modbus.queue.core.core=de.biancoroyal.modbus.queue.core.core||require("./modbus-core"),de.biancoroyal.modbus.queue.core.initQueue=function(e){e.bufferCommandList.clear(),e.sendAllowed.clear(),e.sendToDeviceAllowed=[],e.unitSendingAllowed=[];for(var u=0;u<=255;u++)e.bufferCommandList.set(u,[]),e.sendAllowed.set(u,!0)},de.biancoroyal.modbus.queue.core.checkQueuesAreEmpty=function(e){for(var u=!0,n=0;n<=255;n++)u&=0<e.bufferCommandList.get(n).length;return u},de.biancoroyal.modbus.queue.core.sequentialDequeueCommand=function(e){var u=de.biancoroyal.modbus.queue.core,n=e.unitSendingAllowed.length,t=parseInt(e.unitSendingAllowed.shift()),o=!0;Number.isInteger(t)&&0<e.bufferCommandList.get(t).length?o=e.parallelUnitIdsAllowed?u.sendDataInParallel(e,t,n):u.sendDataPerDevice(e,t,n):e.queueLog(JSON.stringify({type:"queue check is not a unit",unitid:t})),o&&e.stateService.send("EMPTY")},de.biancoroyal.modbus.queue.core.sendDataInParallel=function(e,u,n){var t=null,o=!0;return e.queueLog(JSON.stringify({type:"queue check",unitid:u,sendAllowed:e.sendAllowed.get(u),queueLength:e.bufferCommandList.get(u).length})),e.sendAllowed.get(u)&&(t=e.bufferCommandList.get(u).shift())&&(e.sendAllowed.set(u,!1),e.queueLog(JSON.stringify({type:"serial sending and wait per unitid",unitid:u,queueLength:e.bufferCommandList.get(u).length,sendAllowedForNext:e.sendAllowed.get(u),delay:e.commandDelay})),0<e.bufferCommandList.get(u).length&&e.unitSendingAllowed.push(u),o=!1,t.callModbus(e,t.msg,t.cb,t.cberr)),o},de.biancoroyal.modbus.queue.core.sendDataPerDevice=function(e,u,n){var t=null,o=!0;return e.queueLog(JSON.stringify({type:"queue check",unitid:u,sendAllowed:e.sendAllowed.get(u),queueLength:e.bufferCommandList.get(u).length})),0===e.sendToDeviceAllowed.length&&(t=e.bufferCommandList.get(u).shift())&&(e.sendToDeviceAllowed.push(u),e.queueLog(JSON.stringify({type:"serial sending and wait",unitid:u,queueLength:e.bufferCommandList.get(u).length,sendAllowedForNext:e.sendToDeviceAllowed.length,delay:e.commandDelay})),0<e.bufferCommandList.get(u).length&&e.unitSendingAllowed.push(u),o=!1,t.callModbus(e,t.msg,t.cb,t.cberr)),o},de.biancoroyal.modbus.queue.core.dequeueCommand=function(e){var u=de.biancoroyal.modbus.queue.core,n=e.actualServiceState;-1===e.messageAllowedStates.indexOf(n.value)?e.queueLog(JSON.stringify({state:n.value,message:"dequeue command disallowed state",delay:e.commandDelay})):(e.queueLog(JSON.stringify({state:n.value,message:"dequeue command "+e.clienttype,delay:e.commandDelay})),u.sequentialDequeueCommand(e)),u.checkQueuesAreEmpty(e)&&e.stateService.send("EMPTY")},de.biancoroyal.modbus.queue.core.getQueueNumber=function(e,u){var n=parseInt(u.payload.unitid);return Number.isInteger(n)?e.bufferCommandList.get(n).length:e.bufferCommandList.get(e.unit_id).length},de.biancoroyal.modbus.queue.core.pushToQueueByUnitId=function(e,u,n,t,o){var d=parseInt(n.payload.unitid);Number.isInteger(d)?(n.queueUnit=d,e.queueLog(JSON.stringify({info:"push to Queue by Unit-Id",message:n.payload,unit:d,sendingListLength:e.unitSendingAllowed.length})),e.unitSendingAllowed.push(d),e.bufferCommandList.get(d).push({callModbus:u,msg:n,cb:t,cberr:o})):(n.queueUnit=e.unit_id,e.queueLog(JSON.stringify({info:"push to Queue by default Unit-Id",message:n.payload,unit:e.unit_id,sendingListLength:e.unitSendingAllowed.length})),-1===e.unitSendingAllowed.indexOf(e.unit_id)&&e.unitSendingAllowed.push(e.unit_id),e.bufferCommandList.get(e.unit_id).push({callModbus:u,msg:n,cb:t,cberr:o}))},module.exports=de.biancoroyal.modbus.queue.core; | ||
//# sourceMappingURL=../maps/core/modbus-queue-core.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";module.exports=function(r){require("source-map-support").install();var o=require("./modbus-basics"),a=require("./core/modbus-client-core"),c=require("./core/modbus-queue-core");r.nodes.registerType("modbus-client",function(e){r.nodes.createNode(this,e);var t=require("modbus-serial");this.clienttype=e.clienttype,this.bufferCommands=e.bufferCommands,this.stateLogEnabled=e.stateLogEnabled,this.tcpHost=e.tcpHost,this.tcpPort=parseInt(e.tcpPort)||502,this.tcpType=e.tcpType,this.serialPort=e.serialPort,this.serialBaudrate=e.serialBaudrate,this.serialDatabits=e.serialDatabits,this.serialStopbits=e.serialStopbits,this.serialParity=e.serialParity,this.serialType=e.serialType,this.serialConnectionDelay=parseInt(e.serialConnectionDelay)||500,this.unit_id=parseInt(e.unit_id)||1,this.commandDelay=parseInt(e.commandDelay)||1,this.clientTimeout=parseInt(e.clientTimeout)||1e3,this.reconnectTimeout=parseInt(e.reconnectTimeout)||2e3,this.reconnectOnTimeout=e.reconnectOnTimeout,this.parallelUnitIdsAllowed=e.parallelUnitIdsAllowed;var s=this;function n(e){r.settings.verbose&&s.warn("Client -> "+e+s.serverInfo)}function i(e){r.settings.verbose&&a.internalDebug("Client -> "+e+s.serverInfo)}s.isFirstInitOfConnection=!0,s.closingModbus=!1,s.client=null,s.bufferCommandList=new Map,s.sendAllowed=new Map,s.unitSendingAllowed=[],s.sendToDeviceAllowed=[],s.messageAllowedStates=a.messagesAllowedStates,s.serverInfo="",s.stateMachine=null,s.stateService=null,s.stateMachine=a.createStateMachineService(),s.actualServiceState=s.stateMachine.initialState,s.actualServiceStateBefore=s.actualServiceState,s.stateService=a.startStateService(s.stateMachine),s.setUnitIdFromPayload=function(e){var t=parseInt(e.payload.unitid);Number.isInteger(t)?(s.client.setID(t),e.queueUnitId=t):(a.checkUnitId(s.unit_id,s.clienttype)||(s.unit_id=1),s.client.setID(s.unit_id),e.queueUnitId=s.unit_id)},!Number.isNaN(s.unit_id)&&a.checkUnitId(s.unit_id,s.clienttype)||(s.unit_id=1),s.updateServerinfo=function(){"tcp"===s.clienttype?s.serverInfo=" TCP@"+s.tcpHost+":"+s.tcpPort:s.serverInfo=" Serial@"+s.serialPort+":"+s.serialBaudrate+"bit/s",s.serverInfo+=" default Unit-Id: "+s.unit_id},s.queueLog=function(e){s.bufferCommands&&i(e)},s.stateService.subscribe(function(e){var t;if(s.actualServiceStateBefore=s.actualServiceState,s.actualServiceState=e,t=e.value,s.stateLogEnabled&&i(t),e.matches("init")){s.updateServerinfo(),c.initQueue(s);try{s.isFirstInitOfConnection?(s.isFirstInitOfConnection=!1,setTimeout(s.connectClient,500)):setTimeout(s.connectClient,s.reconnectTimeout)}catch(e){s.error(e,{payload:"client connection error"})}n("reconnect in "+s.reconnectTimeout+" ms"),s.emit("mbinit")}e.matches("connected")&&(s.emit("mbconnected"),s.stateService.send("ACTIVATE")),e.matches("activated")&&(s.emit("mbactive"),s.bufferCommands&&s.stateService.send("QUEUE")),e.matches("queueing")&&(setTimeout(function(){c.dequeueCommand(s)},s.commandDelay),s.emit("mbqueue")),e.matches("opened")&&s.emit("mbopen"),e.matches("closed")&&(s.emit("mbclosed"),s.stateService.send("BREAK")),e.matches("failed")&&(s.emit("mberror","FSM Reset On State "+JSON.stringify(e)),s.stateService.send("BREAK")),e.matches("broken")&&(s.emit("mbbroken"),s.reconnectOnTimeout?(s.reconnectTimeout<=0&&(s.reconnectTimeout=2e3),n("try to reconnect by init in "+s.reconnectTimeout+" ms"),setTimeout(function(){s.stateService.send("INIT")},s.reconnectTimeout)):(n("stay active on broken state without reconnecting"),s.stateService.send("ACTIVATE")))}),s.connectClient=function(){if(s.client)try{s.client.close(function(){i("connection closed")})}catch(e){i(e.message)}if(s.client=null,s.client=new t,s.clientTimeout||(s.clientTimeout=1e3),s.reconnectTimeout||(s.reconnectTimeout=2e3),"tcp"===s.clienttype){if(!a.checkUnitId(s.unit_id,s.clienttype))return s.error(new Error("wrong unit-id (0..255)"),{payload:s.unit_id}),void s.stateService.send("FAILURE");switch(s.tcpType){case"C701":i("C701 port UDP bridge"),s.client.connectC701(s.tcpHost,{port:s.tcpPort,autoOpen:!0}).then(s.setTCPConnectionOptions).then(s.setTCPConnected).catch(s.modbusTcpErrorHandling);break;case"TELNET":i("Telnet port"),s.client.connectTelnet(s.tcpHost,{port:s.tcpPort,autoOpen:!0}).then(s.setTCPConnectionOptions).catch(s.modbusTcpErrorHandling);break;case"TPC-RTU-BUFFERED":i("TCP RTU buffered port"),s.client.connectTcpRTUBuffered(s.tcpHost,{port:s.tcpPort,autoOpen:!0}).then(s.setTCPConnectionOptions).catch(s.modbusTcpErrorHandling);break;default:i("TCP port"),s.client.connectTCP(s.tcpHost,{port:s.tcpPort,autoOpen:!0}).then(s.setTCPConnectionOptions).catch(s.modbusTcpErrorHandling)}}else{if(!a.checkUnitId(s.unit_id,s.clienttype))return s.error(new Error("wrong unit-id serial (1..247)"),{payload:s.unit_id}),void s.stateService.send("FAILURE");if(s.serialConnectionDelay||(s.serialConnectionDelay=500),!s.serialPort)return s.error(new Error("wrong serial port"),{payload:s.serialPort}),void s.stateService.send("FAILURE");var e={baudRate:parseInt(s.serialBaudrate),dataBits:parseInt(s.serialDatabits),stopBits:parseInt(s.serialStopbits),parity:s.serialParity,autoOpen:!1};switch(s.serialType){case"ASCII":i("ASCII port serial"),s.client.connectAsciiSerial(s.serialPort,e).then(s.setSerialConnectionOptions).catch(s.modbusSerialErrorHandling);break;case"RTU":i("RTU port serial"),s.client.connectRTU(s.serialPort,e).then(s.setSerialConnectionOptions).catch(s.modbusSerialErrorHandling);break;default:i("RTU buffered port serial"),s.client.connectRTUBuffered(s.serialPort,e).then(s.setSerialConnectionOptions).catch(s.modbusSerialErrorHandling)}}},s.setTCPConnectionOptions=function(){s.client.setID(s.unit_id),s.client.setTimeout(s.clientTimeout),s.stateService.send("CONNECT")},s.setTCPConnected=function(){a.modbusSerialDebug("modbus tcp connected on "+s.tcpHost)},s.setSerialConnectionOptions=function(){s.stateService.send("OPENSERIAL"),setTimeout(s.openSerialClient,parseInt(s.serialConnectionDelay))},s.modbusErrorHandling=function(e){e.message?a.modbusSerialDebug("modbusErrorHandling:"+e.message):a.modbusSerialDebug("modbusErrorHandling:"+JSON.stringify(e)),e.errno&&a.networkErrors.includes(e.errno)&&s.stateService.send("FAILURE")},s.modbusTcpErrorHandling=function(e){e.message?a.modbusSerialDebug("modbusTcpErrorHandling:"+e.message):a.modbusSerialDebug("modbusTcpErrorHandling:"+JSON.stringify(e)),e.errno&&a.networkErrors.includes(e.errno)&&s.stateService.send("FAILURE")},s.modbusSerialErrorHandling=function(e){e.message?a.modbusSerialDebug("modbusSerialErrorHandling:"+e.message):a.modbusSerialDebug("modbusSerialErrorHandling:"+JSON.stringify(e)),s.stateService.send("FAILURE")},s.openSerialClient=function(){"opened"===s.actualServiceState.value?(i("time to open Unit "+s.unit_id),a.modbusSerialDebug("modbus connection opened"),s.client.setID(s.unit_id),s.client.setTimeout(parseInt(s.clientTimeout)),s.client._port.on("close",s.onModbusClose),s.stateService.send("CONNECT")):(i("wrong state on connect serial "+s.actualServiceState.value),a.modbusSerialDebug("modbus connection not opened state is %s",s.actualServiceState.value),s.stateService.send("FAILURE"))},s.onModbusClose=function(){n("modbus closed port"),a.modbusSerialDebug("modbus closed port"),s.stateService.send("CLOSE")},s.on("readModbus",function(e,t,n){var i=s.actualServiceState;-1!==s.messageAllowedStates.indexOf(i.value)?s.bufferCommands?(e.queueNumber=c.getQueueNumber(s,e),c.pushToQueueByUnitId(s,a.readModbus,e,t,n),s.stateService.send("QUEUE"),s.queueLog(JSON.stringify({info:"queue read msg",message:e.payload,state:i.value,queueLength:s.bufferCommandList.get(e.queueUnit).length}))):a.readModbus(s,e,t,n):n(new Error("FSM Not Ready To Read At State "+i.value),e)}),s.on("writeModbus",function(e,t,n){var i=s.actualServiceState;-1!==s.messageAllowedStates.indexOf(i.value)?s.bufferCommands?(e.queueNumber=c.getQueueNumber(s,e),c.pushToQueueByUnitId(s,a.writeModbus,e,t,n),s.stateService.send("QUEUE"),s.queueLog(JSON.stringify({info:"queue write msg",message:e.payload,state:i.value,queueLength:s.bufferCommandList.get(e.queueUnit).length}))):a.writeModbus(s,e,t,n):n(new Error("FSM Not Ready To Write At State "+i.value),e)}),s.activateSending=function(e){var t=s.sendToDeviceAllowed.shift();s.bufferCommands&&(s.sendAllowed.set(e.queueUnit,!0),s.queueLog(JSON.stringify({info:"queue response activate sending",message:e.payload,queueLength:s.bufferCommandList.length,serialUnitId:t}))),s.stateService.send("ACTIVATE")},i("initialized"),s.setMaxListeners(0),s.on("reconnect",function(){s.stateService.send("FAILURE"),s.stateService.send("CLOSE")}),s.on("dynamicReconnect",function(e){if(o.invalidPayloadIn(e))throw new Error("Message Or Payload Not Valid");a.internalDebug("Dynamic Reconnect Parameters "+JSON.stringify(e.payload)),a.setNewNodeSettings(s,e),a.internalDebug("Dynamic Reconnect Starts on actual state "+s.actualServiceState.value),s.stateService.send("CLOSE")}),s.on("close",function(t){s.stateService.send("FAILURE"),s.stateService.send("CLOSE"),s.stateService.send("STOP"),i("close node"),s.client?s.client.close(function(){i("connection closed"),t()}).catch(function(e){i(e.message),t()}):t()}),s.registeredNodeList={},s.registerForModbus=function(e){s.registeredNodeList[e.id]=e,1===Object.keys(s.registeredNodeList).length&&(s.closingModbus=!1,s.stateService.send("INIT"))},s.deregisterForModbus=function(e,t){delete s.registeredNodeList[e.id],s.closingModbus&&t(),0===Object.keys(s.registeredNodeList).length?(s.closingModbus=!0,s.client?s.client.close(function(){s.stateService.send("CLOSE"),s.stateService.send("BREAK"),s.stateService.send("STOP"),t()}).catch(function(e){s.stateService.send("FAILURE"),s.stateService.send("STOP"),i(e.message),t()}):t()):t()}}),r.httpAdmin.get("/modbus/serial/ports",r.auth.needsPermission("serial.read"),function(e,t){require("serialport").list().then(function(e){t.json(e)}).catch(function(e){a.internalDebug(e.message)})})}; | ||
"use strict";module.exports=function(s){require("source-map-support").install();var o=require("./modbus-basics"),a=require("./core/modbus-client-core"),c=require("./core/modbus-queue-core");s.nodes.registerType("modbus-client",function(e){s.nodes.createNode(this,e);var t=require("modbus-serial");this.clienttype=e.clienttype,this.bufferCommands=e.bufferCommands,this.stateLogEnabled=e.stateLogEnabled,this.tcpHost=e.tcpHost,this.tcpPort=parseInt(e.tcpPort)||502,this.tcpType=e.tcpType,this.serialPort=e.serialPort,this.serialBaudrate=e.serialBaudrate,this.serialDatabits=e.serialDatabits,this.serialStopbits=e.serialStopbits,this.serialParity=e.serialParity,this.serialType=e.serialType,this.serialConnectionDelay=parseInt(e.serialConnectionDelay)||500,this.unit_id=parseInt(e.unit_id)||1,this.commandDelay=parseInt(e.commandDelay)||1,this.clientTimeout=parseInt(e.clientTimeout)||1e3,this.reconnectTimeout=parseInt(e.reconnectTimeout)||2e3,this.reconnectOnTimeout=e.reconnectOnTimeout,this.parallelUnitIdsAllowed=e.parallelUnitIdsAllowed;var r=this;function n(e){s.settings.verbose&&r.warn("Client -> "+e+r.serverInfo)}function i(e){s.settings.verbose&&a.internalDebug("Client -> "+e+r.serverInfo)}r.isFirstInitOfConnection=!0,r.closingModbus=!1,r.client=null,r.bufferCommandList=new Map,r.sendAllowed=new Map,r.unitSendingAllowed=[],r.sendToDeviceAllowed=[],r.messageAllowedStates=a.messagesAllowedStates,r.serverInfo="",r.stateMachine=null,r.stateService=null,r.stateMachine=a.createStateMachineService(),r.actualServiceState=r.stateMachine.initialState,r.actualServiceStateBefore=r.actualServiceState,r.stateService=a.startStateService(r.stateMachine),r.setUnitIdFromPayload=function(e){var t=parseInt(e.payload.unitid);Number.isInteger(t)?(r.client.setID(t),e.queueUnitId=t):(a.checkUnitId(r.unit_id,r.clienttype)||(r.unit_id=1),r.client.setID(r.unit_id),e.queueUnitId=r.unit_id)},!Number.isNaN(r.unit_id)&&a.checkUnitId(r.unit_id,r.clienttype)||(r.unit_id=1),r.updateServerinfo=function(){"tcp"===r.clienttype?r.serverInfo=" TCP@"+r.tcpHost+":"+r.tcpPort:r.serverInfo=" Serial@"+r.serialPort+":"+r.serialBaudrate+"bit/s",r.serverInfo+=" default Unit-Id: "+r.unit_id},r.queueLog=function(e){r.bufferCommands&&i(e)},r.stateService.subscribe(function(e){var t;if(r.actualServiceStateBefore=r.actualServiceState,r.actualServiceState=e,t=e.value,r.stateLogEnabled&&i(t),e.matches("init")){r.updateServerinfo(),c.initQueue(r);try{r.isFirstInitOfConnection?(r.isFirstInitOfConnection=!1,setTimeout(r.connectClient,500)):setTimeout(r.connectClient,r.reconnectTimeout)}catch(e){r.error(e,{payload:"client connection error"})}n("reconnect in "+r.reconnectTimeout+" ms"),r.emit("mbinit")}e.matches("connected")&&(r.emit("mbconnected"),r.stateService.send("ACTIVATE")),e.matches("activated")&&(r.emit("mbactive"),r.bufferCommands&&r.stateService.send("QUEUE")),e.matches("queueing")&&(setTimeout(function(){c.dequeueCommand(r)},r.commandDelay),r.emit("mbqueue")),e.matches("opened")&&r.emit("mbopen"),e.matches("closed")&&(r.emit("mbclosed"),r.stateService.send("BREAK")),e.matches("failed")&&(r.emit("mberror","Modbus Failure Handling On State "+JSON.stringify(e)),r.stateService.send("BREAK")),e.matches("broken")&&(r.emit("mbbroken"),r.reconnectOnTimeout?(r.reconnectTimeout<=0&&(r.reconnectTimeout=2e3),n("try to reconnect by init in "+r.reconnectTimeout+" ms"),setTimeout(function(){r.stateService.send("INIT")},r.reconnectTimeout)):(n("stay active on broken state without reconnecting"),r.stateService.send("ACTIVATE")))}),r.connectClient=function(){if(r.client)try{r.client.close(function(){i("connection closed")})}catch(e){i(e.message)}if(r.client=null,r.client=new t,r.clientTimeout||(r.clientTimeout=1e3),r.reconnectTimeout||(r.reconnectTimeout=2e3),"tcp"===r.clienttype){if(!a.checkUnitId(r.unit_id,r.clienttype))return r.error(new Error("wrong unit-id (0..255)"),{payload:r.unit_id}),void r.stateService.send("FAILURE");switch(r.tcpType){case"C701":i("C701 port UDP bridge"),r.client.connectC701(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).then(r.setTCPConnected).catch(r.modbusTcpErrorHandling);break;case"TELNET":i("Telnet port"),r.client.connectTelnet(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(r.modbusTcpErrorHandling);break;case"TPC-RTU-BUFFERED":i("TCP RTU buffered port"),r.client.connectTcpRTUBuffered(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(r.modbusTcpErrorHandling);break;default:i("TCP port"),r.client.connectTCP(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(r.modbusTcpErrorHandling)}}else{if(!a.checkUnitId(r.unit_id,r.clienttype))return r.error(new Error("wrong unit-id serial (1..247)"),{payload:r.unit_id}),void r.stateService.send("FAILURE");if(r.serialConnectionDelay||(r.serialConnectionDelay=500),!r.serialPort)return r.error(new Error("wrong serial port"),{payload:r.serialPort}),void r.stateService.send("FAILURE");var e={baudRate:parseInt(r.serialBaudrate),dataBits:parseInt(r.serialDatabits),stopBits:parseInt(r.serialStopbits),parity:r.serialParity,autoOpen:!1};switch(r.serialType){case"ASCII":i("ASCII port serial"),r.client.connectAsciiSerial(r.serialPort,e).then(r.setSerialConnectionOptions).catch(r.modbusSerialErrorHandling);break;case"RTU":i("RTU port serial"),r.client.connectRTU(r.serialPort,e).then(r.setSerialConnectionOptions).catch(r.modbusSerialErrorHandling);break;default:i("RTU buffered port serial"),r.client.connectRTUBuffered(r.serialPort,e).then(r.setSerialConnectionOptions).catch(r.modbusSerialErrorHandling)}}},r.setTCPConnectionOptions=function(){r.client.setID(r.unit_id),r.client.setTimeout(r.clientTimeout),r.stateService.send("CONNECT")},r.setTCPConnected=function(){a.modbusSerialDebug("modbus tcp connected on "+r.tcpHost)},r.setSerialConnectionOptions=function(){r.stateService.send("OPENSERIAL"),setTimeout(r.openSerialClient,parseInt(r.serialConnectionDelay))},r.modbusErrorHandling=function(e){e.message?a.modbusSerialDebug("modbusErrorHandling:"+e.message):a.modbusSerialDebug("modbusErrorHandling:"+JSON.stringify(e)),e.errno&&a.networkErrors.includes(e.errno)&&r.stateService.send("FAILURE")},r.modbusTcpErrorHandling=function(e){e.message?a.modbusSerialDebug("modbusTcpErrorHandling:"+e.message):a.modbusSerialDebug("modbusTcpErrorHandling:"+JSON.stringify(e)),e.errno&&a.networkErrors.includes(e.errno)&&r.stateService.send("FAILURE")},r.modbusSerialErrorHandling=function(e){e.message?a.modbusSerialDebug("modbusSerialErrorHandling:"+e.message):a.modbusSerialDebug("modbusSerialErrorHandling:"+JSON.stringify(e)),r.stateService.send("FAILURE")},r.openSerialClient=function(){"opened"===r.actualServiceState.value?(i("time to open Unit "+r.unit_id),a.modbusSerialDebug("modbus connection opened"),r.client.setID(r.unit_id),r.client.setTimeout(parseInt(r.clientTimeout)),r.client._port.on("close",r.onModbusClose),r.stateService.send("CONNECT")):(i("wrong state on connect serial "+r.actualServiceState.value),a.modbusSerialDebug("modbus connection not opened state is %s",r.actualServiceState.value),r.stateService.send("FAILURE"))},r.onModbusClose=function(){n("modbus closed port"),a.modbusSerialDebug("modbus closed port"),r.stateService.send("CLOSE")},r.on("readModbus",function(e,t,n){var i=r.actualServiceState;-1!==r.messageAllowedStates.indexOf(i.value)?r.bufferCommands?(e.queueNumber=c.getQueueNumber(r,e),c.pushToQueueByUnitId(r,a.readModbus,e,t,n),r.stateService.send("QUEUE"),r.queueLog(JSON.stringify({info:"queue read msg",message:e.payload,state:i.value,queueLength:r.bufferCommandList.get(e.queueUnit).length}))):a.readModbus(r,e,t,n):n(new Error("FSM Not Ready To Read At State "+i.value),e)}),r.on("writeModbus",function(e,t,n){var i=r.actualServiceState;-1!==r.messageAllowedStates.indexOf(i.value)?r.bufferCommands?(e.queueNumber=c.getQueueNumber(r,e),c.pushToQueueByUnitId(r,a.writeModbus,e,t,n),r.stateService.send("QUEUE"),r.queueLog(JSON.stringify({info:"queue write msg",message:e.payload,state:i.value,queueLength:r.bufferCommandList.get(e.queueUnit).length}))):a.writeModbus(r,e,t,n):n(new Error("FSM Not Ready To Write At State "+i.value),e)}),r.activateSending=function(e){var t=r.sendToDeviceAllowed.shift();r.bufferCommands&&(r.sendAllowed.set(e.queueUnit,!0),r.queueLog(JSON.stringify({info:"queue response activate sending",message:e.payload,queueLength:r.bufferCommandList.length,serialUnitId:t}))),r.stateService.send("ACTIVATE")},i("initialized"),r.setMaxListeners(0),r.on("reconnect",function(){r.stateService.send("BREAK"),r.stateService.send("CLOSE")}),r.on("dynamicReconnect",function(e,t,n){if(o.invalidPayloadIn(e))throw new Error("Message Or Payload Not Valid");a.internalDebug("Dynamic Reconnect Parameters "+JSON.stringify(e.payload)),a.setNewNodeSettings(r,e)?t(e):n(new Error("Message Or Payload Not Valid"),e),a.internalDebug("Dynamic Reconnect Starts on actual state "+r.actualServiceState.value),r.stateService.send("BREAK"),r.stateService.send("CLOSE")}),r.on("close",function(t){r.stateService.send("BREAK"),r.stateService.send("CLOSE"),r.stateService.send("STOP"),i("close node"),r.client?r.client.close(function(){i("connection closed"),t()}).catch(function(e){i(e.message),t()}):t()}),r.registeredNodeList={},r.registerForModbus=function(e){r.registeredNodeList[e.id]=e,1===Object.keys(r.registeredNodeList).length&&(r.closingModbus=!1,r.stateService.send("INIT"))},r.deregisterForModbus=function(e,t){delete r.registeredNodeList[e.id],r.closingModbus&&t(),0===Object.keys(r.registeredNodeList).length?(r.closingModbus=!0,r.client?r.client.close(function(){r.stateService.send("CLOSE"),r.stateService.send("BREAK"),r.stateService.send("STOP"),t()}).catch(function(e){r.stateService.send("FAILURE"),r.stateService.send("STOP"),i(e.message),t()}):t()):t()}}),s.httpAdmin.get("/modbus/serial/ports",s.auth.needsPermission("serial.read"),function(e,t){require("serialport").list().then(function(e){t.json(e)}).catch(function(e){a.internalDebug(e.message)})})}; | ||
//# sourceMappingURL=maps/modbus-client.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";module.exports=function(i){require("source-map-support").install();var n=require("./modbus-basics"),s=require("debug")("contribModbus:flex:connector");i.nodes.registerType("modbus-flex-connector",function(e){i.nodes.createNode(this,e),this.name=e.name,this.maxReconnectsPerMinute=e.maxReconnectsPerMinute||4,this.emptyQueue=e.emptyQueue,this.showStatusActivities=e.showStatusActivities,this.showErrors=e.showErrors,this.connection=null,this.internalDebugLog=s;var t=this;n.setNodeStatusTo("waiting",t);var o=i.nodes.getNode(e.server);o&&(o.registerForModbus(t),n.initModbusClientEvents(t,o),t.on("input",function(e){n.invalidPayloadIn(e)||o.client&&(t.showStatusActivities&&n.setNodeStatusTo(o.actualServiceState,t),e.payload.connectorType?(s("dynamicReconnect: "+JSON.stringify(e.payload)),e.payload.emptyQueue=t.emptyQueue,o.emit("dynamicReconnect",e)):t.error(new Error("Payload Not Valid - Connector Type"),e))}))})}; | ||
"use strict";module.exports=function(t){require("source-map-support").install();var s=require("./modbus-basics"),i=require("debug")("contribModbus:flex:connector");t.nodes.registerType("modbus-flex-connector",function(e){t.nodes.createNode(this,e),this.name=e.name,this.maxReconnectsPerMinute=e.maxReconnectsPerMinute||4,this.emptyQueue=e.emptyQueue,this.showStatusActivities=e.showStatusActivities,this.showErrors=e.showErrors,this.connection=null,this.internalDebugLog=i;var o=this;s.setNodeStatusTo("waiting",o);var n=t.nodes.getNode(e.server);n&&(n.registerForModbus(o),s.initModbusClientEvents(o,n),o.onConfigDone=function(e){o.showStatusActivities&&s.setNodeStatusTo("config done",o),e.config_change="emitted",o.send(e)},o.onConfigError=function(e,t){i(e.message),o.showErrors&&o.error(e,t),o.emptyMsgOnFail?o.send({payload:"",error:e,status:o.status,msg:t}):(t.error=e,o.send(t))},o.on("input",function(e){if(!s.invalidPayloadIn(e)&&n.client)if(o.showStatusActivities&&s.setNodeStatusTo(n.actualServiceState,o),e.payload.connectorType)i("dynamicReconnect: "+JSON.stringify(e.payload)),e.payload.emptyQueue=o.emptyQueue,n.emit("dynamicReconnect",e,o.onConfigDone,o.onConfigError);else{var t="Payload Not Valid - Connector Type";o.error(new Error(t),e),e.error=t,o.send(e)}}))})}; | ||
//# sourceMappingURL=maps/modbus-flex-connector.js.map |
{ | ||
"name": "node-red-contrib-modbus", | ||
"version": "5.4.0-alpha.0", | ||
"version": "5.4.0-alpha.2", | ||
"private": false, | ||
"description": "The all in one Modbus TCP and Serial contribution package for Node-RED.", | ||
"dependencies": { | ||
"bson": "^4.0.3", | ||
"debug": "^4.1.1", | ||
"jsmodbus": "^4.0.2", | ||
"line-by-line": "^0.1.6", | ||
"modbus-serial": "^7.8.1", | ||
"source-map-support": "^0.5.16", | ||
"vm2": "^3.8.4", | ||
"@xstate/fsm": "^1.3.0" | ||
"bson": "~4.0.3", | ||
"debug": "~4.1.1", | ||
"jsmodbus": "~4.0.2", | ||
"line-by-line": "~0.1.6", | ||
"modbus-serial": "~7.8.1", | ||
"source-map-support": "~0.5.16", | ||
"vm2": "~3.8.4", | ||
"@xstate/fsm": "~1.3.0" | ||
}, | ||
"optionalDependencies": { | ||
"serialport": "^8.0.7", | ||
"@serialport/list": "^8.0.7" | ||
"serialport": "~8.0.7", | ||
"@serialport/list": "~8.0.7" | ||
}, | ||
@@ -72,5 +72,7 @@ "keywords": [ | ||
"release": "standard-version -a", | ||
"release:beta": "standard-version --prerelease beta", | ||
"release:alpha": "standard-version --prerelease alpha", | ||
"rewrite-changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", | ||
"postinstall": "node ./supporter.js", | ||
"dev-link": "npm i && npm link && cd ~/.node-red && npm link node-red-contrib-modbus" | ||
"dev-link": "npm i && npm run build && npm link && cd ~/.node-red && npm link node-red-contrib-modbus" | ||
}, | ||
@@ -77,0 +79,0 @@ "devDependencies": { |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8249143
138416
+ Added@xstate/fsm@1.3.0(transitive)
+ Addedbson@4.0.4(transitive)
+ Addeddebug@4.1.1(transitive)
+ Addedlong@4.0.0(transitive)
+ Addedvm2@3.8.4(transitive)
- Removed@xstate/fsm@1.6.5(transitive)
- Removedacorn@8.14.0(transitive)
- Removedacorn-walk@8.3.4(transitive)
- Removedbson@4.7.2(transitive)
- Removeddebug@4.4.0(transitive)
- Removedvm2@3.9.19(transitive)
Updated@xstate/fsm@~1.3.0
Updatedbson@~4.0.3
Updateddebug@~4.1.1
Updatedjsmodbus@~4.0.2
Updatedline-by-line@~0.1.6
Updatedmodbus-serial@~7.8.1
Updatedsource-map-support@~0.5.16
Updatedvm2@~3.8.4