Manager::Manager( QObject * parent ) :
    QObject( parent ),
    worker_( interruptRequested_ )
{
    // initialize internal fields
    interruptRequested_ = false;
    hasPendingInput_ = false;
    workerBusy_ = false;

    // connect worker and manager
    connect( & worker_, SIGNAL( progress( ResultsG1dFit ) ),
             this, SLOT( onProgress( ResultsG1dFit ) ) );
    connect( & worker_, SIGNAL( done( ResultsG1dFit ) ),
             this, SLOT( onDone( ResultsG1dFit ) ) );
    connect( & worker_, SIGNAL( error( QString ) ),
             this, SLOT( onError( QString ) ) );
    connect( & worker_, SIGNAL( interrupt() ),
             this, SLOT( onInterrupt() ) );
    connect( this, SIGNAL( privateGo( InputParametersG1dFit ) ),
             & worker_, SLOT( onGoFromService( InputParametersG1dFit ) ) );

    // move the worker to a separate thread
    worker_.moveToThread( & workerThread_ );
    workerThread_.start();
}
예제 #2
0
void beepSetup() {
    // Setup PWM timer in fast mode, with no prescaler
    // Clear output on OCRnC compare match, and set when at BOTTOM
    BEEP_PWM_TIMER(TCCR, A) = (1 << BEEP_PWM_TIMER(WGM, 1)) | (1 << BEEP_PWM_TIMER(WGM, 0)) | (1 << BEEP_PWM_TIMER(COM, C1)) | (0 << BEEP_PWM_TIMER(COM, C0));
    BEEP_PWM_TIMER(TCCR, B) = (1 << BEEP_PWM_TIMER(WGM, 3)) | (1 << BEEP_PWM_TIMER(WGM, 2)) | (1 << BEEP_PWM_TIMER(CS, 0));
    BEEP_PWM_TIMER(OCR, A) = BEEP_PWM_PERIOD; // TOP
    BEEP_PWM_TIMER(OCR, C) = BEEP_PWM_PERIOD / 2; // Duty Cycle
    BEEP_PWM_OUTPUT(DDR) |= 1 << BEEP_PWM_OUTPUT_BIT;

    // Update the duty cycle at TOP
    onInterrupt(BEEP_PWM_TIMER(TIMER, _COMPA_vect_num), (void (*)(uint8_t))updateWaveform);
}
예제 #3
0
	void Thread::thisThreadRun()
	{
		_isRunning = true;
		try
		{
			run();
		}
		catch(boost::thread_interrupted& ex)
		{
			onInterrupt();
		}
		catch(std::exception& ex)
		{
			onException(ex);
		}
		_isRunning = false;
		_thisThread = boost::thread();
	}