Commit d2636cc6 authored by Gino Tosti's avatar Gino Tosti
Browse files

added array support to exprimenta opcua server

parent ba62172e
......@@ -50,7 +50,10 @@ class VarUpdater(Thread):
for v in self.var:
ty=v.get_data_type_as_variant_type()
if ty!=ua.VariantType.String and ty!=ua.VariantType.Boolean:
v.set_value(v.get_value()+random.uniform(-5,5))
if v.get_value()!=None:
v.set_value(v.get_value()+random.uniform(-5,5))
else:
v.set_value(random.uniform(-5,5))
time.sleep(2)
......
......@@ -90,9 +90,25 @@
#for $idx in $range(0,$x["NRows"])
#silent L.append($x["Short name"][$idx])
#if ($x["OPC UA Data type"][$idx]).upper()[-1]==']' ## test for arrays
#set $type=($x["OPC UA Data type"][$idx].upper()).split("[")[0].capitalize()
#set $sp=($x["OPC UA Data type"][$idx].upper()).split("[")
#set $type=$sp[0].capitalize()
#if $type[0]=="U"
#set $type=$type.replace("i","I")
#end if
#set $dim=$sp[1].replace("]","")
<UAVariable ArrayDimensions="$dim" NodeId="$x['OPC_UA node'][$idx]" BrowseName="4:$x['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=4;i=2" ValueRank="1">
<DisplayName>$x['Name of command'][$idx]</DisplayName>
<Description>$x['Description'][$idx]</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=2</Reference>
</References>
</UAVariable>
#else
#set $type=$x["OPC UA Data type"][$idx].capitalize()
#if $type[0]=="U"
#set $type=$type.replace("i","I")
#end if
<UAVariable NodeId="$x['OPC_UA node'][$idx]" BrowseName="4:$x['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=4;i=2">
<DisplayName>$x['Name of command'][$idx]</DisplayName>
<Description>$x['Description'][$idx]</Description>
......@@ -100,19 +116,41 @@
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=2</Reference>
</References>
#if $type!="String" and $type != "Boolean"
<Value>
<uax:$type>$x['Default value'][$idx]</uax:$type>
#set $val=str($x['Default value'][$idx])
#if $val=="nan" or $val=="NA"
#set $val="0"
#end if
<uax:$type>$val</uax:$type>
</Value>
#end if
</UAVariable>
#end if
#end for
#for $idx in $range(0,$y["NRows"])
#silent L.append($y["Short name"][$idx])
#if ($y["OPC UA Data type"][$idx]).upper()[-1]==']' ## test for arrays
#set $type=($y["OPC UA Data type"][$idx].upper()).split("[")[0].capitalize()
#set $sp=($y["OPC UA Data type"][$idx].upper()).split("[")
#set $type=$sp[0].capitalize()
#if $type[0]=="U"
#set $type=$type.replace("i","I")
#end if
#set $dim=$sp[1].replace("]","")
<UAVariable ArrayDimensions="$dim" NodeId="$y['OPC_UA node'][$idx]" BrowseName="4:$y['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=4;i=3" UserAccessLevel="3" AccessLevel="3" ValueRank="1">
<DisplayName>$y['Name of command'][$idx]</DisplayName>
<Description>$y['Description'][$idx]</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=3</Reference>
</References>
</UAVariable>
#else
#set $type=$y["OPC UA Data type"][$idx].capitalize()
#end if
#if $type[0]=="U"
#set $type=$type.replace("i","I")
#end if
<UAVariable NodeId="$y['OPC_UA node'][$idx]" BrowseName="4:$y['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=4;i=3" UserAccessLevel="3" AccessLevel="3">
<DisplayName>$y['Name of command'][$idx]</DisplayName>
<Description>$y['Description'][$idx]</Description>
......@@ -120,15 +158,26 @@
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=3</Reference>
</References>
#if $type!="String" and $type != "Boolean"
<Value>
<uax:$type>$y['Default value'][$idx]</uax:$type>
#set $val=str($y['Default value'][$idx])
#if $val=="nan" or $val=="NA"
#set $val="0"
#end if
<uax:$type>$val</uax:$type>
</Value>
</UAVariable>
#end if
</UAVariable>
#end if
#end for
#for $idx in $range(0,$m["NRows"])
#set $name=($m["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_")
#if not $name in L
#set $type=$m["OPC UA Data type"][$idx].capitalize()
#if $type[0]=="U"
#set $type=$type.replace("i","I")
#end if
<UAVariable NodeId="$m['OPC_UA node'][$idx]" BrowseName="4:$name" DataType="$type" ParentNodeId="ns=4;i=4" UserAccessLevel="3" AccessLevel="3">
<DisplayName>$name</DisplayName>
<Description>$m['Description'][$idx]</Description>
......@@ -136,9 +185,15 @@
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=4</Reference>
</References>
#if $type!="String" and $type != "Boolean"
<Value>
<uax:$type>$m['Default value'][$idx]</uax:$type>
#set $val=str($m['Default value'][$idx])
#if $val=="nan" or $val=="NA"
#set $val="0"
#end if
<uax:$type>$val</uax:$type>
</Value>
#end if
</UAVariable>
#silent L.append($name)
#end if
......@@ -147,6 +202,9 @@
#set $name=($c["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_")
#if not $name in L
#set $type=$c["OPC UA Data type"][$idx].capitalize()
#if $type[0]=="U"
#set $type=$type.replace("i","I")
#end if
<UAVariable NodeId="$c['OPC_UA node'][$idx]" BrowseName="4:$c['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=4;i=5" UserAccessLevel="3" AccessLevel="3">
<DisplayName>$c['Name of command'][$idx]</DisplayName>
<Description>$c['Description'][$idx]</Description>
......@@ -154,9 +212,15 @@
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=5</Reference>
</References>
#if $type!="String" and $type != "Boolean"
<Value>
<uax:$type>$c['Default value'][$idx]</uax:$type>
#set $val=str($c['Default value'][$idx])
#if $val=="nan" or $val=="NA"
#set $val="0"
#end if
<uax:$type>$val</uax:$type>
</Value>
#end if
</UAVariable>
#silent L.append($name)
#end if
......
Supports Markdown
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