Example #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 ] );
    }
    
}
Example #2
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;
}