commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11190 - in gnuradio/branches/developers/jblum/grc/grc


From: jblum
Subject: [Commit-gnuradio] r11190 - in gnuradio/branches/developers/jblum/grc/grc: base blocks python
Date: Sat, 13 Jun 2009 22:20:54 -0600 (MDT)

Author: jblum
Date: 2009-06-13 22:20:54 -0600 (Sat, 13 Jun 2009)
New Revision: 11190

Added:
   gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml
Removed:
   gnuradio/branches/developers/jblum/grc/grc/python/block_tree.xml
Modified:
   gnuradio/branches/developers/jblum/grc/grc/base/Platform.py
   gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am
   gnuradio/branches/developers/jblum/grc/grc/python/Constants.py
   gnuradio/branches/developers/jblum/grc/grc/python/Makefile.am
   gnuradio/branches/developers/jblum/grc/grc/python/Platform.py
Log:
Moved block tree into the blocks directory.
Multiple block trees can be defined now.
Add them into the blocks search path.



Modified: gnuradio/branches/developers/jblum/grc/grc/base/Platform.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/base/Platform.py 2009-06-14 
02:08:26 UTC (rev 11189)
+++ gnuradio/branches/developers/jblum/grc/grc/base/Platform.py 2009-06-14 
04:20:54 UTC (rev 11190)
@@ -18,6 +18,7 @@
 """
 
 import os
+import sys
 from .. base import ParseXML
 from Element import Element as _Element
 from FlowGraph import FlowGraph as _FlowGraph
@@ -29,14 +30,13 @@
 
 class Platform(_Element):
 
-       def __init__(self, name, key, block_paths, block_dtd, block_tree, 
default_flow_graph, generator):
+       def __init__(self, name, key, block_paths, block_dtd, 
default_flow_graph, generator):
                """
                Make a platform from the arguments.
                @param name the platform name
                @param key the unique platform key
                @param block_paths the file paths to blocks in this platform
                @param block_dtd the dtd validator for xml block wrappers
-               @param block_tree the nested tree of block keys and categories
                @param default_flow_graph the default flow graph file path
                @param load_one a single file to load into this platform or None
                @return a platform object
@@ -46,42 +46,45 @@
                self._key = key
                self._block_paths = block_paths
                self._block_dtd = block_dtd
-               self._block_tree = block_tree
                self._default_flow_graph = default_flow_graph
                self._generator = generator
                #create a dummy flow graph for the blocks
                self._flow_graph = _Element(self)
-               #load the blocks
-               self._blocks = dict()
-               self._blocks_n = dict()
+               #search for *.xml files in the given search path
+               xml_files = list()
                for block_path in self._block_paths:
-                       if os.path.isfile(block_path): 
self._load_blocks(block_path)
+                       if os.path.isfile(block_path): 
xml_files.append(block_path)
                        elif os.path.isdir(block_path):
                                for dirpath, dirnames, filenames in 
os.walk(block_path):
                                        for filename in filter(lambda f: 
f.endswith('.xml'), filenames):
-                                               
self._load_blocks(os.path.join(dirpath, filename))
+                                               
xml_files.append(os.path.join(dirpath, filename))
+               #load the blocks
+               self._blocks = dict()
+               self._blocks_n = dict()
+               self._block_tree_files = list()
+               for xml_file in xml_files:
+                       try: #try to add the xml file as a block wrapper
+                               ParseXML.validate_dtd(xml_file, self._block_dtd)
+                               n = ParseXML.from_file(xml_file).find('block')
+                               #inject block wrapper path
+                               n['block_wrapper_path'] = xml_file
+                               block = self.Block(self._flow_graph, n)
+                               key = block.get_key()
+                               #test against repeated keys
+                               try:
+                                       assert key not in self.get_block_keys()
+                                       #store the block
+                                       self._blocks[key] = block
+                                       self._blocks_n[key] = n
+                               except AssertionError:
+                                       print >> sys.stderr, 'Warning: Block 
with key "%s" already exists.\n\tIgnoring: %s'%(key, xml_file)
+                       except ParseXML.XMLSyntaxError, e: 
+                               try: #try to add the xml file as a block tree
+                                       ParseXML.validate_dtd(xml_file, 
BLOCK_TREE_DTD)
+                                       self._block_tree_files.append(xml_file)
+                               except ParseXML.XMLSyntaxError, e:
+                                       print >> sys.stderr, 'Warning: Block 
validation failed: %s\n\tIgnoring: %s'%(e, xml_file)
 
-       def _load_blocks(self, f):
-               """
-               Load the block wrappers from the file path.
-               The block wrapper must pass validation.
-               If any of the checks fail, exit with error.
-               @param f the file path
-               """
-               try: ParseXML.validate_dtd(f, self._block_dtd)
-               except ParseXML.XMLSyntaxError, e: self._exit_with_error('Block 
definition "%s" failed: \n\t%s'%(f, e))
-               n = ParseXML.from_file(f).find('block')
-               #inject block wrapper path
-               n['block_wrapper_path'] = f
-               block = self.Block(self._flow_graph, n)
-               key = block.get_key()
-               #test against repeated keys
-               try: assert(key not in self.get_block_keys())
-               except AssertionError: self._exit_with_error('Key "%s" already 
exists in blocks'%key)
-               #store the block
-               self._blocks[key] = block
-               self._blocks_n[key] = n
-
        def load_block_tree(self, block_tree):
                """
                Load a block tree with categories and blocks.
@@ -100,15 +103,13 @@
                        for block_key in cat_n.findall('block'):
                                block_tree.add_block(parent, 
self.get_block(block_key))
                #load the block tree
-               f = self._block_tree
-               try: ParseXML.validate_dtd(f, BLOCK_TREE_DTD)
-               except ParseXML.XMLSyntaxError, e: self._exit_with_error('Block 
tree "%s" failed: \n\t%s'%(f, e))
-               #add all blocks in the tree
-               load_category(ParseXML.from_file(f).find('cat'))
-               #add all other blocks, use the catgory
-               for block in self.get_blocks():
-                       #blocks with empty categories are in the xml block tree 
or hidden
-                       if block.get_category(): 
block_tree.add_block(block.get_category(), block)
+               for block_tree_file in self._block_tree_files:
+                       #add all blocks in the tree
+                       
load_category(ParseXML.from_file(block_tree_file).find('cat'))
+                       #add all other blocks, use the catgory
+                       for block in self.get_blocks():
+                               #blocks with empty categories are in the xml 
block tree or hidden
+                               if block.get_category(): 
block_tree.add_block(block.get_category(), block)
 
        def __str__(self): return 'Platform - %s(%s)'%(self.get_key(), 
self.get_name())
 

Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am       
2009-06-14 02:08:26 UTC (rev 11189)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/Makefile.am       
2009-06-14 04:20:54 UTC (rev 11190)
@@ -23,6 +23,7 @@
 
 ourdatadir = $(grc_blocksdir)
 dist_ourdata_DATA = \
+       block_tree.xml \
        audio_sink.xml \
        audio_source.xml \
        band_pass_filter.xml \

Copied: gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml (from 
rev 11188, gnuradio/branches/developers/jblum/grc/grc/python/block_tree.xml)
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml            
                (rev 0)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/block_tree.xml    
2009-06-14 04:20:54 UTC (rev 11190)
@@ -0,0 +1,293 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Block Tree for platform gnuradio python.
+###################################################
+ -->
+<cat>
+       <name></name> <!-- Blank for Root Name -->
+       <cat>
+               <name>Sources</name>
+               <block>const_source_x</block>
+               <block>gr_sig_source_x</block>
+               <block>gr_noise_source_x</block>
+               <block>gr_vector_source_x</block>
+               <block>random_source_x</block>
+               <block>gr_glfsr_source_x</block>
+               <block>gr_null_source</block>
+               <block>gr_file_source</block>
+               <block>blks2_tcp_source</block>
+               <block>gr_udp_source</block>
+               <block>audio_source</block>
+               <block>gr_wavfile_source</block>
+               <block>pad_source</block>
+       </cat>
+       <cat>
+               <name>Sinks</name>
+               <block>blks2_variable_sink_x</block>
+               <block>gr_vector_sink_x</block>
+               <block>gr_null_sink</block>
+               <block>gr_file_sink</block>
+               <block>blks2_tcp_sink</block>
+               <block>gr_udp_sink</block>
+               <block>audio_sink</block>
+               <block>gr_wavfile_sink</block>
+               <block>pad_sink</block>
+       </cat>
+       <cat>
+               <name>Graphical Sinks</name>
+               <block>wxgui_numbersink2</block>
+               <block>wxgui_scopesink2</block>
+               <block>wxgui_fftsink2</block>
+               <block>wxgui_constellationsink2</block>
+               <block>wxgui_waterfallsink2</block>
+               <block>wxgui_histosink2</block>
+       </cat>
+       <cat>
+               <name>Operators</name>
+               <block>gr_add_xx</block>
+               <block>gr_sub_xx</block>
+               <block>gr_multiply_xx</block>
+               <block>gr_divide_xx</block>
+               <block>gr_nlog10_ff</block>
+
+               <block>gr_add_const_vxx</block>
+               <block>gr_multiply_const_vxx</block>
+
+               <block>gr_not_xx</block>
+               <block>gr_and_xx</block>
+               <block>gr_or_xx</block>
+               <block>gr_xor_xx</block>
+
+               <block>gr_max_xx</block>
+               <block>gr_argmax_xx</block>
+               <block>gr_rms_xx</block>
+               <block>gr_integrate_xx</block>
+
+               <block>gr_conjugate_cc</block>
+
+               <block>gr_fft_vxx</block>
+               <block>blks2_logpwrfft_x</block>
+       </cat>
+       <cat>
+               <name>Type Conversions</name>
+               <block>gr_complex_to_arg</block>
+               <block>gr_complex_to_mag</block>
+               <block>gr_complex_to_mag_squared</block>
+               <block>gr_complex_to_real</block>
+               <block>gr_complex_to_imag</block>
+
+               <block>gr_complex_to_float</block>
+               <block>gr_float_to_complex</block>
+
+               <block>gr_float_to_short</block>
+               <block>gr_short_to_float</block>
+
+               <block>gr_float_to_char</block>
+               <block>gr_char_to_float</block>
+
+               <block>gr_float_to_uchar</block>
+               <block>gr_uchar_to_float</block>
+
+               <block>gr_complex_to_interleaved_short</block>
+               <block>gr_interleaved_short_to_complex</block>
+       </cat>
+       <cat>
+               <name>Stream Conversions</name>
+               <block>gr_interleave</block>
+               <block>gr_deinterleave</block>
+
+               <block>gr_streams_to_stream</block>
+               <block>gr_stream_to_streams</block>
+
+               <block>gr_streams_to_vector</block>
+               <block>gr_vector_to_streams</block>
+
+               <block>gr_stream_to_vector</block>
+               <block>gr_vector_to_stream</block>
+               
+               <block>blks2_stream_to_vector_decimator</block>
+       </cat>
+       <cat>
+               <name>Misc Conversions</name>
+               <block>gr_unpacked_to_packed_xx</block>
+               <block>gr_packed_to_unpacked_xx</block>
+               <block>gr_unpack_k_bits_bb</block>
+               <block>gr_binary_slicer_fb</block>
+               <block>gr_chunks_to_symbols_xx</block>
+               <block>gr_map_bb</block>
+       </cat>
+       <cat>
+               <name>Synchronizers</name>
+               <block>gr_clock_recovery_mm_xx</block>
+
+               <block>gr_costas_loop_cc</block>
+               <block>gr_dd_mpsk_sync_cc</block>
+               <block>gr_mpsk_sync_cc</block>
+               <block>gr_mpsk_receiver_cc</block>
+
+               <block>gr_pll_carriertracking_cc</block>
+               <block>gr_pll_freqdet_cf</block>
+               <block>gr_pll_refout_cc</block>
+
+               <block>gr_correlate_access_code_bb</block>
+               <block>gr_pn_correlator_cc</block>
+               <block>gr_simple_correlator</block>
+               <block>gr_simple_framer</block>
+
+               <block>blks2_packet_decoder</block>
+               <block>blks2_packet_encoder</block>
+       </cat>
+       <cat>
+               <name>Level Controls</name>
+               <block>gr_dpll_bb</block>
+               <block>gr_peak_detector_xb</block>
+               <block>gr_peak_detector2_fb</block>
+               <block>gr_sample_and_hold_xx</block>
+
+               <block>gr_agc_xx</block>
+               <block>gr_agc2_xx</block>
+               <block>gr_feedforward_agc_cc</block>
+
+               <block>gr_mute_xx</block>
+               <block>gr_simple_squelch_cc</block>
+               <block>blks2_standard_squelch</block>
+               <block>gr_pwr_squelch_xx</block>
+               <block>gr_threshold_ff</block>
+       </cat>
+       <cat>
+               <name>Filters</name>
+               <!-- FIR convenience filters -->
+               <block>low_pass_filter</block>
+               <block>high_pass_filter</block>
+               <block>band_pass_filter</block>
+               <block>band_reject_filter</block>
+               <!-- Filters that take taps as aruments -->
+               <block>gr_fir_filter_xxx</block>
+               <block>gr_interp_fir_filter_xxx</block>
+               <block>gr_fft_filter_xxx</block>
+               <block>gr_freq_xlating_fir_filter_xxx</block>
+               <block>gr_iir_filter_ffd</block>
+               <block>gr_filter_delay_fc</block>
+               <block>gr_channel_model</block>
+               <!-- Filter banks -->
+               <block>blks2_synthesis_filterbank</block>
+               <block>blks2_analysis_filterbank</block>
+               <!-- Other filters -->
+               <block>gr_single_pole_iir_filter_xx</block>
+               <block>gr_hilbert_fc</block>
+               <block>gr_goertzel_fc</block>
+               <block>gr_cma_equalizer_cc</block>
+               <block>gr_rational_resampler_base_xxx</block>
+               <block>blks2_rational_resampler_xxx</block>
+               <block>gr_fractional_interpolator_xx</block>
+               <block>gr_keep_one_in_n</block>
+               <block>gr_moving_average_xx</block>
+               <block>gr_iqcomp_cc</block>
+       </cat>
+       <cat>
+               <name>Modulators</name>
+               <block>gr_vco_f</block>
+               <block>gr_frequency_modulator_fc</block>
+               <block>gr_phase_modulator_fc</block>
+               <block>gr_quadrature_demod_cf</block>
+               <block>gr_cpfsk_bc</block>
+
+               <block>gr_diff_phasor_cc</block>
+               <block>gr_constellation_decoder_cb</block>
+
+               <block>gr_diff_encoder_bb</block>
+               <block>gr_diff_decoder_bb</block>
+
+               <block>blks2_wfm_tx</block>
+               <block>blks2_wfm_rcv</block>
+               <block>blks2_wfm_rcv_pll</block>
+
+               <block>blks2_nbfm_tx</block>
+               <block>blks2_nbfm_rx</block>
+
+               <block>blks2_am_demod_cf</block>
+               <block>blks2_fm_demod_cf</block>
+               <block>blks2_fm_deemph</block>
+               <block>blks2_fm_preemph</block>
+
+               <block>blks2_dxpsk_mod</block>
+               <block>blks2_dxpsk_demod</block>
+
+               <block>blks2_gmsk_mod</block>
+               <block>blks2_gmsk_demod</block>
+
+               <block>blks2_qamx_mod</block>
+               <block>blks2_qamx_demod</block>
+
+               <block>blks2_ofdm_mod</block>
+               <block>blks2_ofdm_demod</block>
+       </cat>
+       <cat>
+               <name>Error Correction</name>
+               <cat>
+                       <name>Trellis</name>
+                       <block>trellis_encoder_xx</block>
+                       <block>trellis_metrics_x</block>
+                       <block>trellis_permutation</block>
+                       <block>trellis_siso_combined_f</block>
+                       <block>trellis_siso_f</block>
+                       <block>trellis_viterbi_combined_xx</block>
+                       <block>trellis_viterbi_x</block>
+               </cat>
+
+               <block>gr_encode_ccsds_27_bb</block>
+               <block>gr_decode_ccsds_27_fb</block>
+       </cat>
+       <cat>
+               <name>Line Coding</name>
+               <block>gr_scrambler_bb</block>
+               <block>gr_descrambler_bb</block>
+       </cat>
+       <cat>
+               <name>Probes</name>
+               <block>gr_probe_avg_mag_sqrd_x</block>
+               <block>gr_probe_density_b</block>
+               <block>gr_probe_mpsk_snr_c</block>
+               <block>probe_function</block>
+       </cat>
+       <cat>
+               <name>USRP</name>
+               <block>usrp_simple_source_x</block>
+               <block>usrp_simple_sink_x</block>
+               <block>usrp_dual_source_x</block>
+               <block>usrp_dual_sink_x</block>
+               <block>usrp2_source_xxxx</block>
+               <block>usrp2_sink_xxxx</block>
+       </cat>
+       <cat>
+               <name>Variables</name>
+               <block>variable</block>
+               <block>variable_slider</block>
+               <block>variable_chooser</block>
+               <block>variable_text_box</block>
+               <block>parameter</block>
+       </cat>
+       <cat>
+               <name>Misc</name>
+               <block>note</block>
+               <block>import</block>
+
+               <block>gr_throttle</block>
+               <block>gr_delay</block>
+               <block>gr_repeat</block>
+
+               <block>blks2_selector</block>
+               <block>blks2_valve</block>
+               <block>blks2_error_rate</block>
+
+               <block>gr_head</block>
+               <block>gr_skiphead</block>
+
+               <block>gr_kludge_copy</block>
+               <block>gr_nop</block>
+
+               <block>xmlrpc_server</block>
+               <block>xmlrpc_client</block>
+       </cat>
+</cat>

Modified: gnuradio/branches/developers/jblum/grc/grc/python/Constants.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/Constants.py      
2009-06-14 02:08:26 UTC (rev 11189)
+++ gnuradio/branches/developers/jblum/grc/grc/python/Constants.py      
2009-06-14 04:20:54 UTC (rev 11190)
@@ -1,5 +1,5 @@
 """
-Copyright 2008 Free Software Foundation, Inc.
+Copyright 2008, 2009 Free Software Foundation, Inc.
 This file is part of GNU Radio
 
 GNU Radio Companion is free software; you can redistribute it and/or
@@ -46,7 +46,6 @@
 DATA_DIR = os.path.dirname(__file__)
 FLOW_GRAPH_TEMPLATE = os.path.join(DATA_DIR, 'flow_graph.tmpl')
 BLOCK_DTD = os.path.join(DATA_DIR, 'block.dtd')
-BLOCK_TREE = os.path.join(DATA_DIR, 'block_tree.xml')
 DEFAULT_FLOW_GRAPH = os.path.join(DATA_DIR, 'default_flow_graph.grc')
 
 #coloring

Modified: gnuradio/branches/developers/jblum/grc/grc/python/Makefile.am
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/Makefile.am       
2009-06-14 02:08:26 UTC (rev 11189)
+++ gnuradio/branches/developers/jblum/grc/grc/python/Makefile.am       
2009-06-14 04:20:54 UTC (rev 11190)
@@ -39,6 +39,5 @@
 ourdatadir = $(grc_src_prefix)/python
 dist_ourdata_DATA = \
        block.dtd \
-       block_tree.xml \
        default_flow_graph.grc \
        flow_graph.tmpl

Modified: gnuradio/branches/developers/jblum/grc/grc/python/Platform.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/Platform.py       
2009-06-14 02:08:26 UTC (rev 11189)
+++ gnuradio/branches/developers/jblum/grc/grc/python/Platform.py       
2009-06-14 04:20:54 UTC (rev 11190)
@@ -27,16 +27,13 @@
 from Generator import Generator
 from Constants import \
        HIER_BLOCKS_LIB_DIR, BLOCK_DTD, \
-       BLOCK_TREE, DEFAULT_FLOW_GRAPH, \
-       BLOCKS_DIRS
+       DEFAULT_FLOW_GRAPH, BLOCKS_DIRS
 
 class Platform(_Platform):
 
-       def __init__(self, extra_blocks=[]):
+       def __init__(self):
                """
                Make a platform for gnuradio.
-               @param extra_blocks a list of block paths to load in addition 
to main block library
-               @param critical_only only load critical blocks (used only for 
usrp probe scripts to speed up load time)
                """
                #ensure hier dir
                if not os.path.exists(HIER_BLOCKS_LIB_DIR): 
os.mkdir(HIER_BLOCKS_LIB_DIR)
@@ -50,7 +47,6 @@
                        key='grc',
                        block_paths=block_paths,
                        block_dtd=BLOCK_DTD,
-                       block_tree=BLOCK_TREE,
                        default_flow_graph=DEFAULT_FLOW_GRAPH,
                        generator=Generator,
                )





reply via email to

[Prev in Thread] Current Thread [Next in Thread]