opcua

package module
v0.0.0-...-416ecff Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: MIT Imports: 15 Imported by: 0

README

Форк проекта.

Проект-источник имел недостатки на момент разработки сервиса взаимодействия по OPCUA. При развитии проекта стоит вернуться к проекту-источнику.

Documentation

Overview

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

Index

Constants

This section is empty.

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 GetEndpoints

func GetEndpoints(endpoint string) ([]*ua.EndpointDescription, error)

GetEndpoints returns the available endpoint descriptions for the server.

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

NewClient creates a new Client.

When no options are provided the new client is created from DefaultClientConfig() and DefaultSessionConfig(). If no authentication method is confiugred 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/center2m/opcua#Option

func (*Client) ActivateSession

func (c *Client) ActivateSession(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(req *ua.BrowseRequest) (*ua.BrowseResponse, error)

Browse executes a synchronous browse request.

func (*Client) BrowseNext

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

BrowseNext executes a synchronous browse request.

func (*Client) Close

func (c *Client) Close() error

Close closes the session and the secure channel.

func (*Client) CloseSession

func (c *Client) CloseSession() error

CloseSession closes the current session.

See Part 4, 5.6.4

func (*Client) Connect

func (c *Client) Connect() (err error)

Connect establishes a secure channel and creates a new session.

func (*Client) CreateMonitoredItems

func (c *Client) CreateMonitoredItems(subID uint32, ts ua.TimestampsToReturn, items ...*ua.MonitoredItemCreateRequest) (*ua.CreateMonitoredItemsResponse, error)

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

func (*Client) DetachSession

func (c *Client) DetachSession() (*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() error

Dial establishes a secure channel.

func (*Client) GetEndpoints

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

func (*Client) HistoryReadRawModified

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

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) Publish

func (c *Client) Publish(notif chan<- PublishNotificationData)

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.

func (*Client) Send

func (c *Client) Send(req interface{}, 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 authenticaton token.

func (*Client) Session

func (c *Client) Session() *Session

Session returns the active session.

func (*Client) Subscribe

func (c *Client) Subscribe(intv time.Duration) (*Subscription, error)

todo(fs): return subscription object with channel

func (*Client) Write

func (c *Client) Write(req *ua.WriteRequest) (res *ua.WriteResponse, err error)

Write executes a synchronous write request.

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.

func (*Node) Attribute

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

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

func (*Node) Attributes

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

func (*Node) BrowseName

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

BrowseName returns the browse name of the node.

func (*Node) Children

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

func (*Node) Description

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

Description returns the description of the node.

func (*Node) DisplayName

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

DisplayName returns the display name of the node.

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.

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.

func (*Node) NodeClass

func (n *Node) NodeClass() (ua.NodeClass, error)

NodeClass returns the node class attribute.

func (*Node) ReferencedNodes

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

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. 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) UserAccessLevel

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

UserAccessLevel returns the access level of the node.

func (*Node) Value

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

Value returns the value of the node.

type Option

type Option func(*uasc.Config, *uasc.SessionConfig)

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

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 Certificate

func Certificate(cert []byte) Option

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

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 PrivateKey

func PrivateKey(key *rsa.PrivateKey) Option

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

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.

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 SecurityPolicy

func SecurityPolicy(s string) Option

SecurityPolicy sets the security policy uri for the secure channel.

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.

type Subscription

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

todo(fs): this is not done yet since we need to be able to register todo(fs): monitored items.

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.
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