Master-Slave LogicMachine
Example: MASTER-SLAVE LogicMachine
Task
How to add backup LogicMachine in the installation where SLAVE device will overtake the functionality of MASTER in case if last fails communicating with the bus.
Backup file
On MASTER device create backup file with final configuration in Utilities -> Backup and import it in SLAVE device via Utilities -> Restore
Test group address
Add test group address e.g. 1/1/1 on both devices with data type 4-byte unsigned integer
MASTER resident script
On MASTER add Resident script with Sleep interval 5 seconds and code:
- grp.write('1/1/1', os.time(), dt.uint32)
SLAVE resident scrip
On SLAVE add Resident script with Sleep interval 10 seconds and code:
- -- current object value
- curr = grp.getvalue('1/1/1')
- -- previous object value or current if not set
- prev = prev or curr
-
- -- master timeout
- if curr == prev then
- -- first error
- if not timeout then
- alert('master offline')
- -- enable scripts here
- timeout = true
- end
- -- master ok, recovered from error
- elseif timeout then
- alert('master online')
- -- disable scripts here
- timeout = false
- end
-
- -- save previous object value
- prev = curr
The script will check the KNX bus on MASTER device, if the communication fails, on SLAVE it will Enable specified scripts (comment line — enable scripts here), or if the communication is back and running – will disable the specified scripts (comment line — disable scripts here)
In case no KNX TP1 is used, you can check this example for KNX IP hot-swap solution.