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

Dimensional array read/write support #37

Open
YaroslavH2 opened this issue Aug 1, 2024 · 3 comments
Open

Dimensional array read/write support #37

YaroslavH2 opened this issue Aug 1, 2024 · 3 comments

Comments

@YaroslavH2
Copy link

YaroslavH2 commented Aug 1, 2024

I was facing an issue to read/write dimensional array in the variant variable with direct node access.
It looks like there was a TODO placeholder for dimensional arrays in the decoder. But encoding is also missing it.

opcua/ua/binary_decoder.go

Lines 1294 to 1296 in 387afc9

// TODO: Multidimensional array
return BadDecodingError
}

I have made a comit 348ab93 in a forked branch with read/write example working.

It would be useful to have some kind of a structure to keep the information about additional properties of the Variant like this to be part of the variant.:

type VariantMetadata struct {
	//mask contains the type and the array flags
	//bits 0:5: built-in type id 1-25
	//bit 6: array dimensions
	//bit 7: array values
	EncodingMask          byte
	ArrayLength           int32
	ArrayDimensionsLength int32
	ArrayDimensions       []int32
}

I looked into https://github.com/gopcua/opcua library as alternative solution and used some of its array reconstruction method as well as flattened array read/write.

I hope my fork can help to add it here to the master branch eventually.

What do you think?
Let me know how you see it in the end, so I can adapt it for merging...

@awcullen
Copy link
Owner

That TODO placeholder has been there for years. Thank you for working out a solution.

Why would it be useful to add the metadata fields to Variant?
If we did would users need to use methods like ua.NewVariant() and value.Value() to wrap and unwrap a Variant?

I think your solution is elegant.

@rjboer
Copy link
Contributor

rjboer commented Dec 6, 2024

Hi Andrew,

@awcullen, you did a commit, did you fix this?

@awcullen
Copy link
Owner

I added support to encode a Variant with a 2D or 3D matrix value (from 2D or 3D slices).
I still need to support encoding Structure with a matrix property.
And then I would consider adding more dimensions.

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

No branches or pull requests

3 participants