Bug on Exception handling fixed
authorgreg
Wed, 26 Nov 2008 09:04:28 +0100
changeset 272 9cce83526487
parent 271 ea7928fd07da
child 273 d15a20eb2b8b
Bug on Exception handling fixed
plugins/svgui/svgui.py
--- a/plugins/svgui/svgui.py	Mon Nov 24 08:57:43 2008 +0100
+++ b/plugins/svgui/svgui.py	Wed Nov 26 09:04:28 2008 +0100
@@ -9,6 +9,7 @@
 from SVGUIControler import *
 from SVGUIEditor import *
 from FBD_Objects import *
+from PLCGenerator import PLCGenException
 
 from wxPopen import ProcessLogger
 from wx.wxsvg import SVGDocument
@@ -166,11 +167,10 @@
             dialog.Destroy()
 
     def _StartInkscape(self):
-        if not self._View:
-		svgfile = os.path.join(self.PlugPath(), "gui.svg")		
-		if not os.path.isfile(svgfile):
-		    svgfile = None
-		open_svg(svgfile)
+        svgfile = os.path.join(self.PlugPath(), "gui.svg")		
+        if not os.path.isfile(svgfile):
+            svgfile = None
+        open_svg(svgfile)
 
     PluginMethods = [
         {"bitmap" : os.path.join("images","HMIEditor"),
@@ -251,7 +251,7 @@
             name = block.getinstanceName()
             block_id = self.GetElementIdFromName(name)
             if block_id == None:
-                raise ValueError, "No corresponding block found"
+                raise PLCGenException, "Undefined SVGUI Block \"%s\""%name
             type = block.gettypeName()
             block_infos = GetSVGUIBlockType(type)
             current_location = ".".join(map(str, self.GetCurrentLocation()))
@@ -273,16 +273,17 @@
                 for num, variable in enumerate(block.outputVariables.getvariable()):
                     blockPointx, blockPointy = variable.connectionPointOut.getrelPositionXY()
                     output_info = (generator.TagName, "block", block.getlocalId(), "output", num)
+                    parameter = "%sI%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["outputs"][num][1]], current_location, block_id, num+1)
                     if block.getx() + blockPointx == connectionPoint.getx() and block.gety() + blockPointy == connectionPoint.gety():
-                        return [("%sI%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["outputs"][num][1]], current_location, block_id, num+1), output_info)]
-                raise ValueError, "No output variable found"
+                        return generator.ExtractModifier(variable, [(parameter, output_info)], output_info)
+                raise PLCGenException, "No corresponding output variable found on SVGUI Block \"%s\""%name
             else:
                 return None
 
         def initialise_block(type, name, block = None):
             block_id = self.GetElementIdFromName(name)
             if block_id == None:
-                raise ValueError, "No corresponding block found"
+                raise PLCGenException, "Undefined SVGUI Block \"%s\""%name
             block_infos = GetSVGUIBlockType(type)
             current_location = ".".join(map(str, self.GetCurrentLocation()))
             variables = []