Skip to content

Commit

Permalink
test(modbus-client): rewrite flow examples for modbus client
Browse files Browse the repository at this point in the history
  • Loading branch information
mj committed Jun 21, 2024
1 parent 8613c89 commit 3450d25
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 204 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"test:withStop": "npm run lint && mocha ./test --recursive --bail",
"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-getter-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:core": "npm run lint && mocha './test/core/*-test.js' --parallel --recursive",
"test-nyc": "nyc --reporter=html --reporter=text mocha --recursive",
"test-npx": "npx nyc@latest --reporter=html --reporter=text mocha ./test --parallel --recursive --reporter dot --timeout 10000",
Expand Down
233 changes: 115 additions & 118 deletions test/units/flows/modbus-client-flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,95 +209,87 @@ module.exports = {
testModbusReadFlow: helperExtensions.cleanFlowPositionData(
[
{
"id": "5795a33073f19e7e",
"type": "tab",
"label": "Flow 5",
"disabled": false,
"info": "",
"env": []
"id": "bf0ddd673dfcd1ce",
"type": "modbus-server",
"z": "55dbfaa142bcbd46",
"name": "",
"logEnabled": false,
"hostname": "127.0.0.1",
"serverPort": "10712",
"responseDelay": 100,
"delayUnit": "ms",
"coilsBufferSize": 10000,
"holdingBufferSize": 10000,
"inputBufferSize": 10000,
"discreteBufferSize": 10000,
"showErrors": false,
"x": 340,
"y": 580,
"wires": [
[],
[],
[],
[],
[]
]
},
{
"id": "7c7443c8f1f2da83",
"id": "57ad625f7354acdb",
"type": "modbus-read",
"z": "5795a33073f19e7e",
"z": "55dbfaa142bcbd46",
"name": "",
"topic": "",
"showStatusActivities": false,
"logIOActivities": false,
"showErrors": false,
"showWarnings": true,
"unitid": "",
"dataType": "Input",
"dataType": "Coil",
"adr": "0",
"quantity": "2",
"rate": "1000",
"rateUnit": "",
"delayOnStart": false,
"startDelayTime": "",
"server": "4",
"server": "80aeec4c.0cb9e8",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"x": 350,
"y": 340,
"x": 270,
"y": 680,
"wires": [
[],
[
"a487ecd822058594"
]
]
},
{
"id": "e7c92e251b61ccee",
"type": "modbus-server",
"z": "5795a33073f19e7e",
"name": "",
"logEnabled": false,
"hostname": "127.0.0.1",
"serverPort": "10712",
"responseDelay": 100,
"delayUnit": "ms",
"coilsBufferSize": 10000,
"holdingBufferSize": 10000,
"inputBufferSize": 10000,
"discreteBufferSize": 10000,
"showErrors": false,
"x": 400,
"y": 160,
"wires": [
[],
[],
[],
[],
"2ffa507c6b1a7155"
],
[]
]
},
{
"id": "a487ecd822058594",
"id": "2ffa507c6b1a7155",
"type": "helper",
"z": "5795a33073f19e7e",
"name": "helper 4",
"z": "55dbfaa142bcbd46",
"name": "helper 20",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 700,
"y": 280,
"x": 500,
"y": 680,
"wires": []
},
{
"id": "4",
"id": "80aeec4c.0cb9e8",
"type": "modbus-client",
"name": "Modbus Server",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": true,
"failureLogEnabled": false,
"tcpHost": "127.0.0.1",
"tcpPort": "10712",
"tcpType": "DEFAULT",
Expand All @@ -308,12 +300,12 @@ module.exports = {
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": 1,
"commandDelay": 1,
"clientTimeout": 1000,
"reconnectOnTimeout": true,
"reconnectTimeout": 2000,
"serialAsciiResponseStartDelimiter": "",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "100",
"reconnectOnTimeout": false,
"reconnectTimeout": "200",
"parallelUnitIdsAllowed": true,
"showErrors": false,
"showWarnings": true,
Expand Down Expand Up @@ -526,72 +518,77 @@ module.exports = {
}
]),

testShouldBeTcpDefaultFlow: helperExtensions.cleanFlowPositionData([
{
id: 'b3c94e07c24b7584',
type: 'tab',
label: 'Should Be TCP Default',
disabled: false,
info: '',
env: []
},
{
id: '384fb9f1.e96296',
type: 'modbus-read',
z: 'b3c94e07c24b7584',
name: '',
topic: '',
showStatusActivities: false,
logIOActivities: false,
showErrors: false,
unitid: '',
dataType: 'Coil',
adr: '0',
quantity: '10',
rate: '4',
rateUnit: 's',
delayOnStart: false,
startDelayTime: '',
server: '466860d5.3f6358',
useIOFile: false,
ioFile: '',
useIOForPayload: false,
emptyMsgOnFail: false,
x: 390,
y: 320,
wires: [
[],
[]
]
},
{
id: '466860d5.3f6358',
type: 'modbus-client',
name: 'ModbusClientTCPDefault',
clienttype: 'tcp',
bufferCommands: true,
stateLogEnabled: true,
queueLogEnabled: true,
failureLogEnabled: false,
tcpHost: '127.0.0.1',
tcpPort: '502',
tcpType: 'DEFAULT',
serialPort: '/dev/ttyUSB',
serialType: 'RTU-BUFFERD',
serialBaudrate: '9600',
serialDatabits: '8',
serialStopbits: '1',
serialParity: 'none',
serialConnectionDelay: '50',
serialAsciiResponseStartDelimiter: '',
unit_id: '1',
commandDelay: '1',
clientTimeout: '100',
reconnectOnTimeout: true,
reconnectTimeout: '200',
parallelUnitIdsAllowed: false
}
]),
testShouldBeTcpDefaultFlow: helperExtensions.cleanFlowPositionData(
[
{
"id": "c3db9fd99439b3b1",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "f21af48eccf359b7",
"type": "modbus-read",
"z": "c3db9fd99439b3b1",
"name": "",
"topic": "",
"showStatusActivities": false,
"logIOActivities": false,
"showErrors": false,
"showWarnings": true,
"unitid": "",
"dataType": "Coil",
"adr": "0",
"quantity": "q0",
"rate": "1000",
"rateUnit": "",
"delayOnStart": false,
"startDelayTime": "",
"server": "115bd58ae573c942",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"x": 790,
"y": 220,
"wires": [
[],
[]
]
},
{
"id": "115bd58ae573c942",
"type": "modbus-client",
"name": "ModbusClientTCPDefault",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": false,
"tcpHost": "127.0.0.1",
"tcpPort": "10520",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": "41",
"commandDelay": "100",
"clientTimeout": "1000",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": false,
"showErrors": false,
"showWarnings": false,
"showLogs": false
}
]),
testForFailureLogEnabled: helperExtensions.cleanFlowPositionData([
{
id: 'b3c94e07c24b7584',
Expand Down
Loading

0 comments on commit 3450d25

Please sign in to comment.