node-red-contrib-modbus
Advanced tools
Comparing version 5.27.1 to 5.27.2
@@ -9,3 +9,5 @@ { | ||
"requestMap": "Request Map Editor", | ||
"responseMap": "Response Map Editor" | ||
"responseMap": "Response Map Editor", | ||
"functioncode": "Select FC Map", | ||
"mapPath": "Path to Map JSON" | ||
}, | ||
@@ -12,0 +14,0 @@ "tabs-label": { |
@@ -1,2 +0,2 @@ | ||
"use strict";module.exports=function(a){require("source-map-support").install();var c=require("./modbus-basics"),u=require("./core/modbus-client-core"),l=require("./core/modbus-queue-core"),d=require("debug")("contribModbus:config:client"),m=require("underscore");a.nodes.registerType("modbus-client",function(e){a.nodes.createNode(this,e);var t=require("@plus4nodered/modbus-serial"),n=500,i=" Get More About It By Logging",r=(this.clienttype=e.clienttype,void 0===e.parallelUnitIdsAllowed?this.bufferCommands=!0:this.bufferCommands=e.bufferCommands,this.queueLogEnabled=e.queueLogEnabled,this.stateLogEnabled=e.stateLogEnabled,this.failureLogEnabled=e.failureLogEnabled,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)||n,this.serialAsciiResponseStartDelimiter=e.serialAsciiResponseStartDelimiter||"0x3A",this.unit_id=parseInt(e.unit_id),this.commandDelay=parseInt(e.commandDelay)||1,this.clientTimeout=parseInt(e.clientTimeout)||1e3,this.reconnectTimeout=parseInt(e.reconnectTimeout)||2e3,this.reconnectOnTimeout=e.reconnectOnTimeout,void 0===e.parallelUnitIdsAllowed?this.parallelUnitIdsAllowed=!0:this.parallelUnitIdsAllowed=e.parallelUnitIdsAllowed,this.showErrors=e.showErrors,this.showWarnings=e.showWarnings,this.showLogs=e.showLogs,this);function o(e){a.settings.verbose&&r.showWarnings&&(r.updateServerinfo(),r.warn("Client -> "+e+" "+r.serverInfo))}function s(e){a.settings.verbose&&r.showLogs&&u.internalDebug("Client -> "+e+" "+r.serverInfo)}r.isFirstInitOfConnection=!0,r.closingModbus=!1,r.client=null,r.bufferCommandList=new Map,r.sendingAllowed=new Map,r.unitSendingAllowed=[],r.messageAllowedStates=u.messageAllowedStates,r.serverInfo="",r.stateMachine=null,r.stateService=null,r.stateMachine=u.createStateMachineService(),r.actualServiceState=r.stateMachine.initialState,r.actualServiceStateBefore=r.actualServiceState,r.stateService=u.startStateService(r.stateMachine),r.reconnectTimeoutId=0,r.serialSendingAllowed=!1,r.internalDebugLog=d,l.queueSerialLockCommand(r),r.setDefaultUnitId=function(){"tcp"===this.clienttype?r.unit_id=0:r.unit_id=1},r.setUnitIdFromPayload=function(e){var t=u.getActualUnitId(r,e);u.checkUnitId(t,r.clienttype)||r.setDefaultUnitId(),r.client.setID(t),e.unitId=t},!Number.isNaN(r.unit_id)&&u.checkUnitId(r.unit_id,r.clienttype)||r.setDefaultUnitId(),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.errorProtocolMsg=function(e,t){r.showErrors&&c.logMsgError(r,e,t)},r.queueLog=function(e){r.bufferCommands&&r.queueLogEnabled&&s(e)},r.stateService.subscribe(function(e){var t;if(r.actualServiceStateBefore=r.actualServiceState,r.actualServiceState=e,t=e.value,r.stateLogEnabled&&s(t),e.value&&void 0!==r.actualServiceState.value&&r.actualServiceStateBefore.value!==r.actualServiceState.value){if(e.matches("init")){o("fsm init state after "+r.actualServiceStateBefore.value),r.updateServerinfo(),l.initQueue(r),r.reconnectTimeoutId=0;try{r.isFirstInitOfConnection?(r.isFirstInitOfConnection=!1,o("first fsm init in 500 ms"),setTimeout(r.connectClient,n)):(o("fsm init in "+r.reconnectTimeout+" ms"),setTimeout(r.connectClient,r.reconnectTimeout))}catch(e){r.error(e,{payload:"client connection error "+i})}r.emit("mbinit")}e.matches("connected")&&(o("fsm connected after state "+r.actualServiceStateBefore.value+i),l.queueSerialUnlockCommand(r),r.emit("mbconnected")),e.matches("activated")&&(r.emit("mbactive"),r.bufferCommands)&&!l.checkQueuesAreEmpty(r)&&r.stateService.send("QUEUE"),e.matches("queueing")&&("tcp"===r.clienttype?r.stateService.send("SEND"):r.serialSendingAllowed&&(l.queueSerialLockCommand(r),r.stateService.send("SEND"))),e.matches("sending")&&(setTimeout(function(){l.dequeueCommand(r)},r.commandDelay),r.emit("mbqueue")),e.matches("opened")&&(l.queueSerialUnlockCommand(r),r.emit("mbopen")),e.matches("switch")&&(r.emit("mbswitch"),r.stateService.send("CLOSE")),e.matches("closed")&&(r.emit("mbclosed"),r.stateService.send("RECONNECT")),e.matches("stopped")&&(o("stopped state without reconnecting"),r.emit("mbclosed")),e.matches("failed")&&(o("fsm failed state after "+r.actualServiceStateBefore.value+i),r.emit("mberror","Modbus Failure On State "+r.actualServiceStateBefore.value+i),r.stateService.send("BREAK")),e.matches("broken")&&(o("fsm broken state after "+r.actualServiceStateBefore.value+i),r.emit("mbbroken","Modbus Broken On State "+r.actualServiceStateBefore.value+i),r.reconnectOnTimeout?r.stateService.send("RECONNECT"):r.stateService.send("ACTIVATE")),e.matches("reconnecting")&&(o("fsm reconnect state after "+r.actualServiceStateBefore.value+i),l.queueSerialLockCommand(r),r.emit("mbreconnecting"),r.reconnectTimeout<=0&&(r.reconnectTimeout=2e3),setTimeout(function(){r.reconnectTimeoutId=0,r.stateService.send("INIT")},r.reconnectTimeout))}}),r.connectClient=function(){try{if(r.client)try{r.client.close(function(){s("connection closed")}),s("connection close sent")}catch(e){s(e.message)}if(r.client=null,r.client=new t,r.client.on("error",function(e){r.modbusErrorHandling(e),c.setNodeStatusTo("error",r)}),r.clientTimeout||(r.clientTimeout=1e3),r.reconnectTimeout||(r.reconnectTimeout=2e3),"tcp"===r.clienttype){if(!u.checkUnitId(r.unit_id,r.clienttype))return r.error(new Error("wrong unit-id (0..255)"),{payload:r.unit_id}),r.stateService.send("FAILURE"),!1;try{switch(r.tcpType){case"C701":s("C701 port UDP bridge"),r.client.connectC701(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).then(r.setTCPConnected).catch(function(e){return r.modbusTcpErrorHandling(e),!1});break;case"TELNET":s("Telnet port"),r.client.connectTelnet(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(function(e){return r.modbusTcpErrorHandling(e),!1});break;case"TCP-RTU-BUFFERED":s("TCP RTU buffered port"),r.client.connectTcpRTUBuffered(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(function(e){return r.modbusTcpErrorHandling(e),!1});break;default:s("TCP port"),r.client.connectTCP(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(function(e){return r.modbusTcpErrorHandling(e),!1})}}catch(e){return r.modbusTcpErrorHandling(e),!1}}else{if(!u.checkUnitId(r.unit_id,r.clienttype))return r.error(new Error("wrong unit-id serial (0..247)"),{payload:r.unit_id}),r.stateService.send("FAILURE"),!1;if(r.serialConnectionDelay||(r.serialConnectionDelay=n),!r.serialPort)return r.error(new Error("wrong serial port"),{payload:r.serialPort}),r.stateService.send("FAILURE"),!1;var e={baudRate:parseInt(r.serialBaudrate),dataBits:parseInt(r.serialDatabits),stopBits:parseInt(r.serialStopbits),parity:r.serialParity,autoOpen:!1};try{switch(r.serialType){case"ASCII":s("ASCII port serial"),r.serialAsciiResponseStartDelimiter&&"string"==typeof r.serialAsciiResponseStartDelimiter?e.startOfSlaveFrameChar=parseInt(r.serialAsciiResponseStartDelimiter,16):e.startOfSlaveFrameChar=r.serialAsciiResponseStartDelimiter,s("Using response delimiter: 0x"+e.startOfSlaveFrameChar.toString(16)),r.client.connectAsciiSerial(r.serialPort,e).then(r.setSerialConnectionOptions).catch(function(e){return r.modbusSerialErrorHandling(e),!1});break;case"RTU":s("RTU port serial"),r.client.connectRTU(r.serialPort,e).then(r.setSerialConnectionOptions).catch(function(e){return r.modbusSerialErrorHandling(e),!1});break;default:s("RTU buffered port serial"),r.client.connectRTUBuffered(r.serialPort,e).then(r.setSerialConnectionOptions).catch(function(e){return r.modbusSerialErrorHandling(e),!1})}}catch(e){return r.modbusSerialErrorHandling(e),!1}}}catch(e){return r.modbusErrorHandling(e),!1}return!0},r.setTCPConnectionOptions=function(){r.client.setID(r.unit_id),r.client.setTimeout(r.clientTimeout),r.stateService.send("CONNECT")},r.setTCPConnected=function(){u.modbusSerialDebug("modbus tcp connected on "+r.tcpHost)},r.setSerialConnectionOptions=function(){r.stateService.send("OPENSERIAL"),setTimeout(r.openSerialClient,parseInt(r.serialConnectionDelay))},r.modbusErrorHandling=function(e){l.queueSerialUnlockCommand(r),e.message?u.modbusSerialDebug("modbusErrorHandling:"+e.message):u.modbusSerialDebug("modbusErrorHandling:"+JSON.stringify(e)),e.errno&&u.networkErrors.includes(e.errno)&&r.stateService.send("FAILURE")},r.modbusTcpErrorHandling=function(e){l.queueSerialUnlockCommand(r),r.showErrors&&r.error(e),r.failureLogEnabled&&(e.message?u.modbusSerialDebug("modbusTcpErrorHandling:"+e.message):u.modbusSerialDebug("modbusTcpErrorHandling:"+JSON.stringify(e))),(e.errno&&u.networkErrors.includes(e.errno)||e.code&&u.networkErrors.includes(e.code))&&r.stateService.send("BREAK")},r.modbusSerialErrorHandling=function(e){l.queueSerialUnlockCommand(r),r.showErrors&&r.error(e),r.failureLogEnabled&&(e.message?u.modbusSerialDebug("modbusSerialErrorHandling:"+e.message):u.modbusSerialDebug("modbusSerialErrorHandling:"+JSON.stringify(e))),r.stateService.send("BREAK")},r.openSerialClient=function(){"opened"===r.actualServiceState.value?(s("time to open Unit "+r.unit_id),u.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")):(s("wrong state on connect serial "+r.actualServiceState.value),u.modbusSerialDebug("modbus connection not opened state is %s",r.actualServiceState.value),r.stateService.send("BREAK"))},r.onModbusClose=function(){l.queueSerialUnlockCommand(r),o("Modbus closed port"),u.modbusSerialDebug("modbus closed port"),r.stateService.send("CLOSE")},r.on("customModbusMessage",function(e,t,n){u.customModbusMessage(r,e,t,n)}),r.on("readModbus",function(t,e,n){var i=r.actualServiceState;r.isInactive()?n(new Error("Client Not Ready To Read At State "+i.value),t):r.bufferCommands?l.pushToQueueByUnitId(r,u.readModbus,t,e,n).then(function(){r.queueLog(JSON.stringify({info:"queued read msg",message:t.payload,state:i.value,queueLength:r.bufferCommandList.get(t.queueUnitId).length}))}).catch(function(e){n(e,t)}).finally(function(){r.stateService.send("QUEUE")}):u.readModbus(r,t,e,n)}),r.on("writeModbus",function(t,e,n){var i=r.actualServiceState;r.isInactive()?n(new Error("Client Not Ready To Write At State "+i.value),t):r.bufferCommands?l.pushToQueueByUnitId(r,u.writeModbus,t,e,n).then(function(){r.queueLog(JSON.stringify({info:"queued write msg",message:t.payload,state:i.value,queueLength:r.bufferCommandList.get(t.queueUnitId).length}))}).catch(function(e){n(e,t)}).finally(function(){r.stateService.send("QUEUE")}):u.writeModbus(r,t,e,n)}),r.activateSending=function(n){return r.sendingAllowed.set(n.queueUnitId,!0),l.queueSerialUnlockCommand(r),new Promise(function(e,t){try{r.bufferCommands&&(r.queueLog(JSON.stringify({info:"queue response activate sending",queueLength:r.bufferCommandList.length,sendingAllowed:r.sendingAllowed.get(n.queueUnitId),serialSendingAllowed:r.serialSendingAllowed,queueUnitId:n.queueUnitId})),l.checkQueuesAreEmpty(r))&&r.stateService.send("EMPTY"),e()}catch(e){t(e)}})},s("initialized"),r.setMaxListeners(0),r.on("reconnect",function(){r.stateService.send("CLOSE")}),r.on("dynamicReconnect",function(e,t,n){if(c.invalidPayloadIn(e))throw new Error("Message Or Payload Not Valid");u.internalDebug("Dynamic Reconnect Parameters "+JSON.stringify(e.payload)),u.setNewNodeSettings(r,e)?t(e):n(new Error("Message Or Payload Not Valid"),e),u.internalDebug("Dynamic Reconnect Starts on actual state "+r.actualServiceState.value),r.stateService.send("SWITCH")}),r.on("close",function(t){var n=r.name||r.id;r.closingModbus=!0,s("stop fsm on close "+n),r.stateService.send("STOP"),s("close node "+n),r.internalDebugLog("close node "+n),r.removeAllListeners(),r.client?r.client.isOpen?r.client.close(function(e){s(e?"Connection closed with error "+n:"Connection closed well "+n),t()}):(s("connection was closed "+n),t()):(s("Connection closed simple "+n),t())}),r.registeredNodeList={},r.registerForModbus=function(e){r.registeredNodeList[e]=e,1===Object.keys(r.registeredNodeList).length&&(r.closingModbus=!1,r.stateService.send("NEW"),r.stateService.send("INIT")),r.emit("mbregister",e)},r.setStoppedState=function(e,t){r.stateService.send("STOP"),r.emit("mbderegister",e),t()},r.closeConnectionWithoutRegisteredNodes=function(e,t){0===Object.keys(r.registeredNodeList).length&&(r.closingModbus=!0,r.client)&&"stopped"!==r.actualServiceState.value&&r.client.isOpen?r.client.close(function(){r.setStoppedState(e,t)}):r.setStoppedState(e,t)},r.deregisterForModbus=function(t,n){try{delete r.registeredNodeList[t],r.closingModbus?(n(),r.emit("mbderegister",t)):r.closeConnectionWithoutRegisteredNodes(t,n)}catch(e){o(e.message+" on de-register node "+t),r.error(e),n()}},r.isInactive=function(){return m.isUndefined(r.actualServiceState)||-1===r.messageAllowedStates.indexOf(r.actualServiceState.value)},r.isActive=function(){return!r.isInactive()},r.isReadyToSend=function(e){return!!e.actualServiceState.matches("queueing")||(o("Client not ready to send"),!1)}}),a.httpAdmin.get("/modbus/serial/ports",a.auth.needsPermission("serial.read"),function(e,t){require("serialport").SerialPort.list().then(function(e){t.json(e)}).catch(function(e){t.json([e.message]),u.internalDebug(e.message)})})}; | ||
"use strict";module.exports=function(a){require("source-map-support").install();var c=require("./modbus-basics"),u=require("./core/modbus-client-core"),l=require("./core/modbus-queue-core"),d=require("debug")("contribModbus:config:client"),m=require("underscore");a.nodes.registerType("modbus-client",function(e){a.nodes.createNode(this,e);var t=require("@open-p4nr/modbus-serial"),n=500,i=" Get More About It By Logging",r=(this.clienttype=e.clienttype,void 0===e.parallelUnitIdsAllowed?this.bufferCommands=!0:this.bufferCommands=e.bufferCommands,this.queueLogEnabled=e.queueLogEnabled,this.stateLogEnabled=e.stateLogEnabled,this.failureLogEnabled=e.failureLogEnabled,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)||n,this.serialAsciiResponseStartDelimiter=e.serialAsciiResponseStartDelimiter||"0x3A",this.unit_id=parseInt(e.unit_id),this.commandDelay=parseInt(e.commandDelay)||1,this.clientTimeout=parseInt(e.clientTimeout)||1e3,this.reconnectTimeout=parseInt(e.reconnectTimeout)||2e3,this.reconnectOnTimeout=e.reconnectOnTimeout,void 0===e.parallelUnitIdsAllowed?this.parallelUnitIdsAllowed=!0:this.parallelUnitIdsAllowed=e.parallelUnitIdsAllowed,this.showErrors=e.showErrors,this.showWarnings=e.showWarnings,this.showLogs=e.showLogs,this);function o(e){a.settings.verbose&&r.showWarnings&&(r.updateServerinfo(),r.warn("Client -> "+e+" "+r.serverInfo))}function s(e){a.settings.verbose&&r.showLogs&&u.internalDebug("Client -> "+e+" "+r.serverInfo)}r.isFirstInitOfConnection=!0,r.closingModbus=!1,r.client=null,r.bufferCommandList=new Map,r.sendingAllowed=new Map,r.unitSendingAllowed=[],r.messageAllowedStates=u.messageAllowedStates,r.serverInfo="",r.stateMachine=null,r.stateService=null,r.stateMachine=u.createStateMachineService(),r.actualServiceState=r.stateMachine.initialState,r.actualServiceStateBefore=r.actualServiceState,r.stateService=u.startStateService(r.stateMachine),r.reconnectTimeoutId=0,r.serialSendingAllowed=!1,r.internalDebugLog=d,l.queueSerialLockCommand(r),r.setDefaultUnitId=function(){"tcp"===this.clienttype?r.unit_id=0:r.unit_id=1},r.setUnitIdFromPayload=function(e){var t=u.getActualUnitId(r,e);u.checkUnitId(t,r.clienttype)||r.setDefaultUnitId(),r.client.setID(t),e.unitId=t},!Number.isNaN(r.unit_id)&&u.checkUnitId(r.unit_id,r.clienttype)||r.setDefaultUnitId(),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.errorProtocolMsg=function(e,t){r.showErrors&&c.logMsgError(r,e,t)},r.queueLog=function(e){r.bufferCommands&&r.queueLogEnabled&&s(e)},r.stateService.subscribe(function(e){var t;if(r.actualServiceStateBefore=r.actualServiceState,r.actualServiceState=e,t=e.value,r.stateLogEnabled&&s(t),e.value&&void 0!==r.actualServiceState.value&&r.actualServiceStateBefore.value!==r.actualServiceState.value){if(e.matches("init")){o("fsm init state after "+r.actualServiceStateBefore.value),r.updateServerinfo(),l.initQueue(r),r.reconnectTimeoutId=0;try{r.isFirstInitOfConnection?(r.isFirstInitOfConnection=!1,o("first fsm init in 500 ms"),setTimeout(r.connectClient,n)):(o("fsm init in "+r.reconnectTimeout+" ms"),setTimeout(r.connectClient,r.reconnectTimeout))}catch(e){r.error(e,{payload:"client connection error "+i})}r.emit("mbinit")}e.matches("connected")&&(o("fsm connected after state "+r.actualServiceStateBefore.value+i),l.queueSerialUnlockCommand(r),r.emit("mbconnected")),e.matches("activated")&&(r.emit("mbactive"),r.bufferCommands)&&!l.checkQueuesAreEmpty(r)&&r.stateService.send("QUEUE"),e.matches("queueing")&&("tcp"===r.clienttype?r.stateService.send("SEND"):r.serialSendingAllowed&&(l.queueSerialLockCommand(r),r.stateService.send("SEND"))),e.matches("sending")&&(setTimeout(function(){l.dequeueCommand(r)},r.commandDelay),r.emit("mbqueue")),e.matches("opened")&&(l.queueSerialUnlockCommand(r),r.emit("mbopen")),e.matches("switch")&&(r.emit("mbswitch"),r.stateService.send("CLOSE")),e.matches("closed")&&(r.emit("mbclosed"),r.stateService.send("RECONNECT")),e.matches("stopped")&&(o("stopped state without reconnecting"),r.emit("mbclosed")),e.matches("failed")&&(o("fsm failed state after "+r.actualServiceStateBefore.value+i),r.emit("mberror","Modbus Failure On State "+r.actualServiceStateBefore.value+i),r.stateService.send("BREAK")),e.matches("broken")&&(o("fsm broken state after "+r.actualServiceStateBefore.value+i),r.emit("mbbroken","Modbus Broken On State "+r.actualServiceStateBefore.value+i),r.reconnectOnTimeout?r.stateService.send("RECONNECT"):r.stateService.send("ACTIVATE")),e.matches("reconnecting")&&(o("fsm reconnect state after "+r.actualServiceStateBefore.value+i),l.queueSerialLockCommand(r),r.emit("mbreconnecting"),r.reconnectTimeout<=0&&(r.reconnectTimeout=2e3),setTimeout(function(){r.reconnectTimeoutId=0,r.stateService.send("INIT")},r.reconnectTimeout))}}),r.connectClient=function(){try{if(r.client)try{r.client.close(function(){s("connection closed")}),s("connection close sent")}catch(e){s(e.message)}if(r.client=null,r.client=new t,r.client.on("error",function(e){r.modbusErrorHandling(e),c.setNodeStatusTo("error",r)}),r.clientTimeout||(r.clientTimeout=1e3),r.reconnectTimeout||(r.reconnectTimeout=2e3),"tcp"===r.clienttype){if(!u.checkUnitId(r.unit_id,r.clienttype))return r.error(new Error("wrong unit-id (0..255)"),{payload:r.unit_id}),r.stateService.send("FAILURE"),!1;try{switch(r.tcpType){case"C701":s("C701 port UDP bridge"),r.client.connectC701(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).then(r.setTCPConnected).catch(function(e){return r.modbusTcpErrorHandling(e),!1});break;case"TELNET":s("Telnet port"),r.client.connectTelnet(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(function(e){return r.modbusTcpErrorHandling(e),!1});break;case"TCP-RTU-BUFFERED":s("TCP RTU buffered port"),r.client.connectTcpRTUBuffered(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(function(e){return r.modbusTcpErrorHandling(e),!1});break;default:s("TCP port"),r.client.connectTCP(r.tcpHost,{port:r.tcpPort,autoOpen:!0}).then(r.setTCPConnectionOptions).catch(function(e){return r.modbusTcpErrorHandling(e),!1})}}catch(e){return r.modbusTcpErrorHandling(e),!1}}else{if(!u.checkUnitId(r.unit_id,r.clienttype))return r.error(new Error("wrong unit-id serial (0..247)"),{payload:r.unit_id}),r.stateService.send("FAILURE"),!1;if(r.serialConnectionDelay||(r.serialConnectionDelay=n),!r.serialPort)return r.error(new Error("wrong serial port"),{payload:r.serialPort}),r.stateService.send("FAILURE"),!1;var e={baudRate:parseInt(r.serialBaudrate),dataBits:parseInt(r.serialDatabits),stopBits:parseInt(r.serialStopbits),parity:r.serialParity,autoOpen:!1};try{switch(r.serialType){case"ASCII":s("ASCII port serial"),r.serialAsciiResponseStartDelimiter&&"string"==typeof r.serialAsciiResponseStartDelimiter?e.startOfSlaveFrameChar=parseInt(r.serialAsciiResponseStartDelimiter,16):e.startOfSlaveFrameChar=r.serialAsciiResponseStartDelimiter,s("Using response delimiter: 0x"+e.startOfSlaveFrameChar.toString(16)),r.client.connectAsciiSerial(r.serialPort,e).then(r.setSerialConnectionOptions).catch(function(e){return r.modbusSerialErrorHandling(e),!1});break;case"RTU":s("RTU port serial"),r.client.connectRTU(r.serialPort,e).then(r.setSerialConnectionOptions).catch(function(e){return r.modbusSerialErrorHandling(e),!1});break;default:s("RTU buffered port serial"),r.client.connectRTUBuffered(r.serialPort,e).then(r.setSerialConnectionOptions).catch(function(e){return r.modbusSerialErrorHandling(e),!1})}}catch(e){return r.modbusSerialErrorHandling(e),!1}}}catch(e){return r.modbusErrorHandling(e),!1}return!0},r.setTCPConnectionOptions=function(){r.client.setID(r.unit_id),r.client.setTimeout(r.clientTimeout),r.stateService.send("CONNECT")},r.setTCPConnected=function(){u.modbusSerialDebug("modbus tcp connected on "+r.tcpHost)},r.setSerialConnectionOptions=function(){r.stateService.send("OPENSERIAL"),setTimeout(r.openSerialClient,parseInt(r.serialConnectionDelay))},r.modbusErrorHandling=function(e){l.queueSerialUnlockCommand(r),e.message?u.modbusSerialDebug("modbusErrorHandling:"+e.message):u.modbusSerialDebug("modbusErrorHandling:"+JSON.stringify(e)),e.errno&&u.networkErrors.includes(e.errno)&&r.stateService.send("FAILURE")},r.modbusTcpErrorHandling=function(e){l.queueSerialUnlockCommand(r),r.showErrors&&r.error(e),r.failureLogEnabled&&(e.message?u.modbusSerialDebug("modbusTcpErrorHandling:"+e.message):u.modbusSerialDebug("modbusTcpErrorHandling:"+JSON.stringify(e))),(e.errno&&u.networkErrors.includes(e.errno)||e.code&&u.networkErrors.includes(e.code))&&r.stateService.send("BREAK")},r.modbusSerialErrorHandling=function(e){l.queueSerialUnlockCommand(r),r.showErrors&&r.error(e),r.failureLogEnabled&&(e.message?u.modbusSerialDebug("modbusSerialErrorHandling:"+e.message):u.modbusSerialDebug("modbusSerialErrorHandling:"+JSON.stringify(e))),r.stateService.send("BREAK")},r.openSerialClient=function(){"opened"===r.actualServiceState.value?(s("time to open Unit "+r.unit_id),u.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")):(s("wrong state on connect serial "+r.actualServiceState.value),u.modbusSerialDebug("modbus connection not opened state is %s",r.actualServiceState.value),r.stateService.send("BREAK"))},r.onModbusClose=function(){l.queueSerialUnlockCommand(r),o("Modbus closed port"),u.modbusSerialDebug("modbus closed port"),r.stateService.send("CLOSE")},r.on("customModbusMessage",function(e,t,n){u.customModbusMessage(r,e,t,n)}),r.on("readModbus",function(t,e,n){var i=r.actualServiceState;r.isInactive()?n(new Error("Client Not Ready To Read At State "+i.value),t):r.bufferCommands?l.pushToQueueByUnitId(r,u.readModbus,t,e,n).then(function(){r.queueLog(JSON.stringify({info:"queued read msg",message:t.payload,state:i.value,queueLength:r.bufferCommandList.get(t.queueUnitId).length}))}).catch(function(e){n(e,t)}).finally(function(){r.stateService.send("QUEUE")}):u.readModbus(r,t,e,n)}),r.on("writeModbus",function(t,e,n){var i=r.actualServiceState;r.isInactive()?n(new Error("Client Not Ready To Write At State "+i.value),t):r.bufferCommands?l.pushToQueueByUnitId(r,u.writeModbus,t,e,n).then(function(){r.queueLog(JSON.stringify({info:"queued write msg",message:t.payload,state:i.value,queueLength:r.bufferCommandList.get(t.queueUnitId).length}))}).catch(function(e){n(e,t)}).finally(function(){r.stateService.send("QUEUE")}):u.writeModbus(r,t,e,n)}),r.activateSending=function(n){return r.sendingAllowed.set(n.queueUnitId,!0),l.queueSerialUnlockCommand(r),new Promise(function(e,t){try{r.bufferCommands&&(r.queueLog(JSON.stringify({info:"queue response activate sending",queueLength:r.bufferCommandList.length,sendingAllowed:r.sendingAllowed.get(n.queueUnitId),serialSendingAllowed:r.serialSendingAllowed,queueUnitId:n.queueUnitId})),l.checkQueuesAreEmpty(r))&&r.stateService.send("EMPTY"),e()}catch(e){t(e)}})},s("initialized"),r.setMaxListeners(0),r.on("reconnect",function(){r.stateService.send("CLOSE")}),r.on("dynamicReconnect",function(e,t,n){if(c.invalidPayloadIn(e))throw new Error("Message Or Payload Not Valid");u.internalDebug("Dynamic Reconnect Parameters "+JSON.stringify(e.payload)),u.setNewNodeSettings(r,e)?t(e):n(new Error("Message Or Payload Not Valid"),e),u.internalDebug("Dynamic Reconnect Starts on actual state "+r.actualServiceState.value),r.stateService.send("SWITCH")}),r.on("close",function(t){var n=r.name||r.id;r.closingModbus=!0,s("stop fsm on close "+n),r.stateService.send("STOP"),s("close node "+n),r.internalDebugLog("close node "+n),r.removeAllListeners(),r.client?r.client.isOpen?r.client.close(function(e){s(e?"Connection closed with error "+n:"Connection closed well "+n),t()}):(s("connection was closed "+n),t()):(s("Connection closed simple "+n),t())}),r.registeredNodeList={},r.registerForModbus=function(e){r.registeredNodeList[e]=e,1===Object.keys(r.registeredNodeList).length&&(r.closingModbus=!1,r.stateService.send("NEW"),r.stateService.send("INIT")),r.emit("mbregister",e)},r.setStoppedState=function(e,t){r.stateService.send("STOP"),r.emit("mbderegister",e),t()},r.closeConnectionWithoutRegisteredNodes=function(e,t){0===Object.keys(r.registeredNodeList).length&&(r.closingModbus=!0,r.client)&&"stopped"!==r.actualServiceState.value&&r.client.isOpen?r.client.close(function(){r.setStoppedState(e,t)}):r.setStoppedState(e,t)},r.deregisterForModbus=function(t,n){try{delete r.registeredNodeList[t],r.closingModbus?(n(),r.emit("mbderegister",t)):r.closeConnectionWithoutRegisteredNodes(t,n)}catch(e){o(e.message+" on de-register node "+t),r.error(e),n()}},r.isInactive=function(){return m.isUndefined(r.actualServiceState)||-1===r.messageAllowedStates.indexOf(r.actualServiceState.value)},r.isActive=function(){return!r.isInactive()},r.isReadyToSend=function(e){return!!e.actualServiceState.matches("queueing")||(o("Client not ready to send"),!1)}}),a.httpAdmin.get("/modbus/serial/ports",a.auth.needsPermission("serial.read"),function(e,t){require("serialport").SerialPort.list().then(function(e){t.json(e)}).catch(function(e){t.json([e.message]),u.internalDebug(e.message)})})}; | ||
//# sourceMappingURL=maps/modbus-client.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";module.exports=function(r){require("source-map-support").install();var i=require("./modbus-basics"),d=require("./core/modbus-core"),u=require("debug")("contribModbus:read");r.nodes.registerType("modbus-flex-fc",function(e){r.nodes.createNode(this,e),this.name=e.name,this.topic=e.topic,this.unitid=e.unitid,this.showStatusActivities=e.showStatusActivities,this.showErrors=e.showErrors,this.showWarnings=e.showWarnings,this.connection=null,this.emptyMsgOnFail=e.emptyMsgOnFail,this.internalDebugLog=u,this.verboseLogging=r.settings.verbose,this.fc=e.fc,this.requestCard=e.requestCard,this.responseCard=e.responseCard;var n=this;function o(e){r.settings.verbose&&n.showWarnings&&n.warn("Read -> "+e+" address: "+n.adr)}n.statusText="waiting",t(n.statusText),o("open node "+n.id);var s=r.nodes.getNode(e.server);function t(e){var e=i.setNodeStatusProperties(e,n.showStatusActivities),o=n.statusText,s=e.status;s!==o&&n.status({fill:e.fill,shape:e.shape,text:s})}s&&(n.onModbusInit=function(){t("initialized")},n.onModbusConnect=function(){t("connected"),n.modbusRead()},n.onModbusRegister=function(){n.showStatusActivities&&t("registered"),s.serialSendingAllowed&&t("connected")},n.onModbusActive=function(){t("active")},n.onModbusQueue=function(){t("queue")},n.onModbusError=function(e){t("failure"),n.showErrors&&n.warn(e)},n.onModbusClose=function(){t("closed")},n.onModbusBroken=function(){t("broken")},n.onModbusReadDone=function(e,o){var s;n.showStatusActivities&&t("reading done"),e.data,s=o.topic||n.topic,n.send({topic:s,payload:e,input:o,sendingNodeId:n.id})},n.errorProtocolMsg=function(e,o){n.showErrors&&i.logMsgError(n,e,o)},n.onModbusReadError=function(e,o){n.internalDebugLog(e.message),n.errorProtocolMsg(e,o),i.sendEmptyMsgOnFail(n,e,o),i.setModbusError(n,s,e,o)},n.modbusRead=function(){var e;s.client?(e={topic:"customFc",from:n.name,payload:{unitid:parseInt(n.unitid),fc:parseInt(n.fc,16),requestCard:n.requestCard,responseCard:n.responseCard,messageId:d.getObjectId()}},n.showStatusActivities&&t("reading"),s.emit("customModbusMessage",e,n.onModbusReadDone,n.onModbusReadError)):t("waiting")},n.removeNodeListenerFromModbusClient=function(){s.removeListener("mbinit",n.onModbusInit),s.removeListener("mbqueue",n.onModbusQueue),s.removeListener("mbconnected",n.onModbusConnect),s.removeListener("mbactive",n.onModbusActive),s.removeListener("mberror",n.onModbusError),s.removeListener("mbclosed",n.onModbusClose),s.removeListener("mbbroken",n.onModbusBroken),s.removeListener("mbregister",n.onModbusRegister),s.removeListener("mbderegister",n.onModbusClose)},this.on("close",function(e){n.resetAllReadingTimer(),n.removeNodeListenerFromModbusClient(),t("closed"),o("close node "+n.id),s.deregisterForModbus(n.id,e)}),n.showStatusActivities&&(s.on("mbinit",n.onModbusInit),s.on("mbqueue",n.onModbusQueue)),s.on("mbconnected",n.onModbusConnect),s.on("mbactive",n.onModbusActive),s.on("mberror",n.onModbusError),s.on("mbclosed",n.onModbusClose),s.on("mbbroken",n.onModbusBroken),s.on("mbregister",n.onModbusRegister),s.on("mbderegister",n.onModbusClose),s.registerForModbus(n))}),r.httpAdmin.get("/modbus/fc/si",r.auth.needsPermission("modbus.read"),function(e,s){var o=require("fs"),n="codes.json";o.existsSync("./extras/argumentMaps/defaults/"+n)&&o.readFile("./extras/argumentMaps/defaults/"+n,function(e,o){e&&s.json([e]),s.json(JSON.parse(o))})})}; | ||
"use strict";module.exports=function(r){require("source-map-support").install();var i=require("./modbus-basics"),d=require("./core/modbus-core"),u=require("debug")("contribModbus:read");r.nodes.registerType("modbus-flex-fc",function(e){r.nodes.createNode(this,e),this.name=e.name,this.topic=e.topic,this.unitid=e.unitid,this.showStatusActivities=e.showStatusActivities,this.showErrors=e.showErrors,this.showWarnings=e.showWarnings,this.connection=null,this.emptyMsgOnFail=e.emptyMsgOnFail,this.internalDebugLog=u,this.verboseLogging=r.settings.verbose,this.fc=e.fc,this.requestCard=e.requestCard,this.responseCard=e.responseCard;var n=this;function o(e){r.settings.verbose&&n.showWarnings&&n.warn("Read -> "+e+" address: "+n.adr)}n.statusText="waiting",t(n.statusText),o("open node "+n.id);var s=r.nodes.getNode(e.server);function t(e){var e=i.setNodeStatusProperties(e,n.showStatusActivities),o=n.statusText,s=e.status;s!==o&&n.status({fill:e.fill,shape:e.shape,text:s})}s&&(n.onModbusInit=function(){t("initialized")},n.onModbusConnect=function(){t("connected"),n.modbusRead()},n.onModbusRegister=function(){n.showStatusActivities&&t("registered"),s.serialSendingAllowed&&t("connected")},n.onModbusActive=function(){t("active")},n.onModbusQueue=function(){t("queue")},n.onModbusError=function(e){t("failure"),n.showErrors&&n.warn(e)},n.onModbusClose=function(){t("closed")},n.onModbusBroken=function(){t("broken")},n.onModbusReadDone=function(e,o){var s;n.showStatusActivities&&t("reading done"),e.data,s=o.topic||n.topic,n.send({topic:s,payload:e,input:o,sendingNodeId:n.id})},n.errorProtocolMsg=function(e,o){n.showErrors&&i.logMsgError(n,e,o)},n.onModbusReadError=function(e,o){n.internalDebugLog(e.message),n.errorProtocolMsg(e,o),i.sendEmptyMsgOnFail(n,e,o),i.setModbusError(n,s,e,o)},n.modbusRead=function(){var e;s.client?(e={topic:"customFc",from:n.name,payload:{unitid:parseInt(n.unitid),fc:parseInt(n.fc,16),requestCard:n.requestCard,responseCard:n.responseCard,messageId:d.getObjectId()}},n.showStatusActivities&&t("reading"),s.emit("customModbusMessage",e,n.onModbusReadDone,n.onModbusReadError)):t("waiting")},n.removeNodeListenerFromModbusClient=function(){s.removeListener("mbinit",n.onModbusInit),s.removeListener("mbqueue",n.onModbusQueue),s.removeListener("mbconnected",n.onModbusConnect),s.removeListener("mbactive",n.onModbusActive),s.removeListener("mberror",n.onModbusError),s.removeListener("mbclosed",n.onModbusClose),s.removeListener("mbbroken",n.onModbusBroken),s.removeListener("mbregister",n.onModbusRegister),s.removeListener("mbderegister",n.onModbusClose)},this.on("close",function(e){n.resetAllReadingTimer(),n.removeNodeListenerFromModbusClient(),t("closed"),o("close node "+n.id),s.deregisterForModbus(n.id,e)}),n.showStatusActivities&&(s.on("mbinit",n.onModbusInit),s.on("mbqueue",n.onModbusQueue)),s.on("mbconnected",n.onModbusConnect),s.on("mbactive",n.onModbusActive),s.on("mberror",n.onModbusError),s.on("mbclosed",n.onModbusClose),s.on("mbbroken",n.onModbusBroken),s.on("mbregister",n.onModbusRegister),s.on("mbderegister",n.onModbusClose),s.registerForModbus(n))}),r.httpAdmin.post("/modbus/fc/si/:id",r.auth.needsPermission("modbus.read"),function(e,s){var o=require("fs"),n=require("node:path"),e=e.body.mapPath||"./extras/argumentMaps/defaults/",t="codes.json";o.existsSync(n.resolve(e,t))&&o.readFile(n.resolve(e,t),function(e,o){e&&s.json([e]),s.json(JSON.parse(o))})})}; | ||
//# sourceMappingURL=maps/modbus-flex-fc.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";module.exports=function(i){require("source-map-support").install();var n=require("@plus4nodered/modbus-serial"),u=require("./core/modbus-server-core"),d=require("./modbus-basics"),c=require("debug")("contribModbus:flex:server");try{i.nodes.registerType("modbus-flex-server",function(e){i.nodes.createNode(this,e);var r=(s=require("vm2")).VM,s=s.VMScript,t=(this.name=e.name,this.logEnabled=e.logEnabled,this.serverAddress=e.serverAddress||"0.0.0.0",this.serverPort=parseInt(e.serverPort),this.responseDelay=parseInt(e.responseDelay),this.delayUnit=e.delayUnit,this.unitId=parseInt(e.unitId)||1,this.minAddress=parseInt(e.minAddress)||0,this.splitAddress=parseInt(e.splitAddress)||1e4,this.showErrors=e.showErrors,this.funcGetCoil=new s(e.funcGetCoil).compile(),this.funcGetDiscreteInput=new s(e.funcGetDiscreteInput).compile(),this.funcGetInputRegister=new s(e.funcGetInputRegister).compile(),this.funcGetHoldingRegister=new s(e.funcGetHoldingRegister).compile(),this.funcSetCoil=new s(e.funcSetCoil).compile(),this.funcSetRegister=new s(e.funcSetRegister).compile(),this.internalDebugLog=c,this.verboseLogging=i.settings.verbose,this);function o(e){return[{type:"holding",message:e,payload:t.registers.slice(t.splitAddress*u.bufferFactor)},{type:"coils",message:e,payload:t.coils.slice(0,t.splitAddress*u.bufferFactor)},{type:"input",message:e,payload:t.registers.slice(0,t.splitAddress*u.bufferFactor)},{type:"discrete",message:e,payload:t.coils.slice(t.splitAddress*u.bufferFactor)},{payload:"request",type:"message",message:e}]}t.bufferFactor=u.bufferFactor,t.coilsBufferSize=parseInt(e.coilsBufferSize*u.bufferFactor),t.registersBufferSize=parseInt(e.registersBufferSize*u.bufferFactor),t.coils=Buffer.alloc(t.coilsBufferSize,0),t.registers=Buffer.alloc(t.registersBufferSize,0),t.modbusServer=null,d.setNodeStatusTo("initialized",t),t.vector={},(s=new r({sandbox:{node:t}})).run("node.vector.getCoil = "+e.funcGetCoil),s.run("node.vector.getDiscreteInput = "+e.funcGetDiscreteInput),s.run("node.vector.getInputRegister = "+e.funcGetInputRegister),s.run("node.vector.getHoldingRegister = "+e.funcGetHoldingRegister),s.run("node.vector.setCoil = "+e.funcSetCoil),s.run("node.vector.setRegister = "+e.funcSetRegister),t.startServer=function(){try{if(null===t.modbusServer){try{t.modbusServer=new n.ServerTCP(t.vector,{host:t.serverAddress,port:t.serverPort,debug:t.logEnabled,unitID:t.unitId})}catch(e){t.error(e,{payload:"server net error -> for port 502 on unix, you have to be a super user"})}t.modbusServer.on("socketError",function(e){c(e.message),t.showErrors&&t.warn(e),d.setNodeStatusTo("error",t),t.modbusServer.close(function(){t.startServer()})}),t.modbusServer.on("error",function(e){c("Modbus Flex Server error"),t.showErrors&&t.error(e),d.setNodeStatusTo("error",t)}),t.modbusServer._server.on("connection",function(e){c("Modbus Flex Server client connection"),e&&c("Modbus Flex Server client to "+JSON.stringify(e.address())+" from "+e.remoteAddress+" "+e.remotePort),d.setNodeStatusTo("active",t)}),t.modbusServer._server.on("error",function(e){c("Modbus Flex Server client error"),t.showErrors&&t.error(e),d.setNodeStatusTo("error",t)})}t.showStatusActivities||d.setNodeDefaultStatus(t)}catch(e){c(e.message),t.showErrors&&t.warn(e),d.setNodeStatusTo("error",t)}null!=t.modbusServer?(c("Modbus Flex Server listening on modbus://"+t.serverAddress+":"+t.serverPort),d.setNodeStatusTo("initialized",t)):(c("Modbus Flex Server isn't ready"),d.setNodeStatusTo("error",t))},t.startServer(),t.on("input",function(e){u.isValidMemoryMessage(e)?(u.writeToFlexServerMemory(t,e),1!==e.payload.disableMsgOutput&&t.send(o(e))):(t.showErrors&&t.error("Is Not A Valid Memory Write Message To Server",e),u.isValidMessage(e)&&!e.payload.disableMsgOutput&&t.send(o(e)))}),t.on("close",function(){d.setNodeStatusTo("closed",t),t.modbusServer._server&&t.modbusServer._server.close(),t.modbusServer&&t.modbusServer.close(),t.modbusServer=null})})}catch(e){c(e.message)}}; | ||
"use strict";module.exports=function(i){require("source-map-support").install();var n=require("@open-p4nr/modbus-serial"),u=require("./core/modbus-server-core"),d=require("./modbus-basics"),c=require("debug")("contribModbus:flex:server");try{i.nodes.registerType("modbus-flex-server",function(e){i.nodes.createNode(this,e);var r=(s=require("vm2")).VM,s=s.VMScript,t=(this.name=e.name,this.logEnabled=e.logEnabled,this.serverAddress=e.serverAddress||"0.0.0.0",this.serverPort=parseInt(e.serverPort),this.responseDelay=parseInt(e.responseDelay),this.delayUnit=e.delayUnit,this.unitId=parseInt(e.unitId)||1,this.minAddress=parseInt(e.minAddress)||0,this.splitAddress=parseInt(e.splitAddress)||1e4,this.showErrors=e.showErrors,this.funcGetCoil=new s(e.funcGetCoil).compile(),this.funcGetDiscreteInput=new s(e.funcGetDiscreteInput).compile(),this.funcGetInputRegister=new s(e.funcGetInputRegister).compile(),this.funcGetHoldingRegister=new s(e.funcGetHoldingRegister).compile(),this.funcSetCoil=new s(e.funcSetCoil).compile(),this.funcSetRegister=new s(e.funcSetRegister).compile(),this.internalDebugLog=c,this.verboseLogging=i.settings.verbose,this);function o(e){return[{type:"holding",message:e,payload:t.registers.slice(t.splitAddress*u.bufferFactor)},{type:"coils",message:e,payload:t.coils.slice(0,t.splitAddress*u.bufferFactor)},{type:"input",message:e,payload:t.registers.slice(0,t.splitAddress*u.bufferFactor)},{type:"discrete",message:e,payload:t.coils.slice(t.splitAddress*u.bufferFactor)},{payload:"request",type:"message",message:e}]}t.bufferFactor=u.bufferFactor,t.coilsBufferSize=parseInt(e.coilsBufferSize*u.bufferFactor),t.registersBufferSize=parseInt(e.registersBufferSize*u.bufferFactor),t.coils=Buffer.alloc(t.coilsBufferSize,0),t.registers=Buffer.alloc(t.registersBufferSize,0),t.modbusServer=null,d.setNodeStatusTo("initialized",t),t.vector={},(s=new r({sandbox:{node:t}})).run("node.vector.getCoil = "+e.funcGetCoil),s.run("node.vector.getDiscreteInput = "+e.funcGetDiscreteInput),s.run("node.vector.getInputRegister = "+e.funcGetInputRegister),s.run("node.vector.getHoldingRegister = "+e.funcGetHoldingRegister),s.run("node.vector.setCoil = "+e.funcSetCoil),s.run("node.vector.setRegister = "+e.funcSetRegister),t.startServer=function(){try{if(null===t.modbusServer){try{t.modbusServer=new n.ServerTCP(t.vector,{host:t.serverAddress,port:t.serverPort,debug:t.logEnabled,unitID:t.unitId})}catch(e){t.error(e,{payload:"server net error -> for port 502 on unix, you have to be a super user"})}t.modbusServer.on("socketError",function(e){c(e.message),t.showErrors&&t.warn(e),d.setNodeStatusTo("error",t),t.modbusServer.close(function(){t.startServer()})}),t.modbusServer.on("error",function(e){c("Modbus Flex Server error"),t.showErrors&&t.error(e),d.setNodeStatusTo("error",t)}),t.modbusServer._server.on("connection",function(e){c("Modbus Flex Server client connection"),e&&c("Modbus Flex Server client to "+JSON.stringify(e.address())+" from "+e.remoteAddress+" "+e.remotePort),d.setNodeStatusTo("active",t)}),t.modbusServer._server.on("error",function(e){c("Modbus Flex Server client error"),t.showErrors&&t.error(e),d.setNodeStatusTo("error",t)})}t.showStatusActivities||d.setNodeDefaultStatus(t)}catch(e){c(e.message),t.showErrors&&t.warn(e),d.setNodeStatusTo("error",t)}null!=t.modbusServer?(c("Modbus Flex Server listening on modbus://"+t.serverAddress+":"+t.serverPort),d.setNodeStatusTo("initialized",t)):(c("Modbus Flex Server isn't ready"),d.setNodeStatusTo("error",t))},t.startServer(),t.on("input",function(e){u.isValidMemoryMessage(e)?(u.writeToFlexServerMemory(t,e),1!==e.payload.disableMsgOutput&&t.send(o(e))):(t.showErrors&&t.error("Is Not A Valid Memory Write Message To Server",e),u.isValidMessage(e)&&!e.payload.disableMsgOutput&&t.send(o(e)))}),t.on("close",function(){d.setNodeStatusTo("closed",t),t.modbusServer._server&&t.modbusServer._server.close(),t.modbusServer&&t.modbusServer.close(),t.modbusServer=null})})}catch(e){c(e.message)}}; | ||
//# sourceMappingURL=maps/modbus-flex-server.js.map |
{ | ||
"name": "node-red-contrib-modbus", | ||
"version": "5.27.1", | ||
"version": "5.27.2", | ||
"private": false, | ||
@@ -12,3 +12,3 @@ "description": "The all in one Modbus TCP and Serial contribution package for Node-RED.", | ||
"line-by-line": "~0.1.6", | ||
"@plus4nodered/modbus-serial": "8.1.0", | ||
"@open-p4nr/modbus-serial": "https://dl.cloudsmith.io/public/iniationware-gmbh/plus4nodered/npm/open-p4nr/modbus-serial/8.1.0/modbus-serial-8.1.0.tgz#_gl=1*oezs8a*_gcl_au*NDk2NjE5MzkwLjE2ODc1MDQxODk.", | ||
"source-map-support": "~0.5.21", | ||
@@ -15,0 +15,0 @@ "underscore": "~1.13.6", |
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
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
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
8473020
139244
195
2