-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75d64f5
commit ffc07a1
Showing
10 changed files
with
794 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# OPC UA Resource Pack | ||
|
||
Query all nodes: | ||
|
||
```coffeescript | ||
# gather all available namespaces | ||
opcua.namespaces { * } | ||
opcua.namespaces: [ | ||
0: { | ||
id: 0 | ||
name: "http://opcfoundation.org/UA/" | ||
} | ||
1: { | ||
id: 1 | ||
name: "urn:open62541.server.application" | ||
} | ||
] | ||
|
||
# gather root node | ||
cnquery> opcua.root | ||
opcua.root: opcua.node id="i=84" name="Root" | ||
|
||
|
||
# gather all nodes | ||
cnquery> opcua.nodes { name namespace.name } | ||
|
||
# gather node with a specific id | ||
cnquery> opcua.nodes.where (id == "i=2253") | ||
opcua.nodes.where: [ | ||
0: opcua.node id="i=2253" name="Server" | ||
] | ||
|
||
# gather details about the server | ||
cnquery> opcua.server { * } | ||
opcua.server: { | ||
buildInfo: { | ||
BuildDate: "2023-05-21T21:03:43.817369Z" | ||
BuildNumber: "May 20 2023 15:51:32" | ||
ManufacturerName: "open62541" | ||
ProductName: "open62541 OPC UA Server" | ||
ProductURI: "http://open62541.org" | ||
SoftwareVersion: "1.3.5-994-g5d73f0cc5" | ||
} | ||
node: opcua.node id="i=2253" name="Server" | ||
currentTime: 2023-05-22 08:28:30.625932 +0000 UTC | ||
state: "ServerStateRunning" | ||
startTime: 2023-05-21 21:03:43.834304 +0000 UTC | ||
} | ||
``` | ||
|
||
## Example Servers | ||
|
||
*Open62541* | ||
|
||
The [Open62541](https://github.com/open62541/open62541) includes may examples for building an Open62541 server. | ||
|
||
|
||
*Azure IoT Edge* | ||
|
||
Azure has an example for [OPC PLC server](https://github.com/Azure-Samples/iot-edge-opc-plc) available that you can quickly start locally: | ||
|
||
```bash | ||
# run service with no security configuration | ||
docker run --rm -it -p 50000:50000 -p 8080:8080 --name opcplc mcr.microsoft.com/iotedge/opc-plc:latest --pn=50000 --autoaccept --sph --sn=5 --sr=10 --st=uint --fn=5 --fr=1 --ft=uint --gn=5 --ut --dca | ||
``` | ||
|
||
## UI | ||
|
||
*Simple OPC-UA GUI client* | ||
|
||
This is a very simple [client](https://github.com/FreeOpcUa/opcua-client-gui) that allows you to browse the OPC UA data: | ||
|
||
```bash | ||
pip3 install opcua-client | ||
opcua-client | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"resources":{"opcua":{"id":"opcua","name":"opcua","fields":{"namespaces":{"name":"namespaces","type":"\u0019\u0007"},"root":{"name":"root","type":"\u001bopcua.node"}},"title":"OPC UA"},"opcua.namespace":{"id":"opcua.namespace","name":"opcua.namespace","fields":{"id":{"name":"id","type":"\u0005","is_mandatory":true},"name":{"name":"name","type":"\u0007","is_mandatory":true}},"title":"OPC UA Namespace"},"opcua.node":{"id":"opcua.node","name":"opcua.node","fields":{"accessLevel":{"name":"accessLevel","type":"\u0007","is_mandatory":true},"class":{"name":"class","type":"\u0007","is_mandatory":true},"components":{"name":"components","type":"\u0019\u001bopcua.node"},"dataType":{"name":"dataType","type":"\u0007","is_mandatory":true},"description":{"name":"description","type":"\u0007","is_mandatory":true},"id":{"name":"id","type":"\u0007","is_mandatory":true},"max":{"name":"max","type":"\u0007","is_mandatory":true},"min":{"name":"min","type":"\u0007","is_mandatory":true},"name":{"name":"name","type":"\u0007","is_mandatory":true},"organizes":{"name":"organizes","type":"\u0019\u001bopcua.node"},"properties":{"name":"properties","type":"\u0019\u001bopcua.node"},"unit":{"name":"unit","type":"\u0007","is_mandatory":true},"writeable":{"name":"writeable","type":"\u0004","is_mandatory":true}},"title":"OPC UA Node","defaults":"id name"}}} | ||
{"resources":{"opcua":{"id":"opcua","name":"opcua","fields":{"namespaces":{"name":"namespaces","type":"\u0019\u001bopcua.namespace","title":"Namespaces"},"nodes":{"name":"nodes","type":"\u0019\u001bopcua.node","title":"List of all nodes"},"root":{"name":"root","type":"\u001bopcua.node","title":"Root node"}},"title":"OPC UA"},"opcua.namespace":{"id":"opcua.namespace","name":"opcua.namespace","fields":{"id":{"name":"id","type":"\u0005","is_mandatory":true,"title":"Namespace ID"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Namespace Name"}},"title":"OPC UA Namespace"},"opcua.node":{"id":"opcua.node","name":"opcua.node","fields":{"accessLevel":{"name":"accessLevel","type":"\u0007","is_mandatory":true},"class":{"name":"class","type":"\u0007","is_mandatory":true},"components":{"name":"components","type":"\u0019\u001bopcua.node"},"dataType":{"name":"dataType","type":"\u0007","is_mandatory":true},"description":{"name":"description","type":"\u0007","is_mandatory":true},"id":{"name":"id","type":"\u0007","is_mandatory":true},"max":{"name":"max","type":"\u0007","is_mandatory":true},"min":{"name":"min","type":"\u0007","is_mandatory":true},"name":{"name":"name","type":"\u0007","is_mandatory":true},"namespace":{"name":"namespace","type":"\u001bopcua.namespace"},"organizes":{"name":"organizes","type":"\u0019\u001bopcua.node"},"properties":{"name":"properties","type":"\u0019\u001bopcua.node"},"unit":{"name":"unit","type":"\u0007","is_mandatory":true},"writeable":{"name":"writeable","type":"\u0004","is_mandatory":true}},"title":"OPC UA Node","defaults":"id name"},"opcua.server":{"id":"opcua.server","name":"opcua.server","fields":{"buildInfo":{"name":"buildInfo","type":"\n","is_mandatory":true},"currentTime":{"name":"currentTime","type":"\t","is_mandatory":true},"node":{"name":"node","type":"\u001bopcua.node","is_mandatory":true},"startTime":{"name":"startTime","type":"\t","is_mandatory":true},"state":{"name":"state","type":"\u0007","is_mandatory":true}},"title":"Server Object"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"resources":{"opcua":{"fields":{"namespaces":{},"root":{}},"min_mondoo_version":"latest"},"opcua.namespace":{"fields":{"id":{},"name":{}},"min_mondoo_version":"latest"},"opcua.node":{"fields":{"accessLevel":{},"class":{},"components":{},"dataType":{},"description":{},"id":{},"max":{},"min":{},"name":{},"namespace":{},"nodeid":{},"organizes":{},"properties":{},"unit":{},"writeable":{}},"min_mondoo_version":"latest"}}} | ||
{"resources":{"opcua":{"fields":{"namespaces":{},"nodes":{},"root":{}},"min_mondoo_version":"latest"},"opcua.namespace":{"fields":{"id":{},"name":{}},"min_mondoo_version":"latest"},"opcua.node":{"fields":{"accessLevel":{},"class":{},"components":{},"dataType":{},"description":{},"id":{},"max":{},"min":{},"name":{},"namespace":{},"nodeid":{},"organizes":{},"properties":{},"unit":{},"writeable":{}},"min_mondoo_version":"latest"},"opcua.server":{"fields":{"buildInfo":{},"currentTime":{},"node":{},"startTime":{},"state":{}},"min_mondoo_version":"latest"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package opcua | ||
|
||
import ( | ||
"go.mondoo.com/cnquery/resources" | ||
"strconv" | ||
) | ||
|
||
func (o *mqlOpcuaNamespace) id() (string, error) { | ||
id, err := o.Id() | ||
if err != nil { | ||
return "", err | ||
} | ||
s := strconv.FormatInt(id, 10) | ||
return "opcua.namespace/" + s, nil | ||
} | ||
|
||
// https://reference.opcfoundation.org/DI/v102/docs/11.2 | ||
func (o *mqlOpcua) GetNamespaces() ([]interface{}, error) { | ||
op, err := opcuaProvider(o.MotorRuntime.Motor.Provider) | ||
if err != nil { | ||
return nil, err | ||
} | ||
client := op.Client() | ||
|
||
namespaces := client.Namespaces() | ||
resList := []interface{}{} | ||
for i := range namespaces { | ||
res, err := newMqlOpcuaNamespaceResource(o.MotorRuntime, int64(i), namespaces[i]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resList = append(resList, res) | ||
} | ||
return resList, nil | ||
} | ||
|
||
func newMqlOpcuaNamespaceResource(runtime *resources.Runtime, id int64, name string) (interface{}, error) { | ||
return runtime.CreateResource("opcua.namespace", | ||
"id", id, | ||
"name", name, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.