56 lines
2.1 KiB
C++
56 lines
2.1 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 "MissionState.h"
|
|
#include "IAppManager.h"
|
|
#include "ILog.h"
|
|
#include "MissionStateMachine.h"
|
|
MissionState::MissionState(const std::string &name) : State(name)
|
|
{
|
|
mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&MissionState::MediaReportHandle, this, _1);
|
|
mEventHandle[InternalStateEvent::SD_CARD_HANDLE_STATE_SD_STATUS_REPORTED] =
|
|
std::bind(&MissionState::SdCardEventReportHandle, this, _1);
|
|
mEventHandle[InternalStateEvent::CHECK_UPGRADE_FILE] = std::bind(&MissionState::CheckUpgradeFileHandle, this, _1);
|
|
}
|
|
void MissionState::GoInState()
|
|
{
|
|
LogInfo(" ========== MissionState::GoInState.\n");
|
|
}
|
|
void MissionState::GoOutState()
|
|
{
|
|
LogInfo(" ========== MissionState::GoOutState.\n");
|
|
LedsHandle::DeleteAllLeds();
|
|
}
|
|
bool MissionState::ExecuteStateMsg(VStateMachineData *msg)
|
|
{
|
|
return DataProcessing::EventHandle(msg);
|
|
}
|
|
bool MissionState::MediaReportHandle(VStateMachineData *msg)
|
|
{
|
|
MissionStateMachine::GetInstance()->DelayMessage(msg);
|
|
MissionStateMachine::GetInstance()->SwitchState(SystemState::STORAGE_HANDLE_STATE);
|
|
return EXECUTED;
|
|
}
|
|
bool MissionState::SdCardEventReportHandle(VStateMachineData *msg)
|
|
{
|
|
MissionStateMachine::GetInstance()->DelayMessage(msg);
|
|
MissionStateMachine::GetInstance()->SwitchState(SystemState::SD_CARD_HANDLE_STATE);
|
|
return EXECUTED;
|
|
}
|
|
bool MissionState::CheckUpgradeFileHandle(VStateMachineData *msg)
|
|
{
|
|
MissionStateMachine::GetInstance()->DelayMessage(msg);
|
|
MissionStateMachine::GetInstance()->SwitchState(SystemState::UPGRADE_STATE);
|
|
return EXECUTED;
|
|
} |