--- a/PLCControler.py Tue Feb 26 15:15:27 2008 +0100
+++ b/PLCControler.py Tue Feb 26 15:16:30 2008 +0100
@@ -414,10 +414,10 @@
programfile.write(program)
programfile.close()
self.ProgramFilePath = filepath
- return True
- except:
- pass
- return False
+ return None
+ except PLCGenException, e:
+ return e.message
+ return "No project opened"
#-------------------------------------------------------------------------------
# Project Pous management functions
--- a/PLCGenerator.py Tue Feb 26 15:15:27 2008 +0100
+++ b/PLCGenerator.py Tue Feb 26 15:16:30 2008 +0100
@@ -37,6 +37,9 @@
datatypeComputed = {}
pouComputed = {}
+class PLCGenException(Exception):
+ pass
+
def ReIndentText(text, nb_spaces):
compute = ""
lines = text.splitlines()
@@ -114,7 +117,7 @@
if pou_type in pouTypeNames:
pou_program = PouProgram(pou.getname(), pouTypeNames[pou_type])
else:
- raise ValueError, "Undefined pou type"
+ raise PLCGenException, "Undefined pou type"
pou_program.GenerateInterface(pou.getinterface())
pou_program.GenerateConnectionTypes(pou)
pou_program.GenerateProgram(pou)
@@ -538,7 +541,7 @@
expression = self.ComputeFBDExpression(body, connections[0], order)
self.ComputedConnectors[name] = expression
return expression
- raise ValueError, "No connector found"
+ raise PLCGenException, "No connector found"
def GenerateLDPaths(self, connections, body):
paths = []
--- a/PLCOpenEditor.py Tue Feb 26 15:15:27 2008 +0100
+++ b/PLCOpenEditor.py Tue Feb 26 15:16:30 2008 +0100
@@ -703,8 +703,8 @@
filepath = dialog.GetPath()
if os.path.isdir(os.path.dirname(filepath)):
result = self.Controler.GenerateProgram(filepath)
- if not result:
- message = wx.MessageDialog(self, "Can't generate program to file %s!"%filepath, "Error", wx.OK|wx.ICON_ERROR)
+ if result is not None:
+ message = wx.MessageDialog(self, "Can't generate program to file %s :\n%s"%(filepath, result), "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else: