--- a/PLCControler.py Tue Aug 15 17:01:51 2017 +0300
+++ b/PLCControler.py Tue Aug 15 22:38:43 2017 +0300
@@ -456,7 +456,7 @@
Class implementing a buffer of changes made on the current editing model
- def __init__(self, currentstate, issaved = False):
+ def __init__(self, currentstate, issaved=False): Constructor initialising buffer
@@ -569,7 +569,7 @@
def GetQualifierTypes(self):
- def GetProject(self, debug = False):
+ def GetProject(self, debug=False): if debug and self.CurrentCompiledProject is not None:
return self.CurrentCompiledProject
@@ -601,28 +601,28 @@
# Return project data type names
- def GetProjectDataTypeNames(self, debug = False):
+ def GetProjectDataTypeNames(self, debug=False): project = self.GetProject(debug)
return [datatype.getname() for datatype in project.getdataTypes()]
# Return project pou names
- def GetProjectPouNames(self, debug = False):
+ def GetProjectPouNames(self, debug=False): project = self.GetProject(debug)
return [pou.getname() for pou in project.getpous()]
# Return project pou names
- def GetProjectConfigNames(self, debug = False):
+ def GetProjectConfigNames(self, debug=False): project = self.GetProject(debug)
return [config.getname() for config in project.getconfigurations()]
# Return project pou variable names
- def GetProjectPouVariableNames(self, pou_name = None, debug = False):
+ def GetProjectPouVariableNames(self, pou_name=None, debug=False): project = self.GetProject(debug)
@@ -662,7 +662,7 @@
self.FileName = os.path.splitext(os.path.basename(filepath))[0]
# Change project properties
- def SetProjectProperties(self, name = None, properties = None, buffer = True):
+ def SetProjectProperties(self, name=None, properties=None, buffer=True): if self.Project is not None:
self.Project.setname(name)
@@ -680,7 +680,7 @@
# Return project properties
- def GetProjectProperties(self, debug = False):
+ def GetProjectProperties(self, debug=False): project = self.GetProject(debug)
properties = project.getfileHeader()
@@ -689,7 +689,7 @@
# Return project informations
- def GetProjectInfos(self, debug = False):
+ def GetProjectInfos(self, debug=False): project = self.GetProject(debug)
infos = {"name": project.getname(), "type": ITEM_PROJECT}
@@ -755,7 +755,7 @@
- def GetPouVariables(self, tagname, debug = False):
+ def GetPouVariables(self, tagname, debug=False): project = self.GetProject(debug)
@@ -768,7 +768,7 @@
os.path.join(ScriptDirectory, "plcopen", "pou_variables.xslt"),
- extensions = {("pou_vars_ns", name): getattr(factory, name)
+ extensions={("pou_vars_ns", name): getattr(factory, name) for name in ["SetRoot", "AddVariable"]})
@@ -783,7 +783,7 @@
- def GetInstanceList(self, root, name, debug = False):
+ def GetInstanceList(self, root, name, debug=False): project = self.GetProject(debug)
@@ -796,7 +796,7 @@
os.path.join(ScriptDirectory, "plcopen", "instances_path.xslt"),
("instances_ns", "AddInstance"): factory.AddInstance})
instances_path_xslt_tree(root,
@@ -804,7 +804,7 @@
- def SearchPouInstances(self, tagname, debug = False):
+ def SearchPouInstances(self, tagname, debug=False): project = self.GetProject(debug)
words = tagname.split("::")
@@ -820,7 +820,7 @@
self.ComputePouName(words[1]), debug)]
- def GetPouInstanceTagName(self, instance_path, debug = False):
+ def GetPouInstanceTagName(self, instance_path, debug=False): project = self.GetProject(debug)
factory = InstanceTagName(self)
@@ -831,7 +831,7 @@
os.path.join(ScriptDirectory, "plcopen", "instance_tagname.xslt"),
- extensions = {("instance_tagname_ns", name): getattr(factory, name)
+ extensions={("instance_tagname_ns", name): getattr(factory, name) for name in ["ConfigTagName", "ResourceTagName",
"PouTagName", "ActionTagName",
@@ -841,7 +841,7 @@
return factory.GetTagName()
- def GetInstanceInfos(self, instance_path, debug = False):
+ def GetInstanceInfos(self, instance_path, debug=False): tagname = self.GetPouInstanceTagName(instance_path)
infos = self.GetPouVariables(tagname, debug)
@@ -858,21 +858,21 @@
# Return if data type given by name is used by another data type or pou
- def DataTypeIsUsed(self, name, debug = False):
+ def DataTypeIsUsed(self, name, debug=False): project = self.GetProject(debug)
return len(self.GetInstanceList(project, name, debug)) > 0
# Return if pou given by name is used by another pou
- def PouIsUsed(self, name, debug = False):
+ def PouIsUsed(self, name, debug=False): project = self.GetProject(debug)
return len(self.GetInstanceList(project, name, debug)) > 0
# Return if pou given by name is directly or undirectly used by the reference pou
- def PouIsUsedBy(self, name, reference, debug = False):
+ def PouIsUsedBy(self, name, reference, debug=False): pou_infos = self.GetPou(reference, debug)
if pou_infos is not None:
return len(self.GetInstanceList(pou_infos, name, debug)) > 0
@@ -1005,7 +1005,7 @@
# programs cannot be pasted as functions or function blocks
if orig_type == 'functionBlock' and pou_type == 'function' or \
orig_type == 'program' and pou_type in ['function', 'functionBlock']:
- msg = _('''{a1} "{a2}" can't be pasted as a {a3}.''').format(a1 = orig_type, a2 = name, a3 = pou_type)
+ msg = _('''{a1} "{a2}" can't be pasted as a {a3}.''').format(a1=orig_type, a2=name, a3=pou_type) new_pou.setpouType(pou_type)
@@ -1175,7 +1175,7 @@
# Return the description of the pou given by its name
- def GetPouDescription(self, name, debug = False):
+ def GetPouDescription(self, name, debug=False): project = self.GetProject(debug)
# Found the pou correponding to name and return its type
@@ -1185,7 +1185,7 @@
# Return the description of the pou given by its name
- def SetPouDescription(self, name, description, debug = False):
+ def SetPouDescription(self, name, description, debug=False): project = self.GetProject(debug)
# Found the pou correponding to name and return its type
@@ -1195,7 +1195,7 @@
# Return the type of the pou given by its name
- def GetPouType(self, name, debug = False):
+ def GetPouType(self, name, debug=False): project = self.GetProject(debug)
# Found the pou correponding to name and return its type
@@ -1205,7 +1205,7 @@
# Return pous with SFC language
- def GetSFCPous(self, debug = False):
+ def GetSFCPous(self, debug=False): project = self.GetProject(debug)
@@ -1215,7 +1215,7 @@
# Return the body language of the pou given by its name
- def GetPouBodyType(self, name, debug = False):
+ def GetPouBodyType(self, name, debug=False): project = self.GetProject(debug)
# Found the pou correponding to name and return its body language
@@ -1225,7 +1225,7 @@
# Return the actions of a pou
- def GetPouTransitions(self, pou_name, debug = False):
+ def GetPouTransitions(self, pou_name, debug=False): project = self.GetProject(debug)
@@ -1237,7 +1237,7 @@
# Return the body language of the transition given by its name
- def GetTransitionBodyType(self, pou_name, pou_transition, debug = False):
+ def GetTransitionBodyType(self, pou_name, pou_transition, debug=False): project = self.GetProject(debug)
# Found the pou correponding to name
@@ -1250,7 +1250,7 @@
# Return the actions of a pou
- def GetPouActions(self, pou_name, debug = False):
+ def GetPouActions(self, pou_name, debug=False): project = self.GetProject(debug)
@@ -1262,7 +1262,7 @@
# Return the body language of the pou given by its name
- def GetActionBodyType(self, pou_name, pou_action, debug = False):
+ def GetActionBodyType(self, pou_name, pou_action, debug=False): project = self.GetProject(debug)
# Found the pou correponding to name and return its body language
@@ -1368,7 +1368,7 @@
os.path.join(ScriptDirectory, "plcopen", "variables_infos.xslt"),
- extensions = {("var_infos_ns", name): getattr(factory, name)
+ extensions={("var_infos_ns", name): getattr(factory, name) for name in ["SetType", "AddDimension", "AddTree",
"AddVarToTree", "AddVariable"]})
variables_infos_xslt_tree(object_with_vars,
@@ -1400,7 +1400,7 @@
in self.ExtractVarLists(vars)])
# Return the configuration globalvars
- def GetConfigurationGlobalVars(self, name, debug = False):
+ def GetConfigurationGlobalVars(self, name, debug=False): project = self.GetProject(debug)
# Found the configuration corresponding to name
@@ -1412,7 +1412,7 @@
# Return configuration variable names
- def GetConfigurationVariableNames(self, config_name = None, debug = False):
+ def GetConfigurationVariableNames(self, config_name=None, debug=False): project = self.GetProject(debug)
@@ -1437,7 +1437,7 @@
in self.ExtractVarLists(vars)])
# Return the resource globalvars
- def GetConfigurationResourceGlobalVars(self, config_name, name, debug = False):
+ def GetConfigurationResourceGlobalVars(self, config_name, name, debug=False): project = self.GetProject(debug)
# Found the resource corresponding to name
@@ -1450,7 +1450,7 @@
# Return resource variable names
def GetConfigurationResourceVariableNames(self,
- config_name = None, resource_name = None, debug = False):
+ config_name=None, resource_name=None, debug=False): project = self.GetProject(debug)
@@ -1466,7 +1466,7 @@
# Return the interface for the given pou
- def GetPouInterfaceVars(self, pou, tree=False, debug = False):
+ def GetPouInterfaceVars(self, pou, tree=False, debug=False): interface = pou.interface
# Verify that the pou has an interface
if interface is not None:
@@ -1533,7 +1533,7 @@
os.path.join(ScriptDirectory, "plcopen", "variables_infos.xslt"),
- extensions = {("var_infos_ns", name): getattr(factory, name)
+ extensions={("var_infos_ns", name): getattr(factory, name) for name in ["SetType", "AddDimension",
"AddTree", "AddVarToTree"]})
return_type_infos_xslt_tree(return_type,
@@ -1565,7 +1565,7 @@
self.TotalTypesDict = StdBlckDct.copy()
self.TotalTypes = StdBlckLst[:]
- def GetConfNodeDataTypes(self, exclude = None, only_locatables = False):
+ def GetConfNodeDataTypes(self, exclude=None, only_locatables=False): return [{"name": _("%s Data Types") % confnodetypes["name"],
@@ -1606,7 +1606,7 @@
# Function that returns the block definition associated to the block type given
- def GetBlockType(self, typename, inputs = None, debug = False):
+ def GetBlockType(self, typename, inputs=None, debug=False): for sectioname, blocktype in self.TotalTypesDict.get(typename, []):
if inputs is not None and inputs != "undefined":
@@ -1639,7 +1639,7 @@
# Return Block types checking for recursion
- def GetBlockTypes(self, tagname = "", debug = False):
+ def GetBlockTypes(self, tagname="", debug=False): words = tagname.split("::")
@@ -1666,7 +1666,7 @@
# Return Function Block types checking for recursion
- def GetFunctionBlockTypes(self, tagname = "", debug = False):
+ def GetFunctionBlockTypes(self, tagname="", debug=False): project = self.GetProject(debug)
words = tagname.split("::")
@@ -1685,7 +1685,7 @@
# Return Block types checking for recursion
- def GetBlockResource(self, debug = False):
+ def GetBlockResource(self, debug=False): for category in StdBlckLst[:-1]:
for blocktype in category["list"]:
@@ -1699,7 +1699,7 @@
# Return Data Types checking for recursion
- def GetDataTypes(self, tagname = "", basetypes = True, confnodetypes = True, only_locatables = False, debug = False):
+ def GetDataTypes(self, tagname="", basetypes=True, confnodetypes=True, only_locatables=False, debug=False): datatypes = self.GetBaseTypes()
@@ -1722,7 +1722,7 @@
# Return Data Type Object
- def GetPou(self, typename, debug = False):
+ def GetPou(self, typename, debug=False): project = self.GetProject(debug)
result = project.getpou(typename)
@@ -1739,7 +1739,7 @@
# Return Data Type Object
- def GetDataType(self, typename, debug = False):
+ def GetDataType(self, typename, debug=False): project = self.GetProject(debug)
result = project.getdataType(typename)
@@ -1765,7 +1765,7 @@
# Return Base Type of given possible derived type
- def GetBaseType(self, typename, debug = False):
+ def GetBaseType(self, typename, debug=False): if TypeHierarchy.has_key(typename):
@@ -1786,7 +1786,7 @@
return [x for x, y in TypeHierarchy_list if not x.startswith("ANY")]
- def IsOfType(self, typename, reference, debug = False):
+ def IsOfType(self, typename, reference, debug=False): if reference is None or typename == reference:
@@ -1807,7 +1807,7 @@
return not typename.startswith("ANY")
- def IsLocatableDataType(self, datatype, debug = False):
+ def IsLocatableDataType(self, datatype, debug=False): basetype_content = datatype.baseType.getcontent()
basetype_content_type = basetype_content.getLocalTag()
if basetype_content_type in ["enum", "struct"]:
@@ -1820,7 +1820,7 @@
return self.IsLocatableType(array_base_type.getname(), debug)
- def IsLocatableType(self, typename, debug = False):
+ def IsLocatableType(self, typename, debug=False): if isinstance(typename, TupleType) or self.GetBlockType(typename) is not None:
@@ -1833,7 +1833,7 @@
return self.IsLocatableDataType(datatype)
- def IsEnumeratedType(self, typename, debug = False):
+ def IsEnumeratedType(self, typename, debug=False): if isinstance(typename, TupleType):
datatype = self.GetDataType(typename, debug)
@@ -1845,7 +1845,7 @@
return basetype_content_type == "enum"
- def IsSubrangeType(self, typename, exclude=None, debug = False):
+ def IsSubrangeType(self, typename, exclude=None, debug=False): if isinstance(typename, TupleType):
@@ -1861,11 +1861,11 @@
self.GetDataTypeBaseType(datatype), exclude)
- def IsNumType(self, typename, debug = False):
+ def IsNumType(self, typename, debug=False): return self.IsOfType(typename, "ANY_NUM", debug) or\
self.IsOfType(typename, "ANY_BIT", debug)
- def GetDataTypeRange(self, typename, debug = False):
+ def GetDataTypeRange(self, typename, debug=False): range = DataTypeRange.get(typename)
@@ -1881,7 +1881,7 @@
- def GetSubrangeBaseTypes(self, exclude, debug = False):
+ def GetSubrangeBaseTypes(self, exclude, debug=False): subrange_basetypes = DataTypeRange.keys()
project = self.GetProject(debug)
@@ -1895,7 +1895,7 @@
return subrange_basetypes
# Return Enumerated Values
- def GetEnumeratedDataValues(self, typename = None, debug = False):
+ def GetEnumeratedDataValues(self, typename=None, debug=False): datatype_obj = self.GetDataType(typename, debug)
@@ -1961,7 +1961,7 @@
#-------------------------------------------------------------------------------
# Return the data type informations
- def GetDataTypeInfos(self, tagname, debug = False):
+ def GetDataTypeInfos(self, tagname, debug=False): project = self.GetProject(debug)
words = tagname.split("::")
@@ -2161,7 +2161,7 @@
#-------------------------------------------------------------------------------
- def GetEditedElement(self, tagname, debug = False):
+ def GetEditedElement(self, tagname, debug=False): project = self.GetProject(debug)
words = tagname.split("::")
@@ -2192,14 +2192,14 @@
# Return edited element name and type
- def GetEditedElementType(self, tagname, debug = False):
+ def GetEditedElementType(self, tagname, debug=False): words = tagname.split("::")
if words[0] in ["P", "T", "A"]:
return words[1], self.GetPouType(words[1], debug)
# Return language in which edited element is written
- def GetEditedElementBodyType(self, tagname, debug = False):
+ def GetEditedElementBodyType(self, tagname, debug=False): words = tagname.split("::")
return self.GetPouBodyType(words[1], debug)
@@ -2210,7 +2210,7 @@
# Return the edited element variables
- def GetEditedElementInterfaceVars(self, tagname, tree=False, debug = False):
+ def GetEditedElementInterfaceVars(self, tagname, tree=False, debug=False): words = tagname.split("::")
if words[0] in ["P", "T", "A"]:
project = self.GetProject(debug)
@@ -2221,7 +2221,7 @@
# Return the edited element return type
- def GetEditedElementInterfaceReturnType(self, tagname, tree=False, debug = False):
+ def GetEditedElementInterfaceReturnType(self, tagname, tree=False, debug=False): words = tagname.split("::")
project = self.GetProject(debug)
@@ -2241,14 +2241,14 @@
# Return the edited element text
- def GetEditedElementText(self, tagname, debug = False):
+ def GetEditedElementText(self, tagname, debug=False): element = self.GetEditedElement(tagname, debug)
# Return the edited element transitions
- def GetEditedElementTransitions(self, tagname, debug = False):
+ def GetEditedElementTransitions(self, tagname, debug=False): pou = self.GetEditedElement(tagname, debug)
if pou is not None and pou.getbodyType() == "SFC":
@@ -2258,7 +2258,7 @@
# Return edited element transitions
- def GetEditedElementActions(self, tagname, debug = False):
+ def GetEditedElementActions(self, tagname, debug=False): pou = self.GetEditedElement(tagname, debug)
if pou is not None and pou.getbodyType() == "SFC":
@@ -2268,7 +2268,7 @@
# Return the names of the pou elements
- def GetEditedElementVariables(self, tagname, debug = False):
+ def GetEditedElementVariables(self, tagname, debug=False): words = tagname.split("::")
if words[0] in ["P", "T", "A"]:
return self.GetProjectPouVariableNames(words[1], debug)
@@ -2280,13 +2280,13 @@
- def GetEditedElementCopy(self, tagname, debug = False):
+ def GetEditedElementCopy(self, tagname, debug=False): element = self.GetEditedElement(tagname, debug)
return element.tostring()
- def GetEditedElementInstancesCopy(self, tagname, blocks_id = None, wires = None, debug = False):
+ def GetEditedElementInstancesCopy(self, tagname, blocks_id=None, wires=None, debug=False): element = self.GetEditedElement(tagname, debug)
@@ -2444,7 +2444,7 @@
return new_id, connections
- def GetEditedElementInstancesInfos(self, tagname, debug = False):
+ def GetEditedElementInstancesInfos(self, tagname, debug=False): element_instances = OrderedDict()
element = self.GetEditedElement(tagname, debug)
@@ -2452,7 +2452,7 @@
pou_block_instances_xslt_tree = etree.XSLT(
pou_block_instances_xslt,
("pou_block_instances_ns", name): getattr(factory, name)
for name in ["AddBlockInstance", "SetSpecificValues",
"AddInstanceConnection", "AddConnectionLink",
@@ -2540,7 +2540,7 @@
pou.removepouVar(type, name)
- def AddEditedElementBlock(self, tagname, id, blocktype, blockname = None):
+ def AddEditedElementBlock(self, tagname, id, blocktype, blockname=None): element = self.GetEditedElement(tagname)
block = PLCOpenParser.CreateElement("block", "fbdObjects")
@@ -3093,7 +3093,7 @@
self.RemoveEditedElementPouVar(tagname, instance.gettypeName(), instance.getinstanceName())
element.removeinstance(id)
- def GetEditedResourceVariables(self, tagname, debug = False):
+ def GetEditedResourceVariables(self, tagname, debug=False): words = tagname.split("::")
for var in self.GetConfigurationGlobalVars(words[1], debug):
@@ -3143,7 +3143,7 @@
new_instance.setname(instance["Name"])
new_instance.settypeName(instance["Type"])
- def GetEditedResourceInfos(self, tagname, debug = False):
+ def GetEditedResourceInfos(self, tagname, debug=False): resource = self.GetEditedElement(tagname, debug)
tasks = resource.gettask()
@@ -3212,7 +3212,7 @@
self.CurrentElementEditing = None
- def SaveXMLFile(self, filepath = None):
+ def SaveXMLFile(self, filepath=None): if not filepath and self.FilePath == "":
--- a/PLCGenerator.py Tue Aug 15 17:01:51 2017 +0300
+++ b/PLCGenerator.py Tue Aug 15 22:38:43 2017 +0300
@@ -398,7 +398,7 @@
msg = _("Source signal has to be defined for single task '{a1}' in resource '{a2}.{a3}'.").\
- format(a1 = task.getname(), a2 = config_name, a3 = resource.getname())
+ format(a1=task.getname(), a2=config_name, a3=resource.getname()) raise PLCGenException, msg
if single[0] == '[' and single[-1] == ']':
@@ -787,7 +787,7 @@
for element in body.getcontentInstances():
if isinstance(element, ConnectorClass) and element.getname() == name:
if connector is not None:
- msg = _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1 = name, a2 = self.Name)
+ msg = _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) raise PLCGenException, msg
if connector is not None:
@@ -807,7 +807,7 @@
for connection in related:
self.ConnectionTypes[connection] = var_type
- msg = _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1 = name, a2 = self.Name)
+ msg = _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) raise PLCGenException, msg
elif isinstance(instance, BlockClass):
block_infos = self.GetBlockType(instance.gettypeName(), "undefined")
@@ -962,7 +962,7 @@
block_infos = self.GetBlockType(block_type)
- raise PLCGenException, _("Undefined block type \"{a1}\" in \"{a2}\" POU").format(a1 = block_type, a2 = self.Name)
+ raise PLCGenException, _("Undefined block type \"{a1}\" in \"{a2}\" POU").format(a1=block_type, a2=self.Name) self.GenerateBlock(instance, block_infos, body, None)
@@ -1102,7 +1102,7 @@
self.Program += JoinList([(", ", ())], vars)
self.Program += [(");\n", ())]
- msg = _("\"{a1}\" function cancelled in \"{a2}\" POU: No input connected").format(a1 = type, a2 = self.TagName.split("::")[-1])
+ msg = _("\"{a1}\" function cancelled in \"{a2}\" POU: No input connected").format(a1=type, a2=self.TagName.split("::")[-1]) self.Warnings.append(msg)
elif block_infos["type"] == "functionBlock":
if not self.ComputedBlocks.get(block, False) and not order:
@@ -1192,14 +1192,14 @@
if output_parameter is None:
- blockname = "{a1}({a2})".format(a1 = name, a2 = type)
+ blockname = "{a1}({a2})".format(a1=name, a2=type) msg = _("No output {a1} variable found in block {a2} in POU {a3}. Connection must be broken").\
- format(a1 = output_parameter, a2 = blockname, a3 = self.Name)
+ format(a1=output_parameter, a2=blockname, a3=self.Name) - def GeneratePaths(self, connections, body, order = False, to_inout = False):
+ def GeneratePaths(self, connections, body, order=False, to_inout=False): for connection in connections:
localId = connection.getrefLocalId()
@@ -1215,7 +1215,7 @@
block_infos = self.GetBlockType(block_type)
- msg = _("Undefined block type \"{a1}\" in \"{a2}\" POU").format(a1 = block_type, a2 = self.Name)
+ msg = _("Undefined block type \"{a1}\" in \"{a2}\" POU").format(a1=block_type, a2=self.Name) raise PLCGenException, msg
paths.append(str(self.GenerateBlock(next, block_infos, body, connection, order, to_inout)))
@@ -1231,7 +1231,7 @@
for instance in body.getcontentInstances():
if isinstance(instance, ConnectorClass) and instance.getname() == name:
if connector is not None:
- msg = _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1 = name, a2 = self.Name)
+ msg = _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) raise PLCGenException, msg
if connector is not None:
@@ -1242,7 +1242,7 @@
self.ComputedConnectors[name] = expression
paths.append(str(expression))
- msg = _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1 = name, a2 = self.Name)
+ msg = _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) raise PLCGenException, msg
elif isinstance(next, ContactClass):
contact_info = (self.TagName, "contact", next.getlocalId())
@@ -1264,7 +1264,7 @@
paths.append(str(self.GeneratePaths(next.connectionPointIn.getconnections(), body, order)))
- def ComputePaths(self, paths, first = False):
+ def ComputePaths(self, paths, first=False): if type(paths) == TupleType:
@@ -1282,7 +1282,7 @@
- def ComputeExpression(self, body, connections, order = False, to_inout = False):
+ def ComputeExpression(self, body, connections, order=False, to_inout=False): paths = self.GeneratePaths(connections, body, order, to_inout)
@@ -1393,7 +1393,7 @@
jump_target = jump.gettargetName()
if not pou.hasstep(jump_target):
- msg = _("SFC jump in pou \"{a1}\" refers to non-existent SFC step \"{a2}\"").format( a1 = pname, a2 = jump_target)
+ msg = _("SFC jump in pou \"{a1}\" refers to non-existent SFC step \"{a2}\"").format( a1=pname, a2=jump_target) raise PLCGenException, msg
if jump.connectionPointIn is not None:
@@ -1600,7 +1600,7 @@
self.Program += transition_infos["from"][0]
msg = _("Transition with content \"{a1}\" not connected to a previous step in \"{a2}\" POU").\
- format(a1 = transition_infos["content"], a2 = self.Name)
+ format(a1=transition_infos["content"], a2=self.Name) raise PLCGenException, msg
self.Program += [(" TO ", ())]
if len(transition_infos["to"]) > 1:
@@ -1611,7 +1611,7 @@
self.Program += transition_infos["to"][0]
msg = _("Transition with content \"{a1}\" not connected to a next step in \"{a2}\" POU").\
- format(a1 = transition_infos["content"], a2 = self.Name)
+ format(a1=transition_infos["content"], a2=self.Name) raise PLCGenException, msg
self.Program += transition_infos["content"]
self.Program += [("%sEND_TRANSITION\n\n" % self.CurrentIndent, ())]
--- a/controls/VariablePanel.py Tue Aug 15 17:01:51 2017 +0300
+++ b/controls/VariablePanel.py Tue Aug 15 22:38:43 2017 +0300
@@ -175,9 +175,9 @@
grid.SetReadOnly(row, col, True)
- options = GetOptions(constant = var_class in ["Local", "External", "Global"],
- retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output", "Global"],
- non_retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output"])
+ options = GetOptions(constant=var_class in ["Local", "External", "Global"], + retain=self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output", "Global"], + non_retain=self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output"]) editor = wx.grid.GridCellChoiceEditor()
editor.SetParameters(",".join(map(_, options)))
@@ -279,7 +279,7 @@
base_location_type = self.ParentWindow.Controler.GetBaseType(values[2])
if values[2] != variable_type and base_type != base_location_type:
message = _("Incompatible data types between \"{a1}\" and \"{a2}\"").\
- format(a1 = values[2], a2 = variable_type)
+ format(a1=values[2], a2=variable_type) if not location.startswith("%"):
@@ -289,7 +289,7 @@
message = _("Unrecognized data size \"%s\"") % location[0]
elif base_type not in LOCATIONDATATYPES[location[0]]:
message = _("Incompatible size of data between \"{a1}\" and \"{a2}\"").\
- format(a1 = location, a2 = variable_type)
+ format(a1=location, a2=variable_type) dialog = wx.SingleChoiceDialog(self.ParentWindow.ParentWindow.ParentWindow,
_("Select a variable class:"), _("Variable class"),
@@ -598,7 +598,7 @@
new_row = self.Table.GetNumberRows()
if self.ElementType == "resource":
- self.ParentWindow.RefreshView(variablepanel = False)
+ self.ParentWindow.RefreshView(variablepanel=False) setattr(self.VariablesGrid, "_AddRow", _AddVariable)
@@ -608,7 +608,7 @@
self.Values.remove(self.Table.GetRow(row))
if self.ElementType == "resource":
- self.ParentWindow.RefreshView(variablepanel = False)
+ self.ParentWindow.RefreshView(variablepanel=False) setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable)
@@ -731,7 +731,7 @@
words = self.TagName.split("::")
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection())
self.Controler.BufferProject()
- self.ParentWindow.RefreshView(variablepanel = False)
+ self.ParentWindow.RefreshView(variablepanel=False) self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
@@ -824,7 +824,7 @@
def BuildUserTypesMenu(self, type_menu):
# build a submenu containing user-defined types
datatype_menu = wx.Menu(title='')
- datatypes = self.Controler.GetDataTypes(basetypes = False, confnodetypes = False)
+ datatypes = self.Controler.GetDataTypes(basetypes=False, confnodetypes=False) for datatype in datatypes:
datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
@@ -903,7 +903,7 @@
self.Table.SetValueByName(row, "Type", base_type)
self.Table.ResetView(self.VariablesGrid)
- self.ParentWindow.RefreshView(variablepanel = False)
+ self.ParentWindow.RefreshView(variablepanel=False) self.Controler.BufferProject()
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
return VariableTypeFunction
@@ -917,7 +917,7 @@
self.Table.SetValueByName(row, "Type", dialog.GetValue())
self.Table.ResetView(self.VariablesGrid)
- self.ParentWindow.RefreshView(variablepanel = False)
+ self.ParentWindow.RefreshView(variablepanel=False) self.Controler.BufferProject()
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
@@ -943,7 +943,7 @@
self.Table.ResetView(self.VariablesGrid)
- def SaveValues(self, buffer = True):
+ def SaveValues(self, buffer=True): words = self.TagName.split("::")
if self.ElementType == "config":
self.Controler.SetConfigurationGlobalVars(words[1], self.Values)
--- a/editors/Viewer.py Tue Aug 15 17:01:51 2017 +0300
+++ b/editors/Viewer.py Tue Aug 15 22:38:43 2017 +0300
@@ -262,7 +262,7 @@
elif pou_type == "function" and values[1] != "function":
message = _("Function Blocks can't be used in Functions!")
elif self.ParentWindow.Controler.PouIsUsedBy(pou_name, values[0], self.ParentWindow.Debug):
- message = _("\"{a1}\" is already used by \"{a2}\"!").format(a1 = pou_name, a2 = values[0])
+ message = _("\"{a1}\" is already used by \"{a2}\"!").format(a1=pou_name, a2=values[0]) @@ -277,7 +277,7 @@
message = _("\"%s\" element for this pou already exists!") % blockname
id = self.ParentWindow.GetNewId()
- block = FBD_Block(self.ParentWindow, values[0], blockname, id, inputs = blockinputs)
+ block = FBD_Block(self.ParentWindow, values[0], blockname, id, inputs=blockinputs) width, height = block.GetMinSize()
x = round(float(x) / float(scaling[0])) * scaling[0]
@@ -504,7 +504,7 @@
if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
+ def Bind(self, event, function, id=None): event(self, id, function)
@@ -680,7 +680,7 @@
self.Editor.ParentWindow = self
- def __init__(self, parent, tagname, window, controler, debug = False, instancepath = ""):
+ def __init__(self, parent, tagname, window, controler, debug=False, instancepath=""): self.VARIABLE_PANEL_TYPE = controler.GetPouType(tagname.split("::")[1])
EditorPanel.__init__(self, parent, tagname, window, controler, debug)
@@ -735,17 +735,17 @@
self.ElementRefreshList_lock = Lock()
dc = wx.ClientDC(self.Editor)
- font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
+ font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["mono"]) width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
- font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
+ font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["mono"]) width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
self.MiniTextDC = wx.MemoryDC()
- self.MiniTextDC.SetFont(wx.Font(faces["size"] * 0.75, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["helv"]))
+ self.MiniTextDC.SetFont(wx.Font(faces["size"] * 0.75, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["helv"])) self.SetScale(ZOOM_FACTORS.index(1.0), False)
@@ -977,7 +977,7 @@
- def RefreshVisibleElements(self, xp = None, yp = None):
+ def RefreshVisibleElements(self, xp=None, yp=None): x, y = self.Editor.CalcUnscrolledPosition(0, 0)
x = xp * self.Editor.GetScrollPixelsPerUnit()[0]
@@ -1220,7 +1220,7 @@
# List of ids of already loaded blocks
- instances = self.Controler.GetEditedElementInstancesInfos(self.TagName, debug = self.Debug)
+ instances = self.Controler.GetEditedElementInstancesInfos(self.TagName, debug=self.Debug) # Load Blocks until they are all loaded
while len(instances) > 0:
self.loadInstance(instances.popitem(0)[1], instances, selection)
@@ -1411,7 +1411,7 @@
connector_pos = wx.Point(*output_connector.position)
if isinstance(element, FBD_Block):
connector = element.GetConnector(connector_pos,
- output_name = output_connector.name)
+ output_name=output_connector.name) elif i < len(connectors["outputs"]):
connector = connectors["outputs"][i]
@@ -1427,7 +1427,7 @@
connector_pos = wx.Point(*input_connector.position)
if isinstance(element, FBD_Block):
connector = element.GetConnector(connector_pos,
- input_name = input_connector.name)
+ input_name=input_connector.name) elif i < len(connectors["inputs"]):
connector = connectors["inputs"][i]
@@ -1499,7 +1499,7 @@
def IsEndType(self, type):
return self.Controler.IsEndType(type)
- def GetBlockType(self, type, inputs = None):
+ def GetBlockType(self, type, inputs=None): return self.Controler.GetBlockType(type, inputs, self.Debug)
#-------------------------------------------------------------------------------
@@ -1522,7 +1522,7 @@
- def FindElement(self, event, exclude_group = False, connectors = True):
+ def FindElement(self, event, exclude_group=False, connectors=True): pos = event.GetLogicalPosition(dc)
if self.SelectedElement and not (exclude_group and isinstance(self.SelectedElement, Graphic_Group)):
@@ -1533,11 +1533,11 @@
- def FindBlockConnector(self, pos, direction = None, exclude = None):
+ def FindBlockConnector(self, pos, direction=None, exclude=None): result, error = self.FindBlockConnectorWithError(pos, direction, exclude)
- def FindBlockConnectorWithError(self, pos, direction = None, exclude = None):
+ def FindBlockConnectorWithError(self, pos, direction=None, exclude=None): for block in self.Blocks.itervalues():
@@ -1623,7 +1623,7 @@
self.Editor.PopupMenu(menu)
- def PopupBlockMenu(self, connector = None):
+ def PopupBlockMenu(self, connector=None): if connector is not None and connector.IsCompatible("BOOL"):
self.AddBlockPinMenuItems(menu, connector)
@@ -2383,11 +2383,11 @@
elif position.y > window_size[1] - SCROLL_ZONE:
if move_window.x != 0 or move_window.y != 0:
- self.RefreshVisibleElements(xp = xstart + move_window.x, yp = ystart + move_window.y)
+ self.RefreshVisibleElements(xp=xstart + move_window.x, yp=ystart + move_window.y) self.Scroll(xstart + move_window.x, ystart + move_window.y)
self.RefreshScrollBars(move_window.x, move_window.y)
- def BlockCompatibility(self, startblock=None, endblock=None, direction = None):
+ def BlockCompatibility(self, startblock=None, endblock=None, direction=None): def GetPopupMenuItems(self):
@@ -2585,8 +2585,8 @@
values.setdefault("name", "")
block = FBD_Block(self, values["type"], values["name"], id,
values["extension"], values["inputs"],
- executionControl = values["executionControl"],
- executionOrder = values["executionOrder"])
+ executionControl=values["executionControl"], + executionOrder=values["executionOrder"]) self.Controler.AddEditedElementBlock(self.TagName, id, values["type"], values.get("name", None))
@@ -2748,7 +2748,7 @@
connector = transition.GetConnectors()["inputs"][0]
self.AddNewElement(transition, bbox, wire, connector)
- def AddNewDivergence(self, bbox, poss_div_types = None, wire=None):
+ def AddNewDivergence(self, bbox, poss_div_types=None, wire=None): dialog = SFCDivergenceDialog(self.ParentWindow, self.Controler, self.TagName, poss_div_types)
dialog.SetPreviewFont(self.GetFont())
dialog.SetMinElementSize((bbox.width, bbox.height))
@@ -2812,7 +2812,7 @@
block.SetSize(*self.GetScaledSize(new_values["width"], new_values["height"]))
- block.SetType(new_values["type"], new_values["extension"], executionControl = new_values["executionControl"])
+ block.SetType(new_values["type"], new_values["extension"], executionControl=new_values["executionControl"]) block.SetExecutionOrder(new_values["executionOrder"])
rect = rect.Union(block.GetRedrawRect())
self.RefreshBlockModel(block)
@@ -3622,9 +3622,9 @@
wx.CallAfter(self.Editor.Thaw)
elif event.GetOrientation() == wx.HORIZONTAL:
- self.RefreshVisibleElements(xp = event.GetPosition())
+ self.RefreshVisibleElements(xp=event.GetPosition()) - self.RefreshVisibleElements(yp = event.GetPosition())
+ self.RefreshVisibleElements(yp=event.GetPosition()) # Handle scroll in debug to fully redraw area and ensuring
# instance path is fully draw without flickering
@@ -3647,16 +3647,16 @@
x, y = self.GetViewStart()
xp = max(0, min(x - rotation * 3, self.Editor.GetVirtualSize()[0] / self.Editor.GetScrollPixelsPerUnit()[0]))
- self.RefreshVisibleElements(xp = xp)
+ self.RefreshVisibleElements(xp=xp) elif event.ControlDown():
- self.SetScale(self.CurrentScale + rotation, mouse_event = event)
+ self.SetScale(self.CurrentScale + rotation, mouse_event=event) self.ParentWindow.RefreshDisplayMenu()
x, y = self.GetViewStart()
yp = max(0, min(y - rotation * 3, self.Editor.GetVirtualSize()[1] / self.Editor.GetScrollPixelsPerUnit()[1]))
- self.RefreshVisibleElements(yp = yp)
+ self.RefreshVisibleElements(yp=yp) def OnMoveWindow(self, event):
@@ -3667,7 +3667,7 @@
self.RefreshVisibleElements()
- def DoDrawing(self, dc, printing = False):
+ def DoDrawing(self, dc, printing=False): if getattr(dc, "printing", False):
font = wx.Font(self.GetFont().GetPointSize(), wx.MODERN, wx.NORMAL, wx.NORMAL)
--- a/graphics/FBD_Objects.py Tue Aug 15 17:01:51 2017 +0300
+++ b/graphics/FBD_Objects.py Tue Aug 15 22:38:43 2017 +0300
@@ -42,7 +42,7 @@
- def __init__(self, parent, type, name, id = None, extension = 0, inputs = None, connectors = {}, executionControl = False, executionOrder = 0):
+ def __init__(self, parent, type, name, id=None, extension=0, inputs=None, connectors={}, executionControl=False, executionOrder=0): Graphic_Element.__init__(self, parent)
@@ -59,7 +59,7 @@
# Make a clone of this FBD_Block
- def Clone(self, parent, id = None, name = "", pos = None):
+ def Clone(self, parent, id=None, name="", pos=None): if self.Name != "" and name == "":
block = FBD_Block(parent, self.Type, name, id, self.Extension)
@@ -84,7 +84,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
if movex != 0 or movey != 0:
for input in self.Inputs:
@@ -102,9 +102,9 @@
# Unconnect all inputs and outputs
for input in self.Inputs:
- input.UnConnect(delete = True)
+ input.UnConnect(delete=True) for output in self.Outputs:
- output.UnConnect(delete = True)
+ output.UnConnect(delete=True) # Refresh the size of text for name
def RefreshNameSize(self):
@@ -173,14 +173,14 @@
# Refresh the positions of wires connected to inputs and outputs
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): for input in self.Inputs:
input.MoveConnected(exclude)
for output in self.Outputs:
output.MoveConnected(exclude)
# Returns the block connector that starts with the point given if it exists
- def GetConnector(self, position, output_name = None, input_name = None):
+ def GetConnector(self, position, output_name=None, input_name=None): if input_name is not None:
# Test each input connector
for input in self.Inputs:
@@ -223,7 +223,7 @@
return {"inputs": self.Inputs, "outputs": self.Outputs}
# Test if point given is on one of the block connectors
- def TestConnector(self, pt, direction = None, exclude = True):
+ def TestConnector(self, pt, direction=None, exclude=True): # Test each input connector
for input in self.Inputs:
if input.TestPoint(pt, direction, exclude):
@@ -235,7 +235,7 @@
- def SetType(self, type, extension, inputs = None, connectors = {}, executionControl = False):
+ def SetType(self, type, extension, inputs=None, connectors={}, executionControl=False): if type != self.Type or self.Extension != extension or executionControl != self.ExecutionControl:
@@ -269,7 +269,7 @@
# Extract the inputs properties and create or modify the corresponding connector
for input_name, input_type, input_modifier in inputs:
- connector = Connector(self, input_name, input_type, wx.Point(0, 0), WEST, onlyone = True)
+ connector = Connector(self, input_name, input_type, wx.Point(0, 0), WEST, onlyone=True) if input_modifier == "negated":
connector.SetNegated(True)
elif input_modifier != "none":
@@ -283,7 +283,7 @@
input_connectors.append(connector)
for input in self.Inputs:
- input.UnConnect(delete = True)
+ input.UnConnect(delete=True) self.Inputs = input_connectors
# Extract the outputs properties and create or modify the corresponding connector
@@ -303,7 +303,7 @@
output_connectors.append(connector)
for output in self.Outputs:
- output.UnConnect(delete = True)
+ output.UnConnect(delete=True) self.Outputs = output_connectors
@@ -506,7 +506,7 @@
- def __init__(self, parent, type, name, value_type, id = None, executionOrder = 0):
+ def __init__(self, parent, type, name, value_type, id=None, executionOrder=0): Graphic_Element.__init__(self, parent)
@@ -519,7 +519,7 @@
# Make a clone of this FBD_Variable
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): variable = FBD_Variable(parent, self.Type, self.Name, self.ValueType, id)
variable.SetSize(self.Size[0], self.Size[1])
@@ -549,7 +549,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
if movex != 0 or movey != 0:
if self.Input and self.Input.IsConnected():
@@ -561,9 +561,9 @@
- self.Input.UnConnect(delete = True)
+ self.Input.UnConnect(delete=True) - self.Output.UnConnect(delete = True)
+ self.Output.UnConnect(delete=True) # Delete this variable by calling the appropriate method
@@ -610,14 +610,14 @@
# Refresh the position of wires connected to connector
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Input.MoveConnected(exclude)
self.Output.MoveConnected(exclude)
# Test if point given is on the variable connector
- def TestConnector(self, pt, direction = None, exclude=True):
+ def TestConnector(self, pt, direction=None, exclude=True): if self.Input and self.Input.TestPoint(pt, direction, exclude):
if self.Output and self.Output.TestPoint(pt, direction, exclude):
@@ -625,7 +625,7 @@
# Returns the block connector that starts with the point given if it exists
- def GetConnector(self, position, name = None):
+ def GetConnector(self, position, name=None): # Test input and output connector if they exists
@@ -665,15 +665,15 @@
# Create an input or output connector according to variable type
- self.Input = Connector(self, "", value_type, wx.Point(0, 0), WEST, onlyone = True)
+ self.Input = Connector(self, "", value_type, wx.Point(0, 0), WEST, onlyone=True) - self.Input.UnConnect(delete = True)
+ self.Input.UnConnect(delete=True) self.Output = Connector(self, "", value_type, wx.Point(0, 0), EAST)
- self.Output.UnConnect(delete = True)
+ self.Output.UnConnect(delete=True) self.RefreshBoundingBox()
@@ -802,7 +802,7 @@
# Create a new connection
- def __init__(self, parent, type, name, id = None):
+ def __init__(self, parent, type, name, id=None): Graphic_Element.__init__(self, parent)
@@ -812,7 +812,7 @@
# Create an input or output connector according to connection type
if self.Type == CONNECTOR:
- self.Connector = Connector(self, "", "ANY", wx.Point(0, 0), WEST, onlyone = True)
+ self.Connector = Connector(self, "", "ANY", wx.Point(0, 0), WEST, onlyone=True) self.Connector = Connector(self, "", "ANY", wx.Point(0, 0), EAST)
@@ -824,7 +824,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
if movex != 0 or movey != 0:
if self.Connector and self.Connector.IsConnected():
@@ -832,7 +832,7 @@
# Make a clone of this FBD_Connector
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): connection = FBD_Connector(parent, self.Type, self.Name, id)
connection.SetSize(self.Size[0], self.Size[1])
@@ -848,7 +848,7 @@
- self.Connector.UnConnect(delete = True)
+ self.Connector.UnConnect(delete=True) # Delete this connection by calling the appropriate method
@@ -881,18 +881,18 @@
# Refresh the position of wires connected to connector
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Connector.MoveConnected(exclude)
# Test if point given is on the connection connector
- def TestConnector(self, pt, direction = None, exclude=True):
+ def TestConnector(self, pt, direction=None, exclude=True): if self.Connector and self.Connector.TestPoint(pt, direction, exclude):
# Returns the connection connector
- def GetConnector(self, position = None, name = None):
+ def GetConnector(self, position=None, name=None): # Returns all the block connectors
@@ -919,7 +919,7 @@
# Create an input or output connector according to connection type
if self.Type == CONNECTOR:
- self.Connector = Connector(self, "", "ANY", wx.Point(0, 0), WEST, onlyone = True)
+ self.Connector = Connector(self, "", "ANY", wx.Point(0, 0), WEST, onlyone=True) self.Connector = Connector(self, "", "ANY", wx.Point(0, 0), EAST)
--- a/graphics/GraphicCommons.py Tue Aug 15 17:01:51 2017 +0300
+++ b/graphics/GraphicCommons.py Tue Aug 15 22:38:43 2017 +0300
@@ -131,7 +131,7 @@
-def vector(p1, p2, normal = True):
+def vector(p1, p2, normal=True): Create a vector from two points and define if vector must be normal
@@ -258,7 +258,7 @@
# Create a new graphic element
- def __init__(self, parent, id = None):
+ def __init__(self, parent, id=None): ToolTipProducer.__init__(self, parent)
@@ -404,7 +404,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): scalex, scaley = self.Parent.GetViewScale()
rect.x = self.BoundingBox.x - int(HANDLE_SIZE / scalex) - 3 - abs(movex)
@@ -413,7 +413,7 @@
rect.height = self.BoundingBox.height + 2 * (int(HANDLE_SIZE / scaley) + abs(movey) + 1) + 4
- def Refresh(self, rect = None):
+ def Refresh(self, rect=None): self.Parent.RefreshRect(self.Parent.GetScrolledRect(rect), False)
@@ -554,7 +554,7 @@
- def Move(self, dx, dy, exclude = []):
+ def Move(self, dx, dy, exclude=[]): self.Pos.x += max(-self.BoundingBox.x, dx)
self.Pos.y += max(-self.BoundingBox.y, dy)
self.RefreshConnected(exclude)
@@ -566,7 +566,7 @@
self.SetSize(width, height)
# Refreshes the element state according to move defined and handle selected
- def ProcessDragging(self, movex, movey, event, scaling, width_fac = 1, height_fac = 1):
+ def ProcessDragging(self, movex, movey, event, scaling, width_fac=1, height_fac=1): handle_type, handle = self.Handle
# If it is a resize handle, calculate the values from resizing
if handle_type == HANDLE_RESIZE:
@@ -733,7 +733,7 @@
# Make a clone of this element
- def Clone(self, parent, pos = None):
+ def Clone(self, parent, pos=None): group = Graphic_Group(parent)
@@ -751,9 +751,9 @@
if parent.IsNamedElement(element):
name = parent.GenerateNewName(element, exclude_names)
exclude_names[name.upper()] = True
- new_element = element.Clone(parent, newid, name, pos = new_pos)
+ new_element = element.Clone(parent, newid, name, pos=new_pos) - new_element = element.Clone(parent, newid, pos = new_pos)
+ new_element = element.Clone(parent, newid, pos=new_pos) new_element.SetBestSize(parent.Scaling)
new_element = element.Clone(parent)
@@ -798,7 +798,7 @@
self.WireExcluded.append(element)
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): for element in self.Elements:
@@ -1031,7 +1031,7 @@
- def __init__(self, parent, name, type, position, direction, negated = False, edge = "none", onlyone = False):
+ def __init__(self, parent, name, type, position, direction, negated=False, edge="none", onlyone=False): DebugDataConsumer.__init__(self)
ToolTipProducer.__init__(self, parent.Parent)
self.ParentBlock = parent
@@ -1063,7 +1063,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): parent_pos = self.ParentBlock.GetPosition()
x = min(parent_pos[0] + self.Pos.x, parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE)
y = min(parent_pos[1] + self.Pos.y, parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE)
@@ -1100,7 +1100,7 @@
# Make a clone of the connector
- def Clone(self, parent = None):
+ def Clone(self, parent=None): parent = self.ParentBlock
return Connector(parent, self.Name, self.Type, wx.Point(self.Pos[0], self.Pos[1]),
@@ -1111,7 +1111,7 @@
# Returns the connector type
- def GetType(self, raw = False):
+ def GetType(self, raw=False): if self.ParentBlock.IsEndType(self.Type) or raw:
elif (self.Negated or self.Edge != "none") and self.ParentBlock.IsOfType("BOOL", self.Type):
@@ -1235,7 +1235,7 @@
# Returns the connector absolute position
- def GetPosition(self, size = True):
+ def GetPosition(self, size=True): parent_pos = self.ParentBlock.GetPosition()
# If the position of the end of the connector is asked
@@ -1259,11 +1259,11 @@
self.Direction = direction
# Connect a wire to this connector at the last place
- def Connect(self, wire, refresh = True):
+ def Connect(self, wire, refresh=True): self.InsertConnect(len(self.Wires), wire, refresh)
# Connect a wire to this connector at the place given
- def InsertConnect(self, idx, wire, refresh = True):
+ def InsertConnect(self, idx, wire, refresh=True): if wire not in self.Wires:
self.Wires.insert(idx, wire)
@@ -1281,7 +1281,7 @@
# Unconnect a wire or all wires connected to the connector
- def UnConnect(self, wire = None, unconnect = True, delete = False):
+ def UnConnect(self, wire=None, unconnect=True, delete=False): while i < len(self.Wires) and not found:
@@ -1309,7 +1309,7 @@
return len(self.Wires) > 0
# Move the wires connected
- def MoveConnected(self, exclude = []):
+ def MoveConnected(self, exclude=[]): # Calculate the new position of the end point
parent_pos = self.ParentBlock.GetPosition()
@@ -1565,7 +1565,7 @@
- def __init__(self, parent, start = None, end = None):
+ def __init__(self, parent, start=None, end=None): Graphic_Element.__init__(self, parent)
DebugDataConsumer.__init__(self)
@@ -1603,7 +1603,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
rect = rect.Union(self.StartConnected.GetRedrawRect(movex, movey))
@@ -1630,7 +1630,7 @@
rect = rect.Union(wx.Rect(x, y, width, height))
- def Clone(self, parent, connectors = {}, dx = 0, dy = 0):
+ def Clone(self, parent, connectors={}, dx=0, dy=0): start_connector = connectors.get(self.StartConnected, None)
end_connector = connectors.get(self.EndConnected, None)
if start_connector is not None and end_connector is not None:
@@ -2009,7 +2009,7 @@
# Returns a list of the position of all wire points
- def GetPoints(self, invert = False):
+ def GetPoints(self, invert=False): points = self.VerifyPoints()
points[0] = wx.Point(points[0].x - CONNECTOR_SIZE * self.StartPoint[1][0],
points[0].y - CONNECTOR_SIZE * self.StartPoint[1][1])
@@ -2050,7 +2050,7 @@
# Update the wire points position by keeping at most possible the current positions
- def GeneratePoints(self, realpoints = True):
+ def GeneratePoints(self, realpoints=True): # Calculate the start enad end points with the minimum segment size in the right direction
end = wx.Point(self.EndPoint[0].x + self.EndPoint[1][0] * MIN_SEGMENT_SIZE,
@@ -2209,7 +2209,7 @@
# Moves all the wire points except the first and the last if they are connected
- def Move(self, dx, dy, endpoints = False):
+ def Move(self, dx, dy, endpoints=False): for i, point in enumerate(self.Points):
if endpoints or not (i == 0 and self.StartConnected) and not (i == len(self.Points) - 1 and self.EndConnected):
@@ -2304,12 +2304,12 @@
self.RefreshBoundingBox()
# Unconnects wire start point
- def UnConnectStartPoint(self, delete = False):
+ def UnConnectStartPoint(self, delete=False): self.StartConnected = None
elif self.StartConnected:
- self.StartConnected.UnConnect(self, unconnect = False)
+ self.StartConnected.UnConnect(self, unconnect=False) self.StartConnected = None
self.RefreshBoundingBox()
@@ -2339,12 +2339,12 @@
self.RefreshBoundingBox()
# Unconnects wire end point
- def UnConnectEndPoint(self, delete = False):
+ def UnConnectEndPoint(self, delete=False): - self.EndConnected.UnConnect(self, unconnect = False)
+ self.EndConnected.UnConnect(self, unconnect=False) self.RefreshBoundingBox()
@@ -2767,7 +2767,7 @@
- def __init__(self, parent, content, id = None):
+ def __init__(self, parent, content, id=None): Graphic_Element.__init__(self, parent)
@@ -2776,7 +2776,7 @@
# Make a clone of this comment
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): comment = Comment(parent, self.Content, id)
comment.SetPosition(pos.x, pos.y)
@@ -2841,7 +2841,7 @@
return self.Pos.x, self.Pos.y
- def Move(self, dx, dy, connected = True):
+ def Move(self, dx, dy, connected=True): self.RefreshBoundingBox()
--- a/graphics/LD_Objects.py Tue Aug 15 17:01:51 2017 +0300
+++ b/graphics/LD_Objects.py Tue Aug 15 22:38:43 2017 +0300
@@ -54,7 +54,7 @@
# Make a clone of this LD_PowerRail
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): powerrail = LD_PowerRail(parent, self.Type, id)
powerrail.SetSize(self.Size[0], self.Size[1])
@@ -71,7 +71,7 @@
[connector for connector in element.Connectors]))
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
for connector in self.Connectors:
rect = rect.Union(connector.GetRedrawRect(movex, movey))
@@ -108,7 +108,7 @@
# Unconnect all connectors
for connector in self.Connectors:
- connector.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ connector.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Refresh the power rail bounding box
def RefreshBoundingBox(self):
@@ -195,12 +195,12 @@
# Refresh the position of wires connected to power rail
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): for connector in self.Connectors:
connector.MoveConnected(exclude)
# Returns the power rail connector that starts with the point given if it exists
- def GetConnector(self, position, name = None):
+ def GetConnector(self, position, name=None): # Test each connector if it exists
@@ -218,7 +218,7 @@
return {"inputs": connectors, "outputs": []}
# Test if point given is on one of the power rail connectors
- def TestConnector(self, pt, direction = None, exclude = True):
+ def TestConnector(self, pt, direction=None, exclude=True): for connector in self.Connectors:
if connector.TestPoint(pt, direction, exclude):
@@ -350,7 +350,7 @@
- def __init__(self, parent, type, name, id = None):
+ def __init__(self, parent, type, name, id=None): Graphic_Element.__init__(self, parent)
DebugDataConsumer.__init__(self)
@@ -416,7 +416,7 @@
self.PreviousSpreading = spreading
# Make a clone of this LD_Contact
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): contact = LD_Contact(parent, self.Type, self.Name, id)
contact.SetSize(self.Size[0], self.Size[1])
@@ -431,7 +431,7 @@
return {self.Input: element.Input, self.Output: element.Output}
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
rect = rect.Union(self.Output.GetRedrawRect(movex, movey))
@@ -445,7 +445,7 @@
def ProcessDragging(self, movex, movey, event, scaling):
if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
- return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, height_fac = 2)
+ return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, height_fac=2) # Forbids to change the contact size
def SetSize(self, width, height):
@@ -459,8 +459,8 @@
# Unconnect input and output
- self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
- self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) + self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Refresh the size of text for name
def RefreshNameSize(self):
@@ -505,12 +505,12 @@
# Refresh the position of wire connected to contact
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Input.MoveConnected(exclude)
self.Output.MoveConnected(exclude)
# Returns the contact connector that starts with the point given if it exists
- def GetConnector(self, position, name = None):
+ def GetConnector(self, position, name=None): # Test input and output connector
@@ -525,7 +525,7 @@
return {"inputs": [self.Input], "outputs": [self.Output]}
# Test if point given is on contact input or output connector
- def TestConnector(self, pt, direction = None, exclude=True):
+ def TestConnector(self, pt, direction=None, exclude=True): if self.Input.TestPoint(pt, direction, exclude):
@@ -696,7 +696,7 @@
- def __init__(self, parent, type, name, id = None):
+ def __init__(self, parent, type, name, id=None): Graphic_Element.__init__(self, parent)
@@ -731,7 +731,7 @@
self.Parent.ElementNeedRefresh(self)
# Make a clone of this LD_Coil
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): coil = LD_Coil(parent, self.Type, self.Name, id)
coil.SetSize(self.Size[0], self.Size[1])
@@ -746,7 +746,7 @@
return {self.Input: element.Input, self.Output: element.Output}
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
rect = rect.Union(self.Output.GetRedrawRect(movex, movey))
@@ -760,7 +760,7 @@
def ProcessDragging(self, movex, movey, event, scaling):
if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
- return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, height_fac = 2)
+ return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, height_fac=2) # Forbids to change the Coil size
def SetSize(self, width, height):
@@ -774,8 +774,8 @@
# Unconnect input and output
- self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
- self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) + self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Refresh the size of text for name
def RefreshNameSize(self):
@@ -824,12 +824,12 @@
# Refresh the position of wire connected to coil
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Input.MoveConnected(exclude)
self.Output.MoveConnected(exclude)
# Returns the coil connector that starts with the point given if it exists
- def GetConnector(self, position, name = None):
+ def GetConnector(self, position, name=None): # Test input and output connector
@@ -844,7 +844,7 @@
return {"inputs": [self.Input], "outputs": [self.Output]}
# Test if point given is on coil input or output connector
- def TestConnector(self, pt, direction = None, exclude=True):
+ def TestConnector(self, pt, direction=None, exclude=True): if self.Input.TestPoint(pt, direction, exclude):
--- a/graphics/SFC_Objects.py Tue Aug 15 17:01:51 2017 +0300
+++ b/graphics/SFC_Objects.py Tue Aug 15 22:38:43 2017 +0300
@@ -46,7 +46,7 @@
- def __init__(self, parent, name, initial = False, id = None):
+ def __init__(self, parent, name, initial=False, id=None): Graphic_Element.__init__(self, parent)
DebugDataConsumer.__init__(self)
@@ -105,7 +105,7 @@
self.PreviousSpreading = spreading
# Make a clone of this SFC_Step
- def Clone(self, parent, id = None, name = "Step", pos = None):
+ def Clone(self, parent, id=None, name="Step", pos=None): step = SFC_Step(parent, name, self.Initial, id)
step.SetSize(self.Size[0], self.Size[1])
@@ -131,7 +131,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -155,11 +155,11 @@
# Unconnect input and output
- self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) - self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) - self.Action.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Action.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Refresh the size of text for name
def RefreshNameSize(self):
@@ -174,33 +174,33 @@
# Remove output connector from step
- self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) self.RefreshBoundingBox()
# Add output connector to step
- self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)
+ self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True) self.RefreshBoundingBox()
# Remove output connector from step
- self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) self.RefreshBoundingBox()
# Add action connector to step
- self.Action = Connector(self, "", None, wx.Point(self.Size[0], self.Size[1] / 2), EAST, onlyone = True)
+ self.Action = Connector(self, "", None, wx.Point(self.Size[0], self.Size[1] / 2), EAST, onlyone=True) self.RefreshBoundingBox()
# Remove action connector from step
- self.Action.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Action.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) self.RefreshBoundingBox()
@@ -244,7 +244,7 @@
# Refresh the position of wires connected to step
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Input.MoveConnected(exclude)
@@ -253,7 +253,7 @@
self.Action.MoveConnected(exclude)
# Returns the step connector that starts with the point given if it exists
- def GetConnector(self, position, name = None):
+ def GetConnector(self, position, name=None): # Test input, output and action connector if they exists
@@ -289,7 +289,7 @@
# Test if point given is on step input or output connector
- def TestConnector(self, pt, direction = None, exclude=True):
+ def TestConnector(self, pt, direction=None, exclude=True): # Test input connector if it exists
if self.Input and self.Input.TestPoint(pt, direction, exclude):
@@ -385,7 +385,7 @@
input_block.RefreshInputPosition()
# Align output element with this step
- def RefreshOutputPosition(self, move = None):
+ def RefreshOutputPosition(self, move=None): wires = self.Output.GetWires()
@@ -579,7 +579,7 @@
# Create a new transition
- def __init__(self, parent, type = "reference", condition = None, priority = 0, id = None):
+ def __init__(self, parent, type="reference", condition=None, priority=0, id=None): Graphic_Element.__init__(self, parent)
DebugDataConsumer.__init__(self)
@@ -587,8 +587,8 @@
self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1])
# Create an input and output connector
- self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)
- self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)
+ self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True) + self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True) self.SetType(type, condition)
self.SetPriority(priority)
@@ -632,7 +632,7 @@
self.PreviousSpreading = spreading
# Make a clone of this SFC_Transition
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): transition = SFC_Transition(parent, self.Type, self.Condition, self.Priority, id)
transition.SetSize(self.Size[0], self.Size[1])
@@ -652,7 +652,7 @@
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -698,10 +698,10 @@
# Unconnect input and output
- self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
- self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) + self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) if self.Type == "connection":
- self.Condition.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Condition.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Returns if the point given is in the bounding box
def HitTest(self, pt, connectors=True):
@@ -766,14 +766,14 @@
# Refresh the position of the wires connected to transition
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Input.MoveConnected(exclude)
self.Output.MoveConnected(exclude)
if self.Type == "connection":
self.Condition.MoveConnected(exclude)
# Returns the transition connector that starts with the point given if it exists
- def GetConnector(self, position, name = None):
+ def GetConnector(self, position, name=None): # Test input and output connector
@@ -799,7 +799,7 @@
return {"inputs": [self.Input], "outputs": [self.Output]}
# Test if point given is on transition input or output connector
- def TestConnector(self, pt, direction = None, exclude=True):
+ def TestConnector(self, pt, direction=None, exclude=True): if self.Input.TestPoint(pt, direction, exclude):
@@ -812,10 +812,10 @@
# Changes the transition type
- def SetType(self, type, condition = None):
+ def SetType(self, type, condition=None): if self.Type == "connection":
- self.Condition.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Condition.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2), WEST)
@@ -873,7 +873,7 @@
input_block.RefreshInputPosition()
# Align output element with this step
- def RefreshOutputPosition(self, move = None):
+ def RefreshOutputPosition(self, move=None): wires = self.Output.GetWires()
@@ -920,7 +920,7 @@
self.RefreshOutputPosition()
- return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac = 2, height_fac = 2)
+ return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac=2, height_fac=2) # Refresh input element model
def RefreshInputModel(self):
@@ -1049,7 +1049,7 @@
# Create a new divergence
- def __init__(self, parent, type, number = 2, id = None):
+ def __init__(self, parent, type, number=2, id=None): Graphic_Element.__init__(self, parent)
@@ -1058,15 +1058,15 @@
self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, self.GetMinSize()[1])
# Create an input and output connector
if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
- self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)]
+ self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True)] - self.Outputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone = True))
+ self.Outputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone=True)) elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
- self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone = True))
- self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)]
+ self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone=True)) + self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True)] self.PreviousValue = None
@@ -1105,7 +1105,7 @@
output.SpreadCurrent(False)
# Make a clone of this SFC_Divergence
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): divergence = SFC_Divergence(parent, self.Type, max(len(self.Inputs), len(self.Outputs)), id)
divergence.SetSize(self.Size[0], self.Size[1])
@@ -1120,7 +1120,7 @@
return dict(zip(self.Inputs + self.Outputs, element.Inputs + element.Outputs))
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
if movex != 0 or movey != 0:
for input in self.Inputs:
@@ -1147,9 +1147,9 @@
# Unconnect input and output
for input in self.Inputs:
- input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) for output in self.Outputs:
- output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Add a branch to the divergence
@@ -1158,7 +1158,7 @@
for output in self.Outputs:
pos = output.GetRelPosition()
- connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone = True)
+ connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone=True) self.Outputs.append(connector)
self.MoveConnector(connector, 0)
elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
@@ -1166,7 +1166,7 @@
for input in self.Inputs:
pos = input.GetRelPosition()
- connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone = True)
+ connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone=True) self.Inputs.append(connector)
self.MoveConnector(connector, SFC_DEFAULT_SEQUENCE_INTERVAL)
@@ -1209,7 +1209,7 @@
self.Size[0] + 2 * SFC_SIMULTANEOUS_SEQUENCE_EXTRA + 1, self.Size[1] + 1)
# Refresh the position of wires connected to divergence
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): for input in self.Inputs:
input.MoveConnected(exclude)
for output in self.Outputs:
@@ -1244,7 +1244,7 @@
self.RefreshBoundingBox()
# Returns the divergence connector that starts with the point given if it exists
- def GetConnector(self, position, name = None):
+ def GetConnector(self, position, name=None): # Test each input and output connector
@@ -1261,7 +1261,7 @@
return {"inputs": self.Inputs, "outputs": self.Outputs}
# Test if point given is on divergence input or output connector
- def TestConnector(self, pt, direction = None, exclude=True):
+ def TestConnector(self, pt, direction=None, exclude=True): for input in self.Inputs:
if input.TestPoint(pt, direction, exclude):
@@ -1343,7 +1343,7 @@
# Align output element with this divergence
- def RefreshOutputPosition(self, move = None):
+ def RefreshOutputPosition(self, move=None): for output_connector in self.Outputs:
wires = output_connector.GetWires()
@@ -1509,14 +1509,14 @@
- def __init__(self, parent, target, id = None):
+ def __init__(self, parent, target, id=None): Graphic_Element.__init__(self, parent)
self.Size = wx.Size(SFC_JUMP_SIZE[0], SFC_JUMP_SIZE[1])
# Create an input and output connector
- self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)
+ self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True) self.PreviousValue = None
@@ -1533,7 +1533,7 @@
self.Parent.ElementNeedRefresh(self)
# Make a clone of this SFC_Jump
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): jump = SFC_Jump(parent, self.Target, id)
jump.SetSize(self.Size[0], self.Size[1])
@@ -1547,7 +1547,7 @@
return {self.Input: element.Input}
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -1572,7 +1572,7 @@
- self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Refresh the size of text for target
def RefreshTargetSize(self):
@@ -1613,12 +1613,12 @@
# Refresh the position of wires connected to jump
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Input.MoveConnected(exclude)
# Returns input jump connector
- def GetConnector(self, position = None, name = None):
+ def GetConnector(self, position=None, name=None): # Returns all the jump connectors
@@ -1626,7 +1626,7 @@
return {"inputs": [self.Input], "outputs": []}
# Test if point given is on jump input connector
- def TestConnector(self, pt, direction = None, exclude = True):
+ def TestConnector(self, pt, direction=None, exclude=True): if self.Input and self.Input.TestPoint(pt, direction, exclude):
@@ -1664,7 +1664,7 @@
input_block.RefreshInputPosition()
# Can't align output element, because there is no output
- def RefreshOutputPosition(self, move = None):
+ def RefreshOutputPosition(self, move=None): # Method called when a LeftDClick event have been generated
@@ -1687,7 +1687,7 @@
self.RefreshInputPosition()
- return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac = 2)
+ return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac=2) # Refresh input element model
def RefreshInputModel(self):
@@ -1785,14 +1785,14 @@
# Create a new action block
- def __init__(self, parent, actions = [], id = None):
+ def __init__(self, parent, actions=[], id=None): Graphic_Element.__init__(self, parent)
self.Size = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
# Create an input and output connector
- self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone = True)
+ self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone=True) self.PreviousValue = None
@@ -1810,7 +1810,7 @@
self.Parent.ElementNeedRefresh(self)
# Make a clone of this SFC_ActionBlock
- def Clone(self, parent, id = None, pos = None):
+ def Clone(self, parent, id=None, pos=None): actions = [action.copy() for action in self.Actions]
action_block = SFC_ActionBlock(parent, actions, id)
action_block.SetSize(self.Size[0], self.Size[1])
@@ -1825,7 +1825,7 @@
return {self.Input: element.Input}
- def GetRedrawRect(self, movex = 0, movey = 0):
+ def GetRedrawRect(self, movex=0, movey=0): rect = Graphic_Element.GetRedrawRect(self, movex, movey)
rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -1858,18 +1858,18 @@
# Unconnect input and output
- self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) # Refresh the action block bounding box
def RefreshBoundingBox(self):
self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
# Refresh the position of wires connected to action block
- def RefreshConnected(self, exclude = []):
+ def RefreshConnected(self, exclude=[]): self.Input.MoveConnected(exclude)
# Returns input action block connector
- def GetConnector(self, position = None, name = None):
+ def GetConnector(self, position=None, name=None): # Returns all the action block connectors
@@ -1877,7 +1877,7 @@
return {"inputs": [self.Input], "outputs": []}
# Test if point given is on action block input connector
- def TestConnector(self, pt, direction = None, exclude = True):
+ def TestConnector(self, pt, direction=None, exclude=True): if self.Input.TestPoint(pt, direction, exclude):