hunting/application/MissionManager/src/IdleState.cpp
2024-07-16 22:40:07 +08:00

50 lines
1.8 KiB
C++

/*
* Copyright (c) 2023 Fancy Code.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "IdleState.h"
#include "DataProcessing.h"
#include "ILog.h"
#include "IStateMachine.h"
#include "MissionStateMachine.h"
#include <functional>
IdleState::IdleState() : State("IdleState")
{
mEventHandle[InternalStateEvent::RESET_KEY_MEDIA_TASK] = std::bind(&IdleState::ResetKeyMediaTaskHandle, this, _1);
mEventHandle[InternalStateEvent::FORMAT_KEY_FORMAT_SD_CARD] =
std::bind(&IdleState::FormatKeyFormattingSDCardHandle, this, _1);
}
void IdleState::GoInState()
{
LogInfo(" ========== IdleState::GoInState.\n");
}
void IdleState::GoOutState()
{
LogInfo(" ========== IdleState::GoOutState.\n");
}
bool IdleState::ExecuteStateMsg(VStateMachineData *msg)
{
return DataProcessing::EventHandle(msg);
}
bool IdleState::ResetKeyMediaTaskHandle(VStateMachineData *msg)
{
MissionStateMachine::GetInstance()->DelayMessage(msg);
MissionStateMachine::GetInstance()->SwitchState(SystemState::STORAGE_HANDLE_STATE);
return EXECUTED;
}
bool IdleState::FormatKeyFormattingSDCardHandle(VStateMachineData *msg)
{
MissionStateMachine::GetInstance()->DelayMessage(msg);
MissionStateMachine::GetInstance()->SwitchState(SystemState::STORAGE_HANDLE_STATE);
return EXECUTED;
}