106 lines
2.6 KiB
C++
106 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <string>
|
|
#include "aurora/InterfaceDefs.h"
|
|
#include "aurora/IData.h"
|
|
|
|
|
|
#ifdef AURORA_NATIVE_EXPORTS
|
|
#define AURORA_NATIVE_EXPORT __declspec(dllexport)
|
|
#else
|
|
#define AURORA_NATIVE_EXPORT __declspec(dllimport)
|
|
#endif
|
|
|
|
|
|
namespace lge::pri::aurora {
|
|
|
|
|
|
enum class DeviceType : uint64_t
|
|
{
|
|
MOTOR = 1UL << 0,
|
|
MOVER = 1UL << 1,
|
|
VIEWER = 1UL << 2,
|
|
PATTERN_FINDER = 1UL << 3,
|
|
ALIGNER = 1UL << 4,
|
|
TOGGLE = 1UL << 5,
|
|
SENSOR = 1UL << 6,
|
|
EMITTER = 1UL << 7,
|
|
CALIBRATOR = 1UL << 8,
|
|
DIGITAL_IO = 1UL << 9,
|
|
ETC = 1UL << 10,
|
|
};
|
|
|
|
|
|
using DeviceId = std::string;
|
|
|
|
|
|
class AURORA_NATIVE_EXPORT IDevice
|
|
{
|
|
AS_INTERFACE(IDevice)
|
|
|
|
virtual const DeviceId& getDeviceId() const = 0;
|
|
virtual DeviceType getDeviceType() const = 0;
|
|
|
|
virtual int activate(const IData& config) = 0;
|
|
virtual int deactivate() = 0;
|
|
|
|
virtual int customCommand(int cmd, const IData& param) { return -1; }
|
|
};
|
|
|
|
|
|
inline
|
|
const char* cstrId(const IDevice* device)
|
|
{ return (device) ? device->getDeviceId().c_str() : "null"; }
|
|
|
|
inline
|
|
const char* cstrId(const IDevice& device)
|
|
{ return device.getDeviceId().c_str(); }
|
|
|
|
extern const char* toString(DeviceType type);
|
|
extern const char* cstrType(const IDevice* device);
|
|
extern const char* cstrType(const IDevice& device);
|
|
|
|
|
|
struct DevBaseDat;
|
|
|
|
class AURORA_NATIVE_EXPORT DeviceBase : public IDevice
|
|
{
|
|
private:
|
|
DevBaseDat* mDat;
|
|
|
|
protected:
|
|
DeviceBase(
|
|
const DeviceId& id,
|
|
DeviceType type
|
|
);
|
|
DeviceBase(const DeviceBase&) = delete;
|
|
DeviceBase(DeviceBase&&) = delete;
|
|
DeviceBase& operator=(const DeviceBase&) = delete;
|
|
DeviceBase& operator=(DeviceBase&&) = delete;
|
|
|
|
const char* cstrId() const;
|
|
|
|
public:
|
|
virtual ~DeviceBase();
|
|
|
|
const DeviceId& getDeviceId() const override;
|
|
DeviceType getDeviceType() const override;
|
|
};
|
|
|
|
|
|
#define DECLARE_AS_DEVICE_BASE(CLASS_NAME, DEVICE_TYPE) \
|
|
public: \
|
|
virtual ~CLASS_NAME() {}; \
|
|
protected: \
|
|
CLASS_NAME(const DeviceId& id) \
|
|
: DeviceBase(id, DEVICE_TYPE) {} \
|
|
CLASS_NAME(const CLASS_NAME&) = delete; \
|
|
CLASS_NAME(CLASS_NAME&&) = delete; \
|
|
CLASS_NAME& operator=(const CLASS_NAME&) = delete; \
|
|
CLASS_NAME& operator=(CLASS_NAME&&) = delete; \
|
|
public:
|
|
|
|
|
|
} // end of namespace
|