// Motor_8134.h: interface for the CMotor_8134 class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MOTOR_8134_H__C10921AB_C838_4F26_9C8B_C8E38366E641__INCLUDED_)
#define AFX_MOTOR_8134_H__C10921AB_C838_4F26_9C8B_C8E38366E641__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MotorAdlinkBase.h"

class CMotor_8134 : public CMotorAdlinkBase
{
public:
    CMotor_8134(CMtrProfile mtrProfile, double *dpPos, CMotionControllerBase *pBaseController);
    virtual ~CMotor_8134();

// **************************************************************
// Methods declaration
// **************************************************************

// method to close the axis
    void CloseAxis() override;

// method to initialize and configure the axis
    void ConstructMotor() override;

//  method to On/Off motor
    bool OnMotor() override;
    bool OffMotor() override;

//  method to stop motor with decceleration
    bool DecelStop() override;

//  method to trigger Emergency stop the motor
    bool EmergStop() override;

// method to get commanded position
    bool GetMotorCommandedPosition(int iMtrNo, double *pRaw) override;

// method to get other motor axis IO status
    int GetMotionIOStatus(const CMtrProfile &mtrProfile) override;

// method to get Other axis motor ready status
    BOOL IsMotorReady(const CMtrProfile &mtrProfile) override;

// method to get Other axis Motor On status
    bool IsMtrOn(const CMtrProfile &mtrProfile) override;

// method to get other motor axis current position
    bool GetMotorPosition(const CMtrProfile &mtrProfile, double *pRawPosition) override;

// method to get motor axis current position error
    bool GetMotorPositionError(double *pRawPositionError) override;

// method to do homing by limit sensor
    BOOL HomingByLimit() override;

// method to process interrupt to decode what happen to the motor
    void ProcessInt(int nIntCode = 0) override;

// method to set the commanded position register
    bool SetMotorCommandedPosition(double dPosition) override;

// method to set the mechanical coversion factor
    bool RefreshMotorConversionFactor() override;

// method to set homing modes
    bool SetMotorHomeMode(int iHomeMode) override;

// method to force set the current position
    bool SetMotorPosition(double dPosition) override;

    bool SetupAbsoluteSimultaneousMove(int nNoOfAxis, short *sAxis, double *dPosition, double *dStartVel, double *dMaxVel, double *dAcc, double *dDec) override;
    bool SetupRelativeSimultaneousMove(int nNoOfAxis, short *sAxis, double *dPosition, double *dStartVel, double *dMaxVel, double *dAcc, double *dDec) override;
    bool StartSimultaneousMove(int nFirstAxisNo) override;

// **************************************************************
// Methods declaration applicable to
// ADLINK 8134, 8164 ONLY - starts
// **************************************************************
// method to set the motor type and encoder input type
    bool SetMotorType(int iMtrType) override;

// method to set the motor alarm signal logic
    bool SetMotorAlarmLogic(int iALM) override;

// method to set the home sensor signal logic
    bool SetMotorHomeSensorLogic(int iORGI) override;

// method to set the encoder Index signal logic
    bool SetMotorIndexLogic(int iIndexLogic) override;

// method to set the in position signal logic
    bool SetMotorINPLogic(int iINP) override;

// method to set clk type, out/dir or cw/ccw
    bool SetMotorClk(int iClk) override;

    bool StartHomeMove(double dStartSpeed, double dMaxSpeed, double dAcc) override;

    bool StartContinuousMove(double dStartSpeed, double dMaxSpeed, double dAcc) override;

    bool StartSContinuousMove(double dStartSpeed, double dMaxSpeed, double dAcc, double dSAcc) override;

    bool StartAbsoluteMove(double dPosition, double dStartSpeed, double dMaxSpeed, double dAcc, double dDec) override;

    bool StartSAbsoluteMove(double dPosition, double dStartSpeed, double dMaxSpeed, double dAcc, double dDec, double dSAcc, double dSDec) override;

    bool StartRelativeMove(double dPosition, double dStartSpeed, double dMaxSpeed, double dAcc, double dDec) override;

    bool StartSRelativeMove(double dPosition, double dStartSpeed, double dMaxSpeed, double dAcc, double dDec, double dSAcc, double dSDec) override;

// **************************************************************
// Methods declaration applicable to
// ADLINK 8134, 8164 ONLY - ends
// **************************************************************

private:
    short m_sMtrNo;

    bool FindLimit(HOME_DIR homeDir, MOTION_SPEED speed);

    bool EnableLimitInterrupt();

    bool DisableLimitInterrupt();

    bool GetCurrentPosition(int nMtrNo, double *pPosition);

    bool GetCurrentPosition(double *pPosition);

    bool SetHomingResetPosition(bool bEnable);
};

#endif // !defined(AFX_MOTOR_8134_H__C10921AB_C838_4F26_9C8B_C8E38366E641__INCLUDED_)
