opcua

package module
v0.0.0-...-654ee49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 29 Imported by: 0

README

Artwork by Ashley McNamara
Inspired by Renee French
Taken from https://gopherize.me by Mat Ryer

OPC/UA

A native Go implementation of the OPC/UA Binary Protocol.

We support the current and previous major Go release. See below for a list of Tested Platforms and Supported Features.

GitHub Go Reference License Version

v0.5.x BREAKING CHANGES

  • v0.5.0 released on 14 Aug 2023: all Client methods must have a context
  • v0.5.1 released on 22 Aug 2023: the NewClient function returns an error

In v0.3.0 on 21 Jan 2022 release we added WithContext variants for all methods to avoid a breaking change. All existing methods without a context had a disclaimer that with v0.5.0 their signature would change to include the context and that the WithContext method would be removed.

We missed to update the NewClient function in v0.5.0 which was fixed in v0.5.1.

Please update your code and let us know if there are any issues!

Thank you!

Your GOPCUA Team

Quickstart

# install library
go get -u github.com/zheleziv/opcua

# get current date and time 'ns=0;i=2258'
go run examples/datetime/datetime.go -endpoint opc.tcp://localhost:4840

# read the server version
go run examples/read/read.go -endpoint opc.tcp://localhost:4840 -node 'ns=0;i=2261'

# get the current date time using different security and authentication modes
go run examples/crypto/*.go -endpoint opc.tcp://localhost:4840 -cert path/to/cert.pem -key path/to/key.pem -sec-policy Basic256 -sec-mode SignAndEncrypt

# checkout examples/ for more examples...

Sponsors

The gopcua project is sponsored by the following organizations by supporting the active committers to the project:

Northvolt evosoft Intelecy AS

Users

We would also like to list organizations which use gopcua in production. Please open a PR to include your logo below.

strtaeos

united manufacturing hub

Projects using gopcua

gopcua is not only utilized in production environments, but it also serves as a critical component in other larger projects. Here are some projects that rely on gopcua for their functionality:

  • Telegraf: This plugin-driven server agent is used for collecting and sending metrics. It leverages gopcua to extract data from OPC-UA servers and insert it into InfluxDB. Telegraf supports both polling and subscribing methods for data acquisition.
  • benthos-umh: This project is built upon the benthos stream-processing framework. It utilizes gopcua to extract data from OPC-UA servers and forwards the information to MQTT or Kafka brokers. benthos-umh currently supports polling for data collection.

Disclaimer

We are still actively working on this project and the APIs will change.

However, you can safely assume that we are aiming to make the APIs as stable as possible since the code is in use in several large scale production environments.

The Current State was moved to the Wiki.

Your Help is Appreciated

If you are looking for ways to contribute you can

  • test the high-level client against real OPC/UA servers
  • add functions to the client or tell us which functions you need for gopcua to be useful
  • work on the security layer, server and other components
  • and last but not least, file issues, review code and write/update documentation

Also, if the library is already useful please spread the word as a motivation.

Tested Platforms

gopcua is run in production by several companies and with different equipment. The table below is an incomplete list of where and how gopcua is used to provide some guidance on the level of testing.

We would be happy if you can add your equipment to the list. Just open a PR :)

Device gopcua version Environment By
Siemens S7-1500 v0.1.x..latest production Northvolt
Beckhoff C6015-0010,C6030-0060 on OPC/UA server 4.3.x v0.1.x..latest production Northvolt
Kepware 6.x v0.1.x..latest production Northvolt
Kepware 6.x v0.1.x, v0.2.x production Intelecy
Cogent DataHub 9.x v0.1.x, v0.2.x production Intelecy
ABB Ability EdgeInsight 1.8.X v0.1.x, v0.2.x production Intelecy
GE Digital Historian 2022 HDA Server v0.3.x production Intelecy
B&R Automation PC 3100 v0.3.x production ACS
InfluxDB Telegraf plugin v0.3.x ? Community

Supported Features

The current focus is on the OPC UA Binary protocol over TCP. No other protocols are supported at this point.

Categories Features Supported Notes
Encoding OPC UA Binary Yes
OPC UA JSON not planned
OPC UA XML not planned
Transport UA-TCP UA-SC UA Binary Yes
OPC UA HTTPS not planned
SOAP-HTTP WS-SC UA Binary not planned
SOAP-HTTP WS-SC UA XML not planned
SOAP-HTTP WS-SC UA XML-UA Binary not planned
Encryption None Yes
Basic128Rsa15 Yes
Basic256 Yes
Basic256Sha256 Yes
Authentication Anonymous Yes
User Name Password Yes
X509 Certificate Yes

Services

Here is the current set of supported services. For low-level access use the client Send function directly.

Service Set Service Client Notes
Discovery Service Set FindServers Yes
FindServersOnNetwork Yes
GetEndpoints Yes
RegisterServer
RegisterServer2
Secure Channel Service Set OpenSecureChannel Yes
CloseSecureChannel Yes
Session Service Set CreateSession Yes
CloseSession Yes
ActivateSession Yes
Cancel
Node Management Service Set AddNodes
AddReferences
DeleteNodes
DeleteReferences
View Service Set Browse Yes
BrowseNext Yes
TranslateBrowsePathsToNodeIds
RegisterNodes Yes
UnregisterNodes Yes
Query Service Set QueryFirst
QueryNext
Attribute Service Set Read Yes
Write Yes
HistoryRead Yes
HistoryUpdate
Method Service Set Call Yes
MonitoredItems Service Set CreateMonitoredItems Yes
DeleteMonitoredItems Yes
ModifyMonitoredItems Yes
SetMonitoringMode
SetTriggering
Subscription Service Set CreateSubscription Yes
ModifySubscription
SetPublishingMode
Publish Yes
Republish
DeleteSubscriptions Yes
TransferSubscriptions

Authors

The Gopcua Team.

If you need to get in touch with us directly you may find us on Keybase.io but try to create an issue first.

License

MIT

Documentation

Overview

Package opcua provides easy and painless encoding/decoding of OPC UA protocol in pure Golang.

Index

Constants

View Source
const (
	DefaultSubscriptionMaxNotificationsPerPublish = 10000
	DefaultSubscriptionLifetimeCount              = 10000
	DefaultSubscriptionMaxKeepAliveCount          = 3000
	DefaultSubscriptionInterval                   = 100 * time.Millisecond
	DefaultSubscriptionPriority                   = 0
)

Variables

This section is empty.

Functions

func DefaultClientConfig

func DefaultClientConfig() *uasc.Config

DefaultClientConfig returns the default configuration for a client to establish a secure channel.

func DefaultSessionConfig

func DefaultSessionConfig() *uasc.SessionConfig

DefaultSessionConfig returns the default configuration for a client to establish a session.

func FindServers

func FindServers(ctx context.Context, endpoint string, opts ...Option) ([]*ua.ApplicationDescription, error)

FindServers returns the servers known to a server or discovery server.

func FindServersOnNetwork

func FindServersOnNetwork(ctx context.Context, endpoint string, opts ...Option) ([]*ua.ServerOnNetwork, error)

FindServersOnNetwork returns the servers known to a server or discovery server. Unlike FindServers, this service is only implemented by discovery servers.

func GetEndpoints

func GetEndpoints(ctx context.Context, endpoint string, opts ...Option) ([]*ua.EndpointDescription, error)

GetEndpoints returns the available endpoint descriptions for the server.

func NewDialer

func NewDialer(cfg *Config) *uacp.Dialer

NewDialer creates a uacp.Dialer from the config options

func NewMonitoredItemCreateRequestWithDefaults

func NewMonitoredItemCreateRequestWithDefaults(nodeID *ua.NodeID, attributeID ua.AttributeID, clientHandle uint32) *ua.MonitoredItemCreateRequest

func SelectEndpoint

func SelectEndpoint(endpoints []*ua.EndpointDescription, policy string, mode ua.MessageSecurityMode) *ua.EndpointDescription

SelectEndpoint returns the endpoint with the highest security level which matches security policy and security mode. policy and mode can be omitted so that only one of them has to match. todo(fs): should this function return an error?

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a high-level client for an OPC/UA server. It establishes a secure channel and a session.

func NewClient

func NewClient(endpoint string, opts ...Option) (*Client, error)

NewClient creates a new Client.

When no options are provided the new client is created from DefaultClientConfig() and DefaultSessionConfig(). If no authentication method is configured, a UserIdentityToken for anonymous authentication will be set. See #Client.CreateSession for details.

To modify configuration you can provide any number of Options as opts. See #Option for details.

https://godoc.org/github.com/zheleziv/opcua#Option

func (*Client) ActivateSession

func (c *Client) ActivateSession(ctx context.Context, s *Session) error

ActivateSession activates the session and associates it with the client. If the client already has a session it will be closed. To retain the current session call DetachSession.

See Part 4, 5.6.3

func (*Client) Browse

func (c *Client) Browse(ctx context.Context, req *ua.BrowseRequest) (*ua.BrowseResponse, error)

Browse executes a synchronous browse request.

func (*Client) BrowseNext

func (c *Client) BrowseNext(ctx context.Context, req *ua.BrowseNextRequest) (*ua.BrowseNextResponse, error)

BrowseNext executes a synchronous browse request.

func (*Client) Call

Call executes a synchronous call request for a single method.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close closes the session and the secure channel.

func (*Client) CloseSession

func (c *Client) CloseSession(ctx context.Context) error

CloseSession closes the current session.

See Part 4, 5.6.4

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

Connect establishes a secure channel and creates a new session.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, cfg *uasc.SessionConfig) (*Session, error)

CreateSession creates a new session which is not yet activated and not associated with the client. Call ActivateSession to both activate and associate the session with the client.

If no UserIdentityToken is given explicitly before calling CreateSesion, it automatically sets anonymous identity token with the same PolicyID that the server sent in Create Session Response. The default PolicyID "Anonymous" wii be set if it's missing in response.

See Part 4, 5.6.2

func (*Client) DetachSession

func (c *Client) DetachSession(ctx context.Context) (*Session, error)

DetachSession removes the session from the client without closing it. The caller is responsible to close or re-activate the session. If the client does not have an active session the function returns no error.

func (*Client) Dial

func (c *Client) Dial(ctx context.Context) error

Dial establishes a secure channel.

func (*Client) FindNamespace

func (c *Client) FindNamespace(ctx context.Context, name string) (uint16, error)

FindNamespace returns the id of the namespace with the given name.

func (*Client) FindServers

func (c *Client) FindServers(ctx context.Context) (*ua.FindServersResponse, error)

FindServers finds the servers available at an endpoint

func (*Client) FindServersOnNetwork

func (c *Client) FindServersOnNetwork(ctx context.Context) (*ua.FindServersOnNetworkResponse, error)

FindServersOnNetwork finds the servers available at an endpoint

func (*Client) GetEndpoints

func (c *Client) GetEndpoints(ctx context.Context) (*ua.GetEndpointsResponse, error)

GetEndpoints returns the list of available endpoints of the server.

func (*Client) HistoryReadAtTime

func (c *Client) HistoryReadAtTime(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadAtTimeDetails) (*ua.HistoryReadResponse, error)

func (*Client) HistoryReadEvent

func (c *Client) HistoryReadEvent(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadEventDetails) (*ua.HistoryReadResponse, error)

func (*Client) HistoryReadProcessed

func (c *Client) HistoryReadProcessed(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadProcessedDetails) (*ua.HistoryReadResponse, error)

func (*Client) HistoryReadRawModified

func (c *Client) HistoryReadRawModified(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadRawModifiedDetails) (*ua.HistoryReadResponse, error)

func (*Client) NamespaceArray

func (c *Client) NamespaceArray(ctx context.Context) ([]string, error)

NamespaceArray returns the list of namespaces registered on the server.

func (*Client) Namespaces

func (c *Client) Namespaces() []string

Namespaces returns the currently cached list of namespaces.

func (*Client) Node

func (c *Client) Node(id *ua.NodeID) *Node

Node returns a node object which accesses its attributes through this client connection.

func (*Client) NodeFromExpandedNodeID

func (c *Client) NodeFromExpandedNodeID(id *ua.ExpandedNodeID) *Node

NodeFromExpandedNodeID returns a node object which accesses its attributes through this client connection. This is usually needed when working with node ids returned from browse responses by the server.

func (*Client) Read

func (c *Client) Read(ctx context.Context, req *ua.ReadRequest) (*ua.ReadResponse, error)

Read executes a synchronous read request.

By default, the function requests the value of the nodes in the default encoding of the server.

func (*Client) RegisterNodes

func (c *Client) RegisterNodes(ctx context.Context, req *ua.RegisterNodesRequest) (*ua.RegisterNodesResponse, error)

RegisterNodes registers node ids for more efficient reads.

Part 4, Section 5.8.5

func (*Client) SecureChannel

func (c *Client) SecureChannel() *uasc.SecureChannel

SecureChannel returns the active secure channel. During reconnect this value can change. Make sure to capture the value in a method before using it.

func (*Client) Send

func (c *Client) Send(ctx context.Context, req ua.Request, h func(interface{}) error) error

Send sends the request via the secure channel and registers a handler for the response. If the client has an active session it injects the authentication token.

func (*Client) Session

func (c *Client) Session() *Session

Session returns the active session. During reconnect this value can change. Make sure to capture the value in a method before using it.

func (*Client) State

func (c *Client) State() ConnState

State returns the current connection state.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, params *SubscriptionParameters, notifyCh chan<- *PublishNotificationData) (*Subscription, error)

Subscribe creates a Subscription with given parameters. Parameters that have not been set are set to their default values. See opcua.DefaultSubscription* constants

func (*Client) SubscriptionIDs

func (c *Client) SubscriptionIDs() []uint32

SubscriptionIDs gets a list of subscriptionIDs

func (*Client) UnregisterNodes

func (c *Client) UnregisterNodes(ctx context.Context, req *ua.UnregisterNodesRequest) (*ua.UnregisterNodesResponse, error)

UnregisterNodes unregisters node ids previously registered with RegisterNodes.

Part 4, Section 5.8.6

func (*Client) UpdateNamespaces

func (c *Client) UpdateNamespaces(ctx context.Context) error

UpdateNamespaces updates the list of cached namespaces from the server.

func (*Client) Write

func (c *Client) Write(ctx context.Context, req *ua.WriteRequest) (*ua.WriteResponse, error)

Write executes a synchronous write request.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config contains all config options.

func ApplyConfig

func ApplyConfig(opts ...Option) (*Config, error)

ApplyConfig applies the config options to the default configuration. todo(fs): Can we find a better name?

type ConnState

type ConnState uint8

ConnState is the ua client connection state

const (
	// Closed, the Connection is currently closed
	Closed ConnState = iota
	// Connected, the Connection is currently connected
	Connected
	// Connecting, the Connection is currently connecting to a server for the first time
	Connecting
	// Disconnected, the Connection is currently disconnected
	Disconnected
	// Reconnecting, the Connection is currently attempting to reconnect to a server it was previously connected to
	Reconnecting
)

func (ConnState) String

func (i ConnState) String() string

type InvalidResponseTypeError

type InvalidResponseTypeError struct {
	// contains filtered or unexported fields
}

func (InvalidResponseTypeError) Error

func (e InvalidResponseTypeError) Error() string

type Node

type Node struct {
	// ID is the node id of the node.
	ID *ua.NodeID
	// contains filtered or unexported fields
}

Node is a high-level object to interact with a node in the address space. It provides common convenience functions to access and manipulate the common attributes of a node.

func (*Node) AccessLevel

func (n *Node) AccessLevel(ctx context.Context) (ua.AccessLevelType, error)

AccessLevel returns the access level of the node. The returned value is a mask where multiple values can be set, e.g. read and write.

func (*Node) Attribute

func (n *Node) Attribute(ctx context.Context, attrID ua.AttributeID) (*ua.Variant, error)

Attribute returns the attribute of the node. with the given id.

func (*Node) Attributes

func (n *Node) Attributes(ctx context.Context, attrID ...ua.AttributeID) ([]*ua.DataValue, error)

Attributes returns the given node attributes.

func (*Node) BrowseName

func (n *Node) BrowseName(ctx context.Context) (*ua.QualifiedName, error)

BrowseName returns the browse name of the node.

func (*Node) Children

func (n *Node) Children(ctx context.Context, refs uint32, mask ua.NodeClass) ([]*Node, error)

Children returns the child nodes which match the node class mask.

func (*Node) Description

func (n *Node) Description(ctx context.Context) (*ua.LocalizedText, error)

Description returns the description of the node.

func (*Node) DisplayName

func (n *Node) DisplayName(ctx context.Context) (*ua.LocalizedText, error)

DisplayName returns the display name of the node.

func (*Node) HasAccessLevel

func (n *Node) HasAccessLevel(ctx context.Context, mask ua.AccessLevelType) (bool, error)

HasAccessLevel returns true if all bits from mask are set in the access level mask of the node.

func (*Node) HasUserAccessLevel

func (n *Node) HasUserAccessLevel(ctx context.Context, mask ua.AccessLevelType) (bool, error)

HasUserAccessLevel returns true if all bits from mask are set in the user access level mask of the node.

func (*Node) NodeClass

func (n *Node) NodeClass(ctx context.Context) (ua.NodeClass, error)

NodeClass returns the node class attribute.

func (*Node) ReferencedNodes

func (n *Node) ReferencedNodes(ctx context.Context, refs uint32, dir ua.BrowseDirection, mask ua.NodeClass, includeSubtypes bool) ([]*Node, error)

ReferencedNodes returns the nodes referenced by this node.

func (*Node) References

func (n *Node) References(ctx context.Context, refType uint32, dir ua.BrowseDirection, mask ua.NodeClass, includeSubtypes bool) ([]*ua.ReferenceDescription, error)

References returns all references for the node.

todo(fs): this is not complete since it only returns the todo(fs): top-level reference at this point.

func (*Node) String

func (n *Node) String() string

func (*Node) TranslateBrowsePathInNamespaceToNodeID

func (n *Node) TranslateBrowsePathInNamespaceToNodeID(ctx context.Context, ns uint16, browsePath string) (*ua.NodeID, error)

TranslateBrowsePathInNamespaceToNodeID translates a browseName to a NodeID within the same namespace.

func (*Node) TranslateBrowsePathsToNodeIDs

func (n *Node) TranslateBrowsePathsToNodeIDs(ctx context.Context, pathNames []*ua.QualifiedName) (*ua.NodeID, error)

TranslateBrowsePathsToNodeIDs translates an array of browseName segments to NodeIDs.

func (*Node) UserAccessLevel

func (n *Node) UserAccessLevel(ctx context.Context) (ua.AccessLevelType, error)

UserAccessLevel returns the access level of the node.

func (*Node) Value

func (n *Node) Value(ctx context.Context) (*ua.Variant, error)

Value returns the value of the node.

type Option

type Option func(*Config) error

Option is an option function type to modify the configuration.

func ApplicationName

func ApplicationName(s string) Option

ApplicationName sets the application name in the session configuration.

func ApplicationURI

func ApplicationURI(s string) Option

ApplicationURI sets the application uri in the session configuration.

func AuthAnonymous

func AuthAnonymous() Option

AuthAnonymous sets the client's authentication X509 certificate Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option

func AuthCertificate

func AuthCertificate(cert []byte) Option

AuthCertificate sets the client's authentication X509 certificate Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option

func AuthIssuedToken

func AuthIssuedToken(tokenData []byte) Option

AuthIssuedToken sets the client's authentication data based on an externally-issued token Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option

func AuthPolicyID

func AuthPolicyID(policy string) Option

AuthPolicyID sets the policy ID of the user identity token Note: This should only be called if you know the exact policy ID the server is expecting. Most callers should use SecurityFromEndpoint as it automatically finds the policyID todo(fs): Should we make 'policy' an option to the other todo(fs): AuthXXX methods since this approach requires context todo(fs): and ordering?

func AuthPrivateKey

func AuthPrivateKey(key *rsa.PrivateKey) Option

AuthPrivateKey sets the client's authentication RSA private key Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option

func AuthUsername

func AuthUsername(user, pass string) Option

AuthUsername sets the client's authentication username and password Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option

func AutoReconnect

func AutoReconnect(b bool) Option

AutoReconnect sets the auto reconnect state of the secure channel.

func Certificate

func Certificate(cert []byte) Option

Certificate sets the client X509 certificate in the secure channel configuration. It also detects and sets the ApplicationURI from the URI within the certificate.

func CertificateFile

func CertificateFile(filename string) Option

CertificateFile sets the client X509 certificate in the secure channel configuration from the PEM or DER encoded file. It also detects and sets the ApplicationURI from the URI within the certificate.

func DialTimeout

func DialTimeout(d time.Duration) Option

DialTimeout sets the timeout for establishing the UACP connection. Defaults to DefaultDialTimeout. Set to zero for no timeout.

func Dialer

func Dialer(d *uacp.Dialer) Option

Dialer sets the uacp.Dialer to establish the connection to the server.

func Lifetime

func Lifetime(d time.Duration) Option

Lifetime sets the lifetime of the secure channel in milliseconds.

func Locales

func Locales(locale ...string) Option

Locales sets the locales in the session configuration.

func MaxChunkCount

func MaxChunkCount(n uint32) Option

MaxChunkCount sets the maximum chunk count for the UACP handshake.

func MaxMessageSize

func MaxMessageSize(n uint32) Option

MaxMessageSize sets the maximum message size for the UACP handshake.

func PrivateKey

func PrivateKey(key *rsa.PrivateKey) Option

PrivateKey sets the RSA private key in the secure channel configuration.

func PrivateKeyFile

func PrivateKeyFile(filename string) Option

PrivateKeyFile sets the RSA private key in the secure channel configuration from a PEM or DER encoded file.

func ProductURI

func ProductURI(s string) Option

ProductURI sets the product uri in the session configuration.

func RandomRequestID

func RandomRequestID() Option

RandomRequestID assigns a random initial request id.

The request id is generated using the 'rand' package and it is the caller's responsibility to initialize the random number generator properly.

func ReceiveBufferSize

func ReceiveBufferSize(n uint32) Option

ReceiveBufferSize sets the receive buffer size for the UACP handshake.

func ReconnectInterval

func ReconnectInterval(d time.Duration) Option

ReconnectInterval is interval duration between each reconnection attempt.

func RemoteCertificate

func RemoteCertificate(cert []byte) Option

RemoteCertificate sets the server certificate.

func RemoteCertificateFile

func RemoteCertificateFile(filename string) Option

RemoteCertificateFile sets the server certificate from the file in PEM or DER encoding.

func RequestTimeout

func RequestTimeout(t time.Duration) Option

RequestTimeout sets the timeout for all requests over SecureChannel

func SecurityFromEndpoint

func SecurityFromEndpoint(ep *ua.EndpointDescription, authType ua.UserTokenType) Option

SecurityFromEndpoint sets the server-related security parameters from a chosen endpoint (received from GetEndpoints())

func SecurityMode

func SecurityMode(m ua.MessageSecurityMode) Option

SecurityMode sets the security mode for the secure channel.

func SecurityModeString

func SecurityModeString(s string) Option

SecurityModeString sets the security mode for the secure channel. Valid values are "None", "Sign", and "SignAndEncrypt".

func SecurityPolicy

func SecurityPolicy(s string) Option

SecurityPolicy sets the security policy uri for the secure channel.

func SendBufferSize

func SendBufferSize(n uint32) Option

SendBufferSize sets the send buffer size for the UACP handshake.

func SessionName

func SessionName(s string) Option

SessionName sets the name in the session configuration.

func SessionTimeout

func SessionTimeout(d time.Duration) Option

SessionTimeout sets the timeout in the session configuration.

type PublishNotificationData

type PublishNotificationData struct {
	SubscriptionID uint32
	Error          error
	Value          interface{}
}

type Server

type Server struct {
	EndpointURL string
}

Server is a high-level OPC-UA Server

func (*Server) Close

func (a *Server) Close() error

func (*Server) Open

func (a *Server) Open() error

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is a OPC/UA session as described in Part 4, 5.6.

func (*Session) RevisedTimeout

func (s *Session) RevisedTimeout() time.Duration

RevisedTimeout return actual maximum time that a Session shall remain open without activity. This value is provided by the server in response to CreateSession.

type Subscription

type Subscription struct {
	SubscriptionID            uint32
	RevisedPublishingInterval time.Duration
	RevisedLifetimeCount      uint32
	RevisedMaxKeepAliveCount  uint32
	Notifs                    chan<- *PublishNotificationData
	// contains filtered or unexported fields
}

func (*Subscription) Cancel

func (s *Subscription) Cancel(ctx context.Context) error

Cancel stops the subscription and removes it from the client and the server.

func (*Subscription) ModifyMonitoredItems

func (*Subscription) SetTriggering

func (s *Subscription) SetTriggering(ctx context.Context, triggeringItemID uint32, add, remove []uint32) (*ua.SetTriggeringResponse, error)

SetTriggering sends a request to the server to add and/or remove triggering links from a triggering item. To add links from a triggering item to an item to report provide the server assigned ID(s) in the `add` argument. To remove links from a triggering item to an item to report provide the server assigned ID(s) in the `remove` argument.

func (*Subscription) Stats

Stats returns a diagnostic struct with metadata about the current subscription

func (*Subscription) Unmonitor

func (s *Subscription) Unmonitor(ctx context.Context, monitoredItemIDs ...uint32) (*ua.DeleteMonitoredItemsResponse, error)

type SubscriptionParameters

type SubscriptionParameters struct {
	Interval                   time.Duration
	LifetimeCount              uint32
	MaxKeepAliveCount          uint32
	MaxNotificationsPerPublish uint32
	Priority                   uint8
}

Directories

Path Synopsis
cmd
id
Package debug provides functions for debug logging.
Package debug provides functions for debug logging.
examples
endpoints
Package main provides an example to query the available endpoints of a server.
Package main provides an example to query the available endpoints of a server.
udt
Package stats provides instrumentation for the gopcua library via expvar.
Package stats provides instrumentation for the gopcua library via expvar.
Package ua defines the structures, decoders and encoder for built-in data types described in Part 6 Section 5 Data encoding and for services in OPC UA Binary Protocol.
Package ua defines the structures, decoders and encoder for built-in data types described in Part 6 Section 5 Data encoding and for services in OPC UA Binary Protocol.
Package uacp provides encoding/decoding and automated connection handling for the OPC UA Connection Protocol.
Package uacp provides encoding/decoding and automated connection handling for the OPC UA Connection Protocol.
Package uapolicy implements the encryption, decryption, signing, and signature verifying algorithms for Security Policy profiles as defined in Part 7 of the OPC-UA specifications (version 1.04)
Package uapolicy implements the encryption, decryption, signing, and signature verifying algorithms for Security Policy profiles as defined in Part 7 of the OPC-UA specifications (version 1.04)
Package uasc provides encoding/decoding and automated secure channel and session handling for OPC UA Secure Conversation.
Package uasc provides encoding/decoding and automated secure channel and session handling for OPC UA Secure Conversation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL