12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- from sys import argv, exit
- from os import path
- from ua_namespace 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 "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."
- if __name__ == '__main__':
-
- infiles = []
- ouffile = ""
- if len(argv) < 2:
- usage()
- exit(1)
- for filename in argv[1:-1]:
- if path.exists(filename):
- infiles.append(filename)
- else:
- print "File " + str(filename) + " does not exist."
- usage()
- exit(1)
-
-
-
- outfile = open(argv[-1], r"w+")
-
-
-
-
-
- ns = opcua_namespace("open62541")
-
- for xmlfile in infiles:
- print "Parsing " + xmlfile
- ns.parseXML(xmlfile)
-
- ns.linkOpenPointers()
-
-
- ns.sanitize()
-
-
-
-
-
- ns.buildEncodingRules()
-
-
- ns.allocateVariables()
-
- for line in ns.printOpen62541Header():
- outfile.write(line+"\n")
- outfile.close()
|