示例#1
0
::CORBA::Boolean
tofObserver_i::readData ( ::CORBA::Long pos, ::SignalObserver::DataReadBuffer_out dataReadBuffer )
{
    std::lock_guard< std::mutex > lock( mutex_ );

    if ( pos < 0 )
        pos = fifo_.back();

    if ( !fifo_.empty() && ( fifo_.front() <= pos && pos <= fifo_.back() ) ) {
        int noffs = pos - fifo_.front().pos_;
        if ( noffs < 0 || unsigned(noffs) >= fifo_.size() )
            return false;
        cache_item& d = fifo_[ noffs ];
        if ( d.pos_ != pos ) { // in case if some data lost
            std::deque< cache_item >::iterator it = std::lower_bound( fifo_.begin(), fifo_.end(), pos );
            if ( it != fifo_.end() )
                d = *it;
            else
                return false;
        }

        if ( d.mb_->msg_type() == constants::MB_InfiTOF_DATA ) {

            TAO_InputCDR cdr( d.mb_->cont() );
            InfiTOF::AveragerData data;
            cdr >> data;

            SignalObserver::DataReadBuffer_var res = new SignalObserver::DataReadBuffer;

            res->method <<= data;
            res->uptime = data.uptime;
            res->pos = d.pos_;
            res->events = data.wellKnownEvents;

            res->array.length( data.nbrSamples );
            memcpy( &res->array[0], d.mb_->rd_ptr(), data.nbrSamples * sizeof(long) );

            dataReadBuffer = res._retn();
            return true;
        }
示例#2
0
::CORBA::Boolean
traceObserver_i::readData ( ::CORBA::Long pos, ::SignalObserver::DataReadBuffer_out dataReadBuffer )
{
    acewrapper::scoped_mutex_t<> lock( mutex_ );

    if ( pos < 0 )
        pos = fifo_.back();

    if ( !fifo_.empty() && ( fifo_.front() <= pos && pos <= fifo_.back() ) ) {

        std::deque< cache_item >::iterator it = std::lower_bound( fifo_.begin(), fifo_.end(), pos );

        if ( it != fifo_.end() ) {
            SignalObserver::DataReadBuffer_var rb = new SignalObserver::DataReadBuffer;
            
            rb->pos = it->pos_;
            const TOFInstrument::TraceDescriptor& desc = it->desc_;

            rb->events = desc.wellKnownEvents;
            rb->ndata = std::distance( it, fifo_.end() );

            TOFInstrument::SpectrumProcessedDataArray ar;
            ar.length( rb->ndata );
            for ( size_t i = 0 ; it != fifo_.end(); ++it, ++i ) {
                const TOFInstrument::SpectrumProcessedData& d = it->data_;
                ar[i] = d;
            }

            rb->data <<= ar;

            dataReadBuffer = rb._retn();
            return true;
        }
    }
	return false;
}