Skip to content

Commit

Permalink
refactor!: Change configuration and devices files format to YAML (#445)
Browse files Browse the repository at this point in the history
* refactor!: Change configuration and devices files format to YAML

BREAKING CHANGE: Configuration and devices files are now in YAML format

closes issue #444

Signed-off-by: Valina Li <valina.li@intel.com>
  • Loading branch information
vli11 authored Mar 28, 2023
1 parent 63f56b4 commit 053db68
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 130 deletions.
6 changes: 0 additions & 6 deletions Attribution.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
The following open source projects are referenced by Device Service Modbus Go:

BurntSushi/toml (MIT) https://github.com/BurntSushi/toml
https://github.com/BurntSushi/toml/blob/master/COPYING

cenkalti/backoff (MIT) https://github.com/cenkalti/backoff
https://github.com/cenkalti/backoff/blob/master/LICENSE

Expand Down Expand Up @@ -75,9 +72,6 @@ https://github.com/go-yaml/yaml/blob/v2/LICENSE
google/uuid (BSD-3) https://github.com/google/uuid
https://github.com/google/uuid/blob/master/LICENSE

pelletier/go-toml (MIT) https://github.com/pelletier/go-toml
https://github.com/pelletier/go-toml/blob/master/LICENSE

pkg/errors (BSD-2) https://github.com/pkg/errors
https://github.com/pkg/errors/blob/master/LICENSE

Expand Down
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.

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

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

# Clients:
# core-metadata:
# Host: localhost

Service:
Host: localhost
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
31 changes: 15 additions & 16 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.61
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.34
github.com/goburrow/modbus v0.1.0
github.com/spf13/cast v1.5.0
github.com/stretchr/testify v1.8.2
Expand All @@ -17,25 +17,25 @@ 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.56 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.10 // 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
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/go-playground/validator/v10 v10.12.0 // indirect
github.com/go-redis/redis/v7 v7.3.0 // indirect
github.com/goburrow/serial v0.1.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
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 All @@ -44,7 +44,7 @@ require (
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54 // indirect
Expand All @@ -55,19 +55,18 @@ require (
github.com/nats-io/nats.go v1.24.0 // indirect
github.com/nats-io/nkeys v0.3.0 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/errs v1.3.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230109162033-3c3c17ce83e6 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand Down
Loading

0 comments on commit 053db68

Please sign in to comment.