“Machine Utilization Example” - Machine Connectivity¶
This this file, Modbus TCP based machine connectivity has been handled. Additionally, data has been pre-processed using Connectware Rules.
Download: utilization-connectivity.yml
Note
The example below uses an additional Docker image provided by Cybus that requires a suitable license. You can check the current capabilities and permissions of your Connectware license in the Cybus Portal (https://portal.cybus.io). If your license is not eligible to use the example Docker image, please contact Cybus Sales (sales@cybus.io).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | description: > Machine connectivity and data mapping metadata: name: ModBus Machine Connectivity icon: https://www.cybus.io/wp-content/uploads/2019/03/Cybus-logo-Claim-lang.svg provider: cybus homepage: https://www.cybus.io version: 0.0.1 parameters: modbus_connection_ip: type: string default: 172.17.0.1 modbus_connection_port: type: integer default: 10502 resources: # Modbus simulator service for this example machineSimulator: type: Cybus::Container properties: image: registry.cybus.io/cybus-testing/modbus-machine-simulator:0.0.1 ports: - !sub '${modbus_connection_port}:10502/tcp' modbusConnection: type: Cybus::Connection properties: protocol: Modbus targetState: connected connection: host: !ref modbus_connection_ip port: !ref modbus_connection_port powerLevel: type: Cybus::Endpoint properties: protocol: Modbus connection: !ref modbusConnection subscribe: fc: 3 length: 2 interval: 1000 address: 0 dataType: floatBE mapping: type: Cybus::Mapping properties: mappings: - subscribe: endpoint: !ref powerLevel publish: topic: !sub "${Cybus::MqttRoot}/power-level" - subscribe: endpoint: !ref powerLevel rules: - transform: expression: | ( $stateMap := [ { "lower": 0, "upper": 0, "state": "OFF" }, { "lower": 1, "upper": 10, "state": "IDLE" }, { "lower": 11, "upper": 40, "state": "JOG" }, { "lower": 41, "upper": 100, "state": "RUNNING" } ]; $findState := function($stateRaw) { ( $result := $filter($stateMap, function($v) { ($stateRaw >= $v.lower and $stateRaw <= $v.upper) }); $result ? $result[0].state : "ERROR" ) }; { "powerlevel": value, "state": $findState(value), "timestamp": timestamp } ) publish: topic: !sub "${Cybus::MqttRoot}/machine-state" |