Example #1
0
bool
orb_i::impl::readTrace( const SignalObserver::Description& desc
                         , const SignalObserver::DataReadBuffer& rb
                         , const adcontrols::DataInterpreter& dataInterpreter
                          , unsigned long objid )
{
    std::lock_guard< std::mutex > lock( mutex_ );
    if ( trace_accessors_.find( objid ) == trace_accessors_.end() )
        trace_accessors_[ objid ] = std::shared_ptr< adcontrols::TraceAccessor >( new adcontrols::TraceAccessor );

    adcontrols::TraceAccessor& accessor = *trace_accessors_[ objid ];
    if ( dataInterpreter.translate( accessor
									, reinterpret_cast< const char *>( rb.xdata.get_buffer() ), rb.xdata.length()
									, reinterpret_cast< const char * >( rb.xmeta.get_buffer() ), rb.xmeta.length()
                                    , rb.events ) == adcontrols::translate_complete ) {
        return true;
    }
    return false;
}
Example #2
0
// private
bool
rawdata::fetchTraces( int64_t objid, const adcontrols::DataInterpreter& interpreter, adcontrols::TraceAccessor& accessor )
{

    adfs::stmt sql( dbf_.db() );
    
    if ( sql.prepare( "SELECT rowid, npos, events, fcn FROM AcquiredData WHERE oid = :oid ORDER BY npos" ) ) {

        sql.bind( 1 ) = objid;
        adfs::blob blob;
        std::vector< char > xdata;
        std::vector< char > xmeta;
        size_t nrecord = 0;

        while ( sql.step() == adfs::sqlite_row ) {
            ++nrecord;
            uint64_t rowid = sql.get_column_value< int64_t >( 0 );
            uint64_t npos = sql.get_column_value< int64_t >( 1 );
            uint32_t events = static_cast<uint32_t>(sql.get_column_value< int64_t >( 2 ));
            if ( npos0_ == 0 )
                npos0_ = npos;

            if ( blob.open( dbf_.db(), "main", "AcquiredData", "data", rowid, adfs::readonly ) ) {
                xdata.resize( blob.size() );
                if ( blob.size() )
                    blob.read( reinterpret_cast<int8_t *>(xdata.data()), blob.size() );
            }

            if ( blob.open( dbf_.db(), "main", "AcquiredData", "meta", rowid, adfs::readonly ) ) {
                xmeta.resize( blob.size() );
                if ( blob.size() )
                    blob.read( reinterpret_cast<int8_t *>(xmeta.data()), blob.size() );
            }

            interpreter.translate( accessor, xdata.data(), xdata.size(), xmeta.data(), xmeta.size()
                                   , static_cast<uint32_t>(events) );
        }
        return nrecord != 0;
    }
    return false;
}
Example #3
0
bool
orb_i::impl::readMassSpectra( const SignalObserver::DataReadBuffer& rb
                              , const adcontrols::MassSpectrometer& spectrometer
                              , const adcontrols::DataInterpreter& dataInterpreter
                              , unsigned long objid )
{
    if ( ! rdmap_[ objid ] )
        rdmap_[ objid ].reset( new adcontrols::MassSpectrum );

    adcontrols::MassSpectrum& ms = *rdmap_[ objid ];

    size_t idData = 0;
    adcontrols::translate_state state = 
        dataInterpreter.translate( ms
                                   , reinterpret_cast< const char *>(rb.xdata.get_buffer()), rb.xdata.length()
                                   , reinterpret_cast< const char *>(rb.xmeta.get_buffer()), rb.xmeta.length()
                                   , spectrometer, idData++, 0 );
    if ( state == adcontrols::translate_complete ) {
        std::lock_guard< std::mutex > lock( mutex_ );
        fifo_ms_.push_back( rdmap_[ objid ] );
        rdmap_[ objid ].reset( new adcontrols::MassSpectrum );
    } 
    return state != adcontrols::translate_error;
}