root / grc / src / platforms / python / Platform.py @ 693cf2fa
History | View | Annotate | Download (2.3 kB)
| 1 | """
|
|---|---|
| 2 | Copyright 2008 Free Software Foundation, Inc.
|
| 3 | This file is part of GNU Radio
|
| 4 | |
| 5 | GNU Radio Companion is free software; you can redistribute it and/or
|
| 6 | modify it under the terms of the GNU General Public License
|
| 7 | as published by the Free Software Foundation; either version 2
|
| 8 | of the License, or (at your option) any later version.
|
| 9 | |
| 10 | GNU Radio Companion is distributed in the hope that it will be useful,
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 | GNU General Public License for more details.
|
| 14 | |
| 15 | You should have received a copy of the GNU General Public License
|
| 16 | along with this program; if not, write to the Free Software
|
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
| 18 | """
|
| 19 | |
| 20 | import os |
| 21 | from .. base.Platform import Platform as _Platform |
| 22 | from FlowGraph import FlowGraph as _FlowGraph |
| 23 | from Connection import Connection as _Connection |
| 24 | from Block import Block as _Block |
| 25 | from Port import Source,Sink |
| 26 | from Param import Param as _Param |
| 27 | from Generator import Generator |
| 28 | from Constants import \ |
| 29 | HIER_BLOCKS_LIB_DIR, BLOCK_DTD, \ |
| 30 | BLOCK_TREE, DEFAULT_FLOW_GRAPH, \ |
| 31 | BLOCKS_DIR
|
| 32 | |
| 33 | _critical_blocks_only = map(lambda b: os.path.join(BLOCKS_DIR, b), ['options.xml', 'usrp_probe.xml', 'usrp2_probe.xml']) |
| 34 | |
| 35 | class Platform(_Platform): |
| 36 | |
| 37 | def __init__(self, extra_blocks=[], critical_only=False): |
| 38 | """
|
| 39 | Make a platform for gnuradio.
|
| 40 | @param extra_blocks a list of block paths to load in addition to main block library
|
| 41 | @param critical_only only load critical blocks (used only for usrp probe scripts to speed up load time)
|
| 42 | """ |
| 43 | #ensure hier dir
|
| 44 | if not os.path.exists(HIER_BLOCKS_LIB_DIR): os.mkdir(HIER_BLOCKS_LIB_DIR) |
| 45 | if critical_only: block_paths = _critical_blocks_only
|
| 46 | else: block_paths = extra_blocks + [HIER_BLOCKS_LIB_DIR, BLOCKS_DIR]
|
| 47 | #convert block paths to absolute paths, ensure uniqueness
|
| 48 | block_paths = set(map(os.path.abspath, block_paths)) |
| 49 | #init
|
| 50 | _Platform.__init__( |
| 51 | self,
|
| 52 | name='GRC',
|
| 53 | key='grc',
|
| 54 | block_paths=block_paths, |
| 55 | block_dtd=BLOCK_DTD, |
| 56 | block_tree=BLOCK_TREE, |
| 57 | default_flow_graph=DEFAULT_FLOW_GRAPH, |
| 58 | generator=Generator, |
| 59 | ) |
| 60 | |
| 61 | ##############################################
|
| 62 | # Constructors
|
| 63 | ##############################################
|
| 64 | FlowGraph = _FlowGraph |
| 65 | Connection = _Connection |
| 66 | Block = _Block |
| 67 | Source = Source |
| 68 | Sink = Sink |
| 69 | Param = _Param |