[zhoulongyu]: 完善Led组件的部分代码(没有LedTimer)后编译通过
This commit is contained in:
parent
532598fbaa
commit
ca56f16a20
|
@ -16,8 +16,8 @@
|
||||||
#define IHALCPP_H
|
#define IHALCPP_H
|
||||||
#include "StatusCode.h"
|
#include "StatusCode.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
constexpr int INVALID_PERIOD = -1;
|
constexpr int INVALID_PERIOD = -1;
|
||||||
constexpr int PERIPHERAL_CHECK_PERIOD_MS = 100;
|
constexpr int PERIPHERAL_CHECK_PERIOD_MS = 100;
|
||||||
constexpr int IMEI_LEN = 15;
|
constexpr int IMEI_LEN = 15;
|
||||||
|
@ -46,34 +46,34 @@ public:
|
||||||
virtual const std::string GetKeyName(void) { return "undefine"; }
|
virtual const std::string GetKeyName(void) { return "undefine"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum HalLedState
|
||||||
enum class LedState
|
|
||||||
{
|
{
|
||||||
LED_STATE_OFF = 0,
|
HAL_LED_STATE_OFF = 0,
|
||||||
LED_STATE_ON,
|
HAL_LED_STATE_ON,
|
||||||
LED_STATE_GREEN,
|
HAL_LED_STATE_GREEN,
|
||||||
LED_STATE_RED,
|
HAL_LED_STATE_RED,
|
||||||
LED_STATE_YELLOW,
|
HAL_LED_STATE_YELLOW,
|
||||||
LED_STATE_LEVEL_0,
|
HAL_LED_STATE_LEVEL_0,
|
||||||
LED_STATE_LEVEL_1,
|
HAL_LED_STATE_LEVEL_1,
|
||||||
LED_STATE_LEVEL_2,
|
HAL_LED_STATE_LEVEL_2,
|
||||||
LED_STATE_LEVEL_3,
|
HAL_LED_STATE_LEVEL_3,
|
||||||
LED_STATE_LEVEL_4,
|
HAL_LED_STATE_LEVEL_4,
|
||||||
LED_STATE_LEVEL_END,
|
HAL_LED_STATE_LEVEL_END,
|
||||||
LED_STATE_END
|
HAL_LED_STATE_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class VLedHal
|
class VLedHal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VLedHal() = default;
|
VLedHal() = default;
|
||||||
~VLedHal() = default;
|
~VLedHal() = default;
|
||||||
virtual StatusCode SetLedState(const LedState &state) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
virtual StatusCode SetHalLedState(const HalLedState &state)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
||||||
virtual StatusCode GetLedName(std::string &LedName) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
virtual StatusCode GetLedName(std::string &LedName) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
class WifiLed : public VLedHalOwner, public VLedHal
|
class WifiLed : public VLedHalOwner, public VLedHal
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
~WifiLed() = default;
|
~WifiLed() = default;
|
||||||
|
|
||||||
// StatusCode SetLedHalOwner(std::shared_ptr<VLedHalOwner> owner) override;
|
// StatusCode SetLedHalOwner(std::shared_ptr<VLedHalOwner> owner) override;
|
||||||
StatusCode SetLedState(const LedState &state) override;
|
StatusCode SetHalLedState(const HalLedState &state) override;
|
||||||
StatusCode GetLedName(std::string &LedName) override;
|
StatusCode GetLedName(std::string &LedName) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -93,7 +93,6 @@ private:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class IHalCpp
|
class IHalCpp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -102,10 +101,11 @@ public:
|
||||||
static std::shared_ptr<IHalCpp> &GetInstance(std::shared_ptr<IHalCpp> *impl = nullptr);
|
static std::shared_ptr<IHalCpp> &GetInstance(std::shared_ptr<IHalCpp> *impl = nullptr);
|
||||||
virtual StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
virtual StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||||
virtual StatusCode UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
virtual StatusCode UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||||
virtual StatusCode GetLedHal(std::vector<std::shared_ptr<VLedHal>> &ledHals) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
virtual StatusCode GetLedHal(std::vector<std::shared_ptr<VLedHal>> &ledHals)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
void CreateHalCppModule(void);
|
void CreateHalCppModule(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::shared_ptr<VLedHal>> mLedHals;
|
std::vector<std::shared_ptr<VLedHal>> mLedHals;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -15,8 +15,9 @@
|
||||||
#ifndef IDEVICEMANAGER_H
|
#ifndef IDEVICEMANAGER_H
|
||||||
#define IDEVICEMANAGER_H
|
#define IDEVICEMANAGER_H
|
||||||
#include "StatusCode.h"
|
#include "StatusCode.h"
|
||||||
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "IHalCpp.h"
|
#include <vector>
|
||||||
enum class IpcMission
|
enum class IpcMission
|
||||||
{
|
{
|
||||||
TEST = 0,
|
TEST = 0,
|
||||||
|
@ -31,12 +32,32 @@ enum class KeyAction
|
||||||
END
|
END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum LedState
|
||||||
|
{
|
||||||
|
LED_STATE_OFF = 0,
|
||||||
|
LED_STATE_ON,
|
||||||
|
LED_STATE_GREEN,
|
||||||
|
LED_STATE_RED,
|
||||||
|
LED_STATE_YELLOW,
|
||||||
|
LED_STATE_LEVEL_0,
|
||||||
|
LED_STATE_LEVEL_1,
|
||||||
|
LED_STATE_LEVEL_2,
|
||||||
|
LED_STATE_LEVEL_3,
|
||||||
|
LED_STATE_LEVEL_4,
|
||||||
|
LED_STATE_LEVEL_END,
|
||||||
|
LED_STATE_END
|
||||||
|
};
|
||||||
|
|
||||||
class VLedManager
|
class VLedManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VLedManager() = default;
|
VLedManager() = default;
|
||||||
~VLedManager() = default;
|
~VLedManager() = default;
|
||||||
virtual StatusCode SetLedState(LedState CurrentState, unsigned int KeepAliveTime) {return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
virtual StatusCode SetLedState(std::string ledName, LedState &CurrentState, const unsigned int &KeepAliveTime,
|
||||||
|
const unsigned int &BlinkPeriod)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IDeviceManager
|
class IDeviceManager
|
||||||
|
@ -48,8 +69,8 @@ public:
|
||||||
virtual const StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
virtual const StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||||
virtual const StatusCode UnInit(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
virtual const StatusCode UnInit(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
||||||
virtual const IpcMission GetIpcMissiony(void) { return IpcMission::END; }
|
virtual const IpcMission GetIpcMissiony(void) { return IpcMission::END; }
|
||||||
virtual const StatusCode GetLedManager(std::vector<std::shared_ptr<VLedManager>> &ledManagers) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
// virtual const StatusCode GetLedManager(std::vector<std::shared_ptr<VLedManager>> &ledManagers) { return
|
||||||
|
// CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
||||||
};
|
};
|
||||||
bool CreateDeviceManagerModule(void);
|
bool CreateDeviceManagerModule(void);
|
||||||
#endif
|
#endif
|
|
@ -14,36 +14,27 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DeviceManager.h"
|
#include "DeviceManager.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
const StatusCode DeviceManager::Init(void)
|
const StatusCode DeviceManager::Init(void)
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<VLedHal>> ledHals;
|
std::vector<std::shared_ptr<VLedHal>> ledHals;
|
||||||
IHalCpp::GetInstance()->GetLedHal(ledHals);
|
IHalCpp::GetInstance()->GetLedHal(ledHals);
|
||||||
|
|
||||||
for (auto it = ledHals.begin(); it != ledHals.end(); ++it)
|
for (auto it = ledHals.begin(); it != ledHals.end(); ++it) {
|
||||||
{
|
|
||||||
std::shared_ptr<VLedHal> ledHal = *it;
|
std::shared_ptr<VLedHal> ledHal = *it;
|
||||||
std::shared_ptr<LedManager> ledOut = std::make_shared<LedManager>(ledHal, NEW_LED_STATE, DEFAULT_KEEP_ALIVE_TIME, BLINKING_FAST_MS);
|
std::shared_ptr<LedManager> ledOut =
|
||||||
|
std::make_shared<LedManager>(ledHal, NEW_LED_STATE, DEFAULT_KEEP_ALIVE_TIME, BLINKING_FAST_MS);
|
||||||
mLedManagers.push_back(ledOut);
|
mLedManagers.push_back(ledOut);
|
||||||
}
|
}
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
const StatusCode DeviceManager::UnInit(void)
|
const StatusCode DeviceManager::UnInit(void)
|
||||||
{
|
{
|
||||||
if (!mLedManagers.empty())
|
if (!mLedManagers.empty()) {
|
||||||
{
|
|
||||||
mLedManagers.clear();
|
mLedManagers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
const IpcMission DeviceManager::GetIpcMissiony(void)
|
const IpcMission DeviceManager::GetIpcMissiony(void) { return IpcMission::TEST; }
|
||||||
{
|
|
||||||
return IpcMission::TEST;
|
|
||||||
}
|
|
||||||
const StatusCode DeviceManager::GetLedManager(std::vector<std::shared_ptr<VLedManager>> &ledManagers)
|
|
||||||
{
|
|
||||||
ledManagers = mLedManagers;
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
*/
|
*/
|
||||||
#ifndef DEVICEMANAGER_H
|
#ifndef DEVICEMANAGER_H
|
||||||
#define DEVICEMANAGER_H
|
#define DEVICEMANAGER_H
|
||||||
#include "LedManager.h"
|
|
||||||
#include "IDeviceManager.h"
|
#include "IDeviceManager.h"
|
||||||
|
#include "LedManager.h"
|
||||||
|
|
||||||
class DeviceManager : public IDeviceManager
|
class DeviceManager : public IDeviceManager
|
||||||
{
|
{
|
||||||
|
@ -27,13 +26,9 @@ public:
|
||||||
const StatusCode Init(void) override;
|
const StatusCode Init(void) override;
|
||||||
const StatusCode UnInit(void) override;
|
const StatusCode UnInit(void) override;
|
||||||
const IpcMission GetIpcMissiony(void) override;
|
const IpcMission GetIpcMissiony(void) override;
|
||||||
const StatusCode GetLedManager(std::vector<std::shared_ptr<VLedManager>> &ledManagers) override;
|
// const StatusCode GetLedManager(std::vector<std::shared_ptr<VLedManager>> &ledManagers) override;
|
||||||
private:
|
private:
|
||||||
std::vector<std::shared_ptr<VLedManager>> mLedManagers;
|
std::vector<std::shared_ptr<VLedManager>> mLedManagers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
#include "LedManager.h"
|
#include "LedManager.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LedManager::LedManager()
|
LedManager::LedManager()
|
||||||
{
|
{
|
||||||
mLedHal = nullptr;
|
mLedHal = nullptr;
|
||||||
|
@ -28,20 +26,21 @@ LedManager::LedManager()
|
||||||
}
|
}
|
||||||
LedManager::LedManager(std::shared_ptr<VLedHal> &LedHal, const LedState &CurrentState,
|
LedManager::LedManager(std::shared_ptr<VLedHal> &LedHal, const LedState &CurrentState,
|
||||||
const unsigned int &KeepAliveTime, const unsigned int &BlinkPeriod)
|
const unsigned int &KeepAliveTime, const unsigned int &BlinkPeriod)
|
||||||
: mLedHal(LedHal), mCurrentState(CurrentState), mKeepAliveTime(KeepAliveTime), mBlinkPeriod(BlinkPeriod)
|
|
||||||
{
|
{
|
||||||
|
mLedHal = LedHal;
|
||||||
|
mCurrentState = CurrentState;
|
||||||
|
mKeepAliveTime = KeepAliveTime;
|
||||||
|
mBlinkPeriod = BlinkPeriod;
|
||||||
mStateAliveTime = 0;
|
mStateAliveTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusCode LedManager::SetLedState(std::string ledName, LedState &CurrentState, const unsigned int &KeepAliveTime,
|
||||||
StatusCode LedManager::SetLedState(LedState CurrentState, unsigned int KeepAliveTime)
|
const unsigned int &BlinkPeriod)
|
||||||
{
|
{
|
||||||
mCurrentState = CurrentState;
|
mCurrentState = CurrentState;
|
||||||
mKeepAliveTime = KeepAliveTime;
|
mKeepAliveTime = KeepAliveTime;
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StatusCode LedManager::GetLedState(LedState &CurrentState)
|
StatusCode LedManager::GetLedState(LedState &CurrentState)
|
||||||
{
|
{
|
||||||
CurrentState = mCurrentState;
|
CurrentState = mCurrentState;
|
||||||
|
@ -59,9 +58,3 @@ StatusCode LedManager::BlinkOff(void)
|
||||||
mCurrentState = LedState::LED_STATE_OFF;
|
mCurrentState = LedState::LED_STATE_OFF;
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define LED_MANAGER_H
|
#define LED_MANAGER_H
|
||||||
|
|
||||||
#include "IDeviceManager.h"
|
#include "IDeviceManager.h"
|
||||||
|
#include "IHalCpp.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
@ -33,17 +34,18 @@ public:
|
||||||
LedManager();
|
LedManager();
|
||||||
LedManager(std::shared_ptr<VLedHal> &LedHal, const LedState &CurrentState,
|
LedManager(std::shared_ptr<VLedHal> &LedHal, const LedState &CurrentState,
|
||||||
const unsigned int &KeepAliveTime = DEFAULT_KEEP_ALIVE_TIME,
|
const unsigned int &KeepAliveTime = DEFAULT_KEEP_ALIVE_TIME,
|
||||||
const unsigned int &BlinkPeriod = BLINKING_FAST_MS
|
const unsigned int &BlinkPeriod = BLINKING_FAST_MS);
|
||||||
);
|
|
||||||
~LedManager() = default;
|
~LedManager() = default;
|
||||||
StatusCode Init(void) {return CreateStatusCode(STATUS_CODE_NOT_OK); }
|
StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_NOT_OK); }
|
||||||
StatusCode Unit(void) {return CreateStatusCode(STATUS_CODE_NOT_OK); }
|
StatusCode Unit(void) { return CreateStatusCode(STATUS_CODE_NOT_OK); }
|
||||||
StatusCode SetLedState(LedState CurrentState, unsigned int KeepAliveTime) override;
|
StatusCode SetLedState(std::string ledName, LedState &CurrentState,
|
||||||
|
const unsigned int &KeepAliveTime = DEFAULT_KEEP_ALIVE_TIME,
|
||||||
|
const unsigned int &BlinkPeriod = LED_NOT_BLINK) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StatusCode GetLedState(LedState &CurrentState) {return CreateStatusCode(STATUS_CODE_NOT_OK); }
|
StatusCode GetLedState(LedState &CurrentState);
|
||||||
StatusCode BlinkOn(LedState CurrentState, unsigned int KeepAliveTime) {return CreateStatusCode(STATUS_CODE_NOT_OK); }
|
StatusCode BlinkOn(LedState CurrentState, unsigned int KeepAliveTime);
|
||||||
StatusCode BlinkOff(void) {return CreateStatusCode(STATUS_CODE_NOT_OK); }
|
StatusCode BlinkOff(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<VLedHal> mLedHal;
|
std::shared_ptr<VLedHal> mLedHal;
|
||||||
|
@ -54,4 +56,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "SharedData.h"
|
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "SharedData.h"
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
namespace SharedDataTest
|
namespace SharedDataTest
|
||||||
|
|
Loading…
Reference in New Issue
Block a user