Exemple #1
0
        void populate( SignalObserver::Observer_var& observer )   {
            SignalObserver::Description_var topLevelDesc = observer->getDescription();
                
            std::string topLevelName = topLevelDesc->trace_display_name.in();
			//traceBox_->addItem( QString::fromStdString( topLevelName ) );
            //todo: set name on MainWindow's traceBox_
            
            SignalObserver::Observers_var children = observer->getSiblings();
            for ( CORBA::ULong i = 0; i < children->length(); ++i ) {
                SignalObserver::Description_var secondLevelDesc = children[i]->getDescription();
                CORBA::String_var secondLevelName = children[i]->getDescription()->trace_display_name.in();
				//traceBox_->addItem( QString( "   %1" ).arg( secondLevelName.in() ) );
            }
        }
Exemple #2
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();
    }
}
Exemple #3
0
bool
iTask::initialize_configuration()
{
    using namespace adportable;

    if ( status_current_ >= ControlServer::eConfigured )
        return true;

	adportable::timer x;
	Logging(L"iTask::initialize_configuration...", ::EventLog::pri_DEBUG );

    SignalObserver::Observer_var masterObserver = getObserver();
    if ( CORBA::is_nil( masterObserver.in() ) ) {
        assert(0);
        throw std::runtime_error( "iTask::initialize_configuration - can't get master observer servant" );
    }

    int objid = 0;
    for ( Configuration& item: config_ ) {
        ++objid;
        // initialize instrument proxy
        std::shared_ptr<iProxy> pProxy( new iProxy( *this ) );
        if ( pProxy ) {
			adportable::timer timer;
            pProxy->objId( objid );
            if ( ! pProxy->initialConfiguration( item ) ) {
                Logging(L"iTask::initialize_configuration -- instrument initialization failed for \"%1%\""
                        , ::EventLog::pri_WARNING ) % item.name();
				continue; //return false;
            }
            std::lock_guard< std::mutex > lock( mutex_ );
            iproxies_.push_back( pProxy );
            Logging(L"iTask::initialize_configuration -- instrument \"%1%\" successfully initialized as objId %2% took %3% us"
                    , ::EventLog::pri_INFO )  % item.name() % objid % timer.elapsed();
        }

        // initialize observer proxy
        Instrument::Session_var iSession = pProxy->getSession();
        if ( ! CORBA::is_nil( iSession.in() ) ) {
            std::shared_ptr<oProxy> poProxy( new oProxy( *this ) );
            if ( poProxy ) {
				adportable::timer timer;

                poProxy->objId( objid );
                poProxy->setConfiguration( item );
                if ( poProxy->setInstrumentSession( iSession ) ) { // assign objid to source objects
                    size_t n = poProxy->populateObservers( objid );
                    Logging(L"iTask::initialize_configuration -- \"%1%\" has %2% signal observers %3% us"
						, ::EventLog::pri_INFO ) % item.name() % n % timer.elapsed();
                    objid += int(n);
                }
                std::lock_guard< std::mutex > lock( mutex_ );
                oproxies_.push_back( poProxy );

                // add source into the Cache (1st layer siblings)
                masterObserver->addSibling( poProxy->getObject() );
            }
        }
    }

    // fire connect
    using adcontroller::iProxy;
    using adcontroller::oProxy;
    std::for_each( iproxies_.begin(), iproxies_.end(), boost::bind( &iProxy::connect, _1, "adcontroller.iTask(i)" ) );
    std::for_each( oproxies_.begin(), oproxies_.end(), boost::bind( &oProxy::connect, _1, "adcontroller.iTask(o)" ) );

    status_current_ = status_being_ = ControlServer::eConfigured;  // relevant modules are able to access.
	Logging(L"iTask::initialize_configuration completed. %1% us", ::EventLog::pri_INFO ) % x.elapsed();
    return true;
}