Esempio n. 1
0
void
AutoQNH::Process(const NMEAInfo &basic, DerivedInfo &calculated,
                 const ComputerSettings &settings_computer, const Waypoints &way_points)
{
    if (!calculated.flight.on_ground // must be on ground
            || IsFinished()    // only do it once
            || !basic.gps.real // never in replay mode / simulator
            || !basic.location_available // Reject if no valid GPS fix
            || !basic.static_pressure_available // Reject if no pressure
            || settings_computer.pressure_available // Reject if QNH already known
       ) {
        if (!IsFinished())
            Reset(); // restart if havent performed

        return;
    }

    if (!IsFinished())
        countdown_autoqnh--;

    if (!countdown_autoqnh) {
        if (CalculateQNH(basic, calculated, way_points))
            countdown_autoqnh = UINT_MAX; // disable after performing once
        else
            Reset();
    }
}
void Video::Update(int delta)
{
    if (IsFinished())
    {
        return;
    }

    pCurFrame->Update(delta);

    while (!IsFinished() && pCurFrame->GetIsFinished())
    {
        MoveToNextFrame();
    }
}
Esempio n. 3
0
uint32 FMidiProcessorWorker::Run() {
	UWorld* world = GEngine->GameViewport->GetWorld();
	if (!world)
		return 0;

	if (this->isGameTime) {
		ThePC->start(world->TimeSeconds * 1000.0f);
	}
	else {
		ThePC->start(FPlatformTime::Cycles());
	}

	while (!IsFinished())
	{
		if (isGameTime)
			ThePC->update(world->TimeSeconds * 1000.0f);
		else
			ThePC->update(FPlatformTime::Cycles());
		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		//prevent thread from using too many resources
		FPlatformProcess::Sleep(0.008f);
		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	}
	return 0;
}
void HorizontalAlign::UsePIDOutput(double output)
{
	if (GetPIDController()->OnTarget())
	{
		onTargetCounter++;
	}
	else
	{
		onTargetCounter = 0;
	}
	SmartDashboard::PutNumber("OnTarget Counter", onTargetCounter);

	printf("%f", output);

	if (output > 0)
		output += ROT_SPEED_MIN;
	else if (output < 0)
		output -= ROT_SPEED_MIN;

	if (!PIDUserDisabled && !IsFinished())
		Robot::drivetrain->SetTankDrive(output, -output);
	//printf("\noutput");

	SmartDashboard::PutNumber("AutoAlign Output", output);

	printf("wowowow %f, %u\n" , output, PIDUserDisabled);
}
Esempio n. 5
0
void VoiceCall::SetState(int aState)
{
	if (state == aState)
		return;

	if (aState == VOICE_STATE_RINGING)
		incoming = true;
	else if (aState == VOICE_STATE_CALLING)
		incoming = false;

	RemoveNotifications();

	state = aState;

	if (IsFinished())
	{
		if (end_time == 0)
			end_time = GetTickCount();

		// Remove id because providers can re-use them
		mir_free(id);
		id = NULL;
	}

	Notify();
}
void CTReadWrite::ReadWriteImageL()
    {
    ReadImageFuncL();

    TBool ret = EFalse; 
    for(TInt i=0; i<iBufferSize; i++)
        {
        if(iData[i] == iInitialColour)
            {
            iData[i] = iFinalColour;
            WriteImageFuncL();

            //Re-issue the request
            After(TTimeIntervalMicroSeconds32(0));
            
            ret = ETrue;
            break;
            }
        else if(iData[i] != iFinalColour)
            {
            CActiveScheduler::Stop();
            iTestPass = EFalse;
            
            ret = ETrue;
            break;
            }
        }

    //If no pixels have been modified, check to see if the test should finish
    if( (IsFinished() != EFalse) && (ret == EFalse) )
        {
        //Stop the active scheduler and process with test termination
        CActiveScheduler::Stop();
        }
    }
Esempio n. 7
0
bool
WheelScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta)
{
  TimeStamp now = AsyncPanZoomController::GetFrameTime();
  CSSToParentLayerScale2D zoom = aFrameMetrics.GetZoom();

  // If the animation is finished, make sure the final position is correct by
  // using one last displacement. Otherwise, compute the delta via the timing
  // function as normal.
  bool finished = IsFinished(now);
  nsPoint sampledDest = finished
                        ? mDestination
                        : PositionAt(now);
  ParentLayerPoint displacement =
    (CSSPoint::FromAppUnits(sampledDest) - aFrameMetrics.GetScrollOffset()) * zoom;

  // Note: we ignore overscroll for wheel animations.
  ParentLayerPoint adjustedOffset, overscroll;
  mApzc.mX.AdjustDisplacement(displacement.x, adjustedOffset.x, overscroll.x);
  mApzc.mY.AdjustDisplacement(displacement.y, adjustedOffset.y, overscroll.y,
                              !aFrameMetrics.AllowVerticalScrollWithWheel());

  // If we expected to scroll, but there's no more scroll range on either axis,
  // then end the animation early. Note that the initial displacement could be 0
  // if the compositor ran very quickly (<1ms) after the animation was created.
  // When that happens we want to make sure the animation continues.
  if (!IsZero(displacement) && IsZero(adjustedOffset)) {
    // Nothing more to do - end the animation.
    return false;
  }

  aFrameMetrics.ScrollBy(adjustedOffset / zoom);
  return !finished;
}
Esempio n. 8
0
	/// <summary>
	/// Gets the reward.
	/// </summary>
	/// <param name="token">The token.</param>
	/// <returns></returns>
	int CBoard::GetReward(char token) const
	{
		if (!IsFinished())return 0;
		if (_winner == token)return WIN;
		if (_winner == SPACE)return DRAW;
		return LOSE;
	}
Esempio n. 9
0
csp::WorkResult::Enum csp::OpTestSuite_RunAll::Evaluate( Host& host )
{
    if( m_pCurrentClosure )
    {
        if( m_pCurrentClosure->process.IsRunning() )
            return WorkResult::YIELD;
        else
        {
            if( m_pCurrentClosure->refKey != lua::LUA_NO_REF )
                UnrefClosure( m_pCurrentClosure );

            delete m_pCurrentClosure;
            m_pCurrentClosure = NULL;
        }
    }

    if( m_pCurrentClosure == NULL && m_pClosuresHead )
    {
        TestClosure* pClosure = ListPopFromHead( m_pClosuresHead, m_pClosuresTail );
        CORE_ASSERT( pClosure );

        lua::Print( "Running test %s.%s...\n", pClosure->suiteName, pClosure->functionName );

        m_pCurrentClosure = pClosure;

        pClosure->process.StartEvaluation( host, 0 );
    }

    return IsFinished();
}
bool
WheelScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta)
{
  TimeStamp now = AsyncPanZoomController::GetFrameTime();
  CSSToParentLayerScale2D zoom = aFrameMetrics.GetZoom();

  // If the animation is finished, make sure the final position is correct by
  // using one last displacement. Otherwise, compute the delta via the timing
  // function as normal.
  bool finished = IsFinished(now);
  nsPoint sampledDest = finished
                        ? mDestination
                        : PositionAt(now);
  ParentLayerPoint displacement =
    (CSSPoint::FromAppUnits(sampledDest) - aFrameMetrics.GetScrollOffset()) * zoom;

  // Note: we ignore overscroll for wheel animations.
  ParentLayerPoint adjustedOffset, overscroll;
  mApzc.mX.AdjustDisplacement(displacement.x, adjustedOffset.x, overscroll.x);
  mApzc.mY.AdjustDisplacement(displacement.y, adjustedOffset.y, overscroll.y,
                              !aFrameMetrics.AllowVerticalScrollWithWheel());
  if (IsZero(adjustedOffset)) {
    // Nothing more to do - end the animation.
    return false;
  }

  aFrameMetrics.ScrollBy(adjustedOffset / zoom);
  return !finished;
}
Esempio n. 11
0
void OpenALSound::OnResume()
{
	if (!IsFinished())
	{
		alSourcePlay(source);
		check_openal_error();
	}
}
Esempio n. 12
0
void OpenALSound::OnPause()
{
	if (!IsFinished())
	{
		alSourcePause(source);
		check_openal_error();
	}
}
Esempio n. 13
0
void Video::Draw(Vector2 position, bool flipHorizontally, Color color, RectangleWH clipRect)
{
    if (IsFinished())
    {
        return;
    }

    Image::Draw(pTexture, position, clipRect, flipHorizontally, false /* flipVertically */, 1.0 /* scale */, color);
}
Esempio n. 14
0
void DispBoard2(const BOARD *Board, const int Forbidden[]) {

   int Time, Rank, File, Square;
   static const char *Colour[] = { "Black", "?!?!?", "White" };

   Time = 0;

   if (Board == Game->Board) {
      Time = (int) ElapsedTime[0];
      if (Time < 0) Time = 0;
   }
   printf("\n  A B C D E F G H         %02d:%02d:%02d\n",Time/3600,(Time%3600)/60,Time%60);
   for (Rank = 0, Square = A1; Rank < 8; Rank++, Square++) {
      printf("%d ",Rank+1);
      for (File = 0; File < 8; File++, Square++) {
         board.Square[Rank][File].Colour = Board->Square[Square];
         if (Forbidden != NULL && Forbidden[Square]) {
            printf("= ");
            strcpy(board.Square[Rank][File].String,"#");
         } else if (IsLegalMove(Board,Square)) {
            printf(". ");
            strcpy(board.Square[Rank][File].String,"*");
         } else {
            printf("%c ","*-O"[Board->Square[Square]+1]);
            strcpy(board.Square[Rank][File].String,"");
         }
      }
      printf("%d",Rank+1);
      switch (Rank) {
         case 1 :
            printf("  %2d Disks * %2d Moves",DiskNb(Board,BLACK),Mobility(Board,BLACK));
            break;
         case 3 :
            printf("      %2d Empties",EmptyNb(Board));
            break;
         case 4 :
            if (IsFinished(Board)) {
               printf("      Game ended");
            } else {
               printf("     %s's Turn",Colour[Board->Colour+1]);
            }
            break;
         case 6 :
            printf("  %2d Disks O %2d Moves",DiskNb(Board,WHITE),Mobility(Board,WHITE));
            break;
      }
      printf("\n");
   }
   if (Board == Game->Board) {
      Time = (int) ElapsedTime[1];
      if (Time < 0) Time = 0;
   }
   printf("  A B C D E F G H         %02d:%02d:%02d\n\n",Time/3600,(Time%3600)/60,Time%60);

   board.Colour = Board->Colour;
   DispXBoard();
}
Esempio n. 15
0
csp::WorkResult::Enum csp::OpTestSuite_RunAll::Work( Host& host, CspTime_t dt )
{
    if( m_pCurrentClosure )
    {
        if( m_pCurrentClosure->process.IsRunning() )
            m_pCurrentClosure->process.Work( host, dt );
    }

    return IsFinished();
}
Esempio n. 16
0
void Video::MoveToNextFrame()
{
    double overflowDuration = pCurFrame->GetOverflowDuration();
    curFrameIndex++;

    if (IsFinished() && shouldLoop)
    {
        curFrameIndex = 0;
        av_seek_frame(pFormatContext, videoStream, 0, AVSEEK_FLAG_ANY);
    }

    if (!IsFinished())
    {
        pCurFrame = frameList[curFrameIndex];
        pCurFrame->Begin(overflowDuration);

        WriteNextFrame();
    }
}
Esempio n. 17
0
bool
Element::IsStatic() const
{
	if (IsSquadron() || IsFinished())
	return false;

	const Ship* s = ships.at(0);
	if (s && s->IsStatic())
	return true;

	return false;
}
Esempio n. 18
0
void
Animation::UpdateFinishedState(bool aSeekFlag)
{
  Nullable<TimeDuration> currentTime = GetCurrentTime();
  TimeDuration effectEnd = TimeDuration(EffectEnd());

  if (!mStartTime.IsNull() &&
      mPendingState == PendingState::NotPending) {
    if (mPlaybackRate > 0.0 &&
        !currentTime.IsNull() &&
        currentTime.Value() >= effectEnd) {
      if (aSeekFlag) {
        mHoldTime = currentTime;
      } else if (!mPreviousCurrentTime.IsNull()) {
        mHoldTime.SetValue(std::max(mPreviousCurrentTime.Value(), effectEnd));
      } else {
        mHoldTime.SetValue(effectEnd);
      }
    } else if (mPlaybackRate < 0.0 &&
               !currentTime.IsNull() &&
               currentTime.Value().ToMilliseconds() <= 0.0) {
      if (aSeekFlag) {
        mHoldTime = currentTime;
      } else {
        mHoldTime.SetValue(0);
      }
    } else if (mPlaybackRate != 0.0 &&
               !currentTime.IsNull()) {
      if (aSeekFlag && !mHoldTime.IsNull()) {
        mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
                              (mHoldTime.Value().MultDouble(1 / mPlaybackRate)));
      }
      mHoldTime.SetNull();
    }
  }

  bool currentFinishedState = IsFinished();
  if (currentFinishedState && !mIsPreviousStateFinished) {
    if (mFinished) {
      mFinished->MaybeResolve(this);
    }
  } else if (!currentFinishedState && mIsPreviousStateFinished) {
    // Clear finished promise. We'll create a new one lazily.
    mFinished = nullptr;
    if (mEffect->AsTransition()) {
      mEffect->SetIsFinishedTransition(false);
    }
  }
  mIsPreviousStateFinished = currentFinishedState;
  // We must recalculate the current time to take account of any mHoldTime
  // changes the code above made.
  mPreviousCurrentTime = GetCurrentTime();
}
Esempio n. 19
0
csp::WorkResult::Enum csp::OpAlt::Work( Host& host, CspTime_t dt )
{
	if( m_pCaseTriggered )
	{
		if( m_process.IsRunning() )
			m_process.Work( host, dt );
	}
	else
		SelectTimeProcessToTrigger( host );

	return IsFinished() ? WorkResult::FINISH : WorkResult::YIELD;
}
Esempio n. 20
0
//============================================================================
//		NSocketRequest::GetUnprocessedData : Get the unprocessed data.
//----------------------------------------------------------------------------
UInt8 *NSocketRequest::GetUnprocessedData(void)
{


	// Validate our state
	NN_ASSERT(!IsFinished());



	// Get the data
	return(mData.GetData(mProcessed));
}
Esempio n. 21
0
//============================================================================
//		NSocketRequest::GetData : Get the data.
//----------------------------------------------------------------------------
NData NSocketRequest::GetData(void) const
{


	// Validate our state
	NN_ASSERT(IsFinished());
	
	
	
	// Get the data
	return(mData);
}
Esempio n. 22
0
Promise*
Animation::GetFinished(ErrorResult& aRv)
{
  if (!mFinished) {
    mFinished = CreatePromise(mTimeline, aRv); // Lazily create on demand
  }
  if (!mFinished) {
    aRv.Throw(NS_ERROR_FAILURE);
  } else if (IsFinished()) {
    mFinished->MaybeResolve(this);
  }
  return mFinished;
}
Esempio n. 23
0
//============================================================================
//		NSocketRequest::ProcessedData : Mark data as having been processed.
//----------------------------------------------------------------------------
void NSocketRequest::ProcessedData(NIndex theSize)
{


	// Validate our state
	NN_ASSERT(!IsFinished());
	
	
	
	// Process the data
	mProcessed += theSize;
	NN_ASSERT(mProcessed <= mData.GetSize());
}
Esempio n. 24
0
f32 OpenALSound::GetPlayPosition()
{
	if (IsFinished())
		return 0.0;
	
    ALfloat playPosition = 0.0;
    alGetSourcef(source, AL_SEC_OFFSET, &playPosition);
    
    if (check_openal_error())
		return 0.0;
	
	return playPosition;
}
Esempio n. 25
0
void Torch::Update(Level& level, const sf::Time& timePassed)
{
	light.Update(level);
	if(IsActive() && !IsFinished()) {
		light.Toggle();
		isActive = false;
	}

	if(light.GetIsOn()) {
		PlayAnim("on", timePassed);
	} else {
		PlayAnim("idle", timePassed);
	}
}
Esempio n. 26
0
bool
Element::IsHostileTo(int iff_code) const
{
	if (iff <= 0 || iff >= 100 || launch_time == 0 || IsFinished())
	return false;

	if (IsSquadron())
	return false;

	if (iff_code <= 0 || iff_code >= 100 || iff_code == iff)
	return false;

	return true;
}
Esempio n. 27
0
	/// <summary>
	/// Sets the square if available.
	/// </summary>
	/// <param name="token">The token.</param>
	/// <param name="position">The position.</param>
	/// <returns>Success or fail</returns>
	bool CBoard::SetSquare(char token, unsigned int position)
	{
		if (IsFinished()) return false;

		if (position < _current_state.size() && SPACE == _current_state.at(position))
		{
			_current_state[position] = token;

			Check();

			return true;
		}

		return false;
	}
Esempio n. 28
0
void Video::Finish()
{
    unsigned int lastFrameIndex = curFrameIndex;

    while (!IsFinished() && !pCurFrame->GetIsForever())
    {
        MoveToNextFrame();

        // If we've looped all the way around, then we know that finishing is impossible,
        // so we'll exit.
        if (lastFrameIndex == curFrameIndex)
        {
            break;
        }
    }
}
FMODSoundInstance::~FMODSoundInstance()
{
	if( !IsFinished() )
	{
		Stop();
	}

	// Delete the corresponding sound iff it's a stream (incidentally, stream sounds
	// only get automatically deleted if they're ever actually played).
	if( GetSound()->GetIsStream() )
	{
		SafeDelete( m_Sound );
	}

	m_Channel = NULL;
}
Esempio n. 30
0
//============================================================================
//		NSocketRequest::GetUnprocessedSize : Get the unprocessed size.
//----------------------------------------------------------------------------
NIndex NSocketRequest::GetUnprocessedSize(void) const
{	NIndex	theSize;



	// Validate our state
	NN_ASSERT(!IsFinished());
	
	
	
	// Get the size
	theSize = mData.GetSize() - mProcessed;
	NN_ASSERT(theSize >= 1);
	
	return(theSize);
}