|
@@ -5,9 +5,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -17,12 +19,13 @@
|
|
|
from sys import argv, exit
|
|
|
from os import path
|
|
|
from ua_namespace import *
|
|
|
+from logger import *
|
|
|
|
|
|
def usage():
|
|
|
print "Skript usage:"
|
|
|
print "generate_open62541CCode <namespace XML> [namespace.xml[ namespace.xml[...]]] <output file>"
|
|
|
print ""
|
|
|
- print "generate_open62541CCode will first read all XML files passed on the command line, then "
|
|
|
+ print "generate_open62541CCode will first read all XML files passed on the command line, then "
|
|
|
print "link and check the namespace. All nodes that fullfill the basic requirements will then be"
|
|
|
print "printed as C-Code intended to be included in the open62541 OPC-UA Server that will"
|
|
|
print "initialize the corresponding name space."
|
|
@@ -31,6 +34,9 @@ if __name__ == '__main__':
|
|
|
|
|
|
infiles = []
|
|
|
ouffile = ""
|
|
|
+
|
|
|
+ GLOBAL_LOG_LEVEL = LOG_LEVEL_INFO
|
|
|
+
|
|
|
if len(argv) < 2:
|
|
|
usage()
|
|
|
exit(1)
|
|
@@ -38,18 +44,16 @@ if __name__ == '__main__':
|
|
|
if path.exists(filename):
|
|
|
infiles.append(filename)
|
|
|
else:
|
|
|
- print "File " + str(filename) + " does not exist."
|
|
|
+ log(None, "File " + str(filename) + " does not exist.", LOG_LEVEL_ERROR)
|
|
|
usage()
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ if path.exists(argv[-1]):
|
|
|
+ log(None, "File " + str(filename) + " does already exists.", LOG_LEVEL_INFO)
|
|
|
+ log(None, "Header generation will be skipped. Delete the header and rerun this script if necessary.", LOG_LEVEL_INFO)
|
|
|
+ exit(0)
|
|
|
|
|
|
|
|
|
outfile = open(argv[-1], r"w+")
|
|
@@ -63,10 +67,11 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
for xmlfile in infiles:
|
|
|
- print "Parsing " + xmlfile
|
|
|
+ log(None, "Parsing " + str(xmlfile), LOG_LEVEL_INFO)
|
|
|
ns.parseXML(xmlfile)
|
|
|
|
|
|
|
|
|
+ log(None, "Linking namespace nodes and references", LOG_LEVEL_INFO)
|
|
|
ns.linkOpenPointers()
|
|
|
|
|
|
|
|
@@ -78,14 +83,17 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
+ log(None, "Building datatype encoding rules", LOG_LEVEL_INFO)
|
|
|
ns.buildEncodingRules()
|
|
|
|
|
|
|
|
|
|
|
|
+ log(None, "Allocating variables", LOG_LEVEL_INFO)
|
|
|
ns.allocateVariables()
|
|
|
|
|
|
|
|
|
+ log(None, "Generating Header", LOG_LEVEL_INFO)
|
|
|
for line in ns.printOpen62541Header():
|
|
|
outfile.write(line+"\n")
|
|
|
|
|
|
- outfile.close()
|
|
|
+ outfile.close()
|