903 for num in uncomputed_index: |
903 for num in uncomputed_index: |
904 factorized_paths.append(paths[num]) |
904 factorized_paths.append(paths[num]) |
905 factorized_paths.sort() |
905 factorized_paths.sort() |
906 return factorized_paths |
906 return factorized_paths |
907 |
907 |
908 def GeneratePaths(self, connections, body, order = False): |
908 def GeneratePaths(self, connections, body, order = False, to_inout = False): |
909 paths = [] |
909 paths = [] |
910 for connection in connections: |
910 for connection in connections: |
911 localId = connection.getrefLocalId() |
911 localId = connection.getrefLocalId() |
912 next = body.getcontentInstance(localId) |
912 next = body.getcontentInstance(localId) |
913 if isinstance(next, plcopen.ldObjects_leftPowerRail): |
913 if isinstance(next, plcopen.ldObjects_leftPowerRail): |
920 block_infos = self.GetBlockType(block_type, tuple([self.ConnectionTypes.get(variable.connectionPointIn, "ANY") for variable in next.inputVariables.getvariable() if variable.getformalParameter() != "EN"])) |
920 block_infos = self.GetBlockType(block_type, tuple([self.ConnectionTypes.get(variable.connectionPointIn, "ANY") for variable in next.inputVariables.getvariable() if variable.getformalParameter() != "EN"])) |
921 if block_infos is None: |
921 if block_infos is None: |
922 block_infos = self.GetBlockType(block_type) |
922 block_infos = self.GetBlockType(block_type) |
923 if block_infos is None: |
923 if block_infos is None: |
924 raise PLCGenException, _("Undefined block type \"%s\" in \"%s\" POU")%(block_type, self.Name) |
924 raise PLCGenException, _("Undefined block type \"%s\" in \"%s\" POU")%(block_type, self.Name) |
925 paths.append(str(block_infos["generate"](self, next, block_infos, body, connection, order))) |
925 paths.append(str(block_infos["generate"](self, next, block_infos, body, connection, order, to_inout))) |
926 elif isinstance(next, plcopen.commonObjects_continuation): |
926 elif isinstance(next, plcopen.commonObjects_continuation): |
927 name = next.getname() |
927 name = next.getname() |
928 computed_value = self.ComputedConnectors.get(name, None) |
928 computed_value = self.ComputedConnectors.get(name, None) |
929 if computed_value != None: |
929 if computed_value != None: |
930 paths.append(str(computed_value)) |
930 paths.append(str(computed_value)) |
979 elif paths is None: |
979 elif paths is None: |
980 return [("TRUE", ())] |
980 return [("TRUE", ())] |
981 else: |
981 else: |
982 return eval(paths) |
982 return eval(paths) |
983 |
983 |
984 def ComputeExpression(self, body, connections, order = False): |
984 def ComputeExpression(self, body, connections, order = False, to_inout = False): |
985 paths = self.GeneratePaths(connections, body, order) |
985 paths = self.GeneratePaths(connections, body, order, to_inout) |
986 if len(paths) > 1: |
986 if len(paths) > 1: |
987 factorized_paths = self.FactorizePaths(paths) |
987 factorized_paths = self.FactorizePaths(paths) |
988 if len(factorized_paths) > 1: |
988 if len(factorized_paths) > 1: |
989 paths = tuple(factorized_paths) |
989 paths = tuple(factorized_paths) |
990 else: |
990 else: |