Skip to content

Commit b912d32

Browse files
refactor: update readme and examples
1 parent 2470c80 commit b912d32

2 files changed

Lines changed: 11 additions & 52 deletions

File tree

packages/binding-opcua/README.md

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ const thingDescription = {
2828
type: "number",
2929
forms: [
3030
{
31-
href: "opc.tcp://opcuademo.sterfive.com:26543", // endpoint,
31+
href: "opc.tcp://opcuademo.sterfive.com:26543?id=ns=1;s=PumpSpeed",
3232
op: ["readproperty", "observeproperty"],
33-
"opcua:nodeId": "ns=1;s=PumpSpeed",
3433
},
3534
],
3635
},
@@ -64,60 +63,23 @@ import { thingDescription } from "./demo-opcua-thing-description";
6463

6564
### Run the Example App
6665

67-
The `examples/src/opcua` folder contains a set of typescript demo that shows you
66+
The `examples/src/bindings/opcua` folder contains a set of typescript demo that shows you
6867
how to define a thing description containing OPCUA Variables and methods.
6968

7069
- `demo-opcua1.ts` shows how to define and read an OPC-UA variable in WoT.
7170
- `demo-opcua2.ts` shows how to subscribe to an OPC-UA variable in WoT.
7271
- `opcua-coffee-machine-demo.ts` demonstrates how to define and invoke OPCUA methods as WoT actions.
7372

74-
### Form extensions
73+
### Format for href
7574

76-
#### href
77-
78-
the `href` property must contains a OPCUA endpoint url in the form `opc.tcp://MACHINE:PORT/Application`
75+
The `href` must contain an OPCUA endpoint url in the form of `opc.tcp://<address>:<port>/?id=<nodeId>`
7976
such as for instance:
80-
`opc.tcp://opcuademo.sterfive.com:26543` or `opc.tcp://localhost:48010`
81-
82-
#### opcua:nodeId
83-
84-
The form must contain an `opcua:nodeId` property that describes the nodeId of the OPCUA Variable to read/write/subscribe or the nodeId of the OPCUA Object related to the action.
85-
86-
The `opcua:nodeId` can have 2 forms:
87-
88-
- a **NodeId** as a string, such as `"ns=1;i=1234"` , for instance:
89-
90-
```javascript
91-
"opcua:nodeId": "ns=1;s=\"Machine\".\"Component\""
92-
```
93-
94-
- or **browsePath**: The browse path will be converted into the corresponding nodeId at runtime when first encountered.
95-
96-
```
97-
"opcua:nodeId": { root: "i=84", path: "/Objects/2:DeviceSet/1:CoffeeMachine" },
98-
```
77+
`opc.tcp://opcuademo.sterfive.com:26543?id=ns=1;s=PumpSpeed`
9978

100-
### opcua:method
79+
`<nodeId>` has the following expectations:
10180

102-
for example:
103-
104-
```typescript
105-
const thingDescription = {
106-
// ...
107-
actions: {
108-
brewCoffee: {
109-
forms: [
110-
{
111-
href: "opc.tcp://opcuademo.sterfive.com:26543",
112-
op: ["invokeaction"],
113-
"opcua:nodeId": { root: "i=84", path: "/Objects/2:DeviceSet/1:CoffeeMachine" },
114-
"opcua:method": { root: "i=84", path: "/Objects/2:DeviceSet/1:CoffeeMachine/2:MethodSet/9:Start" },
115-
},
116-
],
117-
},
118-
},
119-
};
120-
```
81+
- any hash character (`#`) must be URL encoded (`%23`)
82+
- any ampersand character (`&`) must be URL encoded (`%26`)
12183

12284
### defining a property
12385

@@ -133,9 +95,8 @@ const thingDescription = {
13395
type: "number",
13496
forms: [
13597
{
136-
href: "opc.tcp://opcuademo.sterfive.com:26543",
98+
href: "opc.tcp://opcuademo.sterfive.com:26543?id=ns=1;s=Temperature",
13799
op: ["readproperty", "observeproperty"],
138-
"opcua:nodeId": "ns=1;s=Temperature",
139100
},
140101
],
141102
},

packages/examples/src/bindings/opcua/demo-opcua-thing-description.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ export const thingDescription: WoT.ThingDescription = {
3434
type: "number",
3535
forms: [
3636
{
37-
href: endpointUrl,
37+
href: endpointUrl + "?id=ns=1;s=PumpSpeed",
3838
op: ["readproperty", "observeproperty"],
39-
"opcua:nodeId": "ns=1;s=PumpSpeed",
4039
},
4140
],
4241
},
@@ -48,9 +47,8 @@ export const thingDescription: WoT.ThingDescription = {
4847
type: "number",
4948
forms: [
5049
{
51-
href: endpointUrl,
50+
href: endpointUrl + "?id=ns=1;s=Temperature",
5251
op: ["readproperty", "observeproperty"],
53-
"opcua:nodeId": "ns=1;s=Temperature",
5452
},
5553
],
5654
},

0 commit comments

Comments
 (0)