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

server: use DataValue instead of Variant for node attributes #766

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

danomagnum
Copy link
Contributor

By keeping the attribute values as DataValues instead of Variants it allows a user to set the timestamp, quality, or any other parameter of each attribute specifically instead of always returning a default.

The SetAttribute function already took a datavalue, so I don't expect there to be any real changes to user code - but now it will keep the value and not throw it away. The big difference is users will have to be careful to set the correct flags on the datavalue where before it ignored these and set the values at the end.

This should make more sense anyway since now you can for example update the timestamp when the value changes instead of when it is read only.
@magiconair
Copy link
Member

magiconair commented Feb 3, 2025

Is this a breaking change? If this is a breaking change then we should tag this as v0.7 or something similar.

@danomagnum
Copy link
Contributor Author

I think the only thing that breaks is custom Node definitions - the attribute map went from map[ua.AttributeID]*ua.Variant to map[ua.AttributeID]*ua.DataValue so if anyone was hand-rolling nodes instead of using helper functions that would break. it probably makes sense to mark it for the next revision.

@danomagnum danomagnum added this to the v0.7.0 milestone Feb 3, 2025
Copy link
Member

@magiconair magiconair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be some tests that need adapting?

@danomagnum
Copy link
Contributor Author

All the tests use the helper functions so they're largely one step removed from the change. A couple lines in the test server did have to change since SetAttribute() now takes a *DataValue instead of a DataValue

There's certainly an argument to be made that more tests are needed, but of the tests that exist there wasn't much to change.

@magiconair
Copy link
Member

Right. Was looking for _test.go files. Missed the tests/go/server.go

Copy link
Member

@magiconair magiconair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only affects the server so lets do it. I've moved some milestones around.

LGTM

@magiconair magiconair merged commit f4f7fae into main Feb 6, 2025
5 checks passed
@magiconair magiconair deleted the server_UseDVs branch February 6, 2025 16:18
@magiconair magiconair changed the title Change server node attributes to use data values directly. Change server node attributes to use DataValue instead of Variant. Feb 6, 2025
@magiconair magiconair changed the title Change server node attributes to use DataValue instead of Variant. Change server node attributes to use DataValue instead of Variant Feb 6, 2025
@magiconair magiconair changed the title Change server node attributes to use DataValue instead of Variant server: use DataValue instead of Variant for node attributes Feb 6, 2025
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.

2 participants