53 lines
1.9 KiB
C++
53 lines
1.9 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 "SdCardHandleState.h"
|
|
#include "IFilesManager.h"
|
|
#include "ILog.h"
|
|
#include "IMediaManager.h"
|
|
#include "MissionStateMachine.h"
|
|
SdCardHandleState::SdCardHandleState() : State("SdCardHandleState")
|
|
{
|
|
mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&SdCardHandleState::MediaReportHandle, this, _1);
|
|
}
|
|
void SdCardHandleState::GoInState()
|
|
{
|
|
LogInfo(" ========== opState::GoInState.\n");
|
|
}
|
|
void SdCardHandleState::GoOutState()
|
|
{
|
|
LogInfo(" ========== opState::GoOutState.\n");
|
|
}
|
|
bool SdCardHandleState::ExecuteStateMsg(VStateMachineData *msg)
|
|
{
|
|
return DataProcessing::EventHandle(msg);
|
|
}
|
|
bool SdCardHandleState::MediaReportHandle(VStateMachineData *msg)
|
|
{
|
|
LogInfo(" MediaReportHandle.\n");
|
|
std::shared_ptr<MissionMessage> message = std::dynamic_pointer_cast<MissionMessage>(msg->GetMessageObj());
|
|
std::shared_ptr<VMissionDataV2<MediaReportEvent>> data =
|
|
std::dynamic_pointer_cast<VMissionDataV2<MediaReportEvent>>(message->mMissionData);
|
|
if (!data) {
|
|
LogError("nullptr pointer.\n");
|
|
return NOT_EXECUTED;
|
|
}
|
|
LogInfo("file = %s.\n", data->mData.mFileName.c_str());
|
|
SaveFileInfo saveFileInfo(data->mData.mFileName);
|
|
StatusCode code = IFilesManager::GetInstance()->SaveFile(saveFileInfo);
|
|
if (IsCodeOK(code) == false) {
|
|
LogError("SaveFile failed.\n");
|
|
}
|
|
return EXECUTED;
|
|
} |