Commit 493068dc authored by Martin Manchev's avatar Martin Manchev

[Fix] Double now works ...

parent 576677e1
...@@ -31,14 +31,14 @@ ...@@ -31,14 +31,14 @@
</UAVariable> </UAVariable>
<!-- Float example --> <!-- Float example -->
<UAVariable NodeId="ns=1;i=4" BrowseName="1:erp5-variable-float" ParentNodeId="i=85" DataType="Float" AccessLevel="3" UserAccessLevel="3"> <!-- <UAVariable NodeId="ns=1;i=4" BrowseName="1:erp5-variable-float" ParentNodeId="i=85" DataType="Float" AccessLevel="3" UserAccessLevel="3">
<DisplayName>erp5-variable-float</DisplayName> <DisplayName>erp5-variable-float</DisplayName>
<Description>erp5-variable-float</Description> <Description>erp5-variable-float</Description>
<References> <References>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=9</Reference> <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=9</Reference>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference> <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References> </References>
</UAVariable> </UAVariable> -->
<!-- Double (float) example --> <!-- Double (float) example -->
<UAVariable NodeId="ns=1;i=5" BrowseName="1:erp5-variable-double" ParentNodeId="i=85" DataType="Double" AccessLevel="3" UserAccessLevel="3"> <UAVariable NodeId="ns=1;i=5" BrowseName="1:erp5-variable-double" ParentNodeId="i=85" DataType="Double" AccessLevel="3" UserAccessLevel="3">
......
...@@ -49,16 +49,11 @@ class ERP5Handler(asyncua.common.subscription.SubHandler): ...@@ -49,16 +49,11 @@ class ERP5Handler(asyncua.common.subscription.SubHandler):
def call(self, http_method="POST", **data): def call(self, http_method="POST", **data):
serialized_data = {} serialized_data = {}
for k, v in data.items(): for k, v in data.items():
# Convert non-serializable types to string
if not isinstance(v, (int, float, str)): if not isinstance(v, (int, float, str)):
v = str(v) v = str(v)
elif isinstance(v, float):
# Ensure proper serialization of float values
if v.is_integer():
v = int(v)
else:
v = float(v)
serialized_data[k] = v serialized_data[k] = v
print(f"Key: {k}\nValue: {v}\nValue Type: {type(v)}\n\n") print(f"Key: {k}\nValue: {v}\nValue Type: {type(v)}\n\n")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment