Adding support for defining plugin library as a plcopen xml file in plugin folder
authorgreg
Thu, 11 Dec 2008 09:13:22 +0100
changeset 293 dbc366959daf
parent 292 800e100038ae
child 294 4a36f2ec8967
Adding support for defining plugin library as a plcopen xml file in plugin folder
PLCControler.py
--- a/PLCControler.py	Tue Dec 09 10:01:12 2008 +0100
+++ b/PLCControler.py	Thu Dec 11 09:13:22 2008 +0100
@@ -498,17 +498,20 @@
             return project.ElementIsUsedBy(name, reference)
         return False
 
-    def GenerateProgram(self, filepath):
+    def GenerateProgram(self, filepath=None):
         if self.Project is not None:
             try:
                 self.ProgramChunks = GenerateCurrentProgram(self, self.Project)
                 self.NextCompiledProject = self.Copy(self.Project)
                 program_text = "".join([item[0] for item in self.ProgramChunks])
-                programfile = open(filepath, "w")
-                programfile.write(program_text)
-                programfile.close()
-                self.ProgramFilePath = filepath
-                return None
+                if filepath is not None:
+                    programfile = open(filepath, "w")
+                    programfile.write(program_text)
+                    programfile.close()
+                    self.ProgramFilePath = filepath
+                    return None
+                else:
+                    return program_text
             except PLCGenException, e:
                 return e.message
         return "No project opened"