FreeOpcUa / python-opcua

LGPL Pure Python OPC-UA Client and Server
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
1.32k stars 661 forks source link

Support custom struct optional fields #1451

Closed deeTEEcee closed 2 years ago

deeTEEcee commented 2 years ago

Add support for OPC UA Optional FIelds

Looking at the code, the library already supports encoding/decoding for custom objects (see struct_to_binary and struct_from_binary) but it was not fully implemented. The missing piece was loading and structuring the generated python code correctly to match the later steps for encoding/decoding. What this means for implementation is:

Handle bits and byte encoding through the use of ua_switches and creating UInt32 bit-encoding objects with necessary. I also added some unit tests to make things easier and let us know what we're really looking at.

Extra:

deeTEEcee commented 2 years ago

@oroulet thanks for merging this in! can we expect a version upgrade too?