-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBlock.py
More file actions
57 lines (42 loc) · 1.67 KB
/
Block.py
File metadata and controls
57 lines (42 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright (c) 2014-2016 Josh Blum
# SPDX-License-Identifier: BSL-1.0
from . PothosModule import *
from . InputPort import InputPort
from . OutputPort import OutputPort
from . Label import Label, LabelIteratorRange
from . BlockRegistry import BlockRegistry
import weakref
class Block(object):
def __init__(self):
self._block = BlockRegistry("/blocks/python_block")
self._block._setPyBlock(weakref.proxy(self))
def __getattr__(self, name):
return lambda *args: self._block.call(name, *args)
def getInternalBlock(self):
"""
Get access to the underlying Pothos::Block handle.
Topology uses this call to speak directly to the block.
"""
return self._block
def inputs(self):
ports = self._block.inputs()
return [InputPort(ports.at(i)) for i in range(ports.size())]
def allInputs(self):
ports = self._block.allInputs()
return dict([(key, InputPort(ports.at(key))) for key in ports.keys()])
def input(self, name):
return InputPort(self._block.input(name))
def outputs(self):
ports = self._block.outputs()
return [OutputPort(ports.at(i)) for i in range(ports.size())]
def allOutputs(self):
ports = self._block.allOutputs()
return dict([(key, OutputPort(ports.at(key))) for key in ports.keys()])
def output(self, name):
return OutputPort(self._block.output(name))
def activate(self): pass
def deactivate(self): pass
def work(self): pass
def propagateLabels(self, input, labels): pass
def propagateLabelsAdaptor(self, input, labels):
self.propagateLabels(InputPort(input), LabelIteratorRange(labels))