Skip to content

Commit

Permalink
Merge branch 'release/v5.41.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
biancode committed Jul 23, 2024
2 parents 253b199 + b23e289 commit c421c3c
Show file tree
Hide file tree
Showing 25 changed files with 4,271 additions and 1,787 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# [5.40.0](https://github.com/biancoroyal/node-red-contrib-modbus/compare/v5.27.2...v5.40.0) (2024-06-23)
# [5.41.0](https://github.com/biancoroyal/node-red-contrib-modbus/compare/v5.40.0...v5.41.0) (2024-07-23)


### Bug Fixes

* **buffer:** nodejs Buffer alloc update ([9a6350c](https://github.com/biancoroyal/node-red-contrib-modbus/commit/9a6350cd67361f10310629a145f8a595e9f3d85c))
* **codeql:** version codeql ([163101f](https://github.com/biancoroyal/node-red-contrib-modbus/commit/163101f91c784a5202acd86b0a10302a22414495))
* **config:** [#442](https://github.com/biancoroyal/node-red-contrib-modbus/issues/442) fixing optional to save correct ([de88e25](https://github.com/biancoroyal/node-red-contrib-modbus/commit/de88e25b10e7e92ea8836d22ee91cb25796f3909))
* **issue#472:** Implemented message queue to handle incoming messages asynchronously ([65ea2a7](https://github.com/biancoroyal/node-red-contrib-modbus/commit/65ea2a7dce2e391a0b46412b798fdc4c14e6f750)), closes [issue#472](https://github.com/issue/issues/472)
* **modbus-client-core:** fixed test cases ([0697df3](https://github.com/biancoroyal/node-red-contrib-modbus/commit/0697df3f4fdf71434e3757f9ae68c6e6db22a948))
* **modbus-client-flow:** fixed modbus client flow example ([8613c89](https://github.com/biancoroyal/node-red-contrib-modbus/commit/8613c892c54d7c73ca818a5fb34729232fb8acef))
* **modbus-fc-flex:** fixed test case for modbus flex fc file ([93b22f8](https://github.com/biancoroyal/node-red-contrib-modbus/commit/93b22f8cafe5dc269811cfef78fba1c05dc57c69))
Expand Down Expand Up @@ -34,6 +35,7 @@
* **flex-fc:** map file needs to be json ([28f6010](https://github.com/biancoroyal/node-red-contrib-modbus/commit/28f60102e07b54d4bd5b86660b4d382341dd54b3))
* **modbus-client-core:** Improve code in modbus-client-core.js file ([f0691e2](https://github.com/biancoroyal/node-red-contrib-modbus/commit/f0691e2cdf8e0986912d60d31432a592de264769))
* **modbus:** new option for the flex-fc to get input msg ([5ff8167](https://github.com/biancoroyal/node-red-contrib-modbus/commit/5ff81672ac9c575a71bb241fc5861f25357012c8))
* **test-flow:** added tets flow for github issue 473 ([6130171](https://github.com/biancoroyal/node-red-contrib-modbus/commit/6130171e2542dc5c8a2c900b4f6b81d5f07367cf))



Expand Down
2 changes: 2 additions & 0 deletions clean-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ rm package-lock.json

rm yarn.lock

npm run clean

npm cache verify

npm install
Expand Down
8 changes: 1 addition & 7 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ npm i --only=dev

yarn

npm test

npm run test-with-coverage

npm run build

npm run rewrite-changelog
npm run test:publish

node -v

Expand Down
2,865 changes: 2,213 additions & 652 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-modbus",
"version": "5.40.0",
"version": "5.41.0",
"private": false,
"description": "The all in one Modbus TCP and Serial contribution long term supported package for Node-RED.",
"dependencies": {
Expand Down Expand Up @@ -57,32 +57,30 @@
"docs",
"examples",
"modbus",
"extras/argumentMaps/defaults",
"extras/argumentMaps/ArgumentMaps.md",
".npmrc"
"extras"
],
"bugs": {
"url": "https://github.com/biancoroyal/node-red-contrib-modbus/issues/"
},
"homepage": "https://plus4nodered.com/",
"scripts": {
"changelog": "npm run rewrite-changelog",
"test": "npm run lint && mocha ./test --parallel --recursive --reporter dot",
"test:slow": "npm run lint && mocha ./test --recursive --reporter dot",
"test": "npm run lint && mocha ./test --parallel --recursive --reporter dot --timeout 6000",
"test:slow": "npm run lint && mocha ./test --recursive --reporter dot --timeout 12000",
"test:verbose": "npm run lint && mocha ./test --recursive",
"test:withStop": "npm run lint && mocha ./test --recursive --bail",
"test:publish": "gulp clean && npm run prepublishOnly",
"lint": "standard --fix",
"test:e2e": "npm run lint && mocha './test/units/modbus-write-e2e-test.js' --parallel --recursive --reporter dot --timeout 100000",
"test:units": "npm run lint && mocha './test/units/modbus-client-test.js' --parallel --recursive --reporter dot --timeout 100000",
"test:units": "npm run lint && mocha './test/units/modbus-client-test.js' --parallel --recursive --reporter dot",
"test:core": "npm run lint && mocha './test/core/*-test.js' --parallel --recursive",
"test-nyc": "nyc --reporter=html --reporter=text mocha --recursive",
"test-npx": "npx --yes nyc@latest --reporter=html --reporter=text mocha ./test --parallel --recursive --reporter dot --timeout 10000",
"test-with-coverage": "nyc --reporter=lcovonly mocha --recursive -R spec && cat ./coverage/lcov.info | codacy-coverage --token $CODACY_COVERAGE_TOKEN && rm -rf ./coverage",
"coverage": "npm run lint && nyc mocha ./test --parallel --recursive --reporter dot --timeout 10000",
"coverage": "npm run lint && nyc --reporter=html --reporter=text mocha ./test --parallel --recursive --reporter dot --timeout 10000",
"coverage-nyc": "npm run lint && nyc report --reporter=text-lcov | coveralls",
"build": "npm run lint && gulp",
"prepublishOnly": "npm run lint && npm run rewrite-changelog && npm test && mocha test --recursive --reporter dot && npm run test-npx && npm run build",
"prepublishOnly": "npm run clean && npm run lint && npm run rewrite-changelog && npm test && npm run coverage && npm run build",
"ci-publish": "ci-publish",
"release": "standard-version -a",
"release:beta": "standard-version --prerelease beta",
Expand Down Expand Up @@ -118,7 +116,7 @@
"js-beautify": "^1.15.1",
"mocha": "^10.4.0",
"nock": "^13.5.4",
"node-red": "^4.0.0-beta.4",
"node-red": "^4.0.2",
"node-red-node-test-helper": "^0.3.4",
"nyc": "^15.1.0",
"pump": "^3.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/de-DE/modbus-flex-connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"showActivities": "Show Activities",
"showErrors": "Show Errors",
"showWarnings": "Show Warnings",
"server": "Server"
"server": "Server",
"emptyMsgOnFail": "Leere msg bei Modbus-Fehler",
"configMsgOnChange": "Config msg bei Modbus-Change"
},
"tabs-label": {
"settings": "Einstellungen",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en-US/modbus-flex-connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"showActivities": "Show Activities",
"showErrors": "Show Errors",
"showWarnings": "Show Warnings",
"server": "Server"
"server": "Server",
"emptyMsgOnFail": "Empty Message on Modbus failure",
"configMsgOnChange": "Config msg on Modbus-Change"
},
"tabs-label": {
"settings": "Settings",
Expand Down
27 changes: 19 additions & 8 deletions src/modbus-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ module.exports = function (RED) {

if (state.matches('queueing')) {
if (node.clienttype === 'tcp') {
node.stateService.send('SEND')
if (!node.parallelUnitIdsAllowed) {
if (node.serialSendingAllowed) {
coreModbusQueue.queueSerialLockCommand(node)
node.stateService.send('SEND')
}
} else {
node.stateService.send('SEND')
}
} else {
if (node.serialSendingAllowed) {
coreModbusQueue.queueSerialLockCommand(node)
Expand Down Expand Up @@ -635,14 +642,18 @@ module.exports = function (RED) {
throw new Error('Message Or Payload Not Valid')
}

coreModbusClient.internalDebug('Dynamic Reconnect Parameters ' + JSON.stringify(msg.payload))
if (coreModbusClient.setNewNodeSettings(node, msg)) {
cb(msg)
} else {
cberr(new Error('Message Or Payload Not Valid'), msg)
try {
coreModbusClient.internalDebug('Dynamic Reconnect Parameters ' + JSON.stringify(msg.payload))
if (coreModbusClient.setNewNodeSettings(node, msg)) {
cb(msg)
} else {
cberr(new Error('Message Or Payload Not Valid'), msg)
}
coreModbusClient.internalDebug('Dynamic Reconnect Starts on actual state ' + node.actualServiceState.value)
node.stateService.send('SWITCH')
} catch (err) {
cberr(err, msg)
}
coreModbusClient.internalDebug('Dynamic Reconnect Starts on actual state ' + node.actualServiceState.value)
node.stateService.send('SWITCH')
})

node.on('close', function (done) {
Expand Down
15 changes: 14 additions & 1 deletion src/modbus-flex-connector.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
emptyQueue: {value: false},
showStatusActivities: {value: false},
showErrors: {value: false},
server: {type: 'modbus-client', required: true}
server: {type: 'modbus-client', required: true},
emptyMsgOnFail: {value: false},
configMsgOnChange: {value: false}
},
inputs: 1,
outputs: 1,
Expand Down Expand Up @@ -50,6 +52,17 @@
<input type="checkbox" id="node-input-emptyQueue" style="max-width:30px">
</div> -->
<hr>
<div class="form-row">
<label style="min-width:190px" for="node-input-emptyMsgOnFail"><i class="fa fa-th"></i> <span
data-i18n="modbus-contrib.label.emptyMsgOnFail"></span></label>
<input type="checkbox" id="node-input-emptyMsgOnFail" style="max-width:30px">
</div>
<div class="form-row">
<label style="min-width:190px" for="node-input-configMsgOnChange"><i class="fa fa-th"></i> <span
data-i18n="modbus-contrib.label.configMsgOnChange"></span></label>
<input type="checkbox" id="node-input-configMsgOnChange" style="max-width:30px">
</div>
<hr>
<div class="form-row">
<label style="min-width:190px" for="node-input-showStatusActivities"><i class="fa fa-th"></i> <span
data-i18n="modbus-contrib.label.showActivities"></span></label>
Expand Down
81 changes: 57 additions & 24 deletions src/modbus-flex-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
@author <a href="mailto:[email protected]">Klaus Landsdorf</a> (Bianco Royal)
*/

/**
* Modbus flexible Getter node.
* @module NodeRedModbusFlexGetter
* Flex Connector Node.
* @module NodeRedModbusFlexConnector
*
* @param RED
*/
Expand All @@ -19,6 +20,7 @@ module.exports = function (RED) {

function ModbusFlexConnector (config) {
RED.nodes.createNode(this, config)

this.name = config.name
this.maxReconnectsPerMinute = config.maxReconnectsPerMinute || 4
this.emptyQueue = config.emptyQueue
Expand All @@ -29,53 +31,82 @@ module.exports = function (RED) {
this.internalDebugLog = internalDebugLog
this.verboseLogging = RED.settings.verbose
this.server = RED.nodes.getNode(config.server)
this.emptyMsgOnFail = config.emptyMsgOnFail
this.configMsgOnChange = config.configMsgOnChange

const node = this

mbBasics.setNodeStatusTo('waiting', node)
if (!this.server) {

if (!node.server) {
mbBasics.setNodeStatusTo('disconnected', node)
return
}
this.server.registerForModbus(node)

mbBasics.setNodeStatusTo('connecting', node)

node.server.registerForModbus(node)
mbBasics.initModbusClientEvents(node, this.server)

node.onConfigDone = function (msg) {
const shouldShowStatus = node.showStatusActivities
if (shouldShowStatus) {
mbBasics.setNodeStatusTo('config done', node)
}
if (shouldShowStatus) {
mbBasics.setNodeStatusTo(this.server.actualServiceState, node)
}

if (!shouldShowStatus) {
if (node.showStatusActivities) {
mbBasics.setNodeStatusTo(node.server.actualServiceState, node)
} else {
mbBasics.setNodeDefaultStatus(node)
}

msg.error.nodeStatus = node.statusText

if (node.emptyMsgOnFail) {
msg.payload = ''
if (node.configMsgOnChange) {
msg.payload = msg.payload || {}
msg.payload.status = 'changed'
} else {
msg.config_change = 'emitted'
}

node.send(msg)
}

node.onConfigError = function (err, msg) {
internalDebugLog(err.message)

if (node.showErrors) {
if (node.showStatusActivities) {
mbBasics.setNodeStatusTo('error', node)
} else {
mbBasics.setNodeDefaultStatus(node)
}

if (err && err.message) {
msg.error = err
} else {
msg.error = new Error(err)
}

msg.error.nodeStatus = node.statusText

node.error(msg.error, msg)

if (node.emptyMsgOnFail) {
msg.payload = ''
}

node.send(msg)
}
}

node.on('input', function (msg) {
if (mbBasics.invalidPayloadIn(msg)) {
return
}

// if (!this.server) {
// return
// }

if (node.showStatusActivities) {
mbBasics.setNodeStatusTo(this.server.actualServiceState, node)
mbBasics.setNodeStatusTo(node.server.actualServiceState, node)
}

if (msg.payload.connectorType) {
internalDebugLog(`dynamicReconnect: ${JSON.stringify(msg.payload)}`)

msg.payload.emptyQueue = node.emptyQueue
this.server.emit('dynamicReconnect', msg, node.onConfigDone, node.onConfigError)
node.server.emit('dynamicReconnect', msg, node.onConfigDone, node.onConfigError)
} else {
const error = new Error('Payload Not Valid - Connector Type')
node.error(error, msg)
Expand All @@ -84,7 +115,9 @@ module.exports = function (RED) {
}
})

if (!node.showStatusActivities) {
if (node.showStatusActivities) {
mbBasics.setNodeStatusTo('active', node)
} else {
mbBasics.setNodeDefaultStatus(node)
}
}
Expand Down
Loading

0 comments on commit c421c3c

Please sign in to comment.