--- a/PLCControler.py Wed Dec 16 15:20:56 2009 +0100
+++ b/PLCControler.py Tue Jun 01 12:41:14 2010 +0200
@@ -2562,7 +2562,10 @@
self.Project = plcopen.project()
for child in tree.childNodes:
if child.nodeType == tree.ELEMENT_NODE and child.nodeName == "project":
- self.Project.loadXMLTree(child, ["xmlns", "xmlns:xhtml", "xmlns:xsi", "xsi:schemaLocation"])
+ try:
+ result = self.Project.loadXMLTree(child, ["xmlns", "xmlns:xhtml", "xmlns:xsi", "xsi:schemaLocation"])
+ except ValueError, e:
+ return _("Project file syntax error:\n\n") + str(e)
self.SetFilePath(filepath)
self.Project.RefreshElementUsingTree()
self.Project.RefreshDataTypeHierarchy()
--- a/PLCGenerator.py Wed Dec 16 15:20:56 2009 +0100
+++ b/PLCGenerator.py Tue Jun 01 12:41:14 2010 +0200
@@ -926,6 +926,8 @@
elif type(paths) == ListType:
vars = [self.ComputePaths(path) for path in paths]
return JoinList([(" AND ", ())], vars)
+ elif paths is None:
+ return [("TRUE", ())]
else:
return eval(paths)
@@ -990,7 +992,7 @@
instances = []
for connectionPointIn in convergence.getconnectionPointIn():
connections = connectionPointIn.getconnections()
- if len(connections) == 1:
+ if connections is not None and len(connections) == 1:
instanceLocalId = connections[0].getrefLocalId()
body = pou.getbody()
if isinstance(body, ListType):
@@ -1010,7 +1012,7 @@
if step.connectionPointIn:
instances = []
connections = step.connectionPointIn.getconnections()
- if len(connections) == 1:
+ if connections is not None and len(connections) == 1:
instanceLocalId = connections[0].getrefLocalId()
body = pou.getbody()
if isinstance(body, ListType):
@@ -1039,7 +1041,7 @@
if jump.connectionPointIn:
instances = []
connections = jump.connectionPointIn.getconnections()
- if len(connections) == 1:
+ if connections is not None and len(connections) == 1:
instanceLocalId = connections[0].getrefLocalId()
body = pou.getbody()
if isinstance(body, ListType):
--- a/PLCOpenEditor.py Wed Dec 16 15:20:56 2009 +0100
+++ b/PLCOpenEditor.py Tue Jun 01 12:41:14 2010 +0200
@@ -2504,12 +2504,15 @@
def __init__(self, parent, fileOpen = None):
IDEFrame.__init__(self, parent)
+ result = None
+
# Open the filepath if defined
if fileOpen is not None and os.path.isfile(fileOpen):
# Create a new controller
self.Controler = PLCControler()
- self.Controler.OpenXMLFile(fileOpen)
- self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
+ result = self.Controler.OpenXMLFile(fileOpen)
+ if result is None:
+ self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
# Define PLCOpenEditor icon
self.SetIcon(wx.Icon(os.path.join(CWD,"Images", "poe.ico"),wx.BITMAP_TYPE_ICO))
@@ -2517,6 +2520,9 @@
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+
+ if result is not None:
+ self.ShowErrorMessage(result)
def OnCloseFrame(self, event):
if self.Controler is None or self.CheckSaveBeforeClosing(_("Close Application")):
@@ -2595,16 +2601,23 @@
directory = os.path.dirname(filepath)
else:
directory = os.getcwd()
+
+ result = None
+
dialog = wx.FileDialog(self, _("Choose a file"), directory, "", _("PLCOpen files (*.xml)|*.xml|All files|*.*"), wx.OPEN)
if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isfile(filepath):
self.ResetView()
self.Controler = PLCControler()
- self.Controler.OpenXMLFile(filepath)
- self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
+ result = self.Controler.OpenXMLFile(filepath)
+ if result is None:
+ self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
dialog.Destroy()
+
+ if result is not None:
+ self.ShowErrorMessage(result)
def OnCloseProjectMenu(self, event):
if not self.CheckSaveBeforeClosing():