void filter_delay_fc_2i_base::processStreamIdChanges() { boost::mutex::scoped_lock lock(_sriMutex); LOG_TRACE( filter_delay_fc_2i_base, "processStreamIDChanges QUEUE: " << _sriQueue.size() ); if ( _sriQueue.size() == 0 ) return; std::string sid(""); if ( validGRBlock() ) { IStreamList::iterator istream; int idx=0; std::string sid(""); int mode=0; SRIQueue::iterator item = _sriQueue.begin(); for ( ; item != _sriQueue.end(); item++ ) { idx = 0; sid = ""; mode= item->second.mode; sid = item->second.streamID; istream = _istreams.begin(); for ( ; istream != _istreams.end(); idx++, istream++ ) { if ( istream->port == item->first ) { LOG_DEBUG( filter_delay_fc_2i_base, " SETTING IN_STREAM ID/STREAM_ID :" << idx << "/" << sid ); istream->sri(true); istream->spe(mode); LOG_DEBUG( filter_delay_fc_2i_base, " SETTING OUT_STREAM ID/STREAM_ID :" << idx << "/" << sid ); setOutputStreamSRI( idx, item->second ); } } } _sriQueue.clear(); } else { LOG_WARN( filter_delay_fc_2i_base, " NEW STREAM ID, NO GNU RADIO BLOCK DEFINED, SRI QUEUE SIZE:" << _sriQueue.size() ); } }
void randomizer_base::setupIOMappings( ) { int ninput_streams = 0; int noutput_streams = 0; std::vector<std::string>::iterator pname; std::string sid(""); int inMode=RealMode; if ( !validGRBlock() ) return; ninput_streams = gr_sptr->get_max_input_streams(); gr_io_signature_sptr g_isig = gr_sptr->input_signature(); noutput_streams = gr_sptr->get_max_output_streams(); gr_io_signature_sptr g_osig = gr_sptr->output_signature(); LOG_DEBUG( randomizer_base, "GNUHAWK IO MAPPINGS IN/OUT " << ninput_streams << "/" << noutput_streams ); // // Someone reset the GR Block so we need to clean up old mappings if they exists // we need to reset the io signatures and check the vlens // if ( _istreams.size() > 0 || _ostreams.size() > 0 ) { LOG_DEBUG( randomizer_base, "RESET INPUT SIGNATURE SIZE:" << _istreams.size() ); IStreamList::iterator istream; for ( int idx=0 ; istream != _istreams.end(); idx++, istream++ ) { // re-add existing stream definitons LOG_DEBUG( randomizer_base, "ADD READ INDEX TO GNU RADIO BLOCK"); if ( ninput_streams == -1 ) gr_sptr->add_read_index(); // setup io signature istream->associate( gr_sptr ); } LOG_DEBUG( randomizer_base, "RESET OUTPUT SIGNATURE SIZE:" << _ostreams.size() ); OStreamList::iterator ostream; for ( int idx=0 ; ostream != _ostreams.end(); idx++, ostream++ ) { // need to evaluate new settings...??? ostream->associate( gr_sptr ); } return; } // // Setup mapping of RH port to GNU RADIO Block input streams // For version 1, we are ignoring the GNU Radio input stream -1 case that allows multiple data // streams over a single connection. We are mapping a single RH Port to a single GNU Radio stream. // Stream Identifiers will be pass along as they are received // LOG_TRACE( randomizer_base, "setupIOMappings INPUT PORTS: " << inPorts.size() ); pname = inputPortOrder.begin(); for( int i=0; pname != inputPortOrder.end(); pname++ ) { // grab ports based on their order in the scd.xml file RH_ProvidesPortMap::iterator p_in = inPorts.find(*pname); if ( p_in != inPorts.end() ) { bulkio::InOctetPort *port = dynamic_cast< bulkio::InOctetPort * >(p_in->second); int mode = inMode; sid = ""; // need to add read index to GNU Radio Block for processing streams when max_input == -1 if ( ninput_streams == -1 ) gr_sptr->add_read_index(); // check if we received SRI during setup BULKIO::StreamSRISequence_var sris = port->activeSRIs(); if ( sris->length() > 0 ) { BULKIO::StreamSRI sri = sris[sris->length()-1]; mode = sri.mode; } std::vector<int> in; io_mapping.push_back( in ); _istreams.push_back( gr_istream< bulkio::InOctetPort > ( port, gr_sptr, i, mode, sid )); LOG_DEBUG( randomizer_base, "ADDING INPUT MAP IDX:" << i << " SID:" << sid ); // increment port counter i++; } } // // Setup mapping of RH port to GNU RADIO Block input streams // For version 1, we are ignoring the GNU Radio output stream -1 case that allows multiple data // streams over a single connection. We are mapping a single RH Port to a single GNU Radio stream. // LOG_TRACE( randomizer_base, "setupIOMappings OutputPorts: " << outPorts.size() ); pname = outputPortOrder.begin(); for( int i=0; pname != outputPortOrder.end(); pname++ ) { // grab ports based on their order in the scd.xml file RH_UsesPortMap::iterator p_out = outPorts.find(*pname); if ( p_out != outPorts.end() ) { bulkio::OutOctetPort *port = dynamic_cast< bulkio::OutOctetPort * >(p_out->second); int idx = -1; BULKIO::StreamSRI sri = createOutputSRI( i, idx ); if (idx == -1) idx = i; if(idx < (int)io_mapping.size()) io_mapping[idx].push_back(i); int mode = sri.mode; sid = sri.streamID; _ostreams.push_back( gr_ostream< bulkio::OutOctetPort > ( port, gr_sptr, i, mode, sid )); LOG_DEBUG( randomizer_base, "ADDING OUTPUT MAP IDX:" << i << " SID:" << sid ); _ostreams[i].setSRI(sri, i ); // increment port counter i++; } } }
void copy_octet_base::processStreamIdChanges() { boost::mutex::scoped_lock lock(_sriMutex); LOG_TRACE( copy_octet_base, "processStreamIDChanges QUEUE: " << _sriQueue.size() ); if ( _sriQueue.size() == 0 ) return; std::string sid(""); if ( validGRBlock() ) { int max_input = gr_sptr->get_max_input_streams(); int n_input = gr_sptr->get_num_input_streams(); LOG_TRACE( copy_octet_base, " IN_MAX=" << max_input << " N_IN:" << n_input); int max_output = gr_sptr->get_max_output_streams(); int n_output = gr_sptr->get_num_output_streams(); LOG_TRACE( copy_octet_base, " OUT_MAX=" << max_output << " N_OUT:" << n_output); bool var_istreams = false; if ( max_input == -1 && inPorts.size() == 1 ) var_istreams = true; bool var_ostreams = false; if ( max_output == -1 && outPorts.size() == 1 ) var_ostreams = true; IStreamList::iterator istream; int idx=0; std::string sid(""); int mode=0; SRIQueue::iterator item = _sriQueue.begin(); for ( ; item != _sriQueue.end(); item++ ) { idx = 0; sid = ""; mode= item->second.mode; sid = item->second.streamID; istream = _istreams.begin(); for ( ; istream != _istreams.end(); idx++, istream++ ) { if ( !var_istreams && istream->port == item->first ) { break; } else if ( var_istreams && (istream->port == item->first) && (istream->streamID == sid) ) { break; } } if ( istream == _istreams.end() ) { if ( var_istreams ) { if ( gr_sptr ) gr_sptr->add_read_index(); _istreams.push_back( gr_istream< BULKIO_dataOctet_In_i >( item->first, sid, gr_sptr, idx, mode ) ); LOG_TRACE( copy_octet_base, "GR_ISTREAM::ADD PORT:" << item->first->getName() << " STREAM_ID:" << sid << " NSTREAMS:" << _istreams.size()); if ( var_ostreams ) { RH_UsesPortMap::iterator p_out = outPorts.begin(); _ostreams.push_back( gr_ostream < BULKIO_dataOctet_Out_i >( dynamic_cast< BULKIO_dataOctet_Out_i *>(p_out->second), sid, gr_sptr, idx )); LOG_TRACE( copy_octet_base, "GR_OSTREAM::ADD PORT:" << p_out->second->getName() << " STREAM_ID:" << sid << " OSTREAMS:" << _ostreams.size()); } } else { LOG_WARN( copy_octet_base, " NEW STREAM ID, MISSING INPUT STREAM DEFINITION" ); } } else if ( !var_istreams ) { LOG_DEBUG( copy_octet_base, " SETTING GR_OSTREAM ID/STREAM_ID :" << idx << "/" << sid ); istream->sri(true); istream->spe(mode); } LOG_DEBUG( copy_octet_base, " GR_OSTREAM ID/STREAM_ID :" << idx << "/" << sid ); setOutputStreamSRI( idx, item->second ); } _sriQueue.clear(); } else { LOG_WARN( copy_octet_base, " NEW STREAM ID, NO GNU RADIO BLOCK DEFINED, SRI QUEUE SIZE:" << _sriQueue.size() ); } LOG_TRACE( copy_octet_base, "processStreamID, GR_ISTREAM MAP SIZE:" << _istreams.size() ); }
void copy_octet_base::setupIOMappings() { int ninput_streams = 0; int noutput_streams = 0; if ( !validGRBlock() ) return; ninput_streams = gr_sptr->get_max_input_streams(); gr_io_signature_sptr g_isig = gr_sptr->input_signature(); noutput_streams = gr_sptr->get_max_output_streams(); gr_io_signature_sptr g_osig = gr_sptr->output_signature(); // // RESOLVE: Still need to resolve the issue with the input port/stream to output port. We also need to resolve issue // with "ganging" ports together as an input to a GNU RADIO Block. transform cplx to real ... r/i -> float // LOG_DEBUG( copy_octet_base, "GNUHAWK IO MAPPINGS IN/OUT " << ninput_streams << "/" << noutput_streams ); std::string sid(""); // // Someone reset the GR Block so we need to clean up old mappings if they exists // we need to reset the io signatures and check the vlens // if ( _istreams.size() > 0 || _ostreams.size() > 0 ) { LOG_DEBUG( copy_octet_base, "RESET INPUT SIGNATURE SIZE:" << _istreams.size() ); IStreamList::iterator istream; for ( int idx=0 ; istream != _istreams.end(); idx++, istream++ ) { // re-add existing stream definitons LOG_DEBUG( copy_octet_base, "ADD READ INDEX TO GNU RADIO BLOCK"); if ( ninput_streams == -1 ) gr_sptr->add_read_index(); // setup io signature istream->associate( gr_sptr ); } LOG_DEBUG( copy_octet_base, "RESET OUTPUT SIGNATURE SIZE:" << _ostreams.size() ); OStreamList::iterator ostream; for ( int idx=0 ; ostream != _ostreams.end(); idx++, ostream++ ) { // need to evaluated new settings...??? ostream->associate( gr_sptr ); } return; } // setup mapping of RH Port to GNU RADIO BLOCK input streams as a 1-1 mapping (basically we ignore streamID when pulling data from port) // for case ninput == -1 and 1 port we map out streamID to each GNU Radio Block input stream this is done in the notifySRI callback method if ( ninput_streams != -1 || ( ninput_streams == -1 && inPorts.size() > 1 ) ) { int nstreams = inPorts.size(); if ( ninput_streams != -1 ) nstreams = std::min( nstreams, ninput_streams); RH_ProvidesPortMap::iterator p_in = inPorts.begin(); for ( int i=0; i < nstreams && p_in != inPorts.end(); i++, p_in++ ) { // need to add read index to GNU Radio Block for processing, if ( ninput_streams == -1 ) gr_sptr->add_read_index(); _istreams.push_back( gr_istream< BULKIO_dataOctet_In_i > ( dynamic_cast< BULKIO_dataOctet_In_i * >(p_in->second), sid, gr_sptr, i)); } } else { // ninput_stream is variable == -1 and component ports == 1 // // need to worry about sync between when service function starts and pushSRI happens, // for ( RH_ProvidesPortMap::iterator p_in = inPorts.begin(); p_in != inPorts.end(); p_in++ ) { BULKIO_dataOctet_In_i *port = dynamic_cast< BULKIO_dataOctet_In_i * >(p_in->second); BULKIO::StreamSRISequence_var sris = port->activeSRIs(); for ( uint32_t i=0 ; i < sris->length(); i++ ) { BULKIO::StreamSRI sri = sris[i]; int mode = sri.mode; sid = sri.streamID; _istreams.push_back( gr_istream< BULKIO_dataOctet_In_i > ( port, sid, gr_sptr, i, mode )); } } } if ( noutput_streams != -1 || (noutput_streams == -1 && outPorts.size() > 1 ) ) { int32_t nstreams = outPorts.size(); if ( noutput_streams != -1 ) { if ( nstreams != noutput_streams ) LOG_WARN( copy_octet_base, "Number of OUTPUT PORTS is different than number of GNU RADIO STREAMS PORTS/STREAMS " << nstreams << "/" << noutput_streams ); nstreams = std::min( nstreams, noutput_streams); } // add number of output streams based min ( gr block output streams, or output ports) LOG_TRACE( copy_octet_base, "setupIOMappings OutputPorts: " << nstreams ); RH_UsesPortMap::iterator p_out = outPorts.begin(); for ( int i=0; i < nstreams && p_out != outPorts.end(); i++, p_out++ ) { _ostreams.push_back( gr_ostream < BULKIO_dataOctet_Out_i >( dynamic_cast< BULKIO_dataOctet_Out_i *>(p_out->second), sid, gr_sptr, i )); } } else if ( (noutput_streams == -1 && outPorts.size() == 1) && ( ninput_streams == 0 ) ) { // RESOLVE: should generate maps based on port connections when output streams is variable and no input stream RH_UsesPortMap::iterator p_out = outPorts.begin(); uint32_t idx =0; std::string sid(""); uint32_t nstreams = getNOutputStreams(); for( ; idx < nstreams; idx++ ) { _ostreams.push_back( gr_ostream < BULKIO_dataOctet_Out_i >( dynamic_cast< BULKIO_dataOctet_Out_i *>(p_out->second), sid, gr_sptr, idx )); } } // for each output stream definition, call createOutputSRI to create initial value for the stream OStreamList::iterator ostream = _ostreams.begin(); for ( int i=0; ostream != _ostreams.end(); i++, ostream++ ) { BULKIO::StreamSRI sri = createOutputSRI( i ); ostream->setSRI(sri, i ); ostream->pushSRI(); } }