Exemplo n.º 1
0
void Runner::tryMoveRight(float delta)
{
    Block* block, *nextblock;
    float nextx = x + vx * delta;
    int ix = nextx;
    float dx = nextx - ix;
//    LOGD("nextx=%f dx=%f", nextx, dx);
    if (ix == field->ncols-1)
    {
        doStop();
        return;
    }
    if (!field->cell(ix+1, round(y))->free())
    {
        doStop();
        return;
    }
    block = field->blockOfXY(nextx+1,y);
    if (!block)
        goto move;
//    block->vx = vx;
    if (!block->canMoveRight())
    {
        doStop();
        block->stop();
        return;
    }
    else
        block->moveRight();
    move:
    x = nextx;
}
Exemplo n.º 2
0
void Runner::tryMoveLeft(float delta)
{
    Block* block; //, *nextblock;
    float nextx = x + vx * delta;
    int ix = nextx;
    float dx = nextx - ix;
//    LOGD("nextx=%f dx=%f", nextx, dx);
    if (ix < 0)
    {
        doStop();
        return;
    }
    if (!field->cell(ix, y)->free())
    {
        doStop();
        return;
    }
    block = field->blockOfXY(nextx,y);
    if (!block)
        goto move;
//    block->vx = vx;
    if (!block->canMoveLeft())
    {
        doStop();
        block->stop();
        return;
    }
    else
        block->moveLeft();
    move:
    x = nextx;
    if (x<0)
        x = 0;
}
Exemplo n.º 3
0
void RescueBTask::onDecision(Drivebase& drive, Sensors& sensor){
  switch(state){
    case Stopped:
      doStop(drive, sensor);
    break;
  }
}
void IVtkAdaptorService::stopping() throw(fwTools::Failed)
{
    /// Stop observation
    m_connections->disconnect();
    doStop();
    requestRender();
}
Exemplo n.º 5
0
 void Service::control( DWORD code )
 {
   switch ( code )
   {
     case SERVICE_CONTROL_INTERROGATE:
       SetServiceStatus( mStatusHandle, &mStatus );
     break;
     case SERVICE_CONTROL_STOP:
     case SERVICE_CONTROL_SHUTDOWN:
       if ( mStatus.dwCurrentState == SERVICE_STOP_PENDING
         || mStatus.dwCurrentState == SERVICE_STOPPED )
         return;
       setState( SERVICE_STOP_PENDING, 0 );
       doStop();
       setState( SERVICE_STOPPED, 0 );
     break;
     case SERVICE_CONTROL_PAUSE:
       if ( mStatus.dwCurrentState != SERVICE_RUNNING )
         return;
       setState( SERVICE_PAUSE_PENDING, 0 );
       doPause();
       setState( SERVICE_PAUSED, 0 );
     break;
     case SERVICE_CONTROL_CONTINUE:
       if ( mStatus.dwCurrentState != SERVICE_PAUSED )
         return;
       setState( SERVICE_CONTINUE_PENDING, 0 );
       doContinue();
       setState( SERVICE_RUNNING, 0 );
     break;
   }
 }
Exemplo n.º 6
0
void Runner::moveStep(float delta)
{
    Cell* cell = field->cell(x,y);
    if (!climbing)
    if (cell->growing() && ((GrowingCell*)cell)->solid())
    {
        this->die();
        return;
    }
    if (falling)
    {
        if (checkFall(delta));
            catchBonus();
    }
    if (climbing)
    {
        x = x + vx * delta;
        y = y + vy * delta;
        checkClimb();
    }
    if (!busy())
    {
        if (vx < 0)
            tryMoveLeft(delta);
        else if (vx > 0)
            tryMoveRight(delta);
        catchBonus();
        if (!field->hasSurface(round(x), y))
            fall();
    }
    if (stopping)
        doStop();
    if (fabs(x-field->grenadePutX)>0.3 || fabs(y-field->grenadePutY)>0.3)
        field->grenadePutX = 1000;
}
Exemplo n.º 7
0
void IAdaptor::stopping() throw ( ::fwTools::Failed )
{
    m_connections->disconnect();
    doStop();

    m_xAxis.reset();
    m_yAxis.reset();
}
Exemplo n.º 8
0
void CZeroconf::Stop()
{
  CSingleLock lock(*mp_crit_sec);
  if(!m_started)
    return;
  doStop();
  m_started = false;
}
Exemplo n.º 9
0
ClusterMgr::~ClusterMgr()
{
  DBUG_ENTER("ClusterMgr::~ClusterMgr");
  doStop();
  NdbCondition_Destroy(waitForHBCond);
  NdbMutex_Destroy(clusterMgrThreadMutex);
  DBUG_VOID_RETURN;
}
Exemplo n.º 10
0
CZeroconfMDNS::~CZeroconfMDNS()
{
  doStop();
#if defined(HAS_MDNS_EMBEDDED)
  StopThread();
  embedded_mDNSExit();
#endif //HAS_MDNS_EMBEDDED
}
Exemplo n.º 11
0
void PeerConnectionBackend::stop()
{
    m_offerAnswerPromise = Nullopt;
    m_setDescriptionPromise = Nullopt;
    m_addIceCandidatePromise = Nullopt;

    doStop();
}
Exemplo n.º 12
0
void AudioPlaybackLocal::releaseHw()
{
    if (mPcmHandle != NULL) {
        LOGV("releaseHw %x", (unsigned int)this);
        doStop();
        pcm_close(mPcmHandle);
        mPcmHandle = NULL;
    }
}
void AudioRecordingLocal::releaseHw()
{
    if (mPcmHandle != NULL) {
        LOGV("releaseHw %x", (unsigned long)this);
        doStop();
        pcm_close(mPcmHandle);
        mPcmHandle = NULL;
    }
}
Exemplo n.º 14
0
 void stop()
 {
     if (!stopped)
     {
         abortSoon = true;
         stopped = true;
         doStop();
     }
     input.clear();
 }
Exemplo n.º 15
0
Timer::~Timer()
{
	TRACE_BEGIN(LOG_LVL_INFO);
	
	// Force stop of this timer
	doStop();
	
	// Remove the Timer from the TimerManager
	TimerManager::getInstance()->removeTimer(this);
	
}
Exemplo n.º 16
0
void CClientRegister::setDevicehPin(const String& pin)
{
    m_strDevicePin = pin;

    if (pin.length() > 0)
    {
        startUp();
    } else
    {
        doStop();
    }
}
Exemplo n.º 17
0
void Timer::stop()
{
	TRACE_BEGIN(LOG_LVL_NOISE);
	
	if (mStoppable == true)
	{
		doStop();
	}
	else
	{
		LOG_WARN("Attempted to stop Timer %p that is not stoppable", this);
	}
}
Exemplo n.º 18
0
void Lift::moveStep(float delta)
{
    float saveY = y;
    MovingObject::moveStep(delta);
    if (runnerWaiting())
        moveToRunner();
    else if (abs(vy) >0.1)
        doStop();

    {
        int i =0;
        if (block && block->x > 999)
            block = 0;
        if (vy >0 )
        for (Block* upblock = block ;;i++)
        {
            if (!upblock)
                break;
            if (y+i >= field->nrows || field->isBrick(x, y+i+1, true))
            {
                y = saveY;
                doStop();
                return;
            }
            upblock  = upblock->blockAbove();
        }
        i=0;
        for (Block* upblock = block ;;i++)
        {
            if (!upblock)
                break;
            //upblock->setX(x);
            upblock->setY(y+i);
            upblock->setVX(0);
            upblock->setVY(vy);
            upblock  = upblock->blockAbove();
        }
    }
}
Exemplo n.º 19
0
	//! Starts the workpool, creating _minwkrcnt
	void start(ushort _minwkrcnt = 0){
		Locker<Mutex> lock(mtx);
		if(state() == Running){
			return;
		}
		if(state() != Stopped){
			doStop(lock, true);
		}
		wkrcnt = 0;
		state(Running);
		for(ushort i(0); i < _minwkrcnt; ++i){
			createWorker();
		}
	}
// Make sure that stop also calls PV author engine's Reset()
// and Close() so that its internal state is maintained correctly
status_t PVMediaRecorder::stop()
{
    LOGV("stop");
    status_t ret = doStop();
    if (OK != ret)
    LOGE("stop failed");
    ret = reset();
    if (OK != ret)
    LOGE("reset failed");
    ret = close();
    if (OK != ret)
    LOGE("close failed");

    return ret;
}
Exemplo n.º 21
0
void Lift::moveToRunner()
{
    float dy = fabs(y-runner()->y);
    if (dy < 0.2 && dy > 0.001)
    {
        y = runner()->y;
        //vy = 0;
        doStop();
    }
    else if (runner()->y > y)
        vy = v;
    else if (runner()->y < y)
        vy = -v;
    else vy = 0;
}
Exemplo n.º 22
0
void Runner::checkClimb()
{
  catchBonus();
    if (dist2(x,y, climbX,climbY) < 0.04)
    {
        climbing = false;
        x = climbX;
        y = climbY;
        vx = postVX;
        vy = 0;
        catchBonus();
        if (vx ==0)
            doStop();
    }
}
Exemplo n.º 23
0
void Action::stop(bool running)
{
    if(mStartTimerId)
    {
        killTimer(mStartTimerId);
        mStartTimerId = 0;
        mRunning = false;
    }

    if(mRunning)
    {
        if(mRestore) doRestore();
        doStop(running);
        mRunning = false;
    }
}
Exemplo n.º 24
0
void Application::stop( bool kill/*=false*/ ) {
	printf( "[app::Application] Stop application: name=%s, kill=%d\n", name().c_str(), kill );

	//	Stop any download
	stopDownload();
		
	//	Application is running ...
	if (isRunning()) {
		doStop( kill );

		{	//	Returns the keys
			std::vector<util::key::type> keys;
			ctrl()->reserveKeys( keys );
		}

		//	Resize main video
		ctrl()->resizeVideo( 0, 0, 1, 1 );		
	}

	//	Change status
	status( status::mounted );
}
Exemplo n.º 25
0
GstPlayer::GstPlayer(QObject *parent):
    IMediaPlayer(parent),
    playing(false),
    loaded(false),
    error(false),
    playingRequested(false),
    mustSeek(true),
    duration(-1),
    position(0),
    formatTime(GST_FORMAT_TIME),
    pipeline(0),
    gstObjectName("player")
{
    GstPlayer::ensureInitGst();
    connect(this,SIGNAL(requestPause()),this,SLOT(doPause()));
    connect(this,SIGNAL(requestPlay()),this,SLOT(doPlay()));
    connect(this,SIGNAL(requestStop()),this,SLOT(doStop()));
    //watcher = NULL;
    theVol = new GValue();
    g_value_init(theVol,G_TYPE_DOUBLE);

    positionQueryTimer = new QTimer(this);

}
Exemplo n.º 26
0
CZeroconfWIN::~CZeroconfWIN()
{
  doStop();
}
void DirectShowPlayerService::run()
{
    QMutexLocker locker(&m_mutex);

    for (;;) {
        ::ResetEvent(m_taskHandle);

        while (m_pendingTasks == 0) {
            DWORD result = 0;

            locker.unlock();
            if (m_eventHandle) {
                HANDLE handles[] = { m_taskHandle, m_eventHandle };

                result = ::WaitForMultipleObjects(2, handles, false, INFINITE);
            } else {
                result = ::WaitForSingleObject(m_taskHandle, INFINITE);
            }
            locker.relock();

            if (result == WAIT_OBJECT_0 + 1) {
                graphEvent(&locker);
            }
        }

        if (m_pendingTasks & ReleaseGraph) {
            m_pendingTasks ^= ReleaseGraph;
            m_executingTask = ReleaseGraph;

            doReleaseGraph(&locker);
        } else if (m_pendingTasks & Shutdown) {
            return;
        } else if (m_pendingTasks & ReleaseAudioOutput) {
            m_pendingTasks ^= ReleaseAudioOutput;
            m_executingTask = ReleaseAudioOutput;

            doReleaseAudioOutput(&locker);
        } else if (m_pendingTasks & ReleaseVideoOutput) {
            m_pendingTasks ^= ReleaseVideoOutput;
            m_executingTask = ReleaseVideoOutput;

            doReleaseVideoOutput(&locker);
        } else if (m_pendingTasks & SetUrlSource) {
            m_pendingTasks ^= SetUrlSource;
            m_executingTask = SetUrlSource;

            doSetUrlSource(&locker);
        } else if (m_pendingTasks & SetStreamSource) {
            m_pendingTasks ^= SetStreamSource;
            m_executingTask = SetStreamSource;

            doSetStreamSource(&locker);
        } else if (m_pendingTasks & Render) {
            m_pendingTasks ^= Render;
            m_executingTask = Render;

            doRender(&locker);
        } else if (!(m_executedTasks & Render)) {
            m_pendingTasks &= ~(FinalizeLoad | SetRate | Stop | Pause | Seek | Play);
        } else if (m_pendingTasks & FinalizeLoad) {
            m_pendingTasks ^= FinalizeLoad;
            m_executingTask = FinalizeLoad;

            doFinalizeLoad(&locker);
        } else if (m_pendingTasks & Stop) {
            m_pendingTasks ^= Stop;
            m_executingTask = Stop;

            doStop(&locker);
        } else if (m_pendingTasks & SetRate) {
            m_pendingTasks ^= SetRate;
            m_executingTask = SetRate;

            doSetRate(&locker);
        } else if (m_pendingTasks & Pause) {
            m_pendingTasks ^= Pause;
            m_executingTask = Pause;

            doPause(&locker);
        } else if (m_pendingTasks & Seek) {
            m_pendingTasks ^= Seek;
            m_executingTask = Seek;

            doSeek(&locker);
        } else if (m_pendingTasks & Play) {
            m_pendingTasks ^= Play;
            m_executingTask = Play;

            doPlay(&locker);
        }
        m_executingTask = 0;
    }
}
task main ()
{
	ubyte type;
	ubyte ID;
	ubyte state;
	ubyte value;
	string dataString;
	string tmpString;

	// initialise the port, etc
	RS485initLib();

	StartTask(updateScreen);

	// Disconnect if already connected
	N2WDisconnect();
	N2WchillOut();
	wait1Msec(1000);
  if (!N2WCustomExist())
  {
    StopTask(updateScreen);
    wait1Msec(50);
    eraseDisplay();
    PlaySound(soundException);
    nxtDisplayCenteredBigTextLine(1, "ERROR");
    nxtDisplayTextLine(3, "No custom profile");
    nxtDisplayTextLine(4, "configured!!");
    while(true) EndTimeSlice();
  }

  N2WLoad();

	wait1Msec(100);

	N2WConnect(true);
	connStatus = "connecting";

	while (!N2WConnected()) wait1Msec(100);
	wait1Msec(1000);

	connStatus = "connected";
	PlaySound(soundBeepBeep);

	wait1Msec(3000);
	N2WgetIP(IPaddress);

	wait1Msec(1000);
	//                123456789012345
	dataStrings[0] = "Tch | Snr | Clr";
	//                on  | 011 |   1"
	while (true)
	{
		if (N2WreadWS(type, ID, state, value))
		{
			writeDebugStreamLine("btn: %d, state: %d", ID, state);
			switch (ID)
			{
			case 1: doStraight(state); break;
			case 3: doRight(state); break;
			case 4: doStop(state); break;
			case 5: doLeft(state); break;
			case 7: doReverse(state); break;
			case 9: doAction(state); break;
			case 11: handleColour(state); break;
			default: break;
			}
		}

		// All values are only updated when they've changed.
		// This cuts backs drastically on the number of messages
		// that have to be sent to the NXT2WIFI

		// Fetch the state of the Touch Sensor
		// This value is displayed by field 0 (in0) on the page
		currTouchState = SensorBoolean[TOUCH];
		if (currTouchState != prevTouchState)
		{
		  memset(data, 0, sizeof(data));
			data[0] = (currTouchState) ? '1' : '0';
			N2WwriteWS(1, 0, data, 2);
			prevTouchState = currTouchState;
			N2WchillOut();
		}

		// Fetch the currently detected colour.
		// This value is displayed by field 1 (in1) on the page
		currDetectedColour = SensorValue[COLOUR];
		if (currDetectedColour != prevDetectedColour)
		{
			sprintf(dataString, "%d", currDetectedColour);
			memcpy(data, dataString, strlen(dataString));
			N2WwriteWS(1, 1, data, strlen(dataString));
			prevDetectedColour = currDetectedColour;
			N2WchillOut();
		}

		// Fetch the distance detected by the sonar sensor
		// This value is displayed by field 2 (in2) on the page
		currSonarDistance = SensorValue[SONAR];
		if (currSonarDistance != prevSonarDistance)
		{
			sprintf(dataString, "%d", currSonarDistance);
			memcpy(data, dataString, strlen(dataString));
			N2WwriteWS(1, 2, data, strlen(dataString));
			prevSonarDistance = currSonarDistance;
			N2WchillOut();
		}

		// Fetch the tacho count for motor A
		// This value is displayed by field 3 (in3) on the page
		currEncMotorA = nMotorEncoder[MOT_ACTION];
		if (currEncMotorA != prevEncMotorA)
		{
			sprintf(dataString, "%d", currEncMotorA);
			memcpy(data, dataString, strlen(dataString));
			N2WwriteWS(1, 3, data, strlen(dataString));
			prevEncMotorA = currEncMotorA;
			N2WchillOut();
		}

		// Fetch the tacho count for motor B
		// This value is displayed by field 4 (in4) on the page
		//currEncMotorB = nMotorEncoder[MOT_LEFT];
		if (currEncMotorB != prevEncMotorB)
		{
			sprintf(dataString, "%d", currEncMotorB);
			memcpy(data, dataString, strlen(dataString));
			N2WwriteWS(1, 4, data, strlen(dataString));
			prevEncMotorB = currEncMotorB;
			N2WchillOut();
		}

		// Fetch the tacho count for motor C
		// This value is displayed by field 5 (in5) on the page
		currEncMotorC = nMotorEncoder[MOT_RIGHT];
		if (currEncMotorC != prevEncMotorC)
		{
			sprintf(dataString, "%d", currEncMotorC);
			memcpy(data, dataString, strlen(dataString));
			N2WwriteWS(1, 5, data, strlen(dataString));
			prevEncMotorC = currEncMotorC;
			N2WchillOut();
		}

		// Fetch the current voltage level.  The average one
		// works best, the other one jumps around too much.
		// This value is displayed by field 6 (in6) on the page

		currBatteryLevel = nAvgBatteryLevel;
		if (currBatteryLevel != prevBatteryLevel)
		{
			sprintf(dataString, "%d", currBatteryLevel);
			memcpy(data, dataString, strlen(dataString));
			N2WwriteWS(1, 6, data, strlen(dataString));
			prevBatteryLevel = currBatteryLevel;
			N2WchillOut();
		}

		sprintf(dataStrings[2], "A: %d", currEncMotorA);
		sprintf(dataStrings[3], "B: %d", currEncMotorB);
		sprintf(dataStrings[4], "C: %d", currEncMotorC);
	  sprintf(tmpString, "%s | %3d", (currTouchState == 0) ? "off" : "on ", currSonarDistance);
		sprintf(dataStrings[1], "%s | %3d", tmpString, currDetectedColour);
	}
}
Exemplo n.º 29
0
void QgsWFSFeatureDownloader::stop()
{
  QgsDebugMsg( "QgsWFSFeatureDownloader::stop()" );
  mStop = true;
  emit doStop();
}
Exemplo n.º 30
0
CZeroconfOSX::~CZeroconfOSX()
{
  doStop();
}