#ifndef CMOTORDRIVER_GUGAO_H
#define CMOTORDRIVER_GUGAO_H
#include "cmotordriver_base.h"

class MOTOR_DRIVER_IMPL_EXPORT CMotorDriver_GUGAO : public CMotorDriver_Base
{
public:
    CMotorDriver_GUGAO(const QString& name,int32_t id);
    int32_t init_driver();
    int32_t exit_driver();

    int32_t freshio(int32_t ioid, int32_t ioidx);
    int32_t freshio_multi(int32_t ioid, int32_t idxstart,int32_t idxend);
    int32_t setio(int32_t ioid, int32_t ioidx, float64_t fdata);

    int32_t freshpos(int32_t motorid);

    int32_t absmove(int32_t motorid,float64_t fpos,bool_t bwaitfinished=true);
    int32_t relmove(int32_t motorid,float64_t fdis,bool_t bwaitfinished=true);

#if 0
    int32_t startmove(int32_t motorid,float64_t  dspd);
#endif
    int32_t stopmove(int32_t motorid);
    int32_t stopmove_all();

    int32_t preparehome(int32_t motorid);
    int32_t home(int32_t motorid, bool_t bwait=false);

    int32_t wait_home_finished(int32_t motorid);

    int32_t setdefaultspeed(int32_t motorid);
    int32_t setspeed(int32_t motorid,float64_t fspd,float64_t faccspd,float64_t fdecspd,
                     float64_t fjerk,float64_t fkdec);
    int32_t emg_on(bool bon);

    int32_t wait_move_finished(int32_t motorid,bool bcheckLimit=true);

    bool_t is_move_finished(int32_t motorid);

    bool_t is_motor_onpaslimit(int32_t motorid);
    bool_t is_motor_onnaglimit(int32_t motorid);


    void offsetHomePos(int32_t motorid);
    void setHomeStatus(int32_t motorid,bool bhasHomed);
    void freshHomeStatus(int32_t motorid);

    int32_t enable_axis(int32_t motorid, bool_t bEnable);

    float64_t freshAPos(int32_t motorid) override;


	float64_t freshFPos(int32_t motorid) override;


    int32_t afterhome(int32_t motorid) override;
	void wait_equal(int32_t motoid);
private:
    void wait_move_arrived(int32_t motorid, double dTargetPos);
	
    //void AssertCollisionDetection();
};

#endif // CMOTORDRIVER_GUGAO_H
