Documentation ¶
Index ¶
- Variables
- type DataChangeMessage
- type ErrHandler
- type Item
- type MsgHandler
- type NodeMonitor
- func (m *NodeMonitor) ChanSubscribe(ctx context.Context, params *opcua.SubscriptionParameters, ...) (*Subscription, error)
- func (m *NodeMonitor) SetErrorHandler(cb ErrHandler)
- func (m *NodeMonitor) Subscribe(ctx context.Context, params *opcua.SubscriptionParameters, cb MsgHandler, ...) (*Subscription, error)
- type Request
- type Subscription
- func (s *Subscription) AddMonitorItems(nodes ...Request) ([]Item, error)
- func (s *Subscription) AddNodeIDs(nodes ...*ua.NodeID) error
- func (s *Subscription) AddNodes(nodes ...string) error
- func (s *Subscription) Delivered() uint64
- func (s *Subscription) Dropped() uint64
- func (s *Subscription) RemoveMonitorItems(items ...Item) error
- func (s *Subscription) RemoveNodeIDs(nodes ...*ua.NodeID) error
- func (s *Subscription) RemoveNodes(nodes ...string) error
- func (s *Subscription) Stats() (*ua.SubscriptionDiagnosticsDataType, error)
- func (s *Subscription) Subscribed() int
- func (s *Subscription) SubscriptionID() uint32
- func (s *Subscription) Unsubscribe() error
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultCallbackBufferLen is the size of the internal buffer when using a callback-based subscription DefaultCallbackBufferLen = 8192 // ErrSlowConsumer is returned when a subscriber does not keep up with the incoming messages ErrSlowConsumer = errors.New("slow consumer. messages may be dropped") )
Functions ¶
This section is empty.
Types ¶
type DataChangeMessage ¶
DataChangeMessage represents the changed DataValue from the server. It also includes a reference to the sending NodeID and error (if any)
type ErrHandler ¶
type ErrHandler func(*opcua.Client, *Subscription, error)
ErrHandler is a function that is called when there is an out of band issue with delivery
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item is a struct to manage Monitored Items
type MsgHandler ¶
type MsgHandler func(*Subscription, *DataChangeMessage)
MsgHandler is a function that is called for each new DataValue
type NodeMonitor ¶
type NodeMonitor struct {
// contains filtered or unexported fields
}
NodeMonitor creates new subscriptions
func NewNodeMonitor ¶
func NewNodeMonitor(client *opcua.Client) (*NodeMonitor, error)
NewNodeMonitor creates a new NodeMonitor
func (*NodeMonitor) ChanSubscribe ¶
func (m *NodeMonitor) ChanSubscribe(ctx context.Context, params *opcua.SubscriptionParameters, ch chan<- *DataChangeMessage, nodes ...string) (*Subscription, error)
ChanSubscribe creates a new channel-based subscription and an optional list of nodes. The channel should be deep enough to allow some buffering, otherwise `ErrSlowConsumer` is sent via the monitor's `ErrHandler`. The caller must call `Unsubscribe` to stop and clean up resources. Canceling the context will also cause the subscription to stop, but `Unsubscribe` must still be called.
func (*NodeMonitor) SetErrorHandler ¶
func (m *NodeMonitor) SetErrorHandler(cb ErrHandler)
SetErrorHandler sets an optional callback for async errors
func (*NodeMonitor) Subscribe ¶
func (m *NodeMonitor) Subscribe(ctx context.Context, params *opcua.SubscriptionParameters, cb MsgHandler, nodes ...string) (*Subscription, error)
Subscribe creates a new callback-based subscription and an optional list of nodes. The caller must call `Unsubscribe` to stop and clean up resources. Canceling the context will also cause the subscription to stop, but `Unsubscribe` must still be called.
type Request ¶
type Request struct { NodeID *ua.NodeID MonitoringMode ua.MonitoringMode MonitoringParameters *ua.MonitoringParameters // contains filtered or unexported fields }
Request is a struct to manage a request to monitor a node
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is an instance of an active subscription. Nodes can be added and removed concurrently.
func (*Subscription) AddMonitorItems ¶
func (s *Subscription) AddMonitorItems(nodes ...Request) ([]Item, error)
AddMonitorItems adds nodes with monitoring parameters to the subscription
func (*Subscription) AddNodeIDs ¶
func (s *Subscription) AddNodeIDs(nodes ...*ua.NodeID) error
AddNodeIDs adds nodes
func (*Subscription) AddNodes ¶
func (s *Subscription) AddNodes(nodes ...string) error
AddNodes adds nodes defined by their string representation
func (*Subscription) Delivered ¶
func (s *Subscription) Delivered() uint64
Delivered returns the number of DataChangeMessages delivered
func (*Subscription) Dropped ¶
func (s *Subscription) Dropped() uint64
Dropped returns the number of DataChangeMessages dropped due to a slow consumer
func (*Subscription) RemoveMonitorItems ¶
func (s *Subscription) RemoveMonitorItems(items ...Item) error
RemoveMonitorItems removes nodes
func (*Subscription) RemoveNodeIDs ¶
func (s *Subscription) RemoveNodeIDs(nodes ...*ua.NodeID) error
RemoveNodeIDs removes nodes
func (*Subscription) RemoveNodes ¶
func (s *Subscription) RemoveNodes(nodes ...string) error
RemoveNodes removes nodes defined by their string representation
func (*Subscription) Stats ¶
func (s *Subscription) Stats() (*ua.SubscriptionDiagnosticsDataType, error)
Stats returns statistics for the subscription
func (*Subscription) Subscribed ¶
func (s *Subscription) Subscribed() int
Subscribed returns the number of currently subscribed to nodes
func (*Subscription) SubscriptionID ¶
func (s *Subscription) SubscriptionID() uint32
SubscriptionID returns the underlying subscription id
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe() error
Unsubscribe removes the subscription interests and cleans up any resources