Backup.
This commit is contained in:
parent
9802e42e67
commit
70749f4612
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
.vscode
|
.vscode
|
||||||
|
Doxygen
|
||||||
cmake-shell/
|
cmake-shell/
|
||||||
external/gtest/googletest-release-1.11.0/
|
external/gtest/googletest-release-1.11.0/
|
||||||
external/libconfig/libconfig-1.7.3/
|
external/libconfig/libconfig-1.7.3/
|
||||||
|
|
|
@ -22,7 +22,7 @@ using std::placeholders::_1;
|
||||||
using DataProcessingFunc = std::function<bool(VStateMachineData *)>;
|
using DataProcessingFunc = std::function<bool(VStateMachineData *)>;
|
||||||
enum class InternalStateEvent
|
enum class InternalStateEvent
|
||||||
{
|
{
|
||||||
TEST = static_cast<int>(MissionEvent::END),
|
STORAGE_HANDLE_STATE_INIT = static_cast<int>(MissionEvent::END),
|
||||||
MEDIA_REPORT_EVENT,
|
MEDIA_REPORT_EVENT,
|
||||||
END
|
END
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,7 +68,7 @@ std::shared_ptr<State> MissionManagerMakePtr::CreateMissionState(const IpcMissio
|
||||||
std::shared_ptr<State> MissionManagerMakePtr::CreateStorageHandleState(void)
|
std::shared_ptr<State> MissionManagerMakePtr::CreateStorageHandleState(void)
|
||||||
{
|
{
|
||||||
std::shared_ptr<State> state = std::make_shared<StorageHandleState>();
|
std::shared_ptr<State> state = std::make_shared<StorageHandleState>();
|
||||||
std::dynamic_pointer_cast<StorageHandleState>(state)->Init();
|
// std::dynamic_pointer_cast<StorageHandleState>(state)->Init();
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
std::shared_ptr<State> MissionManagerMakePtr::CreateSdCardHandleState(void)
|
std::shared_ptr<State> MissionManagerMakePtr::CreateSdCardHandleState(void)
|
||||||
|
|
|
@ -13,10 +13,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "MissionStateMachine.h"
|
#include "MissionStateMachine.h"
|
||||||
|
#include "DataProcessing.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
#include "McuAskBase.h"
|
#include "McuAskBase.h"
|
||||||
#include "MissionManagerMakePtr.h"
|
#include "MissionManagerMakePtr.h"
|
||||||
#include "TopState.h"
|
// #include "TopState.h"
|
||||||
std::shared_ptr<MissionStateMachine> &MissionStateMachine::GetInstance(std::shared_ptr<MissionStateMachine> *impl)
|
std::shared_ptr<MissionStateMachine> &MissionStateMachine::GetInstance(std::shared_ptr<MissionStateMachine> *impl)
|
||||||
{
|
{
|
||||||
static auto instance = std::make_shared<MissionStateMachine>();
|
static auto instance = std::make_shared<MissionStateMachine>();
|
||||||
|
@ -98,4 +99,7 @@ void MissionStateMachine::RunStateMachine(const IpcMission &mission)
|
||||||
mStateTree[SystemState::STORAGE_HANDLE_STATE].get());
|
mStateTree[SystemState::STORAGE_HANDLE_STATE].get());
|
||||||
mStateMachine->SetCurrentState(mStateTree[SystemState::TOP_STATE].get());
|
mStateMachine->SetCurrentState(mStateTree[SystemState::TOP_STATE].get());
|
||||||
mStateMachine->StartStateMachine();
|
mStateMachine->StartStateMachine();
|
||||||
|
std::shared_ptr<VMissionData> message =
|
||||||
|
std::make_shared<VMissionData>(static_cast<MissionEvent>(InternalStateEvent::STORAGE_HANDLE_STATE_INIT));
|
||||||
|
SendStateMessage(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ bool SdCardHandleState::MediaReportHandle(VStateMachineData *msg)
|
||||||
LogError("nullptr pointer.\n");
|
LogError("nullptr pointer.\n");
|
||||||
return NOT_EXECUTED;
|
return NOT_EXECUTED;
|
||||||
}
|
}
|
||||||
LogInfo("file = %s, path = %s.\n", data->mData.mFileName.c_str(), data->mData.mFilePath.c_str());
|
LogInfo("file = %s.\n", data->mData.mFileName.c_str());
|
||||||
SaveFileInfo saveFileInfo(data->mData.mFileName);
|
SaveFileInfo saveFileInfo(data->mData.mFileName);
|
||||||
IFilesManager::GetInstance()->SaveFile(saveFileInfo);
|
IFilesManager::GetInstance()->SaveFile(saveFileInfo);
|
||||||
return EXECUTED;
|
return EXECUTED;
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "MissionStateMachine.h"
|
#include "MissionStateMachine.h"
|
||||||
StorageHandleState::StorageHandleState() : State("StorageHandleState")
|
StorageHandleState::StorageHandleState() : State("StorageHandleState")
|
||||||
{
|
{
|
||||||
|
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
|
||||||
|
std::bind(&StorageHandleState::StorageStartInitHandle, this, _1);
|
||||||
}
|
}
|
||||||
void StorageHandleState::GoInState()
|
void StorageHandleState::GoInState()
|
||||||
{
|
{
|
||||||
|
@ -44,3 +46,8 @@ void StorageHandleState::ReportEvent(const StorageEvent &event)
|
||||||
{
|
{
|
||||||
LogInfo("StorageHandleState::ReportEvent.\n");
|
LogInfo("StorageHandleState::ReportEvent.\n");
|
||||||
}
|
}
|
||||||
|
bool StorageHandleState::StorageStartInitHandle(VStateMachineData *msg)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
return EXECUTED;
|
||||||
|
}
|
|
@ -34,5 +34,6 @@ public:
|
||||||
|
|
||||||
private: // About VStorageMoniter
|
private: // About VStorageMoniter
|
||||||
void ReportEvent(const StorageEvent &event) override;
|
void ReportEvent(const StorageEvent &event) override;
|
||||||
|
bool StorageStartInitHandle(VStateMachineData *msg);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -18,6 +18,7 @@
|
||||||
#include "MissionStateMachine.h"
|
#include "MissionStateMachine.h"
|
||||||
TopState::TopState() : State("TopState")
|
TopState::TopState() : State("TopState")
|
||||||
{
|
{
|
||||||
|
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] = std::bind(&TopState::StorageStartInitHandle, this, _1);
|
||||||
}
|
}
|
||||||
void TopState::GoInState()
|
void TopState::GoInState()
|
||||||
{
|
{
|
||||||
|
@ -36,8 +37,15 @@ bool TopState::ExecuteStateMsg(VStateMachineData *msg)
|
||||||
}
|
}
|
||||||
StatusCode TopState::ReportEvent(const MediaReportEvent &event)
|
StatusCode TopState::ReportEvent(const MediaReportEvent &event)
|
||||||
{
|
{
|
||||||
|
LogInfo("==================================================================ReportEvent:\n");
|
||||||
std::shared_ptr<VMissionData> message = std::make_shared<VMissionDataV2<MediaReportEvent>>(
|
std::shared_ptr<VMissionData> message = std::make_shared<VMissionDataV2<MediaReportEvent>>(
|
||||||
static_cast<MissionEvent>(InternalStateEvent::MEDIA_REPORT_EVENT), event);
|
static_cast<MissionEvent>(InternalStateEvent::MEDIA_REPORT_EVENT), event);
|
||||||
MissionStateMachine::GetInstance()->SendStateMessage(message);
|
MissionStateMachine::GetInstance()->SendStateMessage(message);
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
|
bool TopState::StorageStartInitHandle(VStateMachineData *msg)
|
||||||
|
{
|
||||||
|
MissionStateMachine::GetInstance()->DelayMessage(msg);
|
||||||
|
MissionStateMachine::GetInstance()->SwitchState(SystemState::STORAGE_HANDLE_STATE);
|
||||||
|
return EXECUTED;
|
||||||
|
}
|
|
@ -31,5 +31,8 @@ public:
|
||||||
|
|
||||||
private: // About VMediaMonitor
|
private: // About VMediaMonitor
|
||||||
StatusCode ReportEvent(const MediaReportEvent &event) override;
|
StatusCode ReportEvent(const MediaReportEvent &event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool StorageStartInitHandle(VStateMachineData *msg);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -15,9 +15,8 @@
|
||||||
#include "IHalCpp.h"
|
#include "IHalCpp.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
camera_report_event::camera_report_event(const std::string &fileName, const std::string &filePath,
|
camera_report_event::camera_report_event(const std::string &fileName, const CameraType &cameraType)
|
||||||
const CameraEvent &eventType, const CameraType &cameraType)
|
: mFileName(fileName), mCameraType(cameraType)
|
||||||
: mFileName(fileName), mFilePath(filePath), mEventType(eventType), mCameraType(cameraType)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void VKeyHalMonitor::KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event,
|
void VKeyHalMonitor::KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event,
|
||||||
|
|
|
@ -29,13 +29,6 @@ enum class CameraType
|
||||||
MAIN_CAMERA = 0,
|
MAIN_CAMERA = 0,
|
||||||
END
|
END
|
||||||
};
|
};
|
||||||
enum class CameraEvent
|
|
||||||
{
|
|
||||||
PICTIRUE = 0,
|
|
||||||
VIDEO,
|
|
||||||
PICTIRUE_AND_VIDEO,
|
|
||||||
END
|
|
||||||
};
|
|
||||||
enum class SdCardHalStatus
|
enum class SdCardHalStatus
|
||||||
{
|
{
|
||||||
MOUNTED = 0,
|
MOUNTED = 0,
|
||||||
|
@ -47,11 +40,8 @@ enum class SdCardHalStatus
|
||||||
};
|
};
|
||||||
typedef struct camera_report_event
|
typedef struct camera_report_event
|
||||||
{
|
{
|
||||||
camera_report_event(const std::string &fileName, const std::string &filePath, const CameraEvent &eventType,
|
camera_report_event(const std::string &fileName, const CameraType &cameraType);
|
||||||
const CameraType &cameraType);
|
|
||||||
const std::string mFileName;
|
const std::string mFileName;
|
||||||
const std::string mFilePath;
|
|
||||||
const CameraEvent mEventType;
|
|
||||||
const CameraType mCameraType;
|
const CameraType mCameraType;
|
||||||
} CameraReportEvent;
|
} CameraReportEvent;
|
||||||
void CreateHalCppModule(void);
|
void CreateHalCppModule(void);
|
||||||
|
|
|
@ -89,7 +89,7 @@ StatusCode HalMakePtr::CreateCameraHal(std::shared_ptr<VCameraHal> &impl)
|
||||||
}
|
}
|
||||||
StatusCode HalMakePtr::CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl)
|
StatusCode HalMakePtr::CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl)
|
||||||
{
|
{
|
||||||
LogWarning("CreateSdCardHal.\n");
|
LogInfo("CreateSdCardHal.\n");
|
||||||
impl = std::make_shared<SdCardHal>();
|
impl = std::make_shared<SdCardHal>();
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
|
@ -35,11 +35,8 @@ enum class MediaTaskType
|
||||||
};
|
};
|
||||||
typedef struct media_report_event
|
typedef struct media_report_event
|
||||||
{
|
{
|
||||||
media_report_event(const std::string &fileName, const std::string &filePath, const MediaTaskType &eventType,
|
media_report_event(const std::string &fileName, const MediaChannel &mediaChannedl);
|
||||||
const MediaChannel &mediaChannedl);
|
|
||||||
const std::string mFileName;
|
const std::string mFileName;
|
||||||
const std::string mFilePath; // TODO: delete
|
|
||||||
const MediaTaskType mEventType; // TODO: delete
|
|
||||||
const MediaChannel mMediaChannedl;
|
const MediaChannel mMediaChannedl;
|
||||||
} MediaReportEvent;
|
} MediaReportEvent;
|
||||||
class MediaTaskResponse
|
class MediaTaskResponse
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
*/
|
*/
|
||||||
#include "IMediaManager.h"
|
#include "IMediaManager.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
media_report_event::media_report_event(const std::string &fileName, const std::string &filePath,
|
media_report_event::media_report_event(const std::string &fileName, const MediaChannel &mediaChannedl)
|
||||||
const MediaTaskType &eventType, const MediaChannel &mediaChannedl)
|
: mFileName(fileName), mMediaChannedl(mediaChannedl)
|
||||||
: mFileName(fileName), mFilePath(filePath), mEventType(eventType), mMediaChannedl(mediaChannedl)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
const MediaTaskType VMediaTask::GetTaskType(void)
|
const MediaTaskType VMediaTask::GetTaskType(void)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
StatusCode MediaManagerImpl::Init(void)
|
StatusCode MediaManagerImpl::Init(void)
|
||||||
{
|
{
|
||||||
IHalCpp::GetInstance()->GetCameraHal(mAllCameras);
|
IHalCpp::GetInstance()->GetCameraHal(mAllCameras);
|
||||||
SetCamerasMonitor();
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
StatusCode MediaManagerImpl::UnInit(void)
|
StatusCode MediaManagerImpl::UnInit(void)
|
||||||
|
@ -27,19 +26,15 @@ StatusCode MediaManagerImpl::UnInit(void)
|
||||||
StatusCode MediaManagerImpl::SetMediaMonitor(std::shared_ptr<VMediaMonitor> &monitor)
|
StatusCode MediaManagerImpl::SetMediaMonitor(std::shared_ptr<VMediaMonitor> &monitor)
|
||||||
{
|
{
|
||||||
mMediaMonitor = monitor;
|
mMediaMonitor = monitor;
|
||||||
|
SetCamerasMonitor();
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
void MediaManagerImpl::ReportEvent(const CameraReportEvent &event)
|
void MediaManagerImpl::ReportEvent(const CameraReportEvent &event)
|
||||||
{
|
{
|
||||||
LogInfo("ReportEvent.\n");
|
LogInfo("ReportEvent. file: %s.\n", event.mFileName.c_str());
|
||||||
LogInfo("ReportEvent. file: %s, path: %s.\n", event.mFileName.c_str(), event.mFilePath.c_str());
|
MediaReportEvent reprot(event.mFileName, static_cast<MediaChannel>(event.mCameraType));
|
||||||
MediaReportEvent reprot(event.mFileName,
|
|
||||||
event.mFilePath,
|
|
||||||
static_cast<MediaTaskType>(event.mEventType),
|
|
||||||
static_cast<MediaChannel>(event.mCameraType));
|
|
||||||
auto monitor = mMediaMonitor.lock();
|
auto monitor = mMediaMonitor.lock();
|
||||||
if (mMediaMonitor.expired())
|
if (mMediaMonitor.expired()) {
|
||||||
{
|
|
||||||
LogWarning("MediaMonitor is expired.\n");
|
LogWarning("MediaMonitor is expired.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,7 @@ public:
|
||||||
void MockKeyClick(const std::string &keyName, const unsigned int &pressingTimeMs = 200);
|
void MockKeyClick(const std::string &keyName, const unsigned int &pressingTimeMs = 200);
|
||||||
void SetLedStateExpectations(const std::string &ledName, const LedState &state, const unsigned int &aliveTimeMs,
|
void SetLedStateExpectations(const std::string &ledName, const LedState &state, const unsigned int &aliveTimeMs,
|
||||||
const unsigned int &blinkTimeMs);
|
const unsigned int &blinkTimeMs);
|
||||||
void MockReportCameraEvent(const std::string &fileName, const std::string &filePath, const CameraEvent &eventType,
|
void MockReportCameraEvent(const std::string &fileName, const CameraType &cameraType);
|
||||||
const CameraType &cameraType);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DeviceManagerNotice(const std::string &keyName, const unsigned int &pressingTimeMs);
|
virtual void DeviceManagerNotice(const std::string &keyName, const unsigned int &pressingTimeMs);
|
||||||
|
|
|
@ -101,8 +101,7 @@ void HalTestTool::SetLedStateExpectations(const std::string &ledName, const LedS
|
||||||
// }
|
// }
|
||||||
LedControlMock::SetLedStateMock(led, state, aliveTimeMs, blinkTimeMs);
|
LedControlMock::SetLedStateMock(led, state, aliveTimeMs, blinkTimeMs);
|
||||||
}
|
}
|
||||||
void HalTestTool::MockReportCameraEvent(const std::string &fileName, const std::string &filePath,
|
void HalTestTool::MockReportCameraEvent(const std::string &fileName, const CameraType &cameraType)
|
||||||
const CameraEvent &eventType, const CameraType &cameraType)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<VCameraHal> camera = SearchCamera(cameraType);
|
std::shared_ptr<VCameraHal> camera = SearchCamera(cameraType);
|
||||||
if (!camera) {
|
if (!camera) {
|
||||||
|
@ -111,7 +110,7 @@ void HalTestTool::MockReportCameraEvent(const std::string &fileName, const std::
|
||||||
}
|
}
|
||||||
std::shared_ptr<CameraHalMock> cameraMock = std::dynamic_pointer_cast<CameraHalMock>(camera);
|
std::shared_ptr<CameraHalMock> cameraMock = std::dynamic_pointer_cast<CameraHalMock>(camera);
|
||||||
if (cameraMock) {
|
if (cameraMock) {
|
||||||
CameraReportEvent report(fileName, filePath, eventType, cameraType);
|
CameraReportEvent report(fileName, cameraType);
|
||||||
cameraMock->MockReportCameraEvent(report);
|
cameraMock->MockReportCameraEvent(report);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -80,7 +80,7 @@ TEST_F(MediaManagerTest, INTEGRATION_MediaManager_EXAMPLE_Demo0)
|
||||||
IMediaManager::GetInstance()->Init();
|
IMediaManager::GetInstance()->Init();
|
||||||
IMediaManager::GetInstance()->SetMediaMonitor(monitor);
|
IMediaManager::GetInstance()->SetMediaMonitor(monitor);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
MockReportCameraEvent("test name", "test path", CameraEvent::PICTIRUE, CameraType::MAIN_CAMERA);
|
MockReportCameraEvent("test name", CameraType::MAIN_CAMERA);
|
||||||
// MockAppClientConnect();
|
// MockAppClientConnect();
|
||||||
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
// MockSetRecordingStatus(RecordingStatus::RECORDING_START);
|
// MockSetRecordingStatus(RecordingStatus::RECORDING_START);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user