Documentation
¶
Overview ¶
Package opcua provides easy and painless encoding/decoding of OPC UA protocol in pure Golang.
Index ¶
- Constants
- func DefaultClientConfig() *uasc.Config
- func DefaultSessionConfig() *uasc.SessionConfig
- func GetEndpoints(ctx context.Context, endpoint string, opts ...Option) ([]*ua.EndpointDescription, error)
- func NewDialer(cfg *Config) *uacp.Dialer
- func NewMonitoredItemCreateRequestWithDefaults(nodeID *ua.NodeID, attributeID ua.AttributeID, clientHandle uint32) *ua.MonitoredItemCreateRequest
- func SelectEndpoint(endpoints []*ua.EndpointDescription, policy string, ...) *ua.EndpointDescription
- type Client
- func (c *Client) ActivateSession(s *Session) error
- func (c *Client) ActivateSessionWithContext(ctx context.Context, s *Session) error
- func (c *Client) Browse(req *ua.BrowseRequest) (*ua.BrowseResponse, error)
- func (c *Client) BrowseNext(req *ua.BrowseNextRequest) (*ua.BrowseNextResponse, error)
- func (c *Client) BrowseNextWithContext(ctx context.Context, req *ua.BrowseNextRequest) (*ua.BrowseNextResponse, error)
- func (c *Client) BrowseWithContext(ctx context.Context, req *ua.BrowseRequest) (*ua.BrowseResponse, error)
- func (c *Client) Call(req *ua.CallMethodRequest) (*ua.CallMethodResult, error)
- func (c *Client) CallWithContext(ctx context.Context, req *ua.CallMethodRequest) (*ua.CallMethodResult, error)
- func (c *Client) Close() error
- func (c *Client) CloseSession() error
- func (c *Client) CloseSessionWithContext(ctx context.Context) error
- func (c *Client) CloseWithContext(ctx context.Context) error
- func (c *Client) Connect(ctx context.Context) (err error)
- func (c *Client) CreateSession(cfg *uasc.SessionConfig) (*Session, error)
- func (c *Client) CreateSessionWithContext(ctx context.Context, cfg *uasc.SessionConfig) (*Session, error)
- func (c *Client) DetachSession() (*Session, error)
- func (c *Client) DetachSessionWithContext(ctx context.Context) (*Session, error)
- func (c *Client) Dial(ctx context.Context) error
- func (c *Client) FindNamespace(name string) (uint16, error)
- func (c *Client) FindNamespaceWithContext(ctx context.Context, name string) (uint16, error)
- func (c *Client) GetEndpoints() (*ua.GetEndpointsResponse, error)
- func (c *Client) GetEndpointsWithContext(ctx context.Context) (*ua.GetEndpointsResponse, error)
- func (c *Client) HistoryReadRawModified(nodes []*ua.HistoryReadValueID, details *ua.ReadRawModifiedDetails) (*ua.HistoryReadResponse, error)
- func (c *Client) HistoryReadRawModifiedWithContext(ctx context.Context, nodes []*ua.HistoryReadValueID, ...) (*ua.HistoryReadResponse, error)
- func (c *Client) NamespaceArray() ([]string, error)
- func (c *Client) NamespaceArrayWithContext(ctx context.Context) ([]string, error)
- func (c *Client) Namespaces() []string
- func (c *Client) Node(id *ua.NodeID) *Node
- func (c *Client) Read(req *ua.ReadRequest) (*ua.ReadResponse, error)
- func (c *Client) ReadWithContext(ctx context.Context, req *ua.ReadRequest) (*ua.ReadResponse, error)
- func (c *Client) RegisterNodes(req *ua.RegisterNodesRequest) (*ua.RegisterNodesResponse, error)
- func (c *Client) RegisterNodesWithContext(ctx context.Context, req *ua.RegisterNodesRequest) (*ua.RegisterNodesResponse, error)
- func (c *Client) SecureChannel() *uasc.SecureChannel
- func (c *Client) Send(req ua.Request, h func(interface{}) error) error
- func (c *Client) SendWithContext(ctx context.Context, req ua.Request, h func(interface{}) error) error
- func (c *Client) Session() *Session
- func (c *Client) State() ConnState
- func (c *Client) Subscribe(params *SubscriptionParameters, notifyCh chan<- *PublishNotificationData) (*Subscription, error)
- func (c *Client) SubscribeWithContext(ctx context.Context, params *SubscriptionParameters, ...) (*Subscription, error)
- func (c *Client) SubscriptionIDs() []uint32
- func (c *Client) UnregisterNodes(req *ua.UnregisterNodesRequest) (*ua.UnregisterNodesResponse, error)
- func (c *Client) UnregisterNodesWithContext(ctx context.Context, req *ua.UnregisterNodesRequest) (*ua.UnregisterNodesResponse, error)
- func (c *Client) UpdateNamespaces() error
- func (c *Client) UpdateNamespacesWithContext(ctx context.Context) error
- func (c *Client) Write(req *ua.WriteRequest) (*ua.WriteResponse, error)
- func (c *Client) WriteWithContext(ctx context.Context, req *ua.WriteRequest) (*ua.WriteResponse, error)
- type Config
- type ConnState
- type InvalidResponseTypeError
- type Node
- func (n *Node) AccessLevel() (ua.AccessLevelType, error)
- func (n *Node) AccessLevelWithContext(ctx context.Context) (ua.AccessLevelType, error)
- func (n *Node) Attribute(attrID ua.AttributeID) (*ua.Variant, error)
- func (n *Node) AttributeWithContext(ctx context.Context, attrID ua.AttributeID) (*ua.Variant, error)
- func (n *Node) Attributes(attrID ...ua.AttributeID) ([]*ua.DataValue, error)
- func (n *Node) AttributesWithContext(ctx context.Context, attrID ...ua.AttributeID) ([]*ua.DataValue, error)
- func (n *Node) BrowseName() (*ua.QualifiedName, error)
- func (n *Node) BrowseNameWithContext(ctx context.Context) (*ua.QualifiedName, error)
- func (n *Node) Children(refs uint32, mask ua.NodeClass) ([]*Node, error)
- func (n *Node) ChildrenWithContext(ctx context.Context, refs uint32, mask ua.NodeClass) ([]*Node, error)
- func (n *Node) Description() (*ua.LocalizedText, error)
- func (n *Node) DescriptionWithContext(ctx context.Context) (*ua.LocalizedText, error)
- func (n *Node) DisplayName() (*ua.LocalizedText, error)
- func (n *Node) DisplayNameWithContext(ctx context.Context) (*ua.LocalizedText, error)
- func (n *Node) HasAccessLevel(mask ua.AccessLevelType) (bool, error)
- func (n *Node) HasAccessLevelWithContext(ctx context.Context, mask ua.AccessLevelType) (bool, error)
- func (n *Node) HasUserAccessLevel(mask ua.AccessLevelType) (bool, error)
- func (n *Node) HasUserAccessLevelWithContext(ctx context.Context, mask ua.AccessLevelType) (bool, error)
- func (n *Node) NodeClass(ctx context.Context) (ua.NodeClass, error)
- func (n *Node) NodeClassWithContext(ctx context.Context) (ua.NodeClass, error)
- func (n *Node) ReferencedNodes(refs uint32, dir ua.BrowseDirection, mask ua.NodeClass, includeSubtypes bool) ([]*Node, error)
- func (n *Node) ReferencedNodesWithContext(ctx context.Context, refs uint32, dir ua.BrowseDirection, mask ua.NodeClass, ...) ([]*Node, error)
- func (n *Node) References(refType uint32, dir ua.BrowseDirection, mask ua.NodeClass, ...) ([]*ua.ReferenceDescription, error)
- func (n *Node) ReferencesWithContext(ctx context.Context, refType uint32, dir ua.BrowseDirection, mask ua.NodeClass, ...) ([]*ua.ReferenceDescription, error)
- func (n *Node) String() string
- func (n *Node) TranslateBrowsePathInNamespaceToNodeID(ns uint16, browsePath string) (*ua.NodeID, error)
- func (n *Node) TranslateBrowsePathInNamespaceToNodeIDWithContext(ctx context.Context, ns uint16, browsePath string) (*ua.NodeID, error)
- func (n *Node) TranslateBrowsePathsToNodeIDs(pathNames []*ua.QualifiedName) (*ua.NodeID, error)
- func (n *Node) TranslateBrowsePathsToNodeIDsWithContext(ctx context.Context, pathNames []*ua.QualifiedName) (*ua.NodeID, error)
- func (n *Node) UserAccessLevel() (ua.AccessLevelType, error)
- func (n *Node) UserAccessLevelWithContext(ctx context.Context) (ua.AccessLevelType, error)
- func (n *Node) Value() (*ua.Variant, error)
- func (n *Node) ValueWithContext(ctx context.Context) (*ua.Variant, error)
- type Option
- func ApplicationName(s string) Option
- func ApplicationURI(s string) Option
- func AuthAnonymous() Option
- func AuthCertificate(cert []byte) Option
- func AuthIssuedToken(tokenData []byte) Option
- func AuthPolicyID(policy string) Option
- func AuthUsername(user, pass string) Option
- func AutoReconnect(b bool) Option
- func Certificate(cert []byte) Option
- func CertificateFile(filename string) Option
- func DialTimeout(d time.Duration) Option
- func Dialer(d *uacp.Dialer) Option
- func Lifetime(d time.Duration) Option
- func Locales(locale ...string) Option
- func MaxChunkCount(n uint32) Option
- func MaxMessageSize(n uint32) Option
- func PrivateKey(key *rsa.PrivateKey) Option
- func PrivateKeyFile(filename string) Option
- func ProductURI(s string) Option
- func RandomRequestID() Option
- func ReceiveBufferSize(n uint32) Option
- func ReconnectInterval(d time.Duration) Option
- func RemoteCertificate(cert []byte) Option
- func RemoteCertificateFile(filename string) Option
- func RequestTimeout(t time.Duration) Option
- func SecurityFromEndpoint(ep *ua.EndpointDescription, authType ua.UserTokenType) Option
- func SecurityMode(m ua.MessageSecurityMode) Option
- func SecurityModeString(s string) Option
- func SecurityPolicy(s string) Option
- func SendBufferSize(n uint32) Option
- func SessionName(s string) Option
- func SessionTimeout(d time.Duration) Option
- type PublishNotificationData
- type Server
- type Session
- type Subscription
- func (s *Subscription) Cancel(ctx context.Context) error
- func (s *Subscription) ModifyMonitoredItems(ts ua.TimestampsToReturn, items ...*ua.MonitoredItemModifyRequest) (*ua.ModifyMonitoredItemsResponse, error)
- func (s *Subscription) ModifyMonitoredItemsWithContext(ctx context.Context, ts ua.TimestampsToReturn, ...) (*ua.ModifyMonitoredItemsResponse, error)
- func (s *Subscription) Monitor(ts ua.TimestampsToReturn, items ...*ua.MonitoredItemCreateRequest) (*ua.CreateMonitoredItemsResponse, error)
- func (s *Subscription) MonitorWithContext(ctx context.Context, ts ua.TimestampsToReturn, ...) (*ua.CreateMonitoredItemsResponse, error)
- func (s *Subscription) SetTriggering(triggeringItemID uint32, add, remove []uint32) (*ua.SetTriggeringResponse, error)
- func (s *Subscription) SetTriggeringWithContext(ctx context.Context, triggeringItemID uint32, add, remove []uint32) (*ua.SetTriggeringResponse, error)
- func (s *Subscription) Stats() (*ua.SubscriptionDiagnosticsDataType, error)
- func (s *Subscription) StatsWithContext(ctx context.Context) (*ua.SubscriptionDiagnosticsDataType, error)
- func (s *Subscription) Unmonitor(monitoredItemIDs ...uint32) (*ua.DeleteMonitoredItemsResponse, error)
- func (s *Subscription) UnmonitorWithContext(ctx context.Context, monitoredItemIDs ...uint32) (*ua.DeleteMonitoredItemsResponse, error)
- type SubscriptionParameters
Constants ¶
const ( DefaultSubscriptionMaxNotificationsPerPublish = 10000 DefaultSubscriptionLifetimeCount = 10000 DefaultSubscriptionMaxKeepAliveCount = 3000 DefaultSubscriptionInterval = 100 * time.Millisecond DefaultSubscriptionPriority = 0 )
Variables ¶
This section is empty.
Functions ¶
func DefaultClientConfig ¶
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 GetEndpoints ¶
func GetEndpoints(ctx context.Context, endpoint string, opts ...Option) ([]*ua.EndpointDescription, error)
GetEndpoints returns the available endpoint descriptions for the server.
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 ¶
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/zzylovesll/myOpcUa#Option
Note: Starting with v0.5 this function will will return an error.
func (*Client) ActivateSession ¶
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 ¶
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) ActivateSessionWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) Browse ¶
func (c *Client) Browse(req *ua.BrowseRequest) (*ua.BrowseResponse, error)
Browse executes a synchronous browse request.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) BrowseNext ¶
func (c *Client) BrowseNext(req *ua.BrowseNextRequest) (*ua.BrowseNextResponse, error)
BrowseNext executes a synchronous browse request.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) BrowseNextWithContext ¶
func (c *Client) BrowseNextWithContext(ctx context.Context, req *ua.BrowseNextRequest) (*ua.BrowseNextResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) BrowseWithContext ¶
func (c *Client) BrowseWithContext(ctx context.Context, req *ua.BrowseRequest) (*ua.BrowseResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) Call ¶
func (c *Client) Call(req *ua.CallMethodRequest) (*ua.CallMethodResult, error)
Call executes a synchronous call request for a single method.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) CallWithContext ¶
func (c *Client) CallWithContext(ctx context.Context, req *ua.CallMethodRequest) (*ua.CallMethodResult, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) Close ¶
Close closes the session and the secure channel.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) CloseSession ¶
CloseSession closes the current session.
See Part 4, 5.6.4 ¶
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) CloseSessionWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) CloseWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) CreateSession ¶
func (c *Client) CreateSession(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 ¶
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) CreateSessionWithContext ¶
func (c *Client) CreateSessionWithContext(ctx context.Context, cfg *uasc.SessionConfig) (*Session, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) DetachSession ¶
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.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) DetachSessionWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) FindNamespace ¶
FindNamespace returns the id of the namespace with the given name.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) FindNamespaceWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) GetEndpoints ¶
func (c *Client) GetEndpoints() (*ua.GetEndpointsResponse, error)
GetEndpoints returns the list of available endpoints of the server.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) GetEndpointsWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) HistoryReadRawModified ¶
func (c *Client) HistoryReadRawModified(nodes []*ua.HistoryReadValueID, details *ua.ReadRawModifiedDetails) (*ua.HistoryReadResponse, error)
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) HistoryReadRawModifiedWithContext ¶
func (c *Client) HistoryReadRawModifiedWithContext(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadRawModifiedDetails) (*ua.HistoryReadResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) NamespaceArray ¶
NamespaceArray returns the list of namespaces registered on the server.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) NamespaceArrayWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) Namespaces ¶
Namespaces returns the currently cached list of namespaces.
func (*Client) Node ¶
Node returns a node object which accesses its attributes through this client connection.
func (*Client) Read ¶
func (c *Client) Read(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.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) ReadWithContext ¶
func (c *Client) ReadWithContext(ctx context.Context, req *ua.ReadRequest) (*ua.ReadResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) RegisterNodes ¶
func (c *Client) RegisterNodes(req *ua.RegisterNodesRequest) (*ua.RegisterNodesResponse, error)
RegisterNodes registers node ids for more efficient reads.
Part 4, Section 5.8.5 ¶
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) RegisterNodesWithContext ¶
func (c *Client) RegisterNodesWithContext(ctx context.Context, req *ua.RegisterNodesRequest) (*ua.RegisterNodesResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) SecureChannel ¶
func (c *Client) SecureChannel() *uasc.SecureChannel
SecureChannel returns the active secure channel.
func (*Client) Send ¶
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.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) SendWithContext ¶
func (c *Client) SendWithContext(ctx context.Context, req ua.Request, h func(interface{}) error) error
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(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
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) SubscribeWithContext ¶
func (c *Client) SubscribeWithContext(ctx context.Context, params *SubscriptionParameters, notifyCh chan<- *PublishNotificationData) (*Subscription, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) SubscriptionIDs ¶
SubscriptionIDs gets a list of subscriptionIDs
func (*Client) UnregisterNodes ¶
func (c *Client) UnregisterNodes(req *ua.UnregisterNodesRequest) (*ua.UnregisterNodesResponse, error)
UnregisterNodes unregisters node ids previously registered with RegisterNodes.
Part 4, Section 5.8.6 ¶
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) UnregisterNodesWithContext ¶
func (c *Client) UnregisterNodesWithContext(ctx context.Context, req *ua.UnregisterNodesRequest) (*ua.UnregisterNodesResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) UpdateNamespaces ¶
UpdateNamespaces updates the list of cached namespaces from the server.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) UpdateNamespacesWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Client) Write ¶
func (c *Client) Write(req *ua.WriteRequest) (*ua.WriteResponse, error)
Write executes a synchronous write request.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Client) WriteWithContext ¶
func (c *Client) WriteWithContext(ctx context.Context, req *ua.WriteRequest) (*ua.WriteResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config contains all config options.
func ApplyConfig ¶
ApplyConfig applies the config options to the default configuration. todo(fs): Can we find a better name?
Note: Starting with v0.5 this function will will return an error.
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 )
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() (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.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) AccessLevelWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) Attribute ¶
Attribute returns the attribute of the node. with the given id.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) AttributeWithContext ¶
func (n *Node) AttributeWithContext(ctx context.Context, attrID ua.AttributeID) (*ua.Variant, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) Attributes ¶
Attributes returns the given node attributes.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) AttributesWithContext ¶
func (n *Node) AttributesWithContext(ctx context.Context, attrID ...ua.AttributeID) ([]*ua.DataValue, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) BrowseName ¶
func (n *Node) BrowseName() (*ua.QualifiedName, error)
BrowseName returns the browse name of the node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) BrowseNameWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) Children ¶
Children returns the child nodes which match the node class mask.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) ChildrenWithContext ¶
func (n *Node) ChildrenWithContext(ctx context.Context, refs uint32, mask ua.NodeClass) ([]*Node, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) Description ¶
func (n *Node) Description() (*ua.LocalizedText, error)
Description returns the description of the node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) DescriptionWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) DisplayName ¶
func (n *Node) DisplayName() (*ua.LocalizedText, error)
DisplayName returns the display name of the node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) DisplayNameWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) HasAccessLevel ¶
func (n *Node) HasAccessLevel(mask ua.AccessLevelType) (bool, error)
HasAccessLevel returns true if all bits from mask are set in the access level mask of the node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) HasAccessLevelWithContext ¶
func (n *Node) HasAccessLevelWithContext(ctx context.Context, mask ua.AccessLevelType) (bool, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) HasUserAccessLevel ¶
func (n *Node) HasUserAccessLevel(mask ua.AccessLevelType) (bool, error)
HasUserAccessLevel returns true if all bits from mask are set in the user access level mask of the node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) HasUserAccessLevelWithContext ¶
func (n *Node) HasUserAccessLevelWithContext(ctx context.Context, mask ua.AccessLevelType) (bool, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) NodeClass ¶
NodeClass returns the node class attribute.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) NodeClassWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) ReferencedNodes ¶
func (n *Node) ReferencedNodes(refs uint32, dir ua.BrowseDirection, mask ua.NodeClass, includeSubtypes bool) ([]*Node, error)
ReferencedNodes returns the nodes referenced by this node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) ReferencedNodesWithContext ¶
func (n *Node) ReferencedNodesWithContext(ctx context.Context, refs uint32, dir ua.BrowseDirection, mask ua.NodeClass, includeSubtypes bool) ([]*Node, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) References ¶
func (n *Node) References(refType uint32, dir ua.BrowseDirection, mask ua.NodeClass, includeSubtypes bool) ([]*ua.ReferenceDescription, error)
References returns all references for the node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
todo(fs): this is not complete since it only returns the todo(fs): top-level reference at this point.
func (*Node) ReferencesWithContext ¶
func (n *Node) ReferencesWithContext(ctx context.Context, refType uint32, dir ua.BrowseDirection, mask ua.NodeClass, includeSubtypes bool) ([]*ua.ReferenceDescription, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) TranslateBrowsePathInNamespaceToNodeID ¶
func (n *Node) TranslateBrowsePathInNamespaceToNodeID(ns uint16, browsePath string) (*ua.NodeID, error)
TranslateBrowsePathInNamespaceToNodeID translates a browseName to a NodeID within the same namespace.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) TranslateBrowsePathInNamespaceToNodeIDWithContext ¶
func (n *Node) TranslateBrowsePathInNamespaceToNodeIDWithContext(ctx context.Context, ns uint16, browsePath string) (*ua.NodeID, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) TranslateBrowsePathsToNodeIDs ¶
TranslateBrowsePathsToNodeIDs translates an array of browseName segments to NodeIDs.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) TranslateBrowsePathsToNodeIDsWithContext ¶
func (n *Node) TranslateBrowsePathsToNodeIDsWithContext(ctx context.Context, pathNames []*ua.QualifiedName) (*ua.NodeID, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Node) UserAccessLevel ¶
func (n *Node) UserAccessLevel() (ua.AccessLevelType, error)
UserAccessLevel returns the access level of the node.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Node) UserAccessLevelWithContext ¶
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
type Option ¶
type Option func(*Config)
Option is an option function type to modify the configuration.
func ApplicationName ¶
ApplicationName sets the application name in the session configuration.
func ApplicationURI ¶
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 ¶
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 ¶
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 ¶
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 AuthUsername ¶
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 ¶
AutoReconnect sets the auto reconnect state of the secure channel.
func Certificate ¶
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 ¶
Certificate 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 ¶
DialTimeout sets the timeout for establishing the UACP connection. Defaults to DefaultDialTimeout. Set to zero for no timeout.
func MaxChunkCount ¶
MaxChunkCount sets the maximum chunk count for the UACP handshake.
func MaxMessageSize ¶
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 ¶
PrivateKeyFile sets the RSA private key in the secure channel configuration from a PEM or DER encoded file.
func ProductURI ¶
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 ¶
ReceiveBufferSize sets the receive buffer size for the UACP handshake.
func ReconnectInterval ¶
ReconnectInterval is interval duration between each reconnection attempt.
func RemoteCertificate ¶
RemoteCertificate sets the server certificate.
func RemoteCertificateFile ¶
RemoteCertificateFile sets the server certificate from the file in PEM or DER encoding.
func RequestTimeout ¶
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 ¶
SecurityModeString sets the security mode for the secure channel. Valid values are "None", "Sign", and "SignAndEncrypt".
func SecurityPolicy ¶
SecurityPolicy sets the security policy uri for the secure channel.
func SendBufferSize ¶
SendBufferSize sets the send buffer size for the UACP handshake.
func SessionName ¶
SessionName sets the name in the session configuration.
func SessionTimeout ¶
SessionTimeout sets the timeout in the session configuration.
type PublishNotificationData ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a OPC/UA session as described in Part 4, 5.6.
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 (s *Subscription) ModifyMonitoredItems(ts ua.TimestampsToReturn, items ...*ua.MonitoredItemModifyRequest) (*ua.ModifyMonitoredItemsResponse, error)
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Subscription) ModifyMonitoredItemsWithContext ¶
func (s *Subscription) ModifyMonitoredItemsWithContext(ctx context.Context, ts ua.TimestampsToReturn, items ...*ua.MonitoredItemModifyRequest) (*ua.ModifyMonitoredItemsResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Subscription) Monitor ¶
func (s *Subscription) Monitor(ts ua.TimestampsToReturn, items ...*ua.MonitoredItemCreateRequest) (*ua.CreateMonitoredItemsResponse, error)
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Subscription) MonitorWithContext ¶
func (s *Subscription) MonitorWithContext(ctx context.Context, ts ua.TimestampsToReturn, items ...*ua.MonitoredItemCreateRequest) (*ua.CreateMonitoredItemsResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Subscription) SetTriggering ¶
func (s *Subscription) SetTriggering(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.
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Subscription) SetTriggeringWithContext ¶
func (s *Subscription) SetTriggeringWithContext(ctx context.Context, triggeringItemID uint32, add, remove []uint32) (*ua.SetTriggeringResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Subscription) Stats ¶
func (s *Subscription) Stats() (*ua.SubscriptionDiagnosticsDataType, error)
Stats returns a diagnostic struct with metadata about the current subscription
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Subscription) StatsWithContext ¶
func (s *Subscription) StatsWithContext(ctx context.Context) (*ua.SubscriptionDiagnosticsDataType, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (*Subscription) Unmonitor ¶
func (s *Subscription) Unmonitor(monitoredItemIDs ...uint32) (*ua.DeleteMonitoredItemsResponse, error)
Note: Starting with v0.5 this method will require a context and the corresponding XXXWithContext(ctx) method will be removed.
func (*Subscription) UnmonitorWithContext ¶
func (s *Subscription) UnmonitorWithContext(ctx context.Context, monitoredItemIDs ...uint32) (*ua.DeleteMonitoredItemsResponse, error)
Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
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. |
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. |