Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Event Subscription handling for channels #746

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Jwcode-uk
Copy link
Contributor

Hi, I have added event channel handling. This is a breaking change as it changes the signatures of some of the functions to allow for handling of both event messages and data change messages. Thanks :)

@SCZwilling
Copy link

Hello, I was trying to use your implementation of event subscription but i am getting error- "The attribute is not supported for the specified Node. StatusBadAttributeIDInvalid (0x80350000)". I am subscribing to an object node which has below configuration-

Attribute | Value
Nodeld | ins=2;s=Sinumerik
NamespaceIndex 2 |  
IdentifierType | String
Identifier | Sinumerik
NodeClass | Object
BrowseName | 2, "Sinumerik"
DisplayName | "en-US", "Sinumerik"
Description | "en-US", "An object with several features of Sinumerik"
EventNotifier | SubscribeToEvents

I have tested this node on UA Expert and there i am able to see the events and alarms. I believe i need to change some configuration to subscribe events on this node, could you help with it @Jwcode-uk ?

@magiconair
Copy link
Member

Thank you @Jwcode-uk. I can see that one function in subscription.go gets an additional parameter. I think we could use a different pattern for functions like this. Not sure if we have more than just this one. Might be worthwhile to look. Would like to keep this consistent.

Not sure if this is complex enough to use the Option pattern for this constructor. What do you think?

// Deprectated: Use NewDefaultMonitoredItemCreateRequest instead. Will be removed with 0.8.0
func NewMonitoredItemCreateRequestWithDefaults(nodeID *ua.NodeID, attributeID ua.AttributeID, clientHandle uint32) *ua.MonitoredItemCreateRequest {
	return NewDefaultMonitoredItemCreateRequest(MICreateRequestArgs{
		NodeID:       nodeID,
		AttributeID:  attributeID,
		ClientHandle: clientHandle,
	})
}

type MonitoredItemCreateRequestArgs struct {
	NodeID       *ua.NodeID
	AttributeID  ua.AttributeID
	ClientHandle uint32
	Filter       *ua.ExtensionObject
}

func NewDefaultMonitoredItemCreateRequest(args MonitoredItemCreateRequestArgs) *ua.MonitoredItemCreateRequest {
	if args.AttributeID == 0 {
		args.AttributeID = ua.AttributeIDValue
	}
	return &ua.MonitoredItemCreateRequest{
		ItemToMonitor: &ua.ReadValueID{
			NodeID:       args.NodeID,
			AttributeID:  args.AttributeID,
			DataEncoding: &ua.QualifiedName{},
		},
		MonitoringMode: ua.MonitoringModeReporting,
		RequestedParameters: &ua.MonitoringParameters{
			ClientHandle:     args.ClientHandle,
			DiscardOldest:    true,
			Filter:           args.Filter,
			QueueSize:        10,
			SamplingInterval: 0.0,
		},
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants