Exemple #1
0
void
SampleProcessor::populate_calibration( SignalObserver::Observer * parent )
{
    SignalObserver::Observers_var vec = parent->getSiblings();

    if ( ( vec.ptr() != 0 ) && ( vec->length() > 0 ) ) {
        
        for ( CORBA::ULong i = 0; i < vec->length(); ++i ) {
            
            SignalObserver::Observer_ptr observer = vec[ i ];
            unsigned long objId = observer->objId();
            CORBA::WString_var dataClass;
            SignalObserver::octet_array_var data;
            CORBA::ULong idx = 0;
            while ( observer->readCalibration( idx++, data, dataClass ) ) {
                adfs::stmt sql( fs_->db() );
                sql.prepare( "INSERT INTO Calibration VALUES(:objid,:dataClass,:data,0)" );
                sql.bind( 1 ) = objId;
                sql.bind( 2 ) = std::wstring( dataClass.in() );
                sql.bind( 3 ) = adfs::blob( data->length(), reinterpret_cast< const int8_t *>( data->get_buffer() ) );
                if ( sql.step() == adfs::sqlite_done )
                    sql.commit();
                else
                    sql.reset();
            }
        }
        for ( CORBA::ULong i = 0; i < vec->length(); ++i )
            populate_calibration( vec[ i ] );
    }
    
}
Exemple #2
0
void
SampleProcessor::populate_descriptions( signalobserver::Observer * parent )
{
#if 0
    SignalObserver::Observers_var vec = parent->getSiblings();

    unsigned long pobjId = parent->objId();

    if ( ( vec.ptr() != 0 ) && ( vec->length() > 0 ) ) {
        
        for ( CORBA::ULong i = 0; i < vec->length(); ++i ) {
            
            SignalObserver::Observer_ptr observer = vec[ i ];
            
            unsigned long objId = observer->objId();
            
			CORBA::WString_var clsid = observer->dataInterpreterClsid();
			SignalObserver::Description_var desc = observer->getDescription();
			CORBA::WString_var trace_id = desc->trace_id.in();
			CORBA::WString_var trace_display_name = desc->trace_display_name.in();
			CORBA::WString_var axis_x_label = desc->axis_x_label.in();
			CORBA::WString_var axis_y_label = desc->axis_y_label.in();

            adutils::AcquiredConf::insert( fs_->db()
                                           , objId
                                           , pobjId
                                           , std::wstring( clsid.in() )
                                           , uint64_t( desc->trace_method )
                                           , uint64_t( desc->spectrometer )
                                           , std::wstring( trace_id.in() )
                                           , std::wstring( trace_display_name.in() )
                                           , std::wstring( axis_x_label.in() )
                                           , std::wstring( axis_y_label.in() )
                                           , uint64_t( desc->axis_x_decimals )
                                           , uint64_t( desc->axis_y_decimals ) );
        }

        for ( CORBA::ULong i = 0; i < vec->length(); ++i )
            populate_descriptions( vec[ i ] );

    }
#endif
}
Exemple #3
0
bool
orb_i::readCalibrations( observer_type& obs )
{
    CORBA::String_var dataClass;
    SignalObserver::Observer_ptr tgt = std::get<0>( obs ).in();
    auto spectrometer = std::get<4>( obs );

    SignalObserver::octet_array_var data;

    bool success = false;
    CORBA::ULong idx = 0;
    while ( tgt->readCalibration( idx++, data, dataClass ) ) {
        auto wdataClass = adportable::utf::to_wstring( dataClass.in() );
        if ( std::wcscmp( wdataClass.c_str(), adcontrols::MSCalibrateResult::dataClass() ) == 0 ) {
            adcontrols::MSCalibrateResult result;
            if ( adportable::binary::deserialize<>()(result, reinterpret_cast<const char *>(data->get_buffer()), data->length()) )
                success = true;
            if ( spectrometer )
                spectrometer->setCalibration( idx - 1, result );
        }
    }
    return success;
}
Exemple #4
0
void
orb_i::handle_update_data( unsigned long objId, long pos )
{
    ACE_UNUSED_ARG( pos );

    try {
        std::lock_guard< std::mutex > lock( task_->mutex_ );
        
        if ( observerMap_.find( objId ) == observerMap_.end() ) {
            SignalObserver::Observer_var tgt = observer_->findObserver( objId, true );
            if ( CORBA::is_nil( tgt.in() ) )
                return;

            CORBA::String_var name = tgt->dataInterpreterClsid();
            if ( auto spectrometer = adcontrols::MassSpectrometerBroker::make_massspectrometer( name.in() ))  {

                SignalObserver::Description_var desc = tgt->getDescription();
                observerMap_[ objId ] = std::make_tuple( tgt, desc, adportable::utf::to_wstring( name.in() ), false, spectrometer );
                npos_map_[ objId ] = pos;
            } else {
                ADTRACE() << "receive data from unavilable spectrometer: " << name.in();
                return;
            }
        }
    } catch ( ... ) {
        ADDEBUG() << boost::current_exception_diagnostic_information();
    }
    try {
        long& npos = npos_map_[ objId ];

        if ( pos < npos )
            return;

        auto it = observerMap_.find( objId );
        SignalObserver::Observer_ptr tgt = std::get<0>( it->second ).in();
        SignalObserver::Description_var& desc = std::get<1>( it->second );
        auto spectrometer = std::get<4>( it->second );
        CORBA::String_var name = tgt->dataInterpreterClsid();

        auto interpreter = adcontrols::DataInterpreterBroker::make_datainterpreter( name.in() );
        if ( !interpreter )
            return;
        const adcontrols::DataInterpreter& dataInterpreter = *interpreter; //spectrometer->getDataInterpreter();

        if ( desc->trace_method == SignalObserver::eTRACE_SPECTRA ) {

            // ADDEBUG() << "handle_updae_data( " << objId << ", " << pos << ") npos=" << npos;
            
            if ( !std::get<3>( it->second ) )
                std::get<3>( it->second ) = readCalibrations( it->second );

            try {
                SignalObserver::DataReadBuffer_var rb;
                while ( tgt->readData( npos, rb ) && npos <= pos ) {
                    ADDEBUG() << "\treadData( " << npos << " ) " << rb->pos;
                    ++npos;
                    impl_->readMassSpectra( rb, *spectrometer, dataInterpreter, objId );
                }
                emit onUpdateUIData( objId, pos );
            } catch ( CORBA::Exception& ex ) {
                ADTRACE() << "handle_update_data got an corba exception: " << ex._info().c_str();
            } catch ( ... ) {
                ADTRACE() << boost::current_exception_diagnostic_information();
            }

        } else if ( desc->trace_method == SignalObserver::eTRACE_TRACE ) {
            try {
                SignalObserver::DataReadBuffer_var rb;
                while ( tgt->readData( npos, rb ) ) {
                    npos = rb->pos + rb->ndata;
					impl_->readTrace( desc, rb, dataInterpreter, objId );
                    emit onUpdateUIData( objId, pos );
                    return;
                }
            } catch ( CORBA::Exception& ex ) {
                ADTRACE() << "handle_update_data got an corba exception: " << ex._info().c_str();
            }
        }
    } catch ( ... ) {
        ADDEBUG() << boost::current_exception_diagnostic_information();
    }
}