diff -r 42dd57b23e36 -r d0a0ffbbd61c PLCGenerator.py --- a/PLCGenerator.py Sun Sep 07 19:23:00 2008 +0200 +++ b/PLCGenerator.py Sun Sep 07 19:23:32 2008 +0200 @@ -645,26 +645,6 @@ for connection in related: self.ConnectionTypes[connection] = var_type - def GetNetworkType(self, connections, body): - network_type = "FBD" - for connection in connections: - localId = connection.getrefLocalId() - next = body.getcontentInstance(localId) - if isinstance(next, plcopen.ldObjects_leftPowerRail) or isinstance(next, plcopen.ldObjects_contact): - return "LD" - elif isinstance(next, plcopen.fbdObjects_block): - for variable in next.inputVariables.getvariable(): - result = self.GetNetworkType(variable.connectionPointIn.getconnections(), body) - if result != "FBD": - return result - elif isinstance(next, plcopen.fbdObjects_inVariable): - return "FBD" - elif isinstance(next, plcopen.fbdObjects_inOutVariable): - return self.GetNetworkType(next.connectionPointIn.getconnections(), body) - else: - return None - return "FBD" - def ComputeProgram(self, pou): body = pou.getbody() body_content = body.getcontent() @@ -781,17 +761,23 @@ name = next.getname() computed_value = self.ComputedConnectors.get(name, None) if computed_value != None: - paths.append(computed_value) - for tmp_instance in body.getcontentInstances(): - if isinstance(tmp_instance, plcopen.commonObjects_connector): - if tmp_instance.getname() == name: - connections = tmp_instance.connectionPointIn.getconnections() - if connections is not None: - expression = str(self.ComputeExpression(body, connections, order)) - self.ComputedConnectors[name] = expression - paths.append(expression) - raise PLCGenException, "No connector found corresponding to \"%s\" continuation in \"%s\" POU"%(name, self.Name) - else: + paths.append(str(computed_value)) + else: + connector = None + for instance in body.getcontentInstances(): + if isinstance(instance, plcopen.commonObjects_connector) and instance.getname() == name: + if connector is not None: + raise PLCGenException, "More than one connector found corresponding to \"%s\" continuation in \"%s\" POU"%(name, self.Name) + connector = instance + if connector is not None: + connections = connector.connectionPointIn.getconnections() + if connections is not None: + expression = self.ComputeExpression(body, connections, order) + self.ComputedConnectors[name] = expression + paths.append(str(expression)) + else: + raise PLCGenException, "No connector found corresponding to \"%s\" continuation in \"%s\" POU"%(name, self.Name) + elif isinstance(next, plcopen.ldObjects_contact): contact_info = (self.TagName, "contact", next.getlocalId()) variable = str(self.ExtractModifier(next, [(next.getvariable(), contact_info + ("reference",))], contact_info)) result = self.GeneratePaths(next.connectionPointIn.getconnections(), body, order) @@ -807,6 +793,8 @@ paths.append([variable, result[0]]) else: paths.append(variable) + elif isinstance(next, plcopen.ldObjects_coil): + paths.append(str(self.GeneratePaths(next.connectionPointIn.getconnections(), body, order))) return paths def ComputePaths(self, paths, first = False): @@ -827,6 +815,7 @@ def ComputeExpression(self, body, connections, order = False): paths = self.GeneratePaths(connections, body, order) + print paths if len(paths) > 1: factorized_paths = self.FactorizePaths(paths) if len(factorized_paths) > 1: