summaryrefslogtreecommitdiff
path: root/grc/core/blocks/dummy.py
blob: 8147eededb98f98b47d116b9ce4fdfed387ad562 (plain)
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
# Copyright 2016 Free Software Foundation, Inc.
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-2.0-or-later
#


from . import Block, register_build_in

from ._build import build_params


@register_build_in
class DummyBlock(Block):

    is_dummy_block = True

    label = 'Missing Block'
    key = '_dummy'

    def __init__(self, parent, missing_block_id, parameters, **_):
        self.key = missing_block_id
        self.parameters_data = build_params(
            [], False, False, self.flags, self.key)
        super(DummyBlock, self).__init__(parent=parent)

        param_factory = self.parent_platform.make_param
        for param_id in parameters:
            self.params.setdefault(param_id, param_factory(
                parent=self, id=param_id, dtype='string'))

    def is_valid(self):
        return False

    @property
    def enabled(self):
        return False

    def add_missing_port(self, port_id, direction):
        port = self.parent_platform.make_port(
            parent=self, direction=direction, id=port_id, name='?', dtype='',
        )
        if port.is_source:
            self.sources.append(port)
        else:
            self.sinks.append(port)
        return port