## Deploy on local ### Deploy on windows with wsl2(Ubuntu20.04) type in the terminal > export EDGEX_SECURITY_SECRET_STORE=false 1. install redis-server and edit config 1. build edgex-go 2. build device-virtual-go 3. build app-functions-sdk-go 4. install consul and make consul.hcl ``` node_name = "consul-server" server = true bootstrap = true ui = true datacenter = "dc1" data_dir = "tmp/data" log_level = "INFO" connect { enabled = true } bind_addr = "127.0.0.1" ``` 6. consul agent -ui -bootstrap -server -data-dir=tmp/consul -config-file=tmp/consul.hcl 7. edit cmd/core-common-config-bootstrap/res/configuration.yaml -> db config 8. perform microservice ```bash cd edgex-go/cmd/core-metadata/ nohup ./core-metadata -cp=consul.http://localhost:8500 -registry & ``` --- ```bash cd ../core-data nohup ./core-data -cp=consul.http://localhost:8500 -registry & cd ../core-command nohup ./core-command -cp=consul.http://localhost:8500 -registry & cd ../support-notifications/ nohup ./support-notifications -cp=consul.http://localhost:8500 -registry & cd ../support-scheduler/ nohup ./support-scheduler -cp=consul.http://localhost:8500 -registry & ``` 9. Start Configurable application service ```bash cd /app-service-configurable nohup ./app-service-configurable -cp=consul.http://localhost:8500 -registry -p=rules-engine & ``` 10. Start virtual device service ```bash cd device-virtual-go/cmd nohup ./device-virtual -cp=consul.http://localhost:8500 -registry & ``` 11. Start the GUI localhost:4000 ```bash cd edgex-ui-go/cmd/edgex-ui-server nohup ./edgex-ui-server & ``` ## Deploy on Docker 1. deploy edgex ```bash git clone https://github.com/edgexfoundry/edgex-compose.git cd edgex-compose/compose-builder make gen no-secty ds-modbus docker compose up -d ``` 2. install modbusPal ```bash wget https://sourceforge.net/p/modbuspal/discussion/899955/thread/72cf35ee/cd1f/attachment/ModbusPal.jar sudo apt install librxtx-java sudo java -jar ModbusPal.jar ``` Setting like [Set modbusPal](https://docs.edgexfoundry.org/3.0/examples/Ch-ExamplesAddingModbusDevice/#setup-modbuspal) 3. make device configuration ```bash mkdir -p custom-config cd custom-config nano temperature.profile.yml ``` edit file like below ```bash name: "Ethernet-Temperature-Sensor" manufacturer: "Audon Electronics" model: "Temperature" labels: - "Web" - "Modbus TCP" - "SNMP" description: "The NANO_TEMP is a Ethernet Thermometer measuring from -55°C to 125°C with a web interface and Modbus TCP communications." deviceResources: - name: "ThermostatL" isHidden: true description: "Lower alarm threshold of the temperature" attributes: { primaryTable: "HOLDING_REGISTERS", startingAddress: 3999, rawType: "Int16" } properties: valueType: "Float32" readWrite: "RW" scale: 0.1 - name: "ThermostatH" isHidden: true description: "Upper alarm threshold of the temperature" attributes: { primaryTable: "HOLDING_REGISTERS", startingAddress: 4000, rawType: "Int16" } properties: valueType: "Float32" readWrite: "RW" scale: 0.1 - name: "AlarmMode" isHidden: true description: "1 - OFF (disabled), 2 - Lower, 3 - Higher, 4 - Lower or Higher" attributes: { primaryTable: "HOLDING_REGISTERS", startingAddress: 4001 } properties: valueType: "Int16" readWrite: "RW" - name: "Temperature" isHidden: false description: "Temperature x 10 (np. 10,5 st.C to 105)" attributes: { primaryTable: "HOLDING_REGISTERS", startingAddress: 4003, rawType: "Int16" } properties: valueType: "Float32" readWrite: "R" scale: 0.1 deviceCommands: - name: "AlarmThreshold" readWrite: "RW" isHidden: false resourceOperations: - { deviceResource: "ThermostatL" } - { deviceResource: "ThermostatH" } - name: "AlarmMode" readWrite: "RW" isHidden: false resourceOperations: - { deviceResource: "AlarmMode", mappings: { "1":"OFF","2":"Lower","3":"Higher","4":"Lower or Higher"} } ``` 4. upload device configuration to edgeX ```bash curl http://localhost:59881/api/v3/deviceprofile/uploadfile -F "file=@temperature.profile.yml" curl http://localhost:59881/api/v3/device -H "Content-Type:application/json" -X POST \ -d '[ { "apiVersion" : "v3", "device": { "name" :"Modbus-TCP-Temperature-Sensor", "description":"This device is a product for monitoring the temperature via the ethernet", "labels":[ "Temperature", "Modbus TCP" ], "serviceName": "device-modbus", "profileName": "Ethernet-Temperature-Sensor", "protocols":{ "modbus-tcp":{ "Address" : "172.17.0.1", "Port" : "502", "UnitID" : "1", "Timeout" : "5", "IdleTimeout" : "5" } }, "autoEvents":[ { "Interval":"30s", "onChange":false, "SourceName":"Temperature" } ], "adminState":"UNLOCKED", "operatingState":"UP" } } ]' ``` 5. Find Executable Command ```bash curl http://localhost:59882/api/v3/device/all | json_pp ``` 6. Execute Set and Get Command ```bash Set curl http://localhost:59882/api/v3/device/name/Modbus-TCP-Temperature-Sensor/AlarmThreshold \ -H "Content-Type:application/json" -X PUT \ -d '{"ThermostatL":"15","ThermostatH":"100"}' Get curl http://localhost:59882/api/v3/device/name/Modbus-TCP-Temperature-Sensor/AlarmThreshold | json_pp ``` ## Modbus Simulator https://sourceforge.net/projects/modbuspal/