• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ChangeState函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ChangeState函数的典型用法代码示例。如果您正苦于以下问题:C++ ChangeState函数的具体用法?C++ ChangeState怎么用?C++ ChangeState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ChangeState函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetAccountFromSender

	void AccountActionsManager::handleChangeStatusRequested ()
	{
		auto action = qobject_cast<QAction*> (sender ());
		const auto acc = GetAccountFromSender (sender (), Q_FUNC_INFO);

		QVariant stateVar = action->property ("Azoth/TargetState");
		EntryStatus status;
		if (!stateVar.isNull ())
		{
			const auto state = stateVar.value<State> ();
			status = EntryStatus (state, GetStatusText (action, state));
		}
		else
		{
			SetStatusDialog ssd (acc->GetAccountID ());
			if (ssd.exec () != QDialog::Accepted)
				return;

			status = EntryStatus (ssd.GetState (), ssd.GetStatusText ());
		}

		acc->ChangeState (status);
	}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:23,代码来源:accountactionsmanager.cpp


示例2: ChangeState

void Engine::Update()
{
	DeltaTime = m_DeltaTimer.restart();
	TotalDeltaTime += DeltaTime;

	if(m_QueuedState != nullptr)
		ChangeState();

	while(m_DisplayWindow.pollEvent(EventHandle))
	{
		if(EventHandle.type == sf::Event::KeyPressed && EventHandle.key.code == sf::Keyboard::Return && EventHandle.key.alt)
		{
			VID_FLAGS ^= sf::Style::Fullscreen;
			m_DisplayWindow.create(sf::VideoMode(RESOLUTION.x, RESOLUTION.y), WINDOW_TITLE, VID_FLAGS);
		}

		if (EventHandle.type == sf::Event::Closed)
			Quit();
	}

	if(m_CurrentState != nullptr)
		m_CurrentState->Update(DeltaTime);
}
开发者ID:DafuqStudios,项目名称:Life-In-Hjarnarp,代码行数:23,代码来源:Engine.cpp


示例3: __ASSERT_DEBUG

void CBTHidConnection::OfferControlSocket(const TBTDevAddr& aAddress,
        RSocket*& aSocket)
    {
        TRACE_FUNC
    (_L("[BTHID]\tCBTHidConnection::OfferControlSocket"));
    if (aAddress == iDevice->iAddress)
        {
        __ASSERT_DEBUG((iConnectionState == ELinkLost) || (iConnectionState == EHIDInitConnecting) ||
                (iConnectionState == EHIDReconnecting),
                User::Panic(KPanicBTConnection, ESocketsBadState));

        // Take ownership of this socket
        delete iControlSocket;
        iControlSocket = aSocket;
        aSocket = 0;

        // Mark that the HID Device is reconnecting to us. Skip the state change if an initial connection from HID device. 
        if (iConnectionState != EHIDInitConnecting) 
            {
            ChangeState(EHIDReconnecting);
            }
        }
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:23,代码来源:bthidconnection.cpp


示例4: SetDragState

void TCompGuiDrag::Over()
{
	if (checkEnabled()) {
		if (checkOver()) {
			if (controller->IsGuiItemDragged()) {
				SetDragState(Clicked);
			}
			else render_state = RSTATE_OVER;
			if (controller->IsLeftPressed()) {
				SetValue(value - 0.1f);
				notifyValue();
			}
			else if (controller->IsRightPressed()) {
				SetValue(value + 0.1f);
				notifyValue();
			}
		}
		else {
			ChangeState(STRING(Enabled));
			notifyOver(false);
		}
	}
}
开发者ID:DopaminaInTheVein,项目名称:ItLightens,代码行数:23,代码来源:gui_drag.cpp


示例5: ChangeState

void MyWorld::TakenTurn()
{
    TurnsLeft--;
    if (TurnsLeft < 0)
    {
        // Play end of round music
        Audio::PlayMusic("game_over.mp3", false);

        // Game over
        ChangeState(eGameState_GameOver);
    }
    else
        TurnsLeftChanged = true;

    if (HasWon())
    {
        // Play end of round music
        Audio::PlayMusic("end_round.mp3", false);

        // Next round
        NextRound();
    }
}
开发者ID:AbrahamKO,项目名称:gbsgamejam,代码行数:23,代码来源:MyWorld.cpp


示例6: if

void CAICoreEvent::Update(float _fTime)
{
	if( !m_pCurrState )
		return;

	if( m_pCurrState->Update(_fTime) )
	{
		IAIState* pNewState = nullptr;
		
		if( m_pCurrState == &m_cLaserPhase )
		{
			m_pTower->SetShieldActive(false);
			pNewState = &m_cTurretPhase;
		}
		else if( m_pCurrState == &m_cTurretPhase )
			pNewState = &m_cCoreFight;
		
		if( pNewState )
			ChangeState(pNewState);
		else
			CGame::GetInstance()->GetOF()->StopEvent(this);
	}
}
开发者ID:ianalcid08,项目名称:FinalProject,代码行数:23,代码来源:AICoreEvent.cpp


示例7: ChangeState

void PhoenixEngine::ToggleLoading(bool bToggle)
{
	sf::Context Cont;
	if(m_LoadingState != nullptr)
	{
		if(bToggle)
		{
			bLoading = true;
			m_QueuedState = m_LoadingState;
			ChangeState();
			m_DisplayWindow.setActive(false); //Give thread access to window context
			sf::sleep(sf::milliseconds(100));
			m_AsyncThread.launch();
		}
		else
		{
			bLoading = false;
			m_AsyncThread.wait();
			sf::sleep(sf::milliseconds(100));
			m_DisplayWindow.setActive(true);
		}
	}
}
开发者ID:MasterKenth,项目名称:Mugito,代码行数:23,代码来源:PhoenixEngine.cpp


示例8: AddState

void CThrowBomb::onCreate(const TMsgEntityCreated& msg) {
	if (statemap.empty()) {
		//Specific Bomb nodes
		AddState("born", (statehandler)&CThrowBomb::Born);
		AddState("idle", (statehandler)&CThrowBomb::Idle);
		AddState("throwing", (statehandler)&CThrowBomb::Throwing);
		AddState("throwed", (statehandler)&CThrowBomb::Throwed);
		AddState("impacted", (statehandler)&CThrowBomb::Impacted);
		AddState("explode", (statehandler)&CThrowBomb::Explode);
		AddState("dead", (statehandler)&CThrowBomb::Dead);
	}
	____TIMER_REDEFINE_(t_explode, 2.5f);
	ChangeState("born");
#ifdef CALIBRATE_GAME
	if (calibrate) {
		lmax = lmax_st;
		hmax = hmax_st;
		speed = speed_st;
		t_explode = timer_st;
		rad_squared = powf(radius_st, 2.f);
	}
#endif
}
开发者ID:DopaminaInTheVein,项目名称:ItLightens,代码行数:23,代码来源:throw_bomb.cpp


示例9: if

void TodoList::on_confirmButton_clicked(){
    QString name = ui->nameBox->text();
    if(name.size() == 0){
        warnAniTime = 30;
        return;
    }

    TodoItem item;

    item.SetName(name.toStdString());
    item.SetPlace(ui->placeBox->text().toStdString());
    item.SetContent(ui->contentBox->toPlainText().toStdString());
    item.SetLabel(ui->labelBox->text().toStdString());

    item.SetKind(ui->comboBox->currentIndex());

    QDateTime dateTime = ui->dateTimeEdit->dateTime();
    QDate date = dateTime.date();
    QTime ti = dateTime.time();
    item.SetTime(Date(date.year(),date.month(),date.day(),ti.hour(),ti.minute()));
    item.SetWarnTime(ui->horizontalSlider->value() * 5); //以分为单位

    int level = 0;
    if (ui->radioButton_1->isChecked()) level = 3;
    if (ui->radioButton_2->isChecked()) level = 1;
    if (ui->radioButton_3->isChecked()) level = 2;
    if (ui->radioButton_4->isChecked()) level = 0;
    item.SetLevel(level);

    if(state == WINSTATE::EDIT){
        pa.AddTodo(item);
    }else if(state == WINSTATE::DETAIL){
        pa.ChangeTodo(item,selectID,viewDate.year,viewDate.month);
    }

    ChangeState(WINSTATE::LIST);
}
开发者ID:wkcn,项目名称:TodoList,代码行数:37,代码来源:TodoList.cpp


示例10: newPlaygroup

/**
 * \brief determine initial tv state and playgroup for the recording
 * \param islivetv: true if recording is livetv
 */
void PlayerContext::SetInitialTVState(bool islivetv)
{
    TVState newState = kState_None;
    QString newPlaygroup("Default");

    LockPlayingInfo(__FILE__, __LINE__);
    if (islivetv)
    {
        SetTVChain(new LiveTVChain());
        newState = kState_WatchingLiveTV;
    }
    else if (playingInfo)
    {
        int overrecordseconds = gCoreContext->GetNumSetting("RecordOverTime");
        QDateTime curtime = MythDate::current();
        QDateTime recendts = playingInfo->GetRecordingEndTime()
            .addSecs(overrecordseconds);

        if (playingInfo->IsRecording())
        {
            newState = (curtime < recendts) ?
                kState_WatchingRecording : kState_WatchingPreRecorded;
        }
        else if (playingInfo->IsVideoDVD())
            newState = kState_WatchingDVD;
        else if (playingInfo->IsVideoBD())
            newState = kState_WatchingBD;
        else
            newState = kState_WatchingVideo;

        newPlaygroup = playingInfo->GetPlaybackGroup();
    }
    UnlockPlayingInfo(__FILE__, __LINE__);

    ChangeState(newState);
    SetPlayGroup(newPlaygroup);
}
开发者ID:aravilife,项目名称:mythtv-stabilize2,代码行数:41,代码来源:playercontext.cpp


示例11: SetupZilla

int
SetupZilla(short SpriteNum)
{
    SPRITEp sp = &sprite[SpriteNum];
    USERp u;
    ANIMATOR DoActorDecide;

    if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE))
    {
        u = User[SpriteNum];
        ASSERT(u);
    }
    else
    {
        User[SpriteNum] = u = SpawnUser(SpriteNum,ZILLA_RUN_R0,s_ZillaRun[0]);
        u->Health = 6000;
    }

    if (Skill == 0) u->Health = 2000;
    if (Skill == 1) u->Health = 4000;

    ChangeState(SpriteNum,s_ZillaRun[0]);
    u->Attrib = &ZillaAttrib;
    DoActorSetSpeed(SpriteNum, NORM_SPEED);
    u->StateEnd = s_ZillaDie;
    u->Rot = sg_ZillaRun;

    EnemyDefaults(SpriteNum, &ZillaActionSet, &ZillaPersonality);

    sp->clipdist = (512) >> 2;
    sp->xrepeat = 97;
    sp->yrepeat = 79;

    //SET(u->Flags, SPR_XFLIP_TOGGLE);

    return 0;
}
开发者ID:SilkyPantsDan,项目名称:eduke32,代码行数:37,代码来源:zilla.c


示例12: ChangeState

//*********************************************************************//
// Terminate
//	- exit the current state
//	- terminate the SGD wrappers
void Game::Terminate( void )
{
	// Exit the current state
	ChangeState( nullptr );


	// Terminate & Deallocate the font
	if( m_pFont != nullptr )
	{
		m_pFont->Terminate();
		delete m_pFont;
	}

	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hMainMenuBackground);
	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hPlayerImg);
	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hEnemyImg);

	
	// unloads audio
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hProjectileSecSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hBackgroundMus);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hEnemyHitSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hGameOverSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hGameWinSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hMenuChangeSfx);

	// Terminate the SGD wrappers (in reverse order)
	SGD::AudioManager::GetInstance()->Terminate();
	SGD::AudioManager::DeleteInstance();
	
	SGD::InputManager::GetInstance()->Terminate();
	SGD::InputManager::DeleteInstance();
	
	SGD::GraphicsManager::GetInstance()->Terminate();
	SGD::GraphicsManager::DeleteInstance();
}
开发者ID:evalottaw,项目名称:StardustCrusader,代码行数:40,代码来源:Game.cpp


示例13: ChangeState

void MyCharacter::OnEvent(const irr::SEvent & e)
{	
	
	//键盘事件
	if (e.EventType == EET_KEY_INPUT_EVENT) {
 
		   if ( 
		   //按X 切换 站立 攻击准备模式
			if (e.KeyInput.Key == KEY_KEY_X && e.KeyInput.PressedDown==false) { 
			   ChangeState();
		    }
		   
			//按R 切换跑步走路 模式
			if (e.KeyInput.Key == KEY_KEY_R && e.KeyInput.PressedDown==false) { 
				ChangeRunMode();
		    }

			//按空格,捡物品
			if (e.KeyInput.Key == KEY_SPACE && e.KeyInput.PressedDown==false) { 
				CollectDropItem();
			}


			//按Q 使用包裹里的MP恢复药
			if (e.KeyInput.Key == KEY_KEY_Q && e.KeyInput.PressedDown==false) { 

				//请求使用装备包裹里的消耗品
				property.cmd=CMD_C2S_Request_UsePackageHPItem;
				
				cnet->SendMsg((char*)&property,sizeof(RoleProperty));
			}


	}
	
}
开发者ID:zhouyige,项目名称:3drpgdemo,代码行数:36,代码来源:MyCharacter.cpp


示例14: ELOG1

void CMMAVideoPlayer::CompletePrefetch(TInt aError)
{
    ELOG1(EJavaMMAPI,  "CMMAVideoPlayer::CompletePrefetch + error = %d",aError);
    // Post KNotCompleteVideoError as KErrNone to the Java side, because
    // video can be played.
    if (aError == KNotCompleteVideoError)
    {
        LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::CompletePrefetch  KNotCompleteVideoError ");
        // release java
        PostActionCompleted(KErrNone);
    }
    else
    {
        LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::CompletePrefetch  CompleteVideoError ");
        // release java
        PostActionCompleted(aError);
    }

    if (aError == KErrNone || aError == KNotCompleteVideoError)
    {
        ChangeState(EPrefetched);
    }
    LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::CompletePrefetch - ");
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:24,代码来源:cmmavideoplayer.cpp


示例15: ChatchChange

//=====================================================================================
//
//	* Function : ChatchChange()
//	* Description 
//		이 함수는 WM_SPOOF에서 List View에 문자열들중 해당구조체가 어느 인덱스를 가지는지
//		출력하는 함수이다.
//		두번째 인자로 받는 포인터에 있는 자료구조의 내용을 사용하고 세번째 인자로 
//		PSPOOF_L자료구조 링크시스트의 헤더를 받도록 약속되어있다.
//
//=====================================================================================
INT ChatchChange(HWND hWnd, PSPOOF_L ARP_LIST, PSPOOF_L HEAD)
{
	INT index=-1;
	INT flag = 0;
	PSPOOF_L tmp=HEAD;
	while(tmp!=NULL)
	{
		index++;
		if(memcmp(ARP_LIST->ipAddr,tmp->ipAddr,4)==0)
			break;
		tmp=tmp->next;
	}

	//scan flag changed
	
	ChangeState();
	InvalidateRect(hC2,NULL,TRUE);
	SendMessage(hC2,WM_PAINT,0,0);
	
	InvalidateRect(hC3,NULL,TRUE);
	SendMessage(hC3,WM_PAINT,0,0);

	return index;
}
开发者ID:JeoKim224,项目名称:ziARP,代码行数:34,代码来源:GUI_Right.cpp


示例16: EvaluateTurnBw

/*!
 * \brief Performs a turn while doing backward line following.
 * \return Returns TRUE while turn is still in progress.
 */
static uint8_t EvaluateTurnBw(void) {
  REF_LineKind historyLineKind, currLineKind;
  TURN_Kind turn;
  
  REF_ClearHistory(); /* clear values */
  REF_SampleHistory(); /* store current values */
  TURN_Turn(TURN_STEP_LINE_BW); /* make step over line */
  historyLineKind = REF_HistoryLineKind(); /* new read new values */
  currLineKind = REF_GetLineKind();
#if LINE_DEBUG
  REF_DumpHistory();
  CLS1_SendStr((unsigned char*)" history: ", CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)REF_LineKindStr(historyLineKind), CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)" curr: ", CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)REF_LineKindStr(currLineKind), CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
#endif
  turn = MAZE_SelectTurnBw(historyLineKind, currLineKind);
  if (turn==TURN_STOP) { /* should not happen here? */
    ChangeState(STATE_STOP);
    CLS1_SendStr((unsigned char*)"stopped\r\n", CLS1_GetStdio()->stdOut);
    return ERR_FAILED; /* error case */
  } else { /* turn or do something */
#if LINE_DEBUG
    CLS1_SendStr((unsigned char*)"bw turning ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)TURN_TurnKindStr(turn), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
#endif
    TURN_Turn(TURN_STEP_LINE_FW); /* step over intersection */
    TURN_Turn(TURN_STEP_POST_LINE_FW); /* step past intersection */
    TURN_Turn(turn); /* make turn */
    MAZE_AddPath(MirrorTurn(turn));
    MAZE_SimplifyPath();
    return ERR_OK; /* turn finished */
  }
}
开发者ID:210221030,项目名称:mcuoneclipse,代码行数:40,代码来源:LineFollow.c


示例17: LOG

void CMMAVideoPlayer::PrefetchL()
{
    LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::PrefetchL");
    if (iFileName)
    {
        // File has already been prefetched when realizing

        // If initDisplayMode was called before prefetch,
        // then the display must notified about source size.
        if (iDisplay)
        {
            SourceSizeChanged();
        }

        PostActionCompletedFile();
        ChangeState(EPrefetched);
    }
    else
    {
        // Using TDes -- load the whole video
        iSourceStreams[ 0 ]->ReadAllL();
    }
    // CMMASourceStream will notify with ReadCompleted
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:24,代码来源:cmmavideoplayer.cpp


示例18: ChangeState

void AMS_OpenBase::OnLowerLayerDown(Master* c)
{
	ChangeState(c, AMS_Closed::Inst());
}
开发者ID:diverger,项目名称:dnp3,代码行数:4,代码来源:MasterStates.cpp


示例19: HandlePlayerLeave


//.........这里部分代码省略.........
    Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius);
    Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker);
    Cell::VisitWorldObjects(m_capturePoint, searcher, radius);

    for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
    {
        Player* const player = *itr;
        if (player->IsOutdoorPvPActive())
        {
            if (m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second)
                HandlePlayerEnter(*itr);
        }
    }

    // get the difference of numbers
    float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
    if (!fact_diff)
        return false;

    uint32 Challenger = 0;
    float maxDiff = m_maxSpeed * diff;

    if (fact_diff < 0)
    {
        // horde is in majority, but it's already horde-controlled -> no change
        if (m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue)
            return false;

        if (fact_diff < -maxDiff)
            fact_diff = -maxDiff;

        Challenger = HORDE;
    }
    else
    {
        // ally is in majority, but it's already ally-controlled -> no change
        if (m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue)
            return false;

        if (fact_diff > maxDiff)
            fact_diff = maxDiff;

        Challenger = ALLIANCE;
    }

    float oldValue = m_value;
    TeamId oldTeam = m_team;

    m_OldState = m_State;

    m_value += fact_diff;

    if (m_value < -m_minValue) // red
    {
        if (m_value < -m_maxValue)
            m_value = -m_maxValue;
        m_State = OBJECTIVESTATE_HORDE;
        m_team = TEAM_HORDE;
    }
    else if (m_value > m_minValue) // blue
    {
        if (m_value > m_maxValue)
            m_value = m_maxValue;
        m_State = OBJECTIVESTATE_ALLIANCE;
        m_team = TEAM_ALLIANCE;
    }
    else if (oldValue * m_value <= 0) // grey, go through mid point
    {
        // if challenger is ally, then n->a challenge
        if (Challenger == ALLIANCE)
            m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE;
        // if challenger is horde, then n->h challenge
        else if (Challenger == HORDE)
            m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE;
        m_team = TEAM_NEUTRAL;
    }
    else // grey, did not go through mid point
    {
        // old phase and current are on the same side, so one team challenges the other
        if (Challenger == ALLIANCE && (m_OldState == OBJECTIVESTATE_HORDE || m_OldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE))
            m_State = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE;
        else if (Challenger == HORDE && (m_OldState == OBJECTIVESTATE_ALLIANCE || m_OldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE))
            m_State = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE;
        m_team = TEAM_NEUTRAL;
    }

    if (m_value != oldValue)
        SendChangePhase();

    if (m_OldState != m_State)
    {
        //TC_LOG_ERROR("outdoorpvp", "%u->%u", m_OldState, m_State);
        if (oldTeam != m_team)
            ChangeTeam(oldTeam);
        ChangeState();
        return true;
    }

    return false;
}
开发者ID:Carbenium,项目名称:TrinityCore,代码行数:101,代码来源:OutdoorPvP.cpp


示例20: EvaluteTurn

/*!
 * \brief Performs a turn.
 * \return Returns TRUE while turn is still in progress.
 */
static uint8_t EvaluteTurn(bool *finished, bool *deadEndGoBw) {
  REF_LineKind historyLineKind, currLineKind;
  TURN_Kind turn;
  
  *finished = FALSE; /* defaults */
  *deadEndGoBw = FALSE; /* default */
  currLineKind = REF_GetLineKind();
  if (currLineKind==REF_LINE_NONE) { /* nothing, must be dead end */
#if PL_GO_DEADEND_BW
    TURN_Turn(TURN_STEP_BW); /* step back so we are again on the line for line following */
    turn = TURN_STRAIGHT;
    *deadEndGoBw = TRUE;
#else
    turn = TURN_LEFT180;
#endif
  } else {
    REF_ClearHistory(); /* clear values */
    REF_SampleHistory(); /* store current values */
    TURN_Turn(TURN_STEP_LINE_FW); /* make forward step over line */
    historyLineKind = REF_HistoryLineKind(); /* new read new values */
    currLineKind = REF_GetLineKind();
  #if LINE_DEBUG
    REF_DumpHistory();
    CLS1_SendStr((unsigned char*)" history: ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)REF_LineKindStr(historyLineKind), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)" curr: ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)REF_LineKindStr(currLineKind), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
  #endif
    turn = MAZE_SelectTurn(historyLineKind, currLineKind);
  }
  if (turn==TURN_FINISHED) {
    *finished = TRUE;
    ChangeState(STATE_STOP);
    CLS1_SendStr((unsigned char*)"finished!\r\n", CLS1_GetStdio()->stdOut);
    return ERR_OK;
  } else if (turn==TURN_STRAIGHT && *deadEndGoBw) {
    MAZE_AddPath(TURN_LEFT180); /* would have been a turn around */
    MAZE_SimplifyPath();
    CLS1_SendStr((unsigned char*)"going backward\r\n", CLS1_GetStdio()->stdOut);
    return ERR_OK; 
  } else if (turn==TURN_STRAIGHT) {
    MAZE_AddPath(turn);
    MAZE_SimplifyPath();
    CLS1_SendStr((unsigned char*)"going straight\r\n", CLS1_GetStdio()->stdOut);
    return ERR_OK; 
  } else if (turn==TURN_STOP) { /* should not happen here? */
    ChangeState(STATE_STOP);
    CLS1_SendStr((unsigned char*)"stopped\r\n", CLS1_GetStdio()->stdOut);
    return ERR_FAILED; /* error case */
  } else { /* turn or do something */
#if LINE_DEBUG
    CLS1_SendStr((unsigned char*)"turning ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)TURN_TurnKindStr(turn), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
#endif
    if (turn==TURN_LEFT90 || turn==TURN_RIGHT90) {
      TURN_Turn(TURN_STEP_POST_LINE_FW); /* step before doing the turn so we turn on the middle of the intersection */
    }
    TURN_Turn(turn); /* make turn */
    MAZE_AddPath(turn);
    MAZE_SimplifyPath();
    return ERR_OK; /* turn finished */
  }
}
开发者ID:210221030,项目名称:mcuoneclipse,代码行数:69,代码来源:LineFollow.c



注:本文中的ChangeState函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ChangeWeapon函数代码示例发布时间:2022-05-30
下一篇:
C++ ChangeServiceConfig2函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap