I need to get the name of the variables from the GVL of my application in order to perform some check on the names. How can I get these informations?
Should I read the entire GVL file and parse the text line by line? In that case how can I do it?
You can export your GVL in PLCopenXML and look for the XML node "globalVars" which represents a GVL. You find the variables below that node.
Here some code for exporting a GVL as PLCopenXML:
def error(self, object, message):
system.write_message(Severity.Error, "Error exporting %s: %s" % (object, message))
def warning(self, object, message):
system.write_message(Severity.Warning, "Warning exporting %s: %s" % (object, message))
def nonexportable(self, object):
system.write_message(Severity.Information, "Object not exportable: %s" % object)
# Main program
proj = projects.primary
found = proj.find('GVL', True)
gvl = found
reporter = ExportHandler()
print "exporting to string:"
xmldata = gvl.export_xml(reporter)
print "exporting to file:"
print "script finished."
For the XML you can use one of the Python modules included in the standard library.
I'm totally new in this field (execute Python script in Codesys) and I don't know which functions are available...do you have a guide or something similar?
The documentation of the Scripting API is in the file "ScriptEngine.chm" which is in the sub directory "Online Help" of the CODESYS directory.
Check out the CODESYS store: http://store.codesys.com/CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions