OpcUaServer

Description

The OpcUaServer object provides an OPC UA server to which OpcUaServerNamespace objects with corresponding child nodes can be added.

This object was introduced in InCore 2.3.

› Inherits:Object

Properties

enabled

This property holds whether the OPC UA server should listen for incoming connections.

› Type:Boolean
› Default:true
› Signal:enabledChanged()
› Attributes:Writable

namespaces

› Type:List<OpcUaServerNamespace>
› Signal:namespacesChanged()
› Attributes:Readonly

nodeSets

This property holds a list of OPC UA NodeSet files which to load at start.

This property was introduced in InCore 2.4.

› Type:StringList
› Signal:nodeSetsChanged()
› Attributes:Writable

port

This property holds the network port number which to listen at for incoming connections.

› Type:SignedInteger
› Default:4840
› Signal:portChanged()
› Attributes:Writable

security

This property holds the security settings for the server.

› Type:OpcUaServerSecurity
› Attributes:Readonly

users

› Type:List<OpcUaServerUser>
› Signal:usersChanged()
› Attributes:Readonly

Methods

syncAllNodes()

This method synchronizes all nodes (which may have changed dynamically) with the underlying OPC UA server instance.

This method was introduced in InCore 2.6.

syncNode(OpcUaServerNode startNode)

This method recursively synchronizes the given nodes with the underlying OPC UA server instance.

This method was introduced in InCore 2.6.

Signals

namespacesDataChanged(SignedInteger index)

This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the namespaces list itself emitted the dataChanged() signal.

usersDataChanged(SignedInteger index)

This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the users list itself emitted the dataChanged() signal.

Example

import InCore.Foundation 2.5
import InCore.OpcUa 2.5

Application {
    OpcUaServer {
        security {
            policies: OpcUaServerSecurity.PolicyNone |
                      OpcUaServerSecurity.PolicyBasic256Sha256 |
                      OpcUaServerSecurity.PolicyAes128Sha256RsaOaep
            privateKeyFile: "certs/server_key.der"
            certificateFile: "certs/server_cert.der"
        }

        users: [ OpcUaServerUser { name: "user"; password: "secret" } ]

        OpcUaServerNamespace {
            uri: "http://inhub.de/opcuaserverexample"
            OpcUaServerObjectNode {
                identifier: "s=Machine"
                browseName: "Machine"
                displayName.text: "My Machine"
                description.text: "This is my awesome machine"

                OpcUaServerValueNode {
                    identifier: "s=Machine.ExampleValue"
                    browseName: "ExampleValue"
                    displayName.text: "Example Value"
                    description.text: "This is an example value"
                    valueType: OpcUaType.Double
                    value: 123
                    property var t : Timer { onTriggered: parent.value = Math.random() }
                    readOnly: true
                }

                OpcUaServerMethodNode {
                    identifier: "s=Machine.RunMe"
                    browseName: "ExampleMethod"
                    displayName.text: "Example method"
                    method: (foo, bar) => {
                                console.log("hello world:", foo, bar)
                                return [ foo > 0, "thank you for calling" ]
                            }
                    inputArguments: [
                        OpcUaServerMethodArgument { name: "foo"; type: OpcUaType.Double },
                        OpcUaServerMethodArgument { name: "bar"; type: OpcUaType.String }
                    ]
                    outputArguments: [
                        OpcUaServerMethodArgument { name: "out1"; type: OpcUaType.Boolean; description.text: "Foo is positive" },
                        OpcUaServerMethodArgument { name: "out2"; type: OpcUaType.String }
                    ]
                }
            }
        }
    }
}