Key manager code ok.
This commit is contained in:
parent
be566f10db
commit
079f480076
|
@ -17,6 +17,7 @@ include_directories(
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuManager/include
|
${MIDDLEWARE_SOURCE_PATH}/McuManager/include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade/include
|
${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade/include
|
||||||
|
${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include
|
||||||
)
|
)
|
||||||
#do not rely on any other library
|
#do not rely on any other library
|
||||||
#link_directories(
|
#link_directories(
|
||||||
|
@ -27,7 +28,7 @@ aux_source_directory(./src SRC_FILES)
|
||||||
set(TARGET_NAME MissionManager)
|
set(TARGET_NAME MissionManager)
|
||||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||||
|
|
||||||
target_link_libraries(${TARGET_NAME} McuAskBase StateMachine MediaManager StorageManager HuntingUpgrade StatusCode Log)
|
target_link_libraries(${TARGET_NAME} McuAskBase StateMachine MediaManager StorageManager DeviceManager HuntingUpgrade StatusCode Log)
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
|
|
|
@ -29,6 +29,8 @@ void TopState::GoInState()
|
||||||
std::shared_ptr<VMediaMonitor> mediaMonitor = std::dynamic_pointer_cast<VMediaMonitor>(shared_from_this());
|
std::shared_ptr<VMediaMonitor> mediaMonitor = std::dynamic_pointer_cast<VMediaMonitor>(shared_from_this());
|
||||||
IMediaManager::GetInstance()->SetMediaMonitor(mediaMonitor);
|
IMediaManager::GetInstance()->SetMediaMonitor(mediaMonitor);
|
||||||
MissionStateMachine::GetInstance()->SwitchState(SystemState::MISSION_STATE);
|
MissionStateMachine::GetInstance()->SwitchState(SystemState::MISSION_STATE);
|
||||||
|
std::shared_ptr<VKeyMonitor> keysMonitor = std::dynamic_pointer_cast<VKeyMonitor>(shared_from_this());
|
||||||
|
IDeviceManager::GetInstance()->SetAllKeysMonitor(keysMonitor);
|
||||||
}
|
}
|
||||||
void TopState::GoOutState()
|
void TopState::GoOutState()
|
||||||
{
|
{
|
||||||
|
@ -46,6 +48,10 @@ StatusCode TopState::ReportEvent(const MediaReportEvent &event)
|
||||||
MissionStateMachine::GetInstance()->SendStateMessage(message);
|
MissionStateMachine::GetInstance()->SendStateMessage(message);
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
|
void TopState::KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs)
|
||||||
|
{
|
||||||
|
LogInfo(" KeyEventReport:key name = %s, time = %d\n", keyName.c_str(), timeMs);
|
||||||
|
}
|
||||||
bool TopState::StorageStartInitHandle(VStateMachineData *msg)
|
bool TopState::StorageStartInitHandle(VStateMachineData *msg)
|
||||||
{
|
{
|
||||||
MissionStateMachine::GetInstance()->DelayMessage(msg);
|
MissionStateMachine::GetInstance()->DelayMessage(msg);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#ifndef TOP_STATE_H
|
#ifndef TOP_STATE_H
|
||||||
#define TOP_STATE_H
|
#define TOP_STATE_H
|
||||||
#include "DataProcessing.h"
|
#include "DataProcessing.h"
|
||||||
|
#include "IDeviceManager.h"
|
||||||
#include "IMediaManager.h"
|
#include "IMediaManager.h"
|
||||||
#include "IStateMachine.h"
|
#include "IStateMachine.h"
|
||||||
#include "McuMonitor.h"
|
#include "McuMonitor.h"
|
||||||
|
@ -22,6 +23,7 @@ class TopState : public State,
|
||||||
public DataProcessing,
|
public DataProcessing,
|
||||||
public VMediaMonitor,
|
public VMediaMonitor,
|
||||||
public McuMonitor,
|
public McuMonitor,
|
||||||
|
public VKeyMonitor,
|
||||||
public std::enable_shared_from_this<TopState>
|
public std::enable_shared_from_this<TopState>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -34,6 +36,9 @@ public:
|
||||||
private: // About VMediaMonitor
|
private: // About VMediaMonitor
|
||||||
StatusCode ReportEvent(const MediaReportEvent &event) override;
|
StatusCode ReportEvent(const MediaReportEvent &event) override;
|
||||||
|
|
||||||
|
private: // About KeyMonitor
|
||||||
|
void KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool StorageStartInitHandle(VStateMachineData *msg);
|
bool StorageStartInitHandle(VStateMachineData *msg);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,8 @@ camera_report_event::camera_report_event(const std::string &fileName, const Came
|
||||||
: mFileName(fileName), mCameraType(cameraType)
|
: mFileName(fileName), mCameraType(cameraType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void VKeyHalMonitor::KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event)
|
void VKeyHalMonitor::KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event,
|
||||||
|
const unsigned int &timeMs)
|
||||||
{
|
{
|
||||||
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ class VKeyHalMonitor
|
||||||
public:
|
public:
|
||||||
VKeyHalMonitor() = default;
|
VKeyHalMonitor() = default;
|
||||||
virtual ~VKeyHalMonitor() = default;
|
virtual ~VKeyHalMonitor() = default;
|
||||||
virtual void KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event);
|
virtual void KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs);
|
||||||
};
|
};
|
||||||
class VKeyHal
|
class VKeyHal
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,9 +36,7 @@ class VKeyMonitor
|
||||||
public:
|
public:
|
||||||
VKeyMonitor() = default;
|
VKeyMonitor() = default;
|
||||||
virtual ~VKeyMonitor() = default;
|
virtual ~VKeyMonitor() = default;
|
||||||
virtual void KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs)
|
virtual void KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs);
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
class VirtualLedControl
|
class VirtualLedControl
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
*/
|
*/
|
||||||
#include "IDeviceManager.h"
|
#include "IDeviceManager.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
void VKeyMonitor::KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs)
|
||||||
|
{
|
||||||
|
}
|
||||||
std::shared_ptr<IDeviceManager> &IDeviceManager::GetInstance(std::shared_ptr<IDeviceManager> *impl)
|
std::shared_ptr<IDeviceManager> &IDeviceManager::GetInstance(std::shared_ptr<IDeviceManager> *impl)
|
||||||
{
|
{
|
||||||
static auto instance = std::make_shared<IDeviceManager>();
|
static auto instance = std::make_shared<IDeviceManager>();
|
||||||
|
|
|
@ -87,7 +87,7 @@ void KeyManager::GetAllKeysState(std::map<std::string, KeyStatus> &status)
|
||||||
}
|
}
|
||||||
const StatusCode KeyManager::SetKeyMonitor(std::shared_ptr<VKeyMonitor> &monitor)
|
const StatusCode KeyManager::SetKeyMonitor(std::shared_ptr<VKeyMonitor> &monitor)
|
||||||
{
|
{
|
||||||
mKeyMonitor = monitor;
|
mKeysMonitor = monitor;
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
void KeyManager::SetKeyHalMonitor(void)
|
void KeyManager::SetKeyHalMonitor(void)
|
||||||
|
@ -99,13 +99,13 @@ void KeyManager::SetKeyHalMonitor(void)
|
||||||
keyHal->SetKeyMonitor(monitor);
|
keyHal->SetKeyMonitor(monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void KeyManager::KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event)
|
void KeyManager::KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs)
|
||||||
{
|
{
|
||||||
auto monitor = mKeyMonitor.lock();
|
auto monitor = mKeysMonitor.lock();
|
||||||
if (mKeyMonitor.expired()) {
|
if (mKeysMonitor.expired()) {
|
||||||
LogError("monitor is nullptr.\n");
|
LogError("monitor is nullptr.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogInfo("KeyManager::KeyEventHappened: key = %s, event = %d, time = %u\n", keyName.c_str(), event);
|
LogInfo("KeyManager::KeyEventHappened: key = %s, event = %d, time = %u\n", keyName.c_str(), event);
|
||||||
monitor->KeyEventReport(keyName, static_cast<VirtualKeyEvent>(event), 99999);
|
monitor->KeyEventReport(keyName, static_cast<VirtualKeyEvent>(event), timeMs);
|
||||||
}
|
}
|
|
@ -38,13 +38,14 @@ private:
|
||||||
void SetKeyHalMonitor(void);
|
void SetKeyHalMonitor(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event) override;
|
void KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event,
|
||||||
|
const unsigned int &timeMs) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex mMutex;
|
std::mutex mMutex;
|
||||||
std::map<std::string, std::shared_ptr<VKeyHal>> mAllKeyHal;
|
std::map<std::string, std::shared_ptr<VKeyHal>> mAllKeyHal;
|
||||||
bool mTimerRuning;
|
bool mTimerRuning;
|
||||||
std::thread mTimer;
|
std::thread mTimer;
|
||||||
std::weak_ptr<VKeyMonitor> mKeyMonitor;
|
std::weak_ptr<VKeyMonitor> mKeysMonitor;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -16,6 +16,7 @@ include_directories(
|
||||||
${MIDDLEWARE_SOURCE_PATH}/StorageManager/include
|
${MIDDLEWARE_SOURCE_PATH}/StorageManager/include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/StorageManager/src
|
${MIDDLEWARE_SOURCE_PATH}/StorageManager/src
|
||||||
${MIDDLEWARE_SOURCE_PATH}/FilesManager/include
|
${MIDDLEWARE_SOURCE_PATH}/FilesManager/include
|
||||||
|
${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include
|
||||||
${UTILS_SOURCE_PATH}/StatusCode/include
|
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||||
${UTILS_SOURCE_PATH}/Log/include
|
${UTILS_SOURCE_PATH}/Log/include
|
||||||
${UTILS_SOURCE_PATH}/LinuxApi/include
|
${UTILS_SOURCE_PATH}/LinuxApi/include
|
||||||
|
|
|
@ -38,7 +38,7 @@ void KeyControlTest::KeyEventTrigger(const std::string &keyName, const KeyEvent
|
||||||
LogError("monitor is nullptr.\n");
|
LogError("monitor is nullptr.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
monitor->KeyEventHappened(keyName, static_cast<VirtualKeyEvent>(event));
|
monitor->KeyEventHappened(keyName, static_cast<VirtualKeyEvent>(event), timeMs);
|
||||||
}
|
}
|
||||||
const std::string KeyControlTest::GetKeyName(void)
|
const std::string KeyControlTest::GetKeyName(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user