Skip to content

Commit

Permalink
refactor!: Change configuration and devices files format to YAML
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Configuration and devices files are now in YAML format

closes issue edgexfoundry#444

Signed-off-by: Valina Li <valina.li@intel.com>
  • Loading branch information
vli11 committed Mar 28, 2023
1 parent 63f56b4 commit 7fd9980
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 94 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ See [Compose Builder](https://github.com/edgexfoundry/edgex-compose/tree/main/co
## Usage
Users can refer to [the document](https://docs.edgexfoundry.org/2.0/examples/Ch-ExamplesAddingModbusDevice) to learn how to use this device service.
## Example Profile and Device
The `ProfilesDir` and `DevicesDir` in the configuration.toml are empty string by default.
The `ProfilesDir` and `DevicesDir` in the configuration.yaml are empty string by default.
To use the example Profile and Device in this repository, please fill './res/profiles' and './res/devices'
to `ProfilesDir` and `DevicesDir` respectively.
`modbus.test.device.profile.toml` and `modbus.test.devices.toml` will be loaded and created when the Device Service starts up.
Users can modify those files or add additional Profile YAML or Device TOML to meet their needs.
`modbus.test.device.profile.yml` and `modbus.test.devices.yaml` will be loaded and created when the Device Service starts up.
Users can modify those files or add additional Profile YAML to meet their needs.
## Modbus Simulator
Build and run the Modbus simulator
```
Expand Down
17 changes: 0 additions & 17 deletions cmd/res/configuration.toml

This file was deleted.

25 changes: 25 additions & 0 deletions cmd/res/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Writable:
LogLevel: INFO

# uncomment when running from command-line in hybrid mode with -cp -o flags
Registry:
Host: localhost

Clients:
core-metadata:
Host: localhost # uncomment when running from command-line in hybrid mode

Service:
Port: 59901
StartupMsg: device modbus started

MessageBus:
Host: localhost # uncomment when running from command-line in hybrid mode
Optional:
ClientId: device-modbus

Device:
# These two overrides are so test files are not used by default
# Remove these two in order to use folder settings in common config resulting in use of test profile and devices
ProfilesDir: .
DevicesDir: .
52 changes: 0 additions & 52 deletions cmd/res/devices/modbus.test.devices.toml

This file was deleted.

56 changes: 56 additions & 0 deletions cmd/res/devices/modbus.test.devices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Pre-define Devices
DeviceList:
- Name: Modbus-TCP-test-device
ProfileName: Test-Device-Modbus-Profile
Description: >-
This device is a product for monitoring and controlling digital inputs and
outputs over a LAN.
labels:
- Air conditioner
- modbus TCP
Protocols:
modbus-tcp:
Address: 0.0.0.0
Port: 1502
UnitID: 1
Timeout: 5
IdleTimeout: 5
AutoEvents:
- Interval: 20s
OnChange: false
SourceName: HVACValues
- Name: Modbus-RTU-test-device
ProfileName: Test-Device-Modbus-Profile
Description: >-
This device is a product for monitoring and controlling digital inputs and
outputs over a LAN.
labels:
- Air conditioner
- modbus RTU
Protocols:
modbus-rtu:
Address: /tmp/slave
UnitID: 1
BaudRate: 19200
DataBits: 8
StopBits: 1
Parity: 'N'
Timeout: 5
IdleTimeout: 5
# Pre-define Devices
- Name: Modbus-TCP-Read-String
ProfileName: Test-Device-Modbus-String-Profile
Description: use for auto read a string value
labels:
- modbus TCP
Protocols:
modbus-tcp:
Address: 0.0.0.0
Port: 1502
UnitID: 1
Timeout: 5
IdleTimeout: 5
AutoEvents:
- Interval: 20s
OnChange: false
SourceName: ReadString
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/edgexfoundry/device-modbus-go
go 1.20

require (
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.54
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.28
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.57
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.30
github.com/goburrow/modbus v0.1.0
github.com/spf13/cast v1.5.0
github.com/stretchr/testify v1.8.2
Expand All @@ -17,11 +17,11 @@ require (
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.2 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.47 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.54 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.9 // indirect
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.18 // indirect
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5 // indirect
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.9 // indirect
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.7 // indirect
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.10 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -35,7 +35,7 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/consul/api v1.19.1 // indirect
github.com/hashicorp/consul/api v1.20.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eclipse/paho.mqtt.golang v1.4.2 h1:66wOzfUHSSI1zamx7jR6yMEI5EuHnT1G6rNA5PM12m4=
github.com/eclipse/paho.mqtt.golang v1.4.2/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.54 h1:v0agM9yGlu1036LQXzC0ImOah2zLaaUoho6ngdU2O3I=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.54/go.mod h1:GtXMlc0G7aXEXWhbW+7YwO9F1KA1qFRODhzfWFSWhoU=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.47 h1:KG2CAxu1BKwvT8vMONZC2bTUqJuwRY49XyUISAgjdfQ=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.47/go.mod h1:W26ejUzaSRzq/b/8oIdB8hKve4xW55XbCkfj8pvQNfE=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 h1:pOH2GLDg1KB4EmAzo6IEvl4NEVFAw3ywxPUMa5Wi1Vw=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7/go.mod h1:ZZbOu7K0/P8B1VKhZygVujLQyhvWuPe0E2vC/k2yscw=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.28 h1:aNHlmF2uPcwUr7VKvNVJXdxMDaI41j2laoGxZy5H95g=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.28/go.mod h1:SYoD+tmUP/zwWuuIySmsQSjPx6MHP+2w9FsLgm0IR7A=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.57 h1:MnQOhkZUrhJa4eIG0vzElsj9iOeqUKSDkHDFueLmROM=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.57/go.mod h1:oDZw7N1L0HeG7GF6btSFUj9mFQXDrMahlnbiZsjYXFM=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.54 h1:zbM6LjlXgnvZ1d1WZUiF9GClDaRHawRvN9gGKwSTD1w=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.54/go.mod h1:aKaljiCzEaRb+QO/LP7gyRSrhXs1YVsh02kagZlmi80=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.9 h1:DznnG2F4E+9jHAA+iXsaDaQxYJ+oWS3SddvvdEfQayE=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.9/go.mod h1:ljWfa029h+677rS+khaXWR+8Hv8965UfbMjaxZ4C9QI=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.30 h1:diarfNbfUeSYD7Hq8pOqHzxMtIbaPO6W8nWq34W8X6g=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.30/go.mod h1:SYoD+tmUP/zwWuuIySmsQSjPx6MHP+2w9FsLgm0IR7A=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.18 h1:8empqTOIVhKzebC3gnP9C0LGQvwXtHLJF8x8AqlTGLM=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.18/go.mod h1:Sf7lvKtICWRy0Tmvw+bV6L1wdXKRaTSmKmJKw4Caxe4=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5 h1:FUUfsQUKHJqSwOXEj0j/qAn+uoWzM8nV7IOapGf7D80=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5/go.mod h1:MroNeX/i6ymRu8cyuRB4U5zdBusyUpFhUphko6pInTQ=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.9 h1:12UHZG/Nl+dfFOaNnC87ANP/FQ3rOXe0Z6NVlYdmYgU=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.9/go.mod h1:tjny0Y2/sLTB9qx3pjvT9PfGHpEOdfej7pjV3s1zppk=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.7 h1:sje0agoLi8ayEFxGO3xtN7P/IXwjZUUxpC8G2fCTu44=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.7/go.mod h1:SGyo4fAHzOhDAd2Usa9RaBT/sOzkbceIqLrDG0+iYy8=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.10 h1:NJ5figB8O6vK44YA8LvuAywbY1BwC/5Kf7ZKc+1ItAU=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.10/go.mod h1:8hvfJ8L3mWTEXx3aEleGkh2U80jxfXzfSupDEQEqBjA=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
Expand Down Expand Up @@ -90,8 +90,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/consul/api v1.19.1 h1:GLeK1WD4VIRvt4wRhQKHFudztEkRb8pDs+uRiJgNwes=
github.com/hashicorp/consul/api v1.19.1/go.mod h1:jAt316eYgWGNLJtxkMQrcqRpuDE/kFJdqkEFwRXFv8U=
github.com/hashicorp/consul/api v1.20.0 h1:9IHTjNVSZ7MIwjlW3N3a7iGiykCMDpxZu8jsxFJh0yc=
github.com/hashicorp/consul/api v1.20.0/go.mod h1:nR64eD44KQ59Of/ECwt2vUmIK2DKsDzAwTmwmLl8Wpo=
github.com/hashicorp/consul/sdk v0.13.1 h1:EygWVWWMczTzXGpO93awkHFzfUka6hLYJ0qhETd+6lY=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ parts:
RES=$SNAPCRAFT_PART_INSTALL/config/device-modbus/res/
mkdir -p $RES
cp cmd/res/configuration.toml $RES
cp cmd/res/configuration.yaml $RES
cp -r cmd/res/devices $RES
cp -r cmd/res/profiles $RES
Expand Down

0 comments on commit 7fd9980

Please sign in to comment.