
#ifndef _ECATDEVICEAPI_EX_H_
#define _ECATDEVICEAPI_EX_H_
#include <stdint.h>

/*****************************************************************************/
/** Group command state
 */
#define MC_GRP_CMD_STATE_DONE				0
#define MC_GRP_CMD_STATE_QUEUED				1
#define MC_GRP_CMD_STATE_ACTIVE				2
#define MC_GRP_CMD_STATE_ABORTED			3
#define MC_GRP_CMD_STATE_PAUSE				4
#define MC_GRP_CMD_STATE_ERROR				5

//--------------------------------------
// Definition for "FileFlag" for ECAT_McSetProfileCSV_PLC()
//--------------------------------------
//ECAT_IPC_DATA_SIZE_MAX - defines the maximum size of one data batch (512 bytes)
#define ECAT_CSV_FILE_NEW_WAIT             (0) //Clear the content of the file if it exists before writing new data to it.
                                               //This function will  wait in a loop for a new batch of data to arrive. If within a
                                                                                       //timeout now new data has been received then automatically close the file
#define ECAT_CSV_FILE_CLOSE                (1) //Close the file after the data has been received
#define ECAT_CSV_FILE_NEW_CLOSE            (2) //Clear the content of the existing file, write the received batch CSV data to it
                                               //and then immediately close the file. No wait for new data
#define ECAT_CSV_FILE_APPEND_CLOSE         (3) //Write the received batch data to the file position indicated by "Offset" and close it
#define ECAT_CSV_FILE_APPEND_LAST_CLOSE    (4) //Append the received batch data to the file end position


#ifdef __cplusplus
extern "C" {
#endif

int32_t ECAT_McAxisMove_PLC(uint16_t DeviceNo, uint16_t AxisNo, uint8_t BufferMode, uint8_t AbsMove,  
					double Pos, double Vel, uint16_t AccTime, uint8_t AccDecType, uint32_t *CmdIndex);
int32_t ECAT_McAxisHome_PLC(uint16_t DeviceNo, uint16_t AxisNo, int32_t Method, 
					double Offset, double SeachSw, double SeachZr, double Acc);
int32_t ECAT_McAxisMoveVel_PLC(uint16_t DeviceNo, uint16_t AxisNo, double Vel, uint16_t AccTime, uint32_t *CmdIndex);
int32_t ECAT_McSetAxisCmdBufferMax_PLC(uint16_t DeviceNo, uint16_t AxisNo, uint32_t Max);
int32_t ECAT_McGetAxisCmdState_PLC(uint16_t DeviceNo, uint16_t AxisNo, uint32_t CmdIndex, uint32_t *State);
int32_t ECAT_McAxisStop_PLC(uint16_t DeviceNo, uint16_t AxisNo);
int32_t ECAT_McAxisQuickStop_PLC(uint16_t DeviceNo, uint16_t AxisNo);
int32_t ECAT_McAxisClearStopping_PLC(uint16_t DeviceNo, uint16_t AxisNo);
int32_t ECAT_McAxisStopDone_PLC(uint16_t DeviceNo, uint16_t AxisNo, uint8_t *Done);
int32_t ECAT_McAxisErrorStop_PLC(uint16_t DeviceNo, uint16_t AxisNo);
int32_t ECAT_McGetAxisStates_PLC(uint16_t DeviceNo, uint16_t AxisNo, uint32_t *State, int32_t *LastError, int16_t *DriveError);

int32_t ECAT_McGetAxisInfo_PLC(uint16_t DeviceNo, uint16_t AxisNo, uint32_t *DI, uint32_t *AlStates, uint16_t *HomeState, 
					uint16_t *SoftLimitState);

int32_t ECAT_McGroupMoveLine_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint8_t BufferMode, uint8_t AbsMove,  
					double Pos[], uint32_t ArraySize, double Vel, uint16_t AccTime, uint8_t AccDecType, uint16_t BlendPercent, uint32_t *CmdIndex);
int32_t ECAT_McGroupMoveCircular_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint8_t BufferMode, uint8_t AbsMove,  
					uint8_t CircMode, uint8_t Dir, double Angle, double AuxPos[], double EndPos[], uint32_t ArraySize, double Vel, 
					uint16_t AccTime, uint8_t AccDecType, uint16_t BlendPercent, uint32_t *CmdIndex);
int32_t ECAT_McGroupMoveHelix_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint8_t BufferMode, uint8_t AbsMove, 
					double Angle, double Pitch, double AuxPos[], double NV[], uint32_t ArraySize, double Vel, 
					uint16_t AccTime, uint8_t AccDecType, uint16_t BlendPercent, uint32_t *CmdIndex);
int32_t ECAT_McGroupMoveConicalHelix_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint8_t BufferMode, uint8_t AbsMove, 
					double Angle, double Pitch, double EndRadius, double AuxPos[], double NV[], uint32_t ArraySize, double Vel, 
					uint16_t AccTime, uint8_t AccDecType, uint16_t BlendPercent, uint32_t *CmdIndex);
int32_t ECAT_McSetGroupCmdBufferMax_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint32_t Max);
int32_t ECAT_McGetGroupCmdState_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint32_t CmdIndex, uint32_t *State);
int32_t ECAT_McGroupStop_PLC(uint16_t DeviceNo, uint16_t GroupNo);
int32_t ECAT_McGroupQuickStop_PLC(uint16_t DeviceNo, uint16_t GroupNo);
int32_t ECAT_McGroupClearStopping_PLC(uint16_t DeviceNo, uint16_t GroupNo);
int32_t ECAT_McGroupStopDone_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint8_t *Done);
int32_t ECAT_McGroupErrorStop_PLC(uint16_t DeviceNo, uint16_t GroupNo);
int32_t ECAT_McGetGroupStates_PLC(uint16_t DeviceNo, uint16_t GroupNo, uint32_t *State, int32_t *LastError, int16_t *DriveError);
int32_t ECAT_McGetAxisGroupStates_PLC(uint16_t DeviceNo, uint16_t AxisNo, uint16_t *GroupNo, uint32_t *State);

int32_t ECAT_McGroupMoveVelEx(uint16_t DeviceNo, uint16_t GroupNo, double Vel[], uint32_t *CmdIndex);
int32_t ECAT_McGetGroupAxisNo(uint16_t DeviceNo, uint16_t GroupNo, uint16_t AxisNo[], uint16_t *AxisCnt);
int32_t ECAT_McGetGroupLastError(uint16_t DeviceNo,uint16_t GroupNo,int32_t *Error);
int32_t ECAT_McGroupErrorReset(uint16_t DeviceNo, uint16_t GroupNo);
int32_t ECAT_McGetGroupMotionState(uint16_t DeviceNo, uint16_t GroupNo, uint32_t *State);
int32_t ECAT_McGetGroupAxesActualPos(uint16_t DeviceNo, uint16_t GroupNo, double *Pos, uint16_t Arr);
int32_t ECAT_McGetGroupAxesActualVel(uint16_t DeviceNo, uint16_t GroupNo, double *Vel, uint16_t Arr);
int32_t ECAT_McGetGroupAxesCommandPos(uint16_t DeviceNo, uint16_t GroupNo, double *Pos, uint16_t Arr);
int32_t ECAT_McGetGroupAxesCommandVel(uint16_t DeviceNo, uint16_t GroupNo, double *Vel, uint16_t Arr);
int32_t ECAT_McGetGroupAxesServoOn(uint16_t DeviceNo, uint16_t GroupNo, uint32_t *State);

int32_t ECAT_SetDeviceCmdDataTimeOut(uint16_t DeviceNo, uint32_t TimeOut_ms);
int32_t ECAT_McAxisHalt(uint16_t DeviceNo, uint16_t AxisNo);
int32_t ECAT_McSetAxisAbortingMode(uint16_t DeviceNo, uint16_t AxisNo, uint32_t Enable);

int32_t ECAT_McSetProfileCSV_PLC(uint16_t DeviceNo, uint16_t ProfileNo, uint32_t Offset, char* pData, uint32_t DataSize, uint8_t FileFlag);
int32_t ECAT_McGetGroupAxisState(uint16_t DeviceNo, uint16_t GroupNo, uint16_t *AxisNo, uint32_t *State, uint16_t *AxisCount);


#ifdef __cplusplus
}
#endif

#endif /* _ECATDEVICEAPI_EX_H_ */
