# HG changeset patch # User lbessard # Date 1208873760 -7200 # Node ID c70aefcadf66713dc2ff09a18a4d7acdfa87e353 # Parent b1144bb3660521cb235ae77d81bd7934ab4be925 Bugs with feedback path in View, Controler and Generator fixed Bugs with wire Resize in graphical editor fixed diff -r b1144bb36605 -r c70aefcadf66 PLCControler.py --- a/PLCControler.py Tue Apr 22 10:25:24 2008 +0200 +++ b/PLCControler.py Tue Apr 22 16:16:00 2008 +0200 @@ -1797,6 +1797,8 @@ element = self.GetEditedElement(tagname) if element is not None: block = element.getinstance(id) + if block is None: + return old_name = block.getinstanceName() old_type = block.gettypeName() new_name = infos.get("name", old_name) @@ -1871,6 +1873,8 @@ element = self.GetEditedElement(tagname) if element is not None: variable = element.getinstance(id) + if variable is None: + return for param, value in infos.items(): if param == "name": variable.setexpression(value) @@ -1935,6 +1939,8 @@ element = self.GetEditedElement(tagname) if element is not None: connection = element.getinstance(id) + if connection is None: + return for param, value in infos.items(): if param == "name": connection.setname(value) @@ -1995,6 +2001,8 @@ element = self.GetEditedElement(tagname) if element is not None: powerrail = element.getinstance(id) + if powerrail is None: + return for param, value in infos.items(): if param == "height": powerrail.setheight(value) @@ -2032,6 +2040,8 @@ element = self.GetEditedElement(tagname) if element is not None: contact = element.getinstance(id) + if contact is None: + return for param, value in infos.items(): if param == "name": contact.setvariable(value) @@ -2078,6 +2088,8 @@ element = self.GetEditedElement(tagname) if element is not None: coil = element.getinstance(id) + if coil is None: + return for param, value in infos.items(): if param == "name": coil.setvariable(value) @@ -2124,6 +2136,8 @@ element = self.GetEditedElement(tagname) if element is not None: step = element.getinstance(id) + if step is None: + return for param, value in infos.items(): if param == "name": step.setname(value) @@ -2172,6 +2186,8 @@ element = self.GetEditedElement(tagname) if element is not None: transition = element.getinstance(id) + if transition is None: + return for param, value in infos.items(): if param == "type" and value != "connection": transition.setconditionContent(value, infos["condition"]) @@ -2225,6 +2241,8 @@ element = self.GetEditedElement(tagname) if element is not None: divergence = element.getinstance(id) + if divergence is None: + return for param, value in infos.items(): if param == "height": divergence.setheight(value) @@ -2279,6 +2297,8 @@ element = self.GetEditedElement(tagname) if element is not None: jump = element.getinstance(id) + if jump is None: + return for param, value in infos.items(): if param == "target": jump.settargetName(value) @@ -2307,6 +2327,8 @@ element = self.GetEditedElement(tagname) if element is not None: actionBlock = element.getinstance(id) + if actionBlock is None: + return for param, value in infos.items(): if param == "actions": actionBlock.setactions(value) diff -r b1144bb36605 -r c70aefcadf66 PLCGenerator.py --- a/PLCGenerator.py Tue Apr 22 10:25:24 2008 +0200 +++ b/PLCGenerator.py Tue Apr 22 16:16:00 2008 +0200 @@ -393,7 +393,8 @@ elif var_type is None: var_type = expression.split("#")[0] if isinstance(instance, (plcopen.fbdObjects_inVariable, plcopen.fbdObjects_inOutVariable)): - self.ConnectionTypes[instance.connectionPointOut] = var_type + for connection in self.ExtractRelatedConnections(instance.connectionPointOut): + self.ConnectionTypes[connection] = var_type if isinstance(instance, (plcopen.fbdObjects_outVariable, plcopen.fbdObjects_inOutVariable)): self.ConnectionTypes[instance.connectionPointIn] = var_type connected = self.GetConnectedConnection(instance.connectionPointIn, body) @@ -401,7 +402,8 @@ for connection in self.ExtractRelatedConnections(connected): self.ConnectionTypes[connection] = var_type elif isinstance(instance, (plcopen.ldObjects_contact, plcopen.ldObjects_coil)): - self.ConnectionTypes[instance.connectionPointOut] = "BOOL" + for connection in self.ExtractRelatedConnections(instance.connectionPointOut): + self.ConnectionTypes[connection] = "BOOL" self.ConnectionTypes[instance.connectionPointIn] = "BOOL" connected = self.GetConnectedConnection(instance.connectionPointIn, body) if connected and connected not in self.ConnectionTypes: @@ -409,7 +411,8 @@ self.ConnectionTypes[connection] = "BOOL" elif isinstance(instance, plcopen.ldObjects_leftPowerRail): for connection in instance.getconnectionPointOut(): - self.ConnectionTypes[connection] = "BOOL" + for related in self.ExtractRelatedConnections(connection): + self.ConnectionTypes[related] = "BOOL" elif isinstance(instance, plcopen.ldObjects_rightPowerRail): for connection in instance.getconnectionPointIn(): self.ConnectionTypes[connection] = "BOOL" diff -r b1144bb36605 -r c70aefcadf66 graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Tue Apr 22 10:25:24 2008 +0200 +++ b/graphics/GraphicCommons.py Tue Apr 22 16:16:00 2008 +0200 @@ -1183,6 +1183,7 @@ self.Value = None self.OverStart = False self.OverEnd = False + self.ComputingType = False # Destructor of a wire def __del__(self): @@ -1212,8 +1213,11 @@ # Returns connector to which start point is connected def GetStartConnectedType(self): - if self.StartConnected: - return self.StartConnected.GetType() + if self.StartConnected and not self.ComputingType: + self.ComputingType = True + computed_type = self.StartConnected.GetType() + self.ComputingType = False + return computed_type return None # Returns connector to which end point is connected @@ -1222,8 +1226,11 @@ # Returns connector to which end point is connected def GetEndConnectedType(self): - if self.EndConnected: - return self.EndConnected.GetType() + if self.EndConnected and not self.ComputingType: + self.ComputingType = True + computed_type = self.EndConnected.GetType() + self.ComputingType = False + return computed_type return None def GetOtherConnected(self, connector): @@ -1324,7 +1331,7 @@ miny, minbbxy = min(miny, self.Points[-1].y), min(minbbxy, self.Points[-1].y - end_radius) maxy, maxbbxy = max(maxy, self.Points[-1].y), max(maxbbxy, self.Points[-1].y + end_radius) self.Pos.x, self.Pos.y = minx, miny - self.Size = wx.Size(maxx - minx + 1, maxy - miny + 1) + self.Size = wx.Size(maxx - minx, maxy - miny) self.BoundingBox = wx.Rect(minbbxx, minbbxy, maxbbxx - minbbxx + 1, maxbbxy - minbbxy + 1) # Refresh the realpoints that permits to keep the proportionality in wire during resizing @@ -1652,10 +1659,10 @@ dir = self.EndPoint[1] else: dir = (0, 0) - pointx = max(-dir[0] * MIN_SEGMENT_SIZE, min(int(round(point[0] * (width - 1) / float(lastwidth - 1))), - width - dir[0] * MIN_SEGMENT_SIZE - 1)) - pointy = max(-dir[1] * MIN_SEGMENT_SIZE, min(int(round(point[1] * (height - 1) / float(lastheight - 1))), - height - dir[1] * MIN_SEGMENT_SIZE - 1)) + pointx = max(-dir[0] * MIN_SEGMENT_SIZE, min(int(round(point[0] * width / float(max(lastwidth, 1)))), + width - dir[0] * MIN_SEGMENT_SIZE)) + pointy = max(-dir[1] * MIN_SEGMENT_SIZE, min(int(round(point[1] * height / float(max(lastheight, 1)))), + height - dir[1] * MIN_SEGMENT_SIZE)) self.Points[i] = wx.Point(minx + x + pointx, miny + y + pointy) self.StartPoint[0] = self.Points[0] self.EndPoint[0] = self.Points[-1] @@ -1676,8 +1683,8 @@ # duringa resize dragging for i, point in enumerate(self.RealPoints): if not (i == 0 and self.StartConnected) and not (i == len(self.Points) - 1 and self.EndConnected): - point[0] = point[0] * (width - 1) / float(lastwidth - 1) - point[1] = point[1] * (height - 1) / float(lastheight - 1) + point[0] = point[0] * width / float(max(lastwidth, 1)) + point[1] = point[1] * height / float(max(lastheight, 1)) # Calculate the correct position of the points from real points for i, point in enumerate(self.RealPoints): if not (i == 0 and self.StartConnected) and not (i == len(self.Points) - 1 and self.EndConnected): @@ -1688,9 +1695,9 @@ else: dir = (0, 0) realpointx = max(-dir[0] * MIN_SEGMENT_SIZE, min(int(round(point[0])), - width - dir[0] * MIN_SEGMENT_SIZE - 1)) + width - dir[0] * MIN_SEGMENT_SIZE)) realpointy = max(-dir[1] * MIN_SEGMENT_SIZE, min(int(round(point[1])), - height - dir[1] * MIN_SEGMENT_SIZE - 1)) + height - dir[1] * MIN_SEGMENT_SIZE)) self.Points[i] = wx.Point(minx + x + realpointx, miny + y + realpointy) self.StartPoint[0] = self.Points[0] self.EndPoint[0] = self.Points[-1] diff -r b1144bb36605 -r c70aefcadf66 plcopen/structures.py --- a/plcopen/structures.py Tue Apr 22 10:25:24 2008 +0200 +++ b/plcopen/structures.py Tue Apr 22 16:16:00 2008 +0200 @@ -43,6 +43,7 @@ output_variable = block.outputVariables.getvariable()[0] output_name = "%s%d_OUT"%(type, block.getlocalId()) if not generator.ComputedBlocks.get(block, False) and not order: + generator.ComputedBlocks[block] = True if generator.Interface[-1][0] != "VAR" or generator.Interface[-1][1] or generator.Interface[-1][2] or generator.Interface[-1][3]: generator.Interface.append(("VAR", False, False, False, [])) if output_variable.connectionPointOut in generator.ConnectionTypes: @@ -64,10 +65,10 @@ value = generator.ComputeLDExpression(paths, True) vars.append(generator.ExtractModifier(variable, value)) generator.Program += " %s := %s(%s);\n"%(output_name, type, ", ".join(vars)) - generator.ComputedBlocks[block] = True return generator.ExtractModifier(output_variable, output_name) elif block_infos["type"] == "functionBlock": if not generator.ComputedBlocks.get(block, False) and not order: + generator.ComputedBlocks[block] = True vars = [] for variable in block.inputVariables.getvariable(): connections = variable.connectionPointIn.getconnections() @@ -84,7 +85,6 @@ value = generator.ComputeLDExpression(paths, True) vars.append("%s := %s"%(parameter, generator.ExtractModifier(variable, value))) generator.Program += " %s(%s);\n"%(name, ", ".join(vars)) - generator.ComputedBlocks[block] = True if link: connectionPoint = link.getposition()[-1] else: