Revision 63c92857
| b/grc/base/Block.py | ||
|---|---|---|
| 98 | 98 |
self.get_params().append(param) |
| 99 | 99 |
#create the source objects |
| 100 | 100 |
self._sources = list() |
| 101 |
for source in map(lambda n: self.get_parent().get_parent().Source(self, n), sources):
|
|
| 101 |
for source in map(lambda n: self.get_parent().get_parent().Port(self, n, dir='source'), sources):
|
|
| 102 | 102 |
key = source.get_key() |
| 103 | 103 |
#test against repeated keys |
| 104 | 104 |
try: assert key not in self.get_source_keys() |
| ... | ... | |
| 107 | 107 |
self.get_sources().append(source) |
| 108 | 108 |
#create the sink objects |
| 109 | 109 |
self._sinks = list() |
| 110 |
for sink in map(lambda n: self.get_parent().get_parent().Sink(self, n), sinks):
|
|
| 110 |
for sink in map(lambda n: self.get_parent().get_parent().Port(self, n, dir='sink'), sinks):
|
|
| 111 | 111 |
key = sink.get_key() |
| 112 | 112 |
#test against repeated keys |
| 113 | 113 |
try: assert key not in self.get_sink_keys() |
| b/grc/base/Platform.py | ||
|---|---|---|
| 171 | 171 |
FlowGraph = _FlowGraph |
| 172 | 172 |
Connection = _Connection |
| 173 | 173 |
Block = _Block |
| 174 |
Source = _Port |
|
| 175 |
Sink = _Port |
|
| 174 |
Port = _Port |
|
| 176 | 175 |
Param = _Param |
| b/grc/base/Port.py | ||
|---|---|---|
| 24 | 24 |
##possible port types |
| 25 | 25 |
TYPES = [] |
| 26 | 26 |
|
| 27 |
def __init__(self, block, n): |
|
| 27 |
def __init__(self, block, n, dir):
|
|
| 28 | 28 |
""" |
| 29 | 29 |
Make a new port from nested data. |
| 30 | 30 |
@param block the parent element |
| 31 | 31 |
@param n the nested odict |
| 32 |
@return a new port
|
|
| 32 |
@param dir the direction source or sink
|
|
| 33 | 33 |
""" |
| 34 |
#grab the data |
|
| 35 |
name = n['name'] |
|
| 36 |
key = n['key'] |
|
| 37 |
type = n['type'] |
|
| 38 | 34 |
#build the port |
| 39 | 35 |
Element.__init__(self, block) |
| 40 |
self._name = name |
|
| 41 |
self._key = key |
|
| 42 |
self._type = type |
|
| 36 |
#grab the data |
|
| 37 |
self._name = n['name'] |
|
| 38 |
self._key = n['key'] |
|
| 39 |
self._type = n['type'] |
|
| 40 |
self._dir = dir |
|
| 43 | 41 |
|
| 44 | 42 |
def validate(self): |
| 45 | 43 |
""" |
| ... | ... | |
| 60 | 58 |
def get_color(self): return '#FFFFFF' |
| 61 | 59 |
def get_name(self): return self._name |
| 62 | 60 |
def get_key(self): return self._key |
| 63 |
def is_sink(self): return self in self.get_parent().get_sinks()
|
|
| 64 |
def is_source(self): return self in self.get_parent().get_sources()
|
|
| 61 |
def is_sink(self): return self._dir == 'sink'
|
|
| 62 |
def is_source(self): return self._dir == 'source'
|
|
| 65 | 63 |
def get_type(self): return self.get_parent().resolve_dependencies(self._type) |
| 66 | 64 |
|
| 67 | 65 |
def get_connections(self): |
| b/grc/gui/Platform.py | ||
|---|---|---|
| 1 | 1 |
""" |
| 2 |
Copyright 2008 Free Software Foundation, Inc. |
|
| 2 |
Copyright 2008, 2009 Free Software Foundation, Inc.
|
|
| 3 | 3 |
This file is part of GNU Radio |
| 4 | 4 |
|
| 5 | 5 |
GNU Radio Companion is free software; you can redistribute it and/or |
| ... | ... | |
| 38 | 38 |
('FlowGraph', FlowGraph),
|
| 39 | 39 |
('Connection', Connection),
|
| 40 | 40 |
('Block', Block),
|
| 41 |
('Source', Port),
|
|
| 42 |
('Sink', Port),
|
|
| 41 |
('Port', Port),
|
|
| 43 | 42 |
('Param', Param),
|
| 44 | 43 |
): |
| 45 | 44 |
old_value = getattr(platform, attr) |
| b/grc/gui/Port.py | ||
|---|---|---|
| 1 | 1 |
""" |
| 2 |
Copyright 2007 Free Software Foundation, Inc. |
|
| 2 |
Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
|
|
| 3 | 3 |
This file is part of GNU Radio |
| 4 | 4 |
|
| 5 | 5 |
GNU Radio Companion is free software; you can redistribute it and/or |
| b/grc/python/Platform.py | ||
|---|---|---|
| 23 | 23 |
from FlowGraph import FlowGraph as _FlowGraph |
| 24 | 24 |
from Connection import Connection as _Connection |
| 25 | 25 |
from Block import Block as _Block |
| 26 |
from Port import Source,Sink
|
|
| 26 |
from Port import Port as _Port
|
|
| 27 | 27 |
from Param import Param as _Param |
| 28 | 28 |
from Generator import Generator |
| 29 | 29 |
from Constants import \ |
| ... | ... | |
| 77 | 77 |
FlowGraph = _FlowGraph |
| 78 | 78 |
Connection = _Connection |
| 79 | 79 |
Block = _Block |
| 80 |
Source = Source |
|
| 81 |
Sink = Sink |
|
| 80 |
Port = _Port |
|
| 82 | 81 |
Param = _Param |
| b/grc/python/Port.py | ||
|---|---|---|
| 25 | 25 |
##possible port types |
| 26 | 26 |
TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg'] |
| 27 | 27 |
|
| 28 |
def __init__(self, block, n): |
|
| 28 |
def __init__(self, block, n, dir):
|
|
| 29 | 29 |
""" |
| 30 | 30 |
Make a new port from nested data. |
| 31 | 31 |
@param block the parent element |
| 32 | 32 |
@param n the nested odict |
| 33 |
@param dir the direction |
|
| 33 | 34 |
""" |
| 35 |
self._n = n |
|
| 36 |
if n['type'] == 'msg': n['key'] = 'msg' |
|
| 37 |
if dir == 'source' and not n.find('key'):
|
|
| 38 |
n['key'] = str(block._source_count) |
|
| 39 |
block._source_count += 1 |
|
| 40 |
if dir == 'sink' and not n.find('key'):
|
|
| 41 |
n['key'] = str(block._sink_count) |
|
| 42 |
block._sink_count += 1 |
|
| 34 | 43 |
#build the port |
| 35 | 44 |
_Port.__init__( |
| 36 | 45 |
self, |
| 37 | 46 |
block=block, |
| 38 | 47 |
n=n, |
| 48 |
dir=dir, |
|
| 39 | 49 |
) |
| 40 | 50 |
self._nports = n.find('nports') or ''
|
| 41 | 51 |
self._vlen = n.find('vlen') or ''
|
| ... | ... | |
| 109 | 119 |
def copy(self, new_key=None): |
| 110 | 120 |
n = self._n.copy() |
| 111 | 121 |
if new_key: n['key'] = new_key |
| 112 |
return self.__class__(self.get_parent(), n) |
|
| 113 |
|
|
| 114 |
class Source(Port): |
|
| 115 |
|
|
| 116 |
def __init__(self, block, n): |
|
| 117 |
self._n = n #save n |
|
| 118 |
if n['type'] == 'msg': n['key'] = 'msg' |
|
| 119 |
if not n.find('key'):
|
|
| 120 |
n['key'] = str(block._source_count) |
|
| 121 |
block._source_count = block._source_count + 1 |
|
| 122 |
Port.__init__(self, block, n) |
|
| 123 |
|
|
| 124 |
class Sink(Port): |
|
| 125 |
|
|
| 126 |
def __init__(self, block, n): |
|
| 127 |
self._n = n #save n |
|
| 128 |
if n['type'] == 'msg': n['key'] = 'msg' |
|
| 129 |
if not n.find('key'):
|
|
| 130 |
n['key'] = str(block._sink_count) |
|
| 131 |
block._sink_count = block._sink_count + 1 |
|
| 132 |
Port.__init__(self, block, n) |
|
| 122 |
return self.__class__(self.get_parent(), n, self._dir) |
|
Also available in: Unified diff