Commit 03706a40 authored by Gino Tosti's avatar Gino Tosti
Browse files

update server model generation

parent c1edeb9d
<?xml version="1.0" encoding="utf-8"?>
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.02" LastModified="2013-03-06T05:36:44.0862658Z" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">
<!-- * Generated by: $Author
* Date: $Date
* Description: $Description !-->
#set $ns=$ns
#set $rr=$int($ns)
<NamespaceUris>
<Uri>http://localhost/$Assembly/</Uri>
#for $i in $range(0,$rr-1)
<Uri>http://localhost/$Assembly$str($i)/</Uri>
#end for
<Uri>http://localhost/$Assembly/</Uri>
</NamespaceUris>
<Aliases> <Alias Alias="Boolean">i=1</Alias>
<Aliases>
<Alias Alias="Boolean">i=1</Alias>
<Alias Alias="SByte">i=2</Alias>
<Alias Alias="Byte">i=3</Alias>
<Alias Alias="Int16">i=4</Alias>
......@@ -44,9 +51,10 @@
<Alias Alias="HasDescription">i=39</Alias>
<Alias Alias="Range">i=884</Alias>
</Aliases>
<UAObject NodeId="ns=4;i=1" BrowseName="2:${Assembly}Folder">
#silent L=[]
#silent N=[]
#silent T=[]
<UAObject NodeId="ns=${ns};i=1" BrowseName="${ns}:${Assembly}Folder">
<DisplayName>${Assembly}</DisplayName>
<Description>The folder of the Assembly</Description>
<References>
......@@ -54,40 +62,57 @@
<Reference ReferenceType="HasTypeDefinition">i=61</Reference>
</References>
</UAObject>
<UAObject NodeId="ns=4;i=2" BrowseName="3:${Assembly}_Get_Points" ParentNodeId="ns=4;i=1">
<UAObject NodeId="ns=${ns};i=2" BrowseName="${ns}:${Assembly}_Get_Points" ParentNodeId="ns=${ns};i=1">
<DisplayName>${Assembly} Monitoring Variables</DisplayName>
<Description>The folder of the Assembly Monitoring Variables</Description>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=4;i=1</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=${ns};i=1</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=${ns};i=1</Reference>
#for $idx in $range(0,$x["NRows"])
<Reference ReferenceType="HasProperty">$x['OPC_UA node'][$idx]</Reference>
#end for
</References>
</UAObject>
<UAObject NodeId="ns=4;i=3" BrowseName="3:${Assembly}_Set_Points" ParentNodeId="ns=4;i=1">
<UAObject NodeId="ns=${ns};i=3" BrowseName="${ns}:${Assembly}_Set_Points" ParentNodeId="ns=${ns};i=1">
<DisplayName>${Assembly} Setting Variables</DisplayName>
<Description>The folder of the Assembly Setting Variables</Description>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=4;i=1</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=${ns};i=1</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=${ns};i=1</Reference>
#for $idx in $range(0,$y["NRows"])
<Reference ReferenceType="HasProperty">$y['OPC_UA node'][$idx]</Reference>
#end for
</References>
</UAObject>
<UAObject NodeId="ns=4;i=4" BrowseName="3:${Assembly}_Mode_cmd" ParentNodeId="ns=4;i=1">
<UAObject NodeId="ns=${ns};i=4" BrowseName="${ns}:${Assembly}_Mode_cmd" ParentNodeId="ns=${ns};i=1">
<DisplayName>${Assembly} Mode Variables</DisplayName>
<Description>The folder of the Assembly Setting Variables</Description>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=4;i=1</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=${ns};i=1</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=${ns};i=1</Reference>
#for $idx in $range(0,$m["NRows"])
#if not $m['OPC_UA node'][$idx] in T
<Reference ReferenceType="HasProperty">$m['OPC_UA node'][$idx]</Reference>
#silent T.append($m['OPC_UA node'][$idx])
#end if
#end for
</References>
</UAObject>
<UAObject NodeId="ns=4;i=5" BrowseName="3:${Assembly}_Commands" ParentNodeId="ns=4;i=1">
<UAObject NodeId="ns=${ns};i=5" BrowseName="${ns}:${Assembly}_Commands" ParentNodeId="ns=${ns};i=1">
<DisplayName>${Assembly} Command Variables</DisplayName>
<Description>The folder of the Assembly Monitoring Variables</Description>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=4;i=1</Reference>
<Reference ReferenceType="Organizes" IsForward="false">ns=${ns};i=1</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=${ns};i=1</Reference>
#for $idx in $range(0,$c["NRows"])
#if not $c['OPC_UA node'][$idx] in T
<Reference ReferenceType="HasProperty">$c['OPC_UA node'][$idx]</Reference>
#silent T.append($c['OPC_UA node'][$idx])
#end if
#end for
</References>
</UAObject>
#silent L=[]
#silent N=[]
#for $idx in $range(0,$x["NRows"])
#silent L.append($x["Short name"][$idx])
#if not $x['OPC_UA node'][$idx] in N
......@@ -98,12 +123,12 @@
#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">
<UAVariable ArrayDimensions="$dim" NodeId="$x['OPC_UA node'][$idx]" BrowseName="${ns}:$x['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=${ns};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>
<Reference ReferenceType="HasProperty" IsForward="false">ns=${ns};i=2</Reference>
</References>
</UAVariable>
#else
......@@ -111,12 +136,12 @@
#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">
<UAVariable NodeId="$x['OPC_UA node'][$idx]" BrowseName="${ns}:$x['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=${ns};i=2">
<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>
<Reference ReferenceType="HasProperty" IsForward="false">ns=${ns};i=2</Reference>
</References>
#if $type!="String" and $type != "Boolean"
<Value>
......@@ -145,12 +170,12 @@
#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">
<UAVariable ArrayDimensions="$dim" NodeId="$y['OPC_UA node'][$idx]" BrowseName="${ns}:$y['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=${ns};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>
<Reference ReferenceType="HasProperty" IsForward="false">ns=${ns};i=3</Reference>
</References>
</UAVariable>
#else
......@@ -159,12 +184,12 @@
#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">
<UAVariable NodeId="$y['OPC_UA node'][$idx]" BrowseName="${ns}:$y['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=${ns};i=3" UserAccessLevel="3" AccessLevel="3">
<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>
<Reference ReferenceType="HasProperty" IsForward="false">ns=${ns};i=3</Reference>
</References>
#if $type!="String" and $type != "Boolean"
<Value>
......@@ -189,12 +214,12 @@
#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">
<UAVariable NodeId="$m['OPC_UA node'][$idx]" BrowseName="${ns}:$name" DataType="$type" ParentNodeId="ns=${ns};i=4" UserAccessLevel="3" AccessLevel="3">
<DisplayName>$name</DisplayName>
<Description>$m['Description'][$idx]</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=4</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=${ns};i=4</Reference>
</References>
<Value>
<uax:$type>0</uax:$type>
......@@ -213,12 +238,12 @@
#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">
<UAVariable NodeId="$c['OPC_UA node'][$idx]" BrowseName="${ns}:$c['Name of command'][$idx]" DataType="$type" ParentNodeId="ns=${ns};i=5" UserAccessLevel="3" AccessLevel="3">
<DisplayName>$c['Name of command'][$idx]</DisplayName>
<Description>$c['Description'][$idx]</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=4;i=5</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=${ns};i=5</Reference>
</References>
<Value>
<uax:$type>0</uax:$type>
......
......@@ -13,7 +13,7 @@ if gen_dir==None:
print("PYGEN variable is not set")
os.exit(0)
def createOPCUModel(book,dest):
def createOPCUModel(book,dest,ns):
excel_file =book
wb=excelIcd(excel_file)
......@@ -28,7 +28,7 @@ def createOPCUModel(book,dest):
name_space = {'Author': "Gino Tosti", "Date":today.strftime("%y/%m/%d"),
'Description':Main["Description"][0],
'Assembly': Main['Assembly'][0], 'Url':Main['OPC UA address'][0],'Model':os.path.abspath(outfile),
'x': Get,'y':Set,'z':Main,'c':Cmd,'m':Mode}
'x': Get,'y':Set,'z':Main,'c':Cmd,'m':Mode,'ns':ns}
template_file=gen_dir+"/templates/simpleServerModel.tmpl"
......@@ -53,7 +53,9 @@ if __name__=="__main__":
parser.add_option("-f", "--file", dest="book_file", default=None,
help="ICD Exel File ", metavar="FILE")
parser.add_option("-o", "--outdir", dest="outdir", default="./SimulationOPCUAserver",
help="outputdir will be /SimulationOPCUAserver/ ", metavar="OUTDIR")
help="outputdir will be /SimulationOPCUAserver/ ", metavar="OUTDIR")
parser.add_option("-n", "--ns", dest="ns", default=4,
help="namespace ", metavar="OUTDIR")
(options, args) = parser.parse_args()
if not options.book_file: # if filename is not given
parser.error('ICD file not given')
......@@ -65,5 +67,8 @@ if __name__=="__main__":
else:
print("Directory " , defdest , " already exists")
#gen_dir=os.environ["PYGEN"]
createOPCUModel(options.book_file,os.path.abspath(defdest))
ns=""
ns=options.ns
print(type(ns),ns)
createOPCUModel(options.book_file,os.path.abspath(defdest),ns)
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