Ejemplo n.º 1
0
    def __repr__(self):
        s = 'CompositeNDP'

        if hasattr(self, ATTR_LOAD_NAME):
            s += '\n (loaded as %r)' % getattr(self, ATTR_LOAD_NAME)
#         if hasattr(self, ATTRIBUTE_NDP_RECURSIVE_NAME):
#             s += '\n (labeled as %s)' % getattr(self, ATTRIBUTE_NDP_RECURSIVE_NAME).__str__()
        for f in self._fnames:
            s += '\n provides %s  [%s]' % (f, self.get_ftype(f))
        for r in self._rnames:
            s += '\n requires %s  [%s]' % (r, self.get_rtype(r))

        s += '\n %d nodes, %d edges' % (len(self.context.names), len(self.context.connections))

        s += '\n connections: \n' + format_list_long(self.context.connections, informal=True)
        s += '\n names: \n' + format_dict_long(self.context.names, informal=True)
        return s
Ejemplo n.º 2
0
    def __repr__(self):
        s = 'CompositeNDP'

        att = MCDPConstants.ATTR_LOAD_NAME
        if hasattr(self, att):
            s += '\n (loaded as %r)' % getattr(self, att)


#         if hasattr(self, ATTRIBUTE_NDP_RECURSIVE_NAME):
#             s += '\n (labeled as %s)' % getattr(self, ATTRIBUTE_NDP_RECURSIVE_NAME).__str__()
        for f in self._fnames:
            s += '\n provides %s  [%s]' % (f, self.get_ftype(f))
        for r in self._rnames:
            s += '\n requires %s  [%s]' % (r, self.get_rtype(r))

        s += '\n %d nodes, %d edges' % (len(
            self.context.names), len(self.context.connections))

        s += '\n connections: \n' + format_list_long(self.context.connections,
                                                     informal=True)
        s += '\n names: \n' + format_dict_long(self.context.names,
                                               informal=True)
        return s
Ejemplo n.º 3
0
def dpgraph_(name2dp, connections, split):

    try:
        connections = set(connections)
        check_connections(name2dp, connections)

        G = get_connection_multigraph(connections)
        cycles = list(simple_cycles(G))
        if not cycles:
            res = dpconnect(name2dp, connections, split=split)
            assert isinstance(res, SimpleWrap), (type(res), name2dp)
            return res

        # At this point we never resort to the rest -
        # this is always called without cycles
        assert False


#         c = choose_connection_to_cut1(connections, name2dp)
#
#         other_connections = set()
#         other_connections.update(connections)
#         other_connections.remove(c)
#
#         def connections_include_resource(conns, s):
#             for c in conns:
#                 if c.s1 == s:
#                     return True
#             else:
#                 return False
#
#         # we have to make sure that the signal that we need is not closed
#         if connections_include_resource(other_connections, c.s1):
#             split1 = [c.s1]
#         else:
#             split1 = []
#
#         split1.extend(split)
#
#         ndp = dpgraph(name2dp, other_connections, split=split1)
#
#         # now we make sure that the signals we have are preserved
#         ndp.rindex(c.s1)
#         ndp.findex(c.s2)
#         l = dploop0(ndp, c.s1, c.s2)
#
#         l.rindex(c.s1)
#
#         if c.s1 in split:
#             return l
#
#         else:
#             F = ndp.get_rtype(c.s1)
#             term = dpwrap(Terminator(F), c.s1, [])
#
#             res = connect2(l, term,
#                            set([Connection("-", c.s1, "-", c.s1)]), split=[])
#
#             return res
    except DPSemanticError as e:
        raise_wrapped(DPSemanticError,
                      e,
                      'Error while calling dpgraph().',
                      compact=True,
                      names=format_dict_long(name2dp, informal=True),
                      connection=format_list_long(connections, informal=True))
    except DPInternalError as e:
        raise_wrapped(DPInternalError,
                      e,
                      'Error while calling dpgraph().',
                      names=format_dict_long(name2dp, informal=True),
                      connection=format_list_long(connections, informal=True))
Ejemplo n.º 4
0
def dpgraph_(name2dp, connections, split):

    try:
        connections = set(connections)
        check_connections(name2dp, connections)

        G = get_connection_multigraph(connections)
        cycles = list(simple_cycles(G))
        if not cycles:
            res = dpconnect(name2dp, connections, split=split)
            assert isinstance(res, SimpleWrap), (type(res), name2dp)
            return res

        # At this point we never resort to the rest -
        # this is always called without cycles
        assert False
#         c = choose_connection_to_cut1(connections, name2dp)
# 
#         other_connections = set()
#         other_connections.update(connections)
#         other_connections.remove(c)
# 
#         def connections_include_resource(conns, s):
#             for c in conns:
#                 if c.s1 == s:
#                     return True
#             else:
#                 return False
# 
#         # we have to make sure that the signal that we need is not closed
#         if connections_include_resource(other_connections, c.s1):
#             split1 = [c.s1]
#         else:
#             split1 = []
# 
#         split1.extend(split)
# 
#         ndp = dpgraph(name2dp, other_connections, split=split1)
# 
#         # now we make sure that the signals we have are preserved
#         ndp.rindex(c.s1)
#         ndp.findex(c.s2)
#         l = dploop0(ndp, c.s1, c.s2)
# 
#         l.rindex(c.s1)
# 
#         if c.s1 in split:
#             return l
# 
#         else:
#             F = ndp.get_rtype(c.s1)
#             term = dpwrap(Terminator(F), c.s1, [])
# 
#             res = connect2(l, term,
#                            set([Connection("-", c.s1, "-", c.s1)]), split=[])
# 
#             return res
    except DPSemanticError as e:
        raise_wrapped(DPSemanticError, e, 'Error while calling dpgraph().',
                      compact=True,
                      names=format_dict_long(name2dp, informal=True),
                      connection=format_list_long(connections, informal=True))
    except DPInternalError as e:
        raise_wrapped(DPInternalError, e, 'Error while calling dpgraph().',
                      names=format_dict_long(name2dp, informal=True),
                      connection=format_list_long(connections, informal=True))