179 lines
4.0 KiB
C++
179 lines
4.0 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <mutex>
|
|
#include "aurora/InterfaceDefs.h"
|
|
#include "aurora/device/Device.h"
|
|
#include "aurora/IData.h"
|
|
#include "aurora/Types.h"
|
|
|
|
|
|
#ifdef AURORA_NATIVE_EXPORTS
|
|
#define AURORA_NATIVE_EXPORT __declspec(dllexport)
|
|
#else
|
|
#define AURORA_NATIVE_EXPORT __declspec(dllimport)
|
|
#endif
|
|
|
|
|
|
namespace lge::pri::aurora {
|
|
|
|
|
|
using MoveRange = Range<double>;
|
|
using VelocityLevel = unsigned int;
|
|
using VelocityRange = Range<VelocityLevel>;
|
|
|
|
enum class TargetPosType
|
|
{
|
|
ABS = 0,
|
|
REL
|
|
};
|
|
|
|
|
|
class AURORA_NATIVE_EXPORT Motor : public DeviceBase
|
|
{
|
|
DECLARE_AS_DEVICE_BASE(Motor, DeviceType::MOTOR)
|
|
|
|
|
|
|
|
virtual const MoveRange& getMoveRange() = 0;
|
|
virtual const VelocityRange& getVelocityRange() = 0;
|
|
|
|
virtual int setVelocity(VelocityLevel level) = 0;
|
|
virtual VelocityLevel getVelocity() = 0;
|
|
|
|
virtual bool isReversed() = 0;
|
|
virtual double getCurrentPosition() = 0;
|
|
|
|
virtual int setTargetPosition(
|
|
double targetPos,
|
|
TargetPosType type = TargetPosType::ABS
|
|
) = 0;
|
|
|
|
virtual double getTargetPosition() = 0;
|
|
|
|
virtual int setServoOn(bool on = true) = 0;
|
|
virtual bool isServoOn() = 0;
|
|
|
|
virtual int home() = 0;
|
|
virtual int move() = 0;
|
|
|
|
virtual int jog(
|
|
int direction,
|
|
double velocity
|
|
) = 0;
|
|
|
|
virtual int jogIncrement(
|
|
double increment,
|
|
double velocity
|
|
) = 0;
|
|
|
|
|
|
/**
|
|
* home, move, jog 동작을 중지 시킨다
|
|
*/
|
|
virtual int stop() = 0;
|
|
|
|
/**
|
|
* home, move 혹은 jog 중이면 true를 반환한다
|
|
*/
|
|
virtual bool isMoving() = 0;
|
|
|
|
/**
|
|
* home(원점복귀) 완료여부를 반환한다
|
|
*/
|
|
virtual bool isHomeCompleted() = 0;
|
|
|
|
virtual bool isAlarm() = 0;
|
|
virtual int clearAlarm() = 0;
|
|
virtual std::vector<std::string> getAlarm() = 0;
|
|
};
|
|
|
|
|
|
struct MotorBaseDat;
|
|
|
|
class AURORA_NATIVE_EXPORT MotorBase : public Motor
|
|
{
|
|
private:
|
|
MotorBaseDat *mDat;
|
|
|
|
protected:
|
|
MotorBase(
|
|
const DeviceId& deviceId
|
|
);
|
|
|
|
public:
|
|
virtual ~MotorBase();
|
|
|
|
protected:
|
|
virtual int doActivate(const IData& config) = 0;
|
|
virtual int doDeactivate() = 0;
|
|
|
|
virtual int doSetVelocity(VelocityLevel level);
|
|
virtual double doGetCurrentPosition() = 0;
|
|
virtual int doSetTargetPosition(double targetPos) = 0; // absolute position
|
|
virtual double doGetTargetPosition() = 0;
|
|
virtual int doHome() = 0;
|
|
virtual int doMove() = 0;
|
|
virtual int doJog(int direction, double velocity) = 0;
|
|
virtual int doJogIncrement(double increment, double velocity) = 0;
|
|
virtual int doStop() = 0;
|
|
|
|
public:
|
|
virtual int activate(const IData& config) override;
|
|
virtual int deactivate() override;
|
|
|
|
virtual const MoveRange& getMoveRange() override;
|
|
virtual const VelocityRange& getVelocityRange() override;
|
|
|
|
virtual int setVelocity(VelocityLevel level) override;
|
|
virtual VelocityLevel getVelocity() override;
|
|
|
|
virtual bool isReversed() override;
|
|
|
|
virtual double getCurrentPosition() override;
|
|
virtual int setTargetPosition(
|
|
double targetPos,
|
|
TargetPosType mode = TargetPosType::ABS) override;
|
|
virtual double getTargetPosition() override;
|
|
|
|
virtual int setServoOn(bool on = true) override;
|
|
virtual bool isServoOn() override;
|
|
|
|
virtual int home() override;
|
|
virtual int move() override;
|
|
virtual int jog(int direction, double velocity) override;
|
|
virtual int jogIncrement(double increment, double velocity) override;
|
|
|
|
virtual int stop() override;
|
|
|
|
virtual bool isMoving() override;
|
|
virtual bool isHomeCompleted() override;
|
|
|
|
virtual bool isAlarm() override;
|
|
virtual int clearAlarm() override;
|
|
virtual std::vector<std::string> getAlarm() override;
|
|
};
|
|
|
|
|
|
|
|
extern const char* toString(
|
|
TargetPosType type
|
|
);
|
|
extern bool inRange(
|
|
const VelocityRange& range,
|
|
VelocityLevel level
|
|
);
|
|
extern bool inRange(
|
|
const MoveRange& range,
|
|
double position
|
|
);
|
|
extern MoveRange toMoveRange(
|
|
const IData& config
|
|
);
|
|
extern VelocityRange toVelocityRange(
|
|
const IData& config
|
|
);
|
|
|
|
|
|
} // end of namespace
|