@jsh/opcua
Since v8.0.52Client
The OPCUA client.
Usage example
|
|
Creation
Constructor | Description |
---|---|
new Client(options) | Instantiates a opcua client object with an options |
Options
Option | Type | Default | Description |
---|---|---|---|
endpoint | String | "" | server address |
readRetryInterval | Number | 100 | read retry interval in ms. |
messageSecurityMode | MessageSecurityMode |
close()
Disconnect.
Syntax
close()
Parameters
None.
Return value
None.
read()
Syntax
read(read_request)
Parameters
read_request
Object
ReadRequest
Return value
Object[]
Array of ReadResult
vs = client.read({
nodes: [ "ns=1;s=ro_bool", "ns=1;s=rw_int32"],
timestampsToReturn:ua.TimestampsToReturn.Both
});
vs.forEach((v, idx) => {
console.log(nodes[idx], v.status, v.statusCode, v.value, v.type);
})
write()
Syntax
write(...write_request)
Parameters
write_request
Object
Variable length of WriteRequest
Return value
Object
WriteResult
rsp = client.write(
{node: "ns=1;s=rw_bool", value: false},
{node: "ns=1;s=rw_int32", value: 1234}
)
console.log("results:", rsp.results);
ReadRequest
Option | Type | Default | Description |
---|---|---|---|
nodes | String[] | array of node IDs | |
maxAge | Number | 100 | read retry interval in ms. |
timestampsToReturn | TimestampToReturn |
ReadResult
Properties
Property | Type | Description |
---|---|---|
status | Number | |
statusText | String | |
statusCode | String | |
value | any | |
sourceTimestamp | Number | Unix epoch (milliseconds) |
sourceTimestamp | Number | Unix epoch (milliseconds) |
WriteRequest
Properties
Property | Type | Description |
---|---|---|
node | String | node ID |
value | any | value to write |
WriteResult
Properties
Property | Type | Description |
---|---|---|
results | Number[] | array of status codes |
timestamp | Number | Unix epoch (milliseconds) |
stringTables | String[] | array of strings |
MessageSecurityMode
MessageSecurityMode.None
MessageSecurityMode.Sign
MessageSecurityMode.SignAndEncrypt
TimestampToReturn
TimestampToReturn.Source
TimestampToReturn.Server
TimestampToReturn.Both
TimestampToReturn.Neither
Last updated on