Improve:clang-format setting.
This commit is contained in:
parent
73a7ca3787
commit
6830104fcd
|
@ -33,7 +33,10 @@ void InitSignalHandle(void)
|
|||
signal(SIGKILL, sigHandler);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
}
|
||||
MainThread::MainThread() { mMainThreadRuning = false; }
|
||||
MainThread::MainThread()
|
||||
{
|
||||
mMainThreadRuning = false;
|
||||
}
|
||||
std::shared_ptr<MainThread> &MainThread::GetInstance(std::shared_ptr<MainThread> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<MainThread>();
|
||||
|
@ -87,7 +90,9 @@ void MainThread::DestoryAllModules(void)
|
|||
DestroyMcuManager();
|
||||
DestroyHalCppModule();
|
||||
}
|
||||
void MainThread::ResetAllPtrMaker(void) {}
|
||||
void MainThread::ResetAllPtrMaker(void)
|
||||
{
|
||||
}
|
||||
void MainThread::Runing(void)
|
||||
{
|
||||
while (mMainThreadRuning) {
|
||||
|
|
|
@ -25,7 +25,10 @@ public:
|
|||
virtual StatusCode Init(void);
|
||||
virtual StatusCode UnInit(void);
|
||||
void Runing(void);
|
||||
void Exit(void) { mMainThreadRuning = false; }
|
||||
void Exit(void)
|
||||
{
|
||||
mMainThreadRuning = false;
|
||||
}
|
||||
virtual void CustomizationInit(void);
|
||||
|
||||
private:
|
||||
|
|
|
@ -43,7 +43,9 @@ class VMissionDataV2 : public VMissionData
|
|||
{
|
||||
|
||||
public:
|
||||
VMissionDataV2(const MissionEvent &event, T value) : VMissionData(event), mData(value) {}
|
||||
VMissionDataV2(const MissionEvent &event, T value) : VMissionData(event), mData(value)
|
||||
{
|
||||
}
|
||||
virtual ~VMissionDataV2() = default;
|
||||
|
||||
public:
|
||||
|
|
|
@ -117,9 +117,18 @@ StatusCode AppMonitor::SetTimeZone(const unsigned int &zone)
|
|||
//
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::SetParamValue(const AppSetParamValue ¶m) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
StatusCode AppMonitor::EnterRecorder(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
StatusCode AppMonitor::AppPlayback(const PlayBackEvent &event) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
StatusCode AppMonitor::SetParamValue(const AppSetParamValue ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::EnterRecorder(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::AppPlayback(const PlayBackEvent &event)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::UploadFile(AppUploadFile ¶m)
|
||||
{
|
||||
//
|
||||
|
|
|
@ -27,7 +27,9 @@ enum class InternalStateEvent
|
|||
class MissionData : public VStateMachineData
|
||||
{
|
||||
public:
|
||||
MissionData(const std::shared_ptr<VMissionData> &data) : mMissionData(data) {}
|
||||
MissionData(const std::shared_ptr<VMissionData> &data) : mMissionData(data)
|
||||
{
|
||||
}
|
||||
virtual ~MissionData() = default;
|
||||
const std::shared_ptr<VMissionData> mMissionData;
|
||||
};
|
||||
|
|
|
@ -28,5 +28,11 @@ std::shared_ptr<IMissionManager> &IMissionManager::GetInstance(std::shared_ptr<I
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
const StatusCode IMissionManager::Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IMissionManager::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IMissionManager::Init(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const StatusCode IMissionManager::UnInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
|
@ -15,7 +15,9 @@
|
|||
#include "MissionState.h"
|
||||
#include "IAppManager.h"
|
||||
#include "ILog.h"
|
||||
MissionState::MissionState(const std::string &name) : State(name) {}
|
||||
MissionState::MissionState(const std::string &name) : State(name)
|
||||
{
|
||||
}
|
||||
void MissionState::GoInState()
|
||||
{
|
||||
//
|
||||
|
@ -26,4 +28,7 @@ void MissionState::GoOutState()
|
|||
//
|
||||
LogInfo(" ========== MissionState::GoOutState.\n");
|
||||
}
|
||||
bool MissionState::ExecuteStateMsg(VStateMachineData *msg) { return DataProcessing::EventHandle(msg); }
|
||||
bool MissionState::ExecuteStateMsg(VStateMachineData *msg)
|
||||
{
|
||||
return DataProcessing::EventHandle(msg);
|
||||
}
|
|
@ -63,7 +63,10 @@ IpcMission MissionStateMachine::GetStartMission(void)
|
|||
class McuAskIpcMission : public McuAsk<IpcMission>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskIpcMission() : McuAskBase(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY) { mDataReply = IpcMission::END; }
|
||||
McuAskIpcMission() : McuAskBase(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
mDataReply = IpcMission::END;
|
||||
}
|
||||
virtual ~McuAskIpcMission() = default;
|
||||
};
|
||||
std::shared_ptr<VMcuAsk> ask = std::make_shared<McuAskIpcMission>();
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
#include "TestMissionState.h"
|
||||
#include "IAppManager.h"
|
||||
#include "ILog.h"
|
||||
TestMissionState::TestMissionState() : MissionState("TestMissionState") {}
|
||||
TestMissionState::TestMissionState() : MissionState("TestMissionState")
|
||||
{
|
||||
}
|
||||
void TestMissionState::GoInState()
|
||||
{
|
||||
MissionState::GoInState();
|
||||
|
@ -31,4 +33,7 @@ void TestMissionState::GoOutState()
|
|||
MissionState::GoOutState();
|
||||
LogInfo(" ========== TestMissionState::GoOutState.\n");
|
||||
}
|
||||
bool TestMissionState::ExecuteStateMsg(VStateMachineData *msg) { return MissionState::EventHandle(msg); }
|
||||
bool TestMissionState::ExecuteStateMsg(VStateMachineData *msg)
|
||||
{
|
||||
return MissionState::EventHandle(msg);
|
||||
}
|
|
@ -15,7 +15,9 @@
|
|||
#include "TopState.h"
|
||||
#include "ILog.h"
|
||||
#include "MissionStateMachine.h"
|
||||
TopState::TopState() : State("TopState") {}
|
||||
TopState::TopState() : State("TopState")
|
||||
{
|
||||
}
|
||||
void TopState::GoInState()
|
||||
{
|
||||
//
|
||||
|
@ -27,4 +29,7 @@ void TopState::GoOutState()
|
|||
//
|
||||
LogInfo(" ========== opState::GoOutState.\n");
|
||||
}
|
||||
bool TopState::ExecuteStateMsg(VStateMachineData *msg) { return DataProcessing::EventHandle(msg); }
|
||||
bool TopState::ExecuteStateMsg(VStateMachineData *msg)
|
||||
{
|
||||
return DataProcessing::EventHandle(msg);
|
||||
}
|
|
@ -16,7 +16,10 @@
|
|||
#include "IHalCpp.h"
|
||||
#include "ILog.h"
|
||||
#include <thread>
|
||||
MainThread::MainThread() { mMainThreadRuning = false; }
|
||||
MainThread::MainThread()
|
||||
{
|
||||
mMainThreadRuning = false;
|
||||
}
|
||||
std::shared_ptr<MainThread> &MainThread::GetInstance(std::shared_ptr<MainThread> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<MainThread>();
|
||||
|
@ -56,8 +59,12 @@ StatusCode MainThread::CreateAllModules(void)
|
|||
CreateHalCppModule();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
void MainThread::DestoryAllModules(void) {}
|
||||
void MainThread::ResetAllPtrMaker(void) {}
|
||||
void MainThread::DestoryAllModules(void)
|
||||
{
|
||||
}
|
||||
void MainThread::ResetAllPtrMaker(void)
|
||||
{
|
||||
}
|
||||
void MainThread::Runing(void)
|
||||
{
|
||||
while (mMainThreadRuning) {
|
||||
|
|
|
@ -25,8 +25,13 @@ public:
|
|||
virtual StatusCode Init(void);
|
||||
virtual StatusCode UnInit(void);
|
||||
void Runing(void);
|
||||
void Exit(void) { mMainThreadRuning = false; }
|
||||
virtual void CustomizationInit(void) {}
|
||||
void Exit(void)
|
||||
{
|
||||
mMainThreadRuning = false;
|
||||
}
|
||||
virtual void CustomizationInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
StatusCode CreateAllModules(void);
|
||||
|
|
|
@ -17,16 +17,27 @@
|
|||
#include "StatusCode.h"
|
||||
// #include <stddef.h>
|
||||
#include <string.h>
|
||||
static StatusCode IHalInit(IHal *object) { return IHalCpp::GetInstance()->Init(); }
|
||||
static void IHalFree(void *object) {}
|
||||
static StatusCode IHalUnInit(IHal *object) { return IHalCpp::GetInstance()->UnInit(); }
|
||||
static StatusCode IHalInit(IHal *object)
|
||||
{
|
||||
return IHalCpp::GetInstance()->Init();
|
||||
}
|
||||
static void IHalFree(void *object)
|
||||
{
|
||||
}
|
||||
static StatusCode IHalUnInit(IHal *object)
|
||||
{
|
||||
return IHalCpp::GetInstance()->UnInit();
|
||||
}
|
||||
static IHal default_hal = {
|
||||
.init = IHalInit,
|
||||
.un_init = IHalUnInit,
|
||||
.free = IHalFree,
|
||||
};
|
||||
static IHal *hal_instance = &default_hal;
|
||||
IHal *GetHalIntance(void) { return hal_instance; }
|
||||
IHal *GetHalIntance(void)
|
||||
{
|
||||
return hal_instance;
|
||||
}
|
||||
StatusCode NewIHal(IHal **object)
|
||||
{
|
||||
if (!object || !(*object)) {
|
||||
|
|
|
@ -29,8 +29,14 @@ std::shared_ptr<IHalCpp> &IHalCpp::GetInstance(std::shared_ptr<IHalCpp> *impl)
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
StatusCode IHalCpp::Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode IHalCpp::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode IHalCpp::Init(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode IHalCpp::UnInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode IHalCpp::GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
|
|
|
@ -48,8 +48,14 @@ typedef struct i_hal
|
|||
IHal *GetHalIntance(void);
|
||||
StatusCode NewIHal(IHal **object);
|
||||
void ResetHalImpl(IHal *impl);
|
||||
static inline StatusCode IHalInit(void) { return GetHalIntance()->init(GetHalIntance()); }
|
||||
static inline StatusCode IHalUnInit(void) { return GetHalIntance()->un_init(GetHalIntance()); }
|
||||
static inline StatusCode IHalInit(void)
|
||||
{
|
||||
return GetHalIntance()->init(GetHalIntance());
|
||||
}
|
||||
static inline StatusCode IHalUnInit(void)
|
||||
{
|
||||
return GetHalIntance()->un_init(GetHalIntance());
|
||||
}
|
||||
StatusCode CreateHalModule(void);
|
||||
StatusCode DestroyHalModule(void);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -40,9 +40,15 @@ class VKeyHal
|
|||
public:
|
||||
VKeyHal() = default;
|
||||
virtual ~VKeyHal() = default;
|
||||
virtual void CheckKeyStatus(void) {}
|
||||
virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event) {}
|
||||
virtual void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor) {}
|
||||
virtual void CheckKeyStatus(void)
|
||||
{
|
||||
}
|
||||
virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event)
|
||||
{
|
||||
}
|
||||
virtual void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor)
|
||||
{
|
||||
}
|
||||
};
|
||||
class VLedHal
|
||||
{
|
||||
|
@ -55,7 +61,10 @@ class VWifiHal
|
|||
public:
|
||||
VWifiHal() = default;
|
||||
virtual ~VWifiHal() = default;
|
||||
virtual StatusCode OpenApMode(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
virtual StatusCode OpenApMode(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
};
|
||||
class IHalCpp
|
||||
{
|
||||
|
|
|
@ -24,8 +24,14 @@ public:
|
|||
HalMakePtr() = default;
|
||||
virtual ~HalMakePtr() = default;
|
||||
static std::shared_ptr<HalMakePtr> &GetInstance(std::shared_ptr<HalMakePtr> *impl = nullptr);
|
||||
virtual StatusCode Init() { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
virtual StatusCode UnInit() { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
virtual StatusCode Init()
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
virtual StatusCode UnInit()
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
virtual StatusCode CreateHalPtr(IHal **hal);
|
||||
virtual StatusCode CreateHalSharePtr(std::shared_ptr<IHalCpp> &impl);
|
||||
virtual StatusCode CreateWifiHal(std::shared_ptr<VWifiHal> &impl);
|
||||
|
|
|
@ -153,7 +153,9 @@ enum class FileCopy
|
|||
};
|
||||
typedef struct app_get_product_info
|
||||
{
|
||||
app_get_product_info() {}
|
||||
app_get_product_info()
|
||||
{
|
||||
}
|
||||
std::string mModel;
|
||||
std::string mCompany;
|
||||
std::string mSoc;
|
||||
|
@ -161,7 +163,9 @@ typedef struct app_get_product_info
|
|||
} AppGetProductInfo;
|
||||
typedef struct app_get_device_attr
|
||||
{
|
||||
app_get_device_attr() {}
|
||||
app_get_device_attr()
|
||||
{
|
||||
}
|
||||
std::string mUUID;
|
||||
std::string mSoftVersion;
|
||||
std::string mOtaVersion;
|
||||
|
@ -174,7 +178,10 @@ typedef struct app_get_device_attr
|
|||
} AppGetDeviceAttr;
|
||||
typedef struct app_get_media_info
|
||||
{
|
||||
app_get_media_info() { mPort = -1; }
|
||||
app_get_media_info()
|
||||
{
|
||||
mPort = -1;
|
||||
}
|
||||
std::string mRtspUrl;
|
||||
std::string mTransport;
|
||||
int mPort;
|
||||
|
@ -281,7 +288,10 @@ typedef struct app_get_file_list
|
|||
} AppGetFileList;
|
||||
typedef struct app_set_param_value
|
||||
{
|
||||
app_set_param_value() { mValue = -1; }
|
||||
app_set_param_value()
|
||||
{
|
||||
mValue = -1;
|
||||
}
|
||||
std::string mName;
|
||||
int mValue;
|
||||
} AppSetParamValue;
|
||||
|
@ -311,7 +321,9 @@ typedef struct app_upload_file
|
|||
} AppUploadFile;
|
||||
typedef struct app_get_thumbnail
|
||||
{
|
||||
app_get_thumbnail(const std::string file) : mFile(file) {}
|
||||
app_get_thumbnail(const std::string file) : mFile(file)
|
||||
{
|
||||
}
|
||||
const std::string mFile;
|
||||
std::string mThumbnail;
|
||||
} AppGetThumbnail;
|
||||
|
@ -340,7 +352,9 @@ public:
|
|||
};
|
||||
typedef struct app_param
|
||||
{
|
||||
app_param(const char *ip, const int port) : mIP(ip), mPort(port) {}
|
||||
app_param(const char *ip, const int port) : mIP(ip), mPort(port)
|
||||
{
|
||||
}
|
||||
const char *mIP;
|
||||
const int mPort;
|
||||
} AppParam;
|
||||
|
|
|
@ -22,7 +22,10 @@ StatusCode VAppMonitor::GetDeviceAttr(AppGetDeviceAttr ¶m)
|
|||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetMediaInfo(AppGetMeidaInfo ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::GetMediaInfo(AppGetMeidaInfo ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetSdCardInfo(AppGetSdCardInfo ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
|
@ -31,7 +34,10 @@ StatusCode VAppMonitor::GetBatteryInfo(AppGetBatteryInfo ¶m)
|
|||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetParamValue(AppParamValue ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::GetParamValue(AppParamValue ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetCapability(AppGetCapability ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
|
@ -52,18 +58,30 @@ StatusCode VAppMonitor::SetDateTime(const AppSetDateTime ¶m)
|
|||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::SetTimeZone(const unsigned int &zone) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::SetTimeZone(const unsigned int &zone)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::SetParamValue(const AppSetParamValue ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::EnterRecorder(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::EnterRecorder(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::AppPlayback(const PlayBackEvent &event)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::UploadFile(AppUploadFile ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::GetThumbnail(AppGetThumbnail ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
StatusCode VAppMonitor::UploadFile(AppUploadFile ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
StatusCode VAppMonitor::GetThumbnail(AppGetThumbnail ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
std::shared_ptr<IAppManager> &IAppManager::GetInstance(std::shared_ptr<IAppManager> *impl)
|
||||
{
|
||||
static auto instance = std::make_shared<IAppManager>();
|
||||
|
@ -78,8 +96,14 @@ std::shared_ptr<IAppManager> &IAppManager::GetInstance(std::shared_ptr<IAppManag
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
const StatusCode IAppManager::Init(const AppParam ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IAppManager::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IAppManager::Init(const AppParam ¶m)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const StatusCode IAppManager::UnInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const StatusCode IAppManager::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
|
|
|
@ -30,12 +30,18 @@ class IAppProtocolHandle
|
|||
public:
|
||||
IAppProtocolHandle() = default;
|
||||
virtual ~IAppProtocolHandle() = default;
|
||||
virtual void Init(void) {}
|
||||
virtual void UnInit(void) {}
|
||||
virtual void Init(void)
|
||||
{
|
||||
}
|
||||
virtual void UnInit(void)
|
||||
{
|
||||
}
|
||||
virtual void RequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle,
|
||||
void *context)
|
||||
{
|
||||
}
|
||||
virtual void SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) {}
|
||||
virtual void SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
|
@ -36,7 +36,9 @@ class ParseUrl : public VParseUrl
|
|||
{
|
||||
|
||||
public:
|
||||
ParseUrl() {}
|
||||
ParseUrl()
|
||||
{
|
||||
}
|
||||
virtual ~ParseUrl() = default;
|
||||
|
||||
public:
|
||||
|
|
|
@ -36,7 +36,9 @@ class VKeyMonitor
|
|||
public:
|
||||
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
|
||||
{
|
||||
|
|
|
@ -28,8 +28,14 @@ std::shared_ptr<IDeviceManager> &IDeviceManager::GetInstance(std::shared_ptr<IDe
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
const StatusCode IDeviceManager::Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IDeviceManager::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IDeviceManager::Init(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const StatusCode IDeviceManager::UnInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const StatusCode IDeviceManager::ControlLed(const std::string &ledName, std::shared_ptr<VirtualLedControl> &control)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
|
|
|
@ -96,30 +96,89 @@ class IIpcConfig
|
|||
public:
|
||||
IIpcConfig() = default;
|
||||
virtual ~IIpcConfig() = default;
|
||||
virtual const StatusCode ConfigFileSave(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
virtual const StatusCode ConfigFileSave(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
static std::shared_ptr<IIpcConfig> &GetInstance(std::shared_ptr<IIpcConfig> *impl = nullptr);
|
||||
virtual const StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
virtual const StatusCode UnInit(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
virtual const int GetInt(const IpcConfigKey &key) { return -1; }
|
||||
virtual void SetInt(const IpcConfigKey &key, const int &value) {}
|
||||
virtual const short GetShort(const IpcConfigKey &key) { return -1; }
|
||||
virtual void SetShort(const IpcConfigKey &key, const short &value) {}
|
||||
virtual const long GetLong(const IpcConfigKey &key) { return -1; }
|
||||
virtual void SetLong(const IpcConfigKey &key, const long &value) {}
|
||||
virtual const long long GetLLong(const IpcConfigKey &key) { return -1; }
|
||||
virtual void SetLLong(const IpcConfigKey &key, const long long &value) {}
|
||||
virtual const char GetChar(const IpcConfigKey &key) { return '\0'; }
|
||||
virtual void SetChar(const IpcConfigKey &key, const char &value) {}
|
||||
virtual const float GetFloat(const IpcConfigKey &key) { return -1.0; }
|
||||
virtual void SetFloat(const IpcConfigKey &key, const float &value) {}
|
||||
virtual const double GetDouble(const IpcConfigKey &key) { return -1.0; }
|
||||
virtual void SetDouble(const IpcConfigKey &key, const double &value) {}
|
||||
virtual const long double GetLongDouble(const IpcConfigKey &key) { return -1.0; }
|
||||
virtual void SetLongDouble(const IpcConfigKey &key, const long double &value) {}
|
||||
virtual const bool GetBool(const IpcConfigKey &key) { return true; }
|
||||
virtual void SetBool(const IpcConfigKey &key, const bool &value) {}
|
||||
virtual const std::string GetString(const IpcConfigKey &key) { return "undefine"; }
|
||||
virtual void SetString(const IpcConfigKey &key, const std::string string) {}
|
||||
virtual const StatusCode Init(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
virtual const StatusCode UnInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
virtual const int GetInt(const IpcConfigKey &key)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
virtual void SetInt(const IpcConfigKey &key, const int &value)
|
||||
{
|
||||
}
|
||||
virtual const short GetShort(const IpcConfigKey &key)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
virtual void SetShort(const IpcConfigKey &key, const short &value)
|
||||
{
|
||||
}
|
||||
virtual const long GetLong(const IpcConfigKey &key)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
virtual void SetLong(const IpcConfigKey &key, const long &value)
|
||||
{
|
||||
}
|
||||
virtual const long long GetLLong(const IpcConfigKey &key)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
virtual void SetLLong(const IpcConfigKey &key, const long long &value)
|
||||
{
|
||||
}
|
||||
virtual const char GetChar(const IpcConfigKey &key)
|
||||
{
|
||||
return '\0';
|
||||
}
|
||||
virtual void SetChar(const IpcConfigKey &key, const char &value)
|
||||
{
|
||||
}
|
||||
virtual const float GetFloat(const IpcConfigKey &key)
|
||||
{
|
||||
return -1.0;
|
||||
}
|
||||
virtual void SetFloat(const IpcConfigKey &key, const float &value)
|
||||
{
|
||||
}
|
||||
virtual const double GetDouble(const IpcConfigKey &key)
|
||||
{
|
||||
return -1.0;
|
||||
}
|
||||
virtual void SetDouble(const IpcConfigKey &key, const double &value)
|
||||
{
|
||||
}
|
||||
virtual const long double GetLongDouble(const IpcConfigKey &key)
|
||||
{
|
||||
return -1.0;
|
||||
}
|
||||
virtual void SetLongDouble(const IpcConfigKey &key, const long double &value)
|
||||
{
|
||||
}
|
||||
virtual const bool GetBool(const IpcConfigKey &key)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual void SetBool(const IpcConfigKey &key, const bool &value)
|
||||
{
|
||||
}
|
||||
virtual const std::string GetString(const IpcConfigKey &key)
|
||||
{
|
||||
return "undefine";
|
||||
}
|
||||
virtual void SetString(const IpcConfigKey &key, const std::string string)
|
||||
{
|
||||
}
|
||||
};
|
||||
bool CreateIpcConfig(void);
|
||||
#endif
|
|
@ -121,7 +121,10 @@ const StatusCode IpcConfig::UnInit(void)
|
|||
CloseConfigFile(mCfg);
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
const StatusCode IpcConfig::ConfigFileSave(void) { return ConfigSaveFile(mCfg); }
|
||||
const StatusCode IpcConfig::ConfigFileSave(void)
|
||||
{
|
||||
return ConfigSaveFile(mCfg);
|
||||
}
|
||||
|
||||
const int IpcConfig::GetInt(const IpcConfigKey &key)
|
||||
{
|
||||
|
|
|
@ -57,12 +57,26 @@ typedef struct mcu_ask_date_time
|
|||
class VMcuAsk
|
||||
{
|
||||
public:
|
||||
VMcuAsk() { mSerialNumber = 0; }
|
||||
VMcuAsk()
|
||||
{
|
||||
mSerialNumber = 0;
|
||||
}
|
||||
virtual ~VMcuAsk() = default;
|
||||
virtual ASK_RESULT Blocking(void) { return ASK_RESULT::END; }
|
||||
virtual bool NeedReply(void) { return false; }
|
||||
virtual void ReplyFinished(const bool result) {}
|
||||
virtual bool IfTimeout(const unsigned int &integrationTimeMs) { return false; }
|
||||
virtual ASK_RESULT Blocking(void)
|
||||
{
|
||||
return ASK_RESULT::END;
|
||||
}
|
||||
virtual bool NeedReply(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual void ReplyFinished(const bool result)
|
||||
{
|
||||
}
|
||||
virtual bool IfTimeout(const unsigned int &integrationTimeMs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -87,7 +101,9 @@ class VMcuMonitor
|
|||
public:
|
||||
VMcuMonitor() = default;
|
||||
virtual ~VMcuMonitor() = default;
|
||||
virtual void RecvIpcMissionEvent(std::shared_ptr<VMcuAsk> &recv, const IpcMission &mission) {}
|
||||
virtual void RecvIpcMissionEvent(std::shared_ptr<VMcuAsk> &recv, const IpcMission &mission)
|
||||
{
|
||||
}
|
||||
};
|
||||
class IMcuManager
|
||||
{
|
||||
|
|
|
@ -28,8 +28,14 @@ std::shared_ptr<IMcuManager> &IMcuManager::GetInstance(std::shared_ptr<IMcuManag
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
const StatusCode IMcuManager::Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IMcuManager::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
const StatusCode IMcuManager::Init(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const StatusCode IMcuManager::UnInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const StatusCode IMcuManager::SetMcuMonitor(std::shared_ptr<VMcuMonitor> &monitor)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
|
|
|
@ -28,7 +28,9 @@ McuDevice::McuDevice()
|
|||
mThreadRuning = false;
|
||||
mUartDevice = nullptr;
|
||||
}
|
||||
McuDevice::~McuDevice() {}
|
||||
McuDevice::~McuDevice()
|
||||
{
|
||||
}
|
||||
const StatusCode McuDevice::Init(void)
|
||||
{
|
||||
UartInfo uartDevice = {
|
||||
|
@ -50,9 +52,13 @@ const StatusCode McuDevice::Init(void)
|
|||
return code;
|
||||
}
|
||||
std::shared_ptr<McuDevice> device = std::dynamic_pointer_cast<McuDevice>(SharedFromThis());
|
||||
auto recvThread = [](std::shared_ptr<McuDevice> device) { device->DeviceRecvThread(); };
|
||||
auto recvThread = [](std::shared_ptr<McuDevice> device) {
|
||||
device->DeviceRecvThread();
|
||||
};
|
||||
mUartRecvThread = std::thread(recvThread, device);
|
||||
auto mcuAskHandle = [](std::shared_ptr<McuDevice> device) { device->McuAskHandleThread(); };
|
||||
auto mcuAskHandle = [](std::shared_ptr<McuDevice> device) {
|
||||
device->McuAskHandleThread();
|
||||
};
|
||||
mMcuAskHandleThread = std::thread(mcuAskHandle, device);
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,10 @@
|
|||
#include "McuManagerImpl.h"
|
||||
#include "ILog.h"
|
||||
#include "UartRecvAsk.h"
|
||||
std::shared_ptr<VProtocolBase> McuManagerImpl::SharedFromThis(void) { return shared_from_this(); }
|
||||
std::shared_ptr<VProtocolBase> McuManagerImpl::SharedFromThis(void)
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
const StatusCode McuManagerImpl::Init(void)
|
||||
{
|
||||
McuDevice::Init();
|
||||
|
|
|
@ -36,19 +36,37 @@ enum class SensorTaskType
|
|||
class SensorTaskResponse
|
||||
{
|
||||
public:
|
||||
SensorTaskResponse() {}
|
||||
~SensorTaskResponse() {}
|
||||
SensorTaskResponse()
|
||||
{
|
||||
}
|
||||
~SensorTaskResponse()
|
||||
{
|
||||
}
|
||||
};
|
||||
class VSensorTask
|
||||
{
|
||||
public:
|
||||
VSensorTask() = default;
|
||||
virtual ~VSensorTask() = default;
|
||||
virtual const SensorTaskType GetTaskType(void) { return SensorTaskType::END; }
|
||||
virtual void Response(const std::vector<SensorTaskResponse> &response) {}
|
||||
virtual bool IsTaskFinished(void) { return false; }
|
||||
virtual const signed int GetIsNight(void) { return 0; }
|
||||
virtual const unsigned int GetIsMultShot(void) { return false; }
|
||||
virtual const SensorTaskType GetTaskType(void)
|
||||
{
|
||||
return SensorTaskType::END;
|
||||
}
|
||||
virtual void Response(const std::vector<SensorTaskResponse> &response)
|
||||
{
|
||||
}
|
||||
virtual bool IsTaskFinished(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual const signed int GetIsNight(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual const unsigned int GetIsMultShot(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
class VSensorHandle
|
||||
{
|
||||
|
|
|
@ -36,14 +36,19 @@ public:
|
|||
class State
|
||||
{
|
||||
public:
|
||||
explicit State(const std::string &name) : mStateName(name) {}
|
||||
explicit State(const std::string &name) : mStateName(name)
|
||||
{
|
||||
}
|
||||
virtual ~State() = default;
|
||||
|
||||
public:
|
||||
virtual void GoInState() = 0;
|
||||
virtual void GoOutState() = 0;
|
||||
virtual bool ExecuteStateMsg(VStateMachineData *msg) = 0;
|
||||
std::string GetStateName() { return mStateName; }
|
||||
std::string GetStateName()
|
||||
{
|
||||
return mStateName;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string mStateName;
|
||||
|
@ -53,20 +58,41 @@ class VStateMachineHandle
|
|||
public:
|
||||
VStateMachineHandle() = default;
|
||||
virtual ~VStateMachineHandle() = default;
|
||||
virtual bool InitialStateMachine() { return false; }
|
||||
virtual void StatePlus(State *state, State *upper) {}
|
||||
virtual void SetCurrentState(State *firstState) {}
|
||||
virtual void StartStateMachine() {}
|
||||
virtual void SendMessage(int msgName) {}
|
||||
virtual void StopHandlerThread() {}
|
||||
virtual void SendMessage(int msgName, const std::shared_ptr<VStateMessage> &messageObj) {}
|
||||
virtual bool InitialStateMachine()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual void StatePlus(State *state, State *upper)
|
||||
{
|
||||
}
|
||||
virtual void SetCurrentState(State *firstState)
|
||||
{
|
||||
}
|
||||
virtual void StartStateMachine()
|
||||
{
|
||||
}
|
||||
virtual void SendMessage(int msgName)
|
||||
{
|
||||
}
|
||||
virtual void StopHandlerThread()
|
||||
{
|
||||
}
|
||||
virtual void SendMessage(int msgName, const std::shared_ptr<VStateMessage> &messageObj)
|
||||
{
|
||||
}
|
||||
virtual void MessageExecutedLater(int msgName, const std::shared_ptr<VStateMessage> &messageObj,
|
||||
int64_t delayTimeMs)
|
||||
{
|
||||
}
|
||||
virtual void SwitchState(State *targetState) {}
|
||||
virtual void StopTimer(int timerName) {}
|
||||
virtual void DelayMessage(VStateMachineData *msg) {}
|
||||
virtual void SwitchState(State *targetState)
|
||||
{
|
||||
}
|
||||
virtual void StopTimer(int timerName)
|
||||
{
|
||||
}
|
||||
virtual void DelayMessage(VStateMachineData *msg)
|
||||
{
|
||||
}
|
||||
};
|
||||
class IStateMachine
|
||||
{
|
||||
|
|
|
@ -198,7 +198,10 @@ public:
|
|||
// mMessageObj = T(messageObj);
|
||||
// }
|
||||
|
||||
void SetMessageObj(const std::shared_ptr<VStateMessage> &messageObj) { mMessageObj = messageObj; }
|
||||
void SetMessageObj(const std::shared_ptr<VStateMessage> &messageObj)
|
||||
{
|
||||
mMessageObj = messageObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @DescriptionGet the Message Obj object
|
||||
|
@ -223,7 +226,10 @@ public:
|
|||
// {
|
||||
// return mMessageObj;
|
||||
// }
|
||||
const std::shared_ptr<VStateMessage> &GetMessageObj(void) const override { return mMessageObj; }
|
||||
const std::shared_ptr<VStateMessage> &GetMessageObj(void) const override
|
||||
{
|
||||
return mMessageObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description : Release Message Object.
|
||||
|
|
|
@ -42,14 +42,21 @@ class HunttingCameraTest : public testing::Test,
|
|||
|
||||
{
|
||||
public:
|
||||
HunttingCameraTest() {}
|
||||
virtual ~HunttingCameraTest() {}
|
||||
HunttingCameraTest()
|
||||
{
|
||||
}
|
||||
virtual ~HunttingCameraTest()
|
||||
{
|
||||
}
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
CreateLogModule();
|
||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||
}
|
||||
static void TearDownTestCase() { ILogUnInit(); }
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
ILogUnInit();
|
||||
}
|
||||
virtual void SetUp()
|
||||
{
|
||||
std::shared_ptr<MainThread> mainThread = std::make_shared<MainThreadTest>();
|
||||
|
|
|
@ -32,7 +32,9 @@ public:
|
|||
const unsigned int &blinkTimeMs);
|
||||
|
||||
protected:
|
||||
virtual void DeviceManagerNotice(const std::string &keyName, const unsigned int &pressingTimeMs) {}
|
||||
virtual void DeviceManagerNotice(const std::string &keyName, const unsigned int &pressingTimeMs)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
void KeyEventHappendOnce(std::shared_ptr<VKeyHal> &vMock, const unsigned int &pressingTimeMs);
|
||||
|
|
|
@ -23,11 +23,17 @@ class KeyControlTest : public KeyControl, public VKeyHal
|
|||
public:
|
||||
KeyControlTest(const std::string &keyName);
|
||||
virtual ~KeyControlTest() = default;
|
||||
unsigned int GetStatusCheckPeriodMs(void) override { return PERIPHERAL_CHECK_PERIOD_MS; }
|
||||
unsigned int GetStatusCheckPeriodMs(void) override
|
||||
{
|
||||
return PERIPHERAL_CHECK_PERIOD_MS;
|
||||
}
|
||||
void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor) override;
|
||||
void CheckKeyStatus(void) override;
|
||||
void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) override;
|
||||
const std::string GetKeyName(void) override { return mKeyName; }
|
||||
const std::string GetKeyName(void) override
|
||||
{
|
||||
return mKeyName;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual StatusCode KeyEventTriggerTrace(const std::string &keyName, const KeyEvent &event,
|
||||
|
|
|
@ -24,14 +24,21 @@ namespace AppManagerTest
|
|||
class AppManagerTest : public testing::Test, public AppManagerTestTool, public HalTestTool
|
||||
{
|
||||
public:
|
||||
AppManagerTest() : mAppParam(APP_MANAGER_HTTP_SERVER_IP, APP_MANAGER_HTTP_SERVER_PORT) {}
|
||||
virtual ~AppManagerTest() {}
|
||||
AppManagerTest() : mAppParam(APP_MANAGER_HTTP_SERVER_IP, APP_MANAGER_HTTP_SERVER_PORT)
|
||||
{
|
||||
}
|
||||
virtual ~AppManagerTest()
|
||||
{
|
||||
}
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
CreateLogModule();
|
||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||
}
|
||||
static void TearDownTestCase() { ILogUnInit(); }
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
ILogUnInit();
|
||||
}
|
||||
virtual void SetUp()
|
||||
{
|
||||
HalTestTool::Init();
|
||||
|
|
|
@ -26,14 +26,21 @@ const char *LED_TEST = "LED_TEST";
|
|||
class DeviceManagerTest : public testing::Test, virtual public HalTestTool, public DeviceManagerTestTool
|
||||
{
|
||||
public:
|
||||
DeviceManagerTest() {}
|
||||
virtual ~DeviceManagerTest() {}
|
||||
DeviceManagerTest()
|
||||
{
|
||||
}
|
||||
virtual ~DeviceManagerTest()
|
||||
{
|
||||
}
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
CreateLogModule();
|
||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||
}
|
||||
static void TearDownTestCase() { ILogUnInit(); }
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
ILogUnInit();
|
||||
}
|
||||
virtual void SetUp()
|
||||
{
|
||||
CreateAllKeysMcok();
|
||||
|
|
|
@ -22,8 +22,14 @@ public:
|
|||
SingleControlTool(const LedState &state, const unsigned int aliveTimeMs, const unsigned int &blinkTimeMs);
|
||||
virtual ~SingleControlTool() = default;
|
||||
virtual StatusCode GetLedState(LedState &state);
|
||||
virtual unsigned int GetKeepAliveTimeMs(void) { return mAliveTimeMs; }
|
||||
virtual unsigned int GetBlinkTimeMs(void) { return mBlinkTimeMs; }
|
||||
virtual unsigned int GetKeepAliveTimeMs(void)
|
||||
{
|
||||
return mAliveTimeMs;
|
||||
}
|
||||
virtual unsigned int GetBlinkTimeMs(void)
|
||||
{
|
||||
return mBlinkTimeMs;
|
||||
}
|
||||
|
||||
private:
|
||||
const LedState mState;
|
||||
|
|
|
@ -32,10 +32,18 @@ public:
|
|||
bool IfTimeout(const unsigned int &integrationTimeMs) override;
|
||||
|
||||
protected:
|
||||
virtual void BlockingTrace(void) {}
|
||||
virtual void NeedReplyTrace(void) {}
|
||||
virtual void ReplyFinishedTrace(const bool result) {}
|
||||
virtual void IfTimeoutTrace(const unsigned int &integrationTimeMs) {}
|
||||
virtual void BlockingTrace(void)
|
||||
{
|
||||
}
|
||||
virtual void NeedReplyTrace(void)
|
||||
{
|
||||
}
|
||||
virtual void ReplyFinishedTrace(const bool result)
|
||||
{
|
||||
}
|
||||
virtual void IfTimeoutTrace(const unsigned int &integrationTimeMs)
|
||||
{
|
||||
}
|
||||
};
|
||||
class McuAskBaseTestTool : public McuAskBaseTest
|
||||
{
|
||||
|
|
|
@ -12,14 +12,21 @@ namespace McuManagerMockTest
|
|||
class McuManagerMockTest : public testing::Test, public McuManagerTestTool
|
||||
{
|
||||
public:
|
||||
McuManagerMockTest() {}
|
||||
virtual ~McuManagerMockTest() {}
|
||||
McuManagerMockTest()
|
||||
{
|
||||
}
|
||||
virtual ~McuManagerMockTest()
|
||||
{
|
||||
}
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
CreateLogModule();
|
||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||
}
|
||||
static void TearDownTestCase() { ILogUnInit(); }
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
ILogUnInit();
|
||||
}
|
||||
virtual void SetUp()
|
||||
{
|
||||
mLinuxTest = LinuxTest::CreateLinuxTest();
|
||||
|
@ -58,7 +65,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_GetIpcMission)
|
|||
class McuAskTest : public McuAsk<IpcMission>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBase(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::BLOCK
|
||||
McuAskTest() : McuAskBase(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::BLOCK
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -96,7 +105,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_GetIpcMission2)
|
|||
class McuAskTest : public McuAsk<IpcMission>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::NOT_BLOCK
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::NOT_BLOCK
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -156,8 +167,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_CutOffPowerSupply)
|
|||
class McuAskTest : public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest()
|
||||
: McuAskBase(McuAskBlock::UNRELATED, McuAskReply::NEED_NOT_REPLY) {} // using McuAskReply::NEED_NOT_REPLY
|
||||
McuAskTest() : McuAskBase(McuAskBlock::UNRELATED, McuAskReply::NEED_NOT_REPLY)
|
||||
{
|
||||
} // using McuAskReply::NEED_NOT_REPLY
|
||||
virtual ~McuAskTest() = default;
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
@ -176,8 +188,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_FeedWatchDog)
|
|||
class McuAskTest : public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest()
|
||||
: McuAskBase(McuAskBlock::UNRELATED, McuAskReply::NEED_NOT_REPLY) {} // using McuAskReply::NEED_NOT_REPLY
|
||||
McuAskTest() : McuAskBase(McuAskBlock::UNRELATED, McuAskReply::NEED_NOT_REPLY)
|
||||
{
|
||||
} // using McuAskReply::NEED_NOT_REPLY
|
||||
virtual ~McuAskTest() = default;
|
||||
};
|
||||
IMcuManager::GetInstance()->Init();
|
||||
|
@ -196,7 +209,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_SetFeedingCycleForWatc
|
|||
class McuAskTest : public McuAsk<ASK_RESULT>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBase(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::BLOCK
|
||||
McuAskTest() : McuAskBase(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::BLOCK
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -230,7 +245,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_SetDateTime)
|
|||
class McuAskTest : public McuAsk<ASK_RESULT>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::NOT_BLOCK
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::NOT_BLOCK
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -262,7 +279,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_SetPirSensitivity)
|
|||
class McuAskTest : public McuAsk<ASK_RESULT>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::NOT_BLOCK
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::NOT_BLOCK
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -293,7 +312,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_ContorlInfraredLight)
|
|||
class McuAskTest : public McuAsk<ASK_RESULT>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::NOT_BLOCK
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::NOT_BLOCK
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -324,7 +345,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_EXAMPLE_GetPhotosensitivityVal
|
|||
class McuAskTest : public McuAsk<ASK_RESULT>, public McuAskBase
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::NOT_BLOCK
|
||||
McuAskTest() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::NOT_BLOCK
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -351,7 +374,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_AUTO_GetIpcMission)
|
|||
class McuAskTest : public McuAsk<IpcMission>, public McuAskBaseTestTool
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBaseTestTool(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY) {}
|
||||
McuAskTest() : McuAskBaseTestTool(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
}
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -381,7 +406,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_AUTO_GetIpcMission2)
|
|||
class McuAskTest : public McuAsk<IpcMission>, public McuAskBaseTestTool
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBaseTestTool(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY) {}
|
||||
McuAskTest() : McuAskBaseTestTool(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
}
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -573,8 +600,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_AUTO_STRESS_MultiThreadWrite)
|
|||
class McuAskTest2 : public McuAsk<IpcMission>, public McuAskBaseTestTool
|
||||
{
|
||||
public:
|
||||
McuAskTest2()
|
||||
: McuAskBaseTestTool(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY) {} // using McuAskBlock::NOT_BLOCK
|
||||
McuAskTest2() : McuAskBaseTestTool(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
} // using McuAskBlock::NOT_BLOCK
|
||||
virtual ~McuAskTest2() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
@ -763,7 +791,9 @@ TEST_F(McuManagerMockTest, INTEGRATION_McuManager_AUTO_GetIpcMissionFailed)
|
|||
class McuAskTest : public McuAsk<IpcMission>, public McuAskBaseTestTool
|
||||
{
|
||||
public:
|
||||
McuAskTest() : McuAskBaseTestTool(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY) {}
|
||||
McuAskTest() : McuAskBaseTestTool(McuAskBlock::BLOCK, McuAskReply::NEED_REPLY)
|
||||
{
|
||||
}
|
||||
virtual ~McuAskTest() = default;
|
||||
void ReplyFinished(const bool result) override
|
||||
{
|
||||
|
|
|
@ -60,8 +60,12 @@ public:
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
virtual void Init() {}
|
||||
virtual void UnInit() {}
|
||||
virtual void Init()
|
||||
{
|
||||
}
|
||||
virtual void UnInit()
|
||||
{
|
||||
}
|
||||
virtual int fx_open(const char *pathname, int flags);
|
||||
virtual int fx_tcgetattr(int fd, struct termios *termios_p);
|
||||
virtual int fx_tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
|
||||
|
@ -103,7 +107,10 @@ public:
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
virtual int GetHandleForMock(void) { return INVALID_HANDLE; }
|
||||
virtual int GetHandleForMock(void)
|
||||
{
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
|
||||
public:
|
||||
static std::shared_ptr<LinuxTest> CreateLinuxTest(void);
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "HandleManager.h"
|
||||
HandleManager::HandleManager() { mFdMax = 1000; }
|
||||
HandleManager::HandleManager()
|
||||
{
|
||||
mFdMax = 1000;
|
||||
}
|
||||
int HandleManager::GetHandleForMock(void)
|
||||
{
|
||||
int value = mFdMax;
|
||||
|
|
|
@ -92,7 +92,9 @@ void LinuxTestImpl::ApiInit(std::shared_ptr<LinuxTest> &mock)
|
|||
Invoke((std::dynamic_pointer_cast<LinuxTestImpl>(mock)).get(), &LinuxTestImpl::ApiUnlockThread),
|
||||
ReturnPointee(&selectResult)));
|
||||
}
|
||||
void LinuxTestImpl::Init() {}
|
||||
void LinuxTestImpl::Init()
|
||||
{
|
||||
}
|
||||
void LinuxTestImpl::UnInit()
|
||||
{
|
||||
if (mApiThread.joinable()) {
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int __wrap_fx_open(const char *pathname, int flags) { return LinuxApiMock::GetInstance()->fx_open(pathname, flags); }
|
||||
int __wrap_fx_open(const char *pathname, int flags)
|
||||
{
|
||||
return LinuxApiMock::GetInstance()->fx_open(pathname, flags);
|
||||
}
|
||||
int __wrap_fx_tcgetattr(int fd, struct termios *termios_p)
|
||||
{
|
||||
return LinuxApiMock::GetInstance()->fx_tcgetattr(fd, termios_p);
|
||||
|
@ -30,7 +33,10 @@ ssize_t __wrap_fx_write(int fd, const void *buf, size_t count)
|
|||
{
|
||||
return LinuxApiMock::GetInstance()->fx_write(fd, buf, count);
|
||||
}
|
||||
ssize_t __wrap_fx_read(int fd, void *buf, size_t count) { return LinuxApiMock::GetInstance()->fx_read(fd, buf, count); }
|
||||
ssize_t __wrap_fx_read(int fd, void *buf, size_t count)
|
||||
{
|
||||
return LinuxApiMock::GetInstance()->fx_read(fd, buf, count);
|
||||
}
|
||||
int __wrap_fx_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
|
||||
{
|
||||
return LinuxApiMock::GetInstance()->fx_select(nfds, readfds, writefds, exceptfds, timeout);
|
||||
|
|
|
@ -601,7 +601,9 @@ void McuProtocolTestTool::GetPhotosensitivityValueInit(std::shared_ptr<LinuxTest
|
|||
}
|
||||
void McuProtocolTestTool::UnlockProtocolHandle(void)
|
||||
{
|
||||
auto unlockThread = [=](McuProtocolTestTool *testTool) { testTool->UnlockThread(); };
|
||||
auto unlockThread = [=](McuProtocolTestTool *testTool) {
|
||||
testTool->UnlockThread();
|
||||
};
|
||||
if (mUnLockThread.joinable()) {
|
||||
mUnLockThread.join();
|
||||
}
|
||||
|
|
|
@ -33,14 +33,21 @@ static UartInfo gUartDevice = {
|
|||
class UartDeviceMockTest : public testing::Test, public UartDeviceTestTool
|
||||
{
|
||||
public:
|
||||
UartDeviceMockTest() {}
|
||||
virtual ~UartDeviceMockTest() {}
|
||||
UartDeviceMockTest()
|
||||
{
|
||||
}
|
||||
virtual ~UartDeviceMockTest()
|
||||
{
|
||||
}
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
CreateLogModule();
|
||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||
}
|
||||
static void TearDownTestCase() { ILogUnInit(); }
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
ILogUnInit();
|
||||
}
|
||||
virtual void SetUp()
|
||||
{
|
||||
mLinuxTest = LinuxTest::CreateLinuxTest();
|
||||
|
|
|
@ -99,7 +99,9 @@ void UartDeviceTestTool::SetRecvApiOnce(std::shared_ptr<LinuxTest> &mock, const
|
|||
EXPECT_CALL(*mock.get(), fx_select(uartFd + 1, _, _, _, _))
|
||||
.WillOnce(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(selectSucceed)), Return(SELECT_READABLE)))
|
||||
.WillRepeatedly(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(selectTimeOut)), Return(MOCK_SELECT_TIME_OUT)));
|
||||
auto readBuf = [=, &mock](int fd, void *buf, size_t count) { memcpy(buf, recvBuff, length); };
|
||||
auto readBuf = [=, &mock](int fd, void *buf, size_t count) {
|
||||
memcpy(buf, recvBuff, length);
|
||||
};
|
||||
EXPECT_CALL(*mock.get(), fx_read(uartFd, _, _))
|
||||
.WillOnce(DoAll(WithArgs<0, 1, 2>(Invoke(readBuf)), Return(length)))
|
||||
.WillRepeatedly(DoAll(Return(UART_DEVICE_READ_NOTHING)));
|
||||
|
|
|
@ -16,9 +16,18 @@
|
|||
#include "ConfigImpl.h"
|
||||
#include "ILog.h"
|
||||
#include <stddef.h>
|
||||
const StatusCode ConfigInit(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
const StatusCode ConfigUnInit(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||
VConfig *OpenConfigFile(const char *fileName) { return (VConfig *)NewConfig(fileName); }
|
||||
const StatusCode ConfigInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
const StatusCode ConfigUnInit(void)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
VConfig *OpenConfigFile(const char *fileName)
|
||||
{
|
||||
return (VConfig *)NewConfig(fileName);
|
||||
}
|
||||
const StatusCode ConfigSaveFile(VConfig *cfg)
|
||||
{
|
||||
if (NULL == cfg) {
|
||||
|
|
|
@ -38,9 +38,17 @@ class VKeyControl
|
|||
public:
|
||||
VKeyControl() = default;
|
||||
virtual ~VKeyControl() = default;
|
||||
virtual const std::string GetKeyName(void) { return "undefine"; }
|
||||
virtual unsigned int GetStatusCheckPeriodMs(void) { return 0; }
|
||||
virtual void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) {}
|
||||
virtual const std::string GetKeyName(void)
|
||||
{
|
||||
return "undefine";
|
||||
}
|
||||
virtual unsigned int GetStatusCheckPeriodMs(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs)
|
||||
{
|
||||
}
|
||||
};
|
||||
class KeyControl : public VKeyControl, public std::enable_shared_from_this<KeyControl>
|
||||
{
|
||||
|
|
|
@ -21,9 +21,16 @@ KeyControl::KeyControl()
|
|||
mPressingTime = KEY_NOT_PRESSING;
|
||||
mLongClickTime = 0;
|
||||
}
|
||||
KeyControl::~KeyControl() {}
|
||||
bool KeyControl::IsKeyPressing(void) { return mPressingTime >= KEY_PRESSING ? true : false; }
|
||||
void KeyControl::UnInit(void) {}
|
||||
KeyControl::~KeyControl()
|
||||
{
|
||||
}
|
||||
bool KeyControl::IsKeyPressing(void)
|
||||
{
|
||||
return mPressingTime >= KEY_PRESSING ? true : false;
|
||||
}
|
||||
void KeyControl::UnInit(void)
|
||||
{
|
||||
}
|
||||
void KeyControl::KeyHalEventHandle(const std::string &key, const KeyHalEvent &keyEvent)
|
||||
{
|
||||
if (KEY_PRESSING <= mPressingTime) {
|
||||
|
|
|
@ -44,20 +44,39 @@ class VSingleControl
|
|||
public:
|
||||
VSingleControl() = default;
|
||||
virtual ~VSingleControl() = default;
|
||||
virtual StatusCode GetLedState(LedState &state) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
virtual unsigned int GetKeepAliveTimeMs(void) { return KEEP_ALIVE_FOREVER; }
|
||||
virtual unsigned int GetBlinkTimeMs(void) { return LED_NOT_BLINK; }
|
||||
virtual StatusCode GetLedState(LedState &state)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
virtual unsigned int GetKeepAliveTimeMs(void)
|
||||
{
|
||||
return KEEP_ALIVE_FOREVER;
|
||||
}
|
||||
virtual unsigned int GetBlinkTimeMs(void)
|
||||
{
|
||||
return LED_NOT_BLINK;
|
||||
}
|
||||
};
|
||||
class VLedControl
|
||||
{
|
||||
public:
|
||||
VLedControl() = default;
|
||||
virtual ~VLedControl() = default;
|
||||
virtual StatusCode SetLedState(const LedState &state) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||
virtual void AddLedState(std::shared_ptr<VSingleControl> &control) {}
|
||||
virtual void CheckState(const unsigned int &period) {}
|
||||
virtual StatusCode SetLedState(const LedState &state)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
virtual void AddLedState(std::shared_ptr<VSingleControl> &control)
|
||||
{
|
||||
}
|
||||
virtual void CheckState(const unsigned int &period)
|
||||
{
|
||||
}
|
||||
// virtual void SetHalLedState(const VirtualLedState &state) {}
|
||||
virtual std::string GetLedName(void) { return "undefine"; }
|
||||
virtual std::string GetLedName(void)
|
||||
{
|
||||
return "undefine";
|
||||
}
|
||||
};
|
||||
class LedControl : virtual public VLedControl
|
||||
{
|
||||
|
|
|
@ -22,15 +22,30 @@
|
|||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int fx_system(const char *command) { return system(command); }
|
||||
int fx_open(const char *pathname, int flags) { return open(pathname, flags); }
|
||||
int fx_tcgetattr(int fd, struct termios *termios_p) { return tcgetattr(fd, termios_p); }
|
||||
int fx_system(const char *command)
|
||||
{
|
||||
return system(command);
|
||||
}
|
||||
int fx_open(const char *pathname, int flags)
|
||||
{
|
||||
return open(pathname, flags);
|
||||
}
|
||||
int fx_tcgetattr(int fd, struct termios *termios_p)
|
||||
{
|
||||
return tcgetattr(fd, termios_p);
|
||||
}
|
||||
int fx_tcsetattr(int fd, int optional_actions, const struct termios *termios_p)
|
||||
{
|
||||
return tcsetattr(fd, optional_actions, termios_p);
|
||||
}
|
||||
ssize_t fx_write(int fd, const void *buf, size_t count) { return write(fd, buf, count); }
|
||||
ssize_t fx_read(int fd, void *buf, size_t count) { return read(fd, buf, count); }
|
||||
ssize_t fx_write(int fd, const void *buf, size_t count)
|
||||
{
|
||||
return write(fd, buf, count);
|
||||
}
|
||||
ssize_t fx_read(int fd, void *buf, size_t count)
|
||||
{
|
||||
return read(fd, buf, count);
|
||||
}
|
||||
int fx_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
|
||||
{
|
||||
return select(nfds, readfds, writefds, exceptfds, timeout);
|
||||
|
|
|
@ -39,7 +39,9 @@ class ProtocolContext : public VProtocolContext
|
|||
{
|
||||
|
||||
public:
|
||||
ProtocolContext(T &value) : mData(value) {}
|
||||
ProtocolContext(T &value) : mData(value)
|
||||
{
|
||||
}
|
||||
virtual ~ProtocolContext() = default;
|
||||
|
||||
public:
|
||||
|
@ -48,7 +50,9 @@ public:
|
|||
class SingleMcuPacket
|
||||
{
|
||||
public:
|
||||
SingleMcuPacket(const void *buf, const size_t &length) : mBuf(buf), mLength(length) {}
|
||||
SingleMcuPacket(const void *buf, const size_t &length) : mBuf(buf), mLength(length)
|
||||
{
|
||||
}
|
||||
~SingleMcuPacket() = default;
|
||||
const void *mBuf;
|
||||
const size_t mLength;
|
||||
|
@ -60,7 +64,10 @@ public:
|
|||
virtual ~VProtocolBase() = default;
|
||||
|
||||
protected:
|
||||
virtual std::shared_ptr<VProtocolBase> SharedFromThis(void) { return std::make_shared<VProtocolBase>(); }
|
||||
virtual std::shared_ptr<VProtocolBase> SharedFromThis(void)
|
||||
{
|
||||
return std::make_shared<VProtocolBase>();
|
||||
}
|
||||
virtual size_t WriteData(const void *buff, const size_t buffLength, std::shared_ptr<VProtocolContext> &context,
|
||||
const unsigned int &serialNumber)
|
||||
{
|
||||
|
@ -68,12 +75,17 @@ protected:
|
|||
}
|
||||
|
||||
protected:
|
||||
virtual size_t GetKeyHeadLength(void) { return 0; }
|
||||
virtual size_t GetKeyHeadLength(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual StatusCode GetDataLength(const void *keyHead, const size_t &headLength, size_t &dataLength)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_INVALID_PARAMENTER);
|
||||
}
|
||||
virtual void PushMcuData(const void *buf, const size_t &length) {}
|
||||
virtual void PushMcuData(const void *buf, const size_t &length)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
};
|
||||
|
@ -88,15 +100,21 @@ class OtherSideReply
|
|||
public:
|
||||
OtherSideReply() = default;
|
||||
virtual ~OtherSideReply() = default;
|
||||
virtual void GetIpcMissionReply(const unsigned int &serialNumber, const unsigned char &mission) {}
|
||||
virtual void OnlyResultReply(const unsigned int &serialNumber, const ReplyResult &result) {}
|
||||
virtual void GetIpcMissionReply(const unsigned int &serialNumber, const unsigned char &mission)
|
||||
{
|
||||
}
|
||||
virtual void OnlyResultReply(const unsigned int &serialNumber, const ReplyResult &result)
|
||||
{
|
||||
}
|
||||
};
|
||||
class OtherSideAsk
|
||||
{
|
||||
public:
|
||||
OtherSideAsk() = default;
|
||||
virtual ~OtherSideAsk() = default;
|
||||
virtual void OtherSideSendIpcMission(const unsigned int &serialNumber, const unsigned char &mission) {}
|
||||
virtual void OtherSideSendIpcMission(const unsigned int &serialNumber, const unsigned char &mission)
|
||||
{
|
||||
}
|
||||
};
|
||||
class VProtocolRecv : public OtherSideReply, public OtherSideAsk
|
||||
{
|
||||
|
|
|
@ -33,7 +33,10 @@ void LittleEndianHandle::BigEndianConversion(ProtocolPacket &packet)
|
|||
packet.mCheckCode = htons(packet.mCheckCode);
|
||||
packet.mSerialNumber = htonl(packet.mSerialNumber);
|
||||
}
|
||||
short LittleEndianHandle::BigEndianConversion(const short &number) { return htons(number); }
|
||||
short LittleEndianHandle::BigEndianConversion(const short &number)
|
||||
{
|
||||
return htons(number);
|
||||
}
|
||||
void LittleEndianHandle::HostByteOrderConversion(ProtocolPacket &packet)
|
||||
{
|
||||
packet.mHead = ntohs(packet.mHead);
|
||||
|
|
|
@ -30,7 +30,9 @@ const StatusCode McuProtocol::Init(void)
|
|||
constexpr int THREAD_SHARING = 0;
|
||||
constexpr int INITIAL_VALUE_OF_SEMAPHORE = 0;
|
||||
sem_init(&mSem, THREAD_SHARING, INITIAL_VALUE_OF_SEMAPHORE);
|
||||
auto dataHandleThread = [](std::shared_ptr<McuProtocol> handle) { handle->DataHandleThread(); };
|
||||
auto dataHandleThread = [](std::shared_ptr<McuProtocol> handle) {
|
||||
handle->DataHandleThread();
|
||||
};
|
||||
std::shared_ptr<McuProtocol> handle = std::dynamic_pointer_cast<McuProtocol>(SharedFromThis());
|
||||
mDataHandleThread = std::thread(dataHandleThread, handle);
|
||||
std::shared_ptr<VProtocolRecv> reply = std::dynamic_pointer_cast<VProtocolRecv>(SharedFromThis());
|
||||
|
@ -153,7 +155,10 @@ void McuProtocol::ReplyOtherSideSendIpcMission(const ReplyResult &result, const
|
|||
WriteProtocolData(
|
||||
handle->GetProtocolDataBuff(), handle->GetProtocolDataLength(), NULL_CONTEXT, handle->GetSerialNumber());
|
||||
}
|
||||
size_t McuProtocol::GetKeyHeadLength(void) { return ProtocolHandle::GetKeyHeadLength(); }
|
||||
size_t McuProtocol::GetKeyHeadLength(void)
|
||||
{
|
||||
return ProtocolHandle::GetKeyHeadLength();
|
||||
}
|
||||
StatusCode McuProtocol::GetDataLength(const void *keyHead, const size_t &headLength, size_t &dataLength)
|
||||
{
|
||||
return ProtocolHandle::GetDataLength(keyHead, headLength, dataLength);
|
||||
|
|
|
@ -30,7 +30,10 @@ std::shared_ptr<McuProtocolMakePtr> &McuProtocolMakePtr::GetInstance(std::shared
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
McuProtocolMakePtr::McuProtocolMakePtr() { mByteOrder = 0x00; }
|
||||
McuProtocolMakePtr::McuProtocolMakePtr()
|
||||
{
|
||||
mByteOrder = 0x00;
|
||||
}
|
||||
const StatusCode McuProtocolMakePtr::CreateProtocolHandle(std::shared_ptr<ProtocolHandle> &impl,
|
||||
const std::shared_ptr<VProtocolParam> ¶m)
|
||||
{
|
||||
|
|
|
@ -265,7 +265,10 @@ void ProtocolHandle::ProtocolAnalysis(const void *data, const size_t &length)
|
|||
handle->AnalyzeProtocolPacket();
|
||||
}
|
||||
}
|
||||
size_t ProtocolHandle::GetKeyHeadLength(void) { return KEY_HEAD_LENGTH; }
|
||||
size_t ProtocolHandle::GetKeyHeadLength(void)
|
||||
{
|
||||
return KEY_HEAD_LENGTH;
|
||||
}
|
||||
StatusCode ProtocolHandle::GetDataLength(const void *keyHead, const size_t &headLength, size_t &dataLength)
|
||||
{
|
||||
if (KEY_HEAD_LENGTH != headLength) {
|
||||
|
|
|
@ -104,7 +104,9 @@ class ProtocolParam : public VProtocolParam
|
|||
{
|
||||
|
||||
public:
|
||||
ProtocolParam(const PROTOCOL_COMMAND &command, T &value) : VProtocolParam(command), mData(value) {}
|
||||
ProtocolParam(const PROTOCOL_COMMAND &command, T &value) : VProtocolParam(command), mData(value)
|
||||
{
|
||||
}
|
||||
virtual ~ProtocolParam() = default;
|
||||
|
||||
public:
|
||||
|
@ -126,9 +128,18 @@ public:
|
|||
ProtocolHandle(const std::shared_ptr<VProtocolParam> ¶m);
|
||||
ProtocolHandle(const void *data, const size_t &length);
|
||||
virtual ~ProtocolHandle();
|
||||
void *GetProtocolDataBuff(void) { return mProtocolData; }
|
||||
size_t GetProtocolDataLength(void) { return mProtocolDataLength; }
|
||||
unsigned int GetSerialNumber(void) { return mProtocolSerialNumber; }
|
||||
void *GetProtocolDataBuff(void)
|
||||
{
|
||||
return mProtocolData;
|
||||
}
|
||||
size_t GetProtocolDataLength(void)
|
||||
{
|
||||
return mProtocolDataLength;
|
||||
}
|
||||
unsigned int GetSerialNumber(void)
|
||||
{
|
||||
return mProtocolSerialNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief These functions assemble scattered data into continuous memory protocol packets and complete the sending
|
||||
|
@ -172,9 +183,16 @@ private:
|
|||
void AnalyzeOtherSideSendIpcMissionPacket(const ProtocolPacket &packet);
|
||||
|
||||
private:
|
||||
virtual void BigEndianConversion(ProtocolPacket &packet) {}
|
||||
virtual short BigEndianConversion(const short &number) { return number; }
|
||||
virtual void HostByteOrderConversion(ProtocolPacket &packet) {}
|
||||
virtual void BigEndianConversion(ProtocolPacket &packet)
|
||||
{
|
||||
}
|
||||
virtual short BigEndianConversion(const short &number)
|
||||
{
|
||||
return number;
|
||||
}
|
||||
virtual void HostByteOrderConversion(ProtocolPacket &packet)
|
||||
{
|
||||
}
|
||||
virtual bool CheckoutTheCheckCode(const ProtocolPacket &packet);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
#include "ILog.h"
|
||||
#include <string.h>
|
||||
static const char *MEDIA_ADAPTER_NAME = "media_adapter";
|
||||
const char inline *GetMediaAdapterModuleName(void) { return MEDIA_ADAPTER_NAME; }
|
||||
const char inline *GetMediaAdapterModuleName(void)
|
||||
{
|
||||
return MEDIA_ADAPTER_NAME;
|
||||
}
|
||||
std::shared_ptr<IMediaAdapter> *NewIMediaAdapter(const SENSOR_NUM &num)
|
||||
{
|
||||
LogInfo("Create the uart device object.\n");
|
||||
|
|
|
@ -21,7 +21,9 @@ class IMediaAdapter
|
|||
public:
|
||||
IMediaAdapter() = default;
|
||||
virtual ~IMediaAdapter() = default;
|
||||
virtual void TestApi(void) {}
|
||||
virtual void TestApi(void)
|
||||
{
|
||||
}
|
||||
};
|
||||
typedef struct media_adapter_header
|
||||
{
|
||||
|
|
|
@ -15,7 +15,10 @@
|
|||
#include "MediaAdapter.h"
|
||||
#include "ILog.h"
|
||||
#include "IMediaAdapter.h"
|
||||
void *CreateMediaAdapter(const SENSOR_NUM num) { return NewIMediaAdapter(num); }
|
||||
void *CreateMediaAdapter(const SENSOR_NUM num)
|
||||
{
|
||||
return NewIMediaAdapter(num);
|
||||
}
|
||||
static bool ObjectCheck(void *object)
|
||||
{
|
||||
if (nullptr == object) {
|
||||
|
|
|
@ -14,8 +14,14 @@
|
|||
*/
|
||||
#include "curl_serve.h"
|
||||
static ServerParam gCurlServe;
|
||||
void SetVerboseLog(LogFlag flag) { gCurlServe.logFlag = flag; }
|
||||
void SetSslVerify(SslFlag flag) { gCurlServe.sslVerifyFlag = flag; }
|
||||
void SetVerboseLog(LogFlag flag)
|
||||
{
|
||||
gCurlServe.logFlag = flag;
|
||||
}
|
||||
void SetSslVerify(SslFlag flag)
|
||||
{
|
||||
gCurlServe.sslVerifyFlag = flag;
|
||||
}
|
||||
CURL *CurlEasyMake(void)
|
||||
{
|
||||
CURL *curl;
|
||||
|
|
|
@ -26,7 +26,9 @@ void ServersInit(ServerParam init)
|
|||
SetVerboseLog(init.logFlag);
|
||||
SetSslVerify(init.sslVerifyFlag);
|
||||
}
|
||||
void ServersUnInit(void) {}
|
||||
void ServersUnInit(void)
|
||||
{
|
||||
}
|
||||
void HttpGet(ServerHttp *param)
|
||||
{
|
||||
LogInfo("HttpGet\n");
|
||||
|
@ -105,7 +107,10 @@ void DeleteServersFtp(ServerFtp *ptr)
|
|||
free(ptr);
|
||||
}
|
||||
}
|
||||
void FtpServersCheck(ServerFtp *param) { FtpServersCheckConnect(param); }
|
||||
void FtpServersCheck(ServerFtp *param)
|
||||
{
|
||||
FtpServersCheckConnect(param);
|
||||
}
|
||||
void FtpDownload(ServerFtp *param)
|
||||
{
|
||||
LogInfo("FtpDownload\n");
|
||||
|
|
|
@ -45,7 +45,10 @@ static inline const StatusCode IMakeSharedData(SharedData *object, const unsigne
|
|||
{
|
||||
return object->mMakeSharedData(object, readableSize, writableSize);
|
||||
}
|
||||
static inline const StatusCode ICleanSharedData(SharedData *object) { return object->mCleanSharedData(object); }
|
||||
static inline const StatusCode ICleanSharedData(SharedData *object)
|
||||
{
|
||||
return object->mCleanSharedData(object);
|
||||
}
|
||||
static inline const StatusCode IGetReadableData(SharedData *object, void *buf, const unsigned int bufLength)
|
||||
{
|
||||
return object->mGetReadableData(object, buf, bufLength);
|
||||
|
@ -54,7 +57,10 @@ static inline void ISetWritableData(SharedData *object, void *buf, const unsigne
|
|||
{
|
||||
object->mSetWritableData(object, buf, bufLength);
|
||||
}
|
||||
static inline void IShareDataFree(SharedData *object) { object->mFree(object); }
|
||||
static inline void IShareDataFree(SharedData *object)
|
||||
{
|
||||
object->mFree(object);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -35,9 +35,18 @@ typedef struct status_code
|
|||
const long int mStatusCode;
|
||||
} StatusCode;
|
||||
const StatusCode CreateStatusCode(const long int code);
|
||||
static inline const char *PrintStringCode(const StatusCode code) { return code.mPrintStringCode(code); }
|
||||
static inline bool IsCodeOK(const StatusCode code) { return STATUS_CODE_OK == code.mStatusCode ? true : false; }
|
||||
static inline bool StatusCodeEqual(const StatusCode code, const char *value) { return code.mCodeEqual(code, value); }
|
||||
static inline const char *PrintStringCode(const StatusCode code)
|
||||
{
|
||||
return code.mPrintStringCode(code);
|
||||
}
|
||||
static inline bool IsCodeOK(const StatusCode code)
|
||||
{
|
||||
return STATUS_CODE_OK == code.mStatusCode ? true : false;
|
||||
}
|
||||
static inline bool StatusCodeEqual(const StatusCode code, const char *value)
|
||||
{
|
||||
return code.mCodeEqual(code, value);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
#include "ILog.h"
|
||||
#include <cstring>
|
||||
static const char *TCP_MODULE_NAME = "tcp_module";
|
||||
const char *GetTcpModuleName(void) { return TCP_MODULE_NAME; }
|
||||
const char *GetTcpModuleName(void)
|
||||
{
|
||||
return TCP_MODULE_NAME;
|
||||
}
|
||||
void *NewTcpModuleImpl(const TcpPram &tcpParam)
|
||||
{
|
||||
if (nullptr == tcpParam.mIp) {
|
||||
|
@ -31,4 +34,7 @@ void *NewTcpModuleImpl(const TcpPram &tcpParam)
|
|||
impl->mTcpImpl = std::make_shared<TcpModuleImpl>(tcpParam);
|
||||
return (void *)(((char *)impl) + sizeof(TcpModuleHeader));
|
||||
}
|
||||
void *NewTcpServer(const TcpPram &tcpParam) { return nullptr; }
|
||||
void *NewTcpServer(const TcpPram &tcpParam)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
|
@ -16,7 +16,10 @@
|
|||
#include "ILog.h"
|
||||
#include "StatusCode.h"
|
||||
#include "UartDeviceImpl.h"
|
||||
void *CreateUartDevice(const UartInfo info) { return NewUartDeviceImpl(info); }
|
||||
void *CreateUartDevice(const UartInfo info)
|
||||
{
|
||||
return NewUartDeviceImpl(info);
|
||||
}
|
||||
const StatusCode IUartOpen(void *object)
|
||||
{
|
||||
if (nullptr == object) {
|
||||
|
|
|
@ -26,8 +26,14 @@
|
|||
#include <unistd.h>
|
||||
constexpr int INVALID_FD = -1;
|
||||
static const char *UART_DEVICE_NAME = "uart_device";
|
||||
const char *GetUartDeviceModuleName(void) { return UART_DEVICE_NAME; }
|
||||
UartDeviceImpl::UartDeviceImpl(const UartInfo &uatrInfo) : mUatrInfo(uatrInfo) { mFd = -1; }
|
||||
const char *GetUartDeviceModuleName(void)
|
||||
{
|
||||
return UART_DEVICE_NAME;
|
||||
}
|
||||
UartDeviceImpl::UartDeviceImpl(const UartInfo &uatrInfo) : mUatrInfo(uatrInfo)
|
||||
{
|
||||
mFd = -1;
|
||||
}
|
||||
const StatusCode UartDeviceImpl::UartOpen(void)
|
||||
{
|
||||
mFd = fx_open(mUatrInfo.mDevice, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
|
|
Loading…
Reference in New Issue
Block a user