Skip to content

Commit

Permalink
fix: change go mod name to device-opc-ua
Browse files Browse the repository at this point in the history
Signed-off-by: Jieke Choo <[email protected]>
  • Loading branch information
jiekechoo committed Mar 27, 2024
1 parent 372f484 commit 11f2cd1
Show file tree
Hide file tree
Showing 21 changed files with 925 additions and 189 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: Apache-2.0
#
FROM golang:1.21-alpine3.18 AS builder
WORKDIR /device-opcua-go
WORKDIR /device-opcua

# Install our build time packages.
RUN apk update && apk add --no-cache make git zeromq-dev gcc pkgconfig musl-dev
Expand All @@ -28,10 +28,10 @@ RUN apk --no-cache upgrade
# expose command data port
EXPOSE 59997

COPY --from=builder /device-opcua-go/cmd/device-opcua /
COPY --from=builder /device-opcua-go/cmd/res /res
COPY --from=builder /device-opcua/cmd/device-opcua /
COPY --from=builder /device-opcua/cmd/res /res
COPY LICENSE /
COPY --from=builder /device-opcua-go/Attribution.txt /Attribution.txt
COPY --from=builder /device-opcua/Attribution.txt /Attribution.txt

ENTRYPOINT ["/device-opcua"]
CMD ["--cp=consul://edgex-core-consul:8500", "--registry"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/device-sdk-go/v3

DOCKER_TAG=$(VERSION)-dev

GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-opcua-go.Version=$(VERSION) \
GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-opc-ua.Version=$(VERSION) \
-X github.com/edgexfoundry/device-sdk-go/v3/internal/common.SDKVersion=$(SDKVERSION)" \
-trimpath -mod=readonly
GOTESTFLAGS?=-race
Expand Down
76 changes: 35 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# OPC-UA Device Service


> **Warning**
> The **main** branch of this repository contains work-in-progress development code for the upcoming release, and is **not guaranteed to be stable or working**.
> It is only compatible with the [main branch of edgex-compose](https://github.com/edgexfoundry/edgex-compose) which uses the Docker images built from the **main** branch of this repo and other repos.
>
> **The source for the latest release can be found at [Releases](https://github.com/edgexfoundry/device-opc-ua/releases).**
## Documentation

For latest documentation please visit https://docs.edgexfoundry.org/latest/microservices/device/services/device-opc-ua/Purpose

## Overview

This repository is a Go-based EdgeX Foundry Device Service which uses OPC-UA protocol to interact with the devices or IoT objects.
Expand All @@ -22,45 +33,21 @@ This repository is a Go-based EdgeX Foundry Device Service which uses OPC-UA pro

Download the Prosys OPC UA Simulation Server from [here](https://www.prosysopc.com/products/opc-ua-simulation-server/). Install and run it to have access to the default configured resources.

### Pre-defined Devices

Define devices for device-sdk to auto upload device profile and create device instance. Please modify `devices.toml` file found under the `./cmd/res/devices` folder.
### Configuration

> This device service is currently limited to a single device instance.
Modify [configuration.yaml](./cmd/res/configuration.yaml) file found under the `./cmd/res` folder if needed

```toml
# Pre-define Devices
[[DeviceList]]
Name = "SimulationServer"
Profile = "OPCUA-Server"
Description = "OPCUA device is created for test purpose"
Labels = [ "test" ]
[DeviceList.Protocols]
[DeviceList.Protocols.opcua]
Endpoint = "opc.tcp://127.0.0.1:53530/OPCUA/SimulationServer"
```
### Pre-defined Devices

### Configuration
Define devices for device-sdk to auto upload device profile and create device instance. Please modify [Simple_Devices.yaml](./cmd/res/devices/Simple-Devices.yaml) file found under the `./cmd/res/devices` folder.

Modify `configuration.toml` file found under the `./cmd/res` folder if needed

```toml
# Driver configs
[OPCUAServer]
DeviceName = "SimulationServer" # Name of existing Device
Policy = "None" # Security policy: None, Basic128Rsa15, Basic256, Basic256Sha256. Default: None
Mode = "None" # Security mode: None, Sign, SignAndEncrypt. Default: None
CertFile = "" # Path to cert.pem. Required for security mode/policy != None
KeyFile = "" # Path to private key.pem. Required for security mode/policy != None
[OPCUAServer.Writable]
Resources = "Counter,Random" # Device resources related to Node IDs to subscribe to (comma-separated values)
```
> This device service is currently limited to a single device instance.
## Device Profile
### Device Profile

A Device Profile can be thought of as a template of a type or classification of a Device.

Write a device profile for your own devices; define `deviceResources` and `deviceCommands`. Please refer to `cmd/res/profiles/OpcuaServer.yaml`.
Write a device profile for your own devices; define `deviceResources` and `deviceCommands`. Please refer to [OpcuaServer.yaml](cmd/res/profiles/OpcuaServer.yaml).

### Using Methods

Expand Down Expand Up @@ -91,19 +78,20 @@ Notice that method calls require specifying the NodeId of both the method and it
The `attributes` field may also contain an `inputMap: []` that passes parameters to the method, if applicable.

## Build and Run

```bash
make build
cd cmd
EDGEX_SECURITY_SECRET_STORE=false ./device-opcua -cp -d -o
```
## Build Instructions

## Build a Container Image
1. Clone the device-rest-go repo with the following command:

```bash
make docker
```
git clone https://github.com/edgexfoundry/device-opc-ua.git

2. Build a docker image by using the following command:

make docker

3. Alternatively the device service can be built natively:

make build

## Testing

Expand All @@ -128,6 +116,12 @@ python3 -m pip install opcua
make test
```

## Packaging

This component is packaged as docker images.

Please refer to the [Dockerfile](./Dockerfile) and [Docker Compose Builder](https://github.com/edgexfoundry/edgex-compose/tree/main/compose-builder) scripts.

## Reference

- [EdgeX Foundry Services](https://github.com/edgexfoundry/edgex-go)
Expand Down
2 changes: 1 addition & 1 deletion bin/edgex-launch.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (c) 2018 Mainflux
# Copyright (C) 2023 YIQISOFT
# Copyright (C) 2024 YIQISOFT
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down
6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// Copyright (C) 2017-2018 Canonical Ltd
// Copyright (C) 2018 IOTech Ltd
// Copyright (C) 2021 Schneider Electric
// Copyright (C) 2023 YIQISOFT
// Copyright (C) 2024 YIQISOFT
//
// SPDX-License-Identifier: Apache-2.0

package main

import (
device_opcua "github.com/edgexfoundry/device-opcua-go"
"github.com/edgexfoundry/device-opcua-go/internal/driver"
device_opcua "github.com/edgexfoundry/device-opc-ua"
"github.com/edgexfoundry/device-opc-ua/internal/driver"
"github.com/edgexfoundry/device-sdk-go/v3/pkg/startup"
)

Expand Down
136 changes: 99 additions & 37 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
module github.com/edgexfoundry/device-opcua-go
module github.com/edgexfoundry/device-opc-ua

go 1.21

require (
github.com/edgexfoundry/device-sdk-go/v3 v3.2.0-dev.4
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.2
github.com/edgexfoundry/device-sdk-go/v3 v3.2.0-dev.12
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.15
github.com/gopcua/opcua v0.5.3
github.com/spf13/cast v1.6.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0

)

require (
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/eclipse/paho.mqtt.golang v1.4.3 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.2.0-dev.7 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.2.0-dev.1 // indirect
github.com/edgexfoundry/go-mod-messaging/v3 v3.2.0-dev.3 // indirect
github.com/edgexfoundry/go-mod-registry/v3 v3.2.0-dev.1 // indirect
github.com/edgexfoundry/go-mod-secrets/v3 v3.2.0-dev.2 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.2.0-dev.27 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.2.0-dev.3 // indirect
github.com/edgexfoundry/go-mod-messaging/v3 v3.2.0-dev.14 // indirect
github.com/edgexfoundry/go-mod-registry/v3 v3.2.0-dev.3 // indirect
github.com/edgexfoundry/go-mod-secrets/v3 v3.2.0-dev.5 // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa // indirect
github.com/fxamacker/cbor/v2 v2.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
github.com/go-openapi/runtime v0.28.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // 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.16.0 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/go-redis/redis/v7 v7.3.0 // indirect
github.com/go-resty/resty/v2 v2.12.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/consul/api v1.25.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/consul/api v1.27.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
Expand All @@ -46,39 +68,79 @@ 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/klauspost/compress v1.17.1 // indirect
github.com/labstack/echo/v4 v4.11.3 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kataras/go-events v0.0.3 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/labstack/echo/v4 v4.11.4 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/michaelquigley/pfxlog v0.6.10 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/nats-io/nats.go v1.31.0 // indirect
github.com/nats-io/nkeys v0.4.6 // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/nats-io/nats.go v1.33.1 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openziti/channel/v2 v2.0.121 // indirect
github.com/openziti/edge-api v0.26.13 // indirect
github.com/openziti/foundation/v2 v2.0.39 // indirect
github.com/openziti/identity v1.0.72 // indirect
github.com/openziti/metrics v1.2.47 // indirect
github.com/openziti/sdk-golang v0.23.13 // indirect
github.com/openziti/secretstream v0.1.17 // indirect
github.com/openziti/transport/v2 v2.0.124 // indirect
github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect
github.com/parallaxsecond/parsec-client-go v0.0.0-20221025095442-f0a77d263cf9 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.6 // indirect
github.com/shirou/gopsutil/v3 v3.24.1 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/speps/go-hashids v2.0.0+incompatible // indirect
github.com/spiffe/go-spiffe/v2 v2.1.7 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zeebo/errs v1.3.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.30.0 // indirect
github.com/zitadel/oidc/v2 v2.12.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.10 // indirect
)
Loading

0 comments on commit 11f2cd1

Please sign in to comment.