Skip to content

Historize ExtensionObjects or custom Structures? #1789

Closed Answered by dakotahorstman
dakotahorstman asked this question in Q&A
Discussion options

You must be logged in to vote

Found the solution after some more digging. asyncua provides the functions struct_to_binary and struct_from_binary. These will work perfectly for my needs for historization. Here's an updated snippet for the above:

from asyncua.ua.ua_binary import struct_from_binary, struct_to_binary

...

@logger.catch
async def save_node_value(self, node_id: NodeId, datavalue: DataValue) -> None:
    print(f"Original: {node_id} -> {datavalue}")
    binary = struct_to_binary(datavalue.Value.Value)
    binary_stream = io.BytesIO(binary)
    print(f"Serialized: {binary}")
    print(
        f"Deserialized: {struct_from_binary(datavalue.Value.Value.__class__, binary_stream)}"
    )
    print("-" * 200)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dakotahorstman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant