#ifndef PCI_8134A_H
#define PCI_8134A_H

#include "motion.h"

#include "type_def.h"


#if defined (_MYWIN32)
	
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
	
#include <windows.h>

#endif

#if defined _MYWINCE
	
#include <windows.h>
#endif


#ifdef __cplusplus
extern "C" {
#endif

// Initialization  Section 7.3
I16 FNTYPE _8134_initial(I16 *existCards);
I16 FNTYPE _8134_close(void);
I16 FNTYPE _8134_config_from_file(U8 *fileName);
I16 FNTYPE _8134_get_irq_channel(I16 CardNo, U16 *irq_no );
I16 FNTYPE _8134_get_base_addr(I16 CardNo, U16 *base_addr );
I16 FNTYPE _8134_version_info(I16 CardNo, U16 *HardwareInfo, I32 *SoftwareInfo, I32 *DriverInfo);
I16 FNTYPE _8134_set_security_key(I16 CardNo, U16 old_secu_code, U16 New_secu_code);
I16 FNTYPE _8134_check_security_key( I16 CardNo, U16 secu_code);
I16 FNTYPE _8134_reset_security_key(I16 CardNo);

// Pulse Input/Output Configuration Section 7.4
I16 FNTYPE _8134_set_pls_outmode(I16 AxisNo, I16 pls_outmode);
I16 FNTYPE _8134_set_pls_iptmode(I16 AxisNo, I16 pls_iptmode);
I16 FNTYPE _8134_set_feedback_src(I16 AxisNo, I16 src);
I16 FNTYPE _8134_set_move_ratio(I16 AxisNo, F64 move_ratio);

// Continuously Motion Mode Section 7.5
I16 FNTYPE _8134_tv_move(I16 AxisNo, F64 StrVel, F64 MaxVel, F64 Tacc);
I16 FNTYPE _8134_sv_move(I16 AxisNo, F64 StrVel, F64 MaxVel, F64 Tacc, F64 SVacc);
I16 FNTYPE _8134_v_change(I16 AxisNo, F64 Vel, F64 Time);
I16 FNTYPE _8134_sd_stop(I16 AxisNo,F64 Tdec);
I16 FNTYPE _8134_emg_stop(I16 AxisNo);
I16 FNTYPE _8134_set_sd(I16 AxisNo, I16 enable, I16 sd_logic, I16 sd_latch, I16 sd_mode);
I16 FNTYPE _8134_fix_speed_range(I16 AxisNo, F64 MaxVel);
I16 FNTYPE _8134_unfix_speed_range(I16 AxisNo);
I16 FNTYPE _8134_get_current_speed(I16 AxisNo, F64 *speed);
F64 FNTYPE _8134_verify_speed(F64 StrVel,F64 MaxVel,F64 *minAccT,F64 *maxAccT, F64 MaxSpeed);

// Trapezoidal Motion Mode Section 7.6
I16 FNTYPE _8134_start_tr_move(I16 AxisNo, F64 Dist, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec);
I16 FNTYPE _8134_start_ta_move(I16 AxisNo, F64 Pos, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec);

// S-Curve Profile Motion Section 7.7
I16 FNTYPE _8134_start_sr_move(I16 AxisNo, F64 Dist, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec);
I16 FNTYPE _8134_start_sa_move(I16 AxisNo, F64 Pos, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec);

// Multiple Axes Point to Point Motion Section 7.8
I16 FNTYPE _8134_start_move_all(I16 FirstAxisNo);
I16 FNTYPE _8134_stop_move_all(I16 FirstAxisNo);
I16 FNTYPE _8134_set_tr_move_all(I16 TotalAx, I16 *AxisArray, F64 *DistA, F64 *StrVelA, F64 *MaxVelA, F64 *TaccA, F64 *TdecA);
I16 FNTYPE _8134_set_ta_move_all(I16 TotalAx, I16 *AxisArray, F64 *PosA, F64 *StrVelA, F64 *MaxVelA, F64 *TaccA, F64 *TdecA);
I16 FNTYPE _8134_set_sr_move_all(I16 TotalAx, I16 *AxisArray, F64 *DistA, F64 *StrVelA, F64 *MaxVelA, F64 *TaccA, F64 *TdecA, F64 *SVaccA, F64 *SVdecA);
I16 FNTYPE _8134_set_sa_move_all(I16 TotalAx, I16 *AxisArray, F64 *PosA, F64 *StrVelA, F64 *MaxVelA, F64 *TaccA, F64 *TdecA, F64 *SVaccA, F64 *SVdecA);
/* Multiple Axes simultaneous continuous move */
I16 FNTYPE _8134_set_tv_move_all(I16 TotalAx, I16 *AxisArray, F64 *StrVelA, F64 *MaxVelA, F64 *TaccA );
I16 FNTYPE _8134_set_sv_move_all(I16 TotalAx, I16 *AxisArray, F64 *StrVelA, F64 *MaxVelA, F64 *TaccA, F64 *SVaccA );

I16 FNTYPE _8134_set_sync_option(I16 AxisNo, I16 sync_stop_on, I16 cstop_output_on);

// Linear / Circular Interpolated Motion Section 7.9
I16 FNTYPE _8134_start_tr_move_xy(I16 CardNo, F64 DistX, F64 DistY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec);
I16 FNTYPE _8134_start_ta_move_xy(I16 CardNo, F64 PosX, F64 PosY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec);
I16 FNTYPE _8134_start_sr_move_xy(I16 CardNo, F64 DistX, F64 DistY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec);
I16 FNTYPE _8134_start_sa_move_xy(I16 CardNo, F64 PosX, F64 PosY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec);
I16 FNTYPE _8134_start_tr_move_zu(I16 CardNo, F64 DistX, F64 DistY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec);
I16 FNTYPE _8134_start_ta_move_zu(I16 CardNo, F64 PosX, F64 PosY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec);
I16 FNTYPE _8134_start_sr_move_zu(I16 CardNo, F64 DistX, F64 DistY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec);
I16 FNTYPE _8134_start_sa_move_zu(I16 CardNo, F64 PosX, F64 PosY, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec);

// Home Return Mode Section 7.10
I16 FNTYPE _8134_set_home_config(I16 AxisNo, I16 home_mode, I16 org_logic, I16 ez_logic, I16 ez_count, I16 erc_out);
I16 FNTYPE _8134_home_move(I16 AxisNo, F64 StrVel, F64 MaxVel, F64 Tacc);
I16 FNTYPE _8134_set_org_offset(I16 AxisNo, F64 Offset);
I16 FNTYPE _8134_set_org_logic(I16 AxisNo, I16 org_logic);
I16 FNTYPE _8134_set_bounce_filter(I16 AxisNo, I16 Value);
      /* Simultaneous home move functions */
I16 FNTYPE _8134_set_home_config_all(I16 totalAxis, I16 *AxisNo, I16 *home_mode, I16 *org_logic, I16 *ez_logic, I16 *ez_count, I16 *erc_out);
I16 FNTYPE _8134_home_move_all(I16 totalAxis, I16 *AxisNo, F64 *StrVel, F64 *MaxVel, F64 *Tacc);
I16 FNTYPE _8134_set_org_latch(I16 AxisNo, I16 org_latch);
I16 FNTYPE _8134_reset_when_home_finish(I16 AxisNo, U8 Enable);

// Manual Pulser Motion Section 7.11
I16 FNTYPE _8134_set_pulser_iptmode(I16 AxisNo, I16 InputMode, I16 Indep_Com);
I16 FNTYPE _8134_pulser_vmove(I16 AxisNo,F64 SpeedLimit);
I16 FNTYPE _8134_set_pulser_ratio(I16 AxisNo, I16 Value);

// Motion Status Section 7.12
I16 FNTYPE _8134_motion_done(I16 AxisNo);

// Servo Driver Interface Section 7.13
I16 FNTYPE _8134_set_alm(I16 AxisNo, I16 alm_logic, I16 alm_mode);
I16 FNTYPE _8134_set_inp(I16 AxisNo, I16 inp_enable, I16 inp_logic);
I16 FNTYPE _8134_set_erc_enable(I16 AxisNo, I16 erc_enable);

// I/O Control and Monitoring Section 7.14
I16 FNTYPE _8134_set_servo(I16 AxisNo, I16 on_off);
I16 FNTYPE _8134_get_io_status(I16 AxisNo, U16 *io_sts);

// Position Counter Control Section 7.15
I16 FNTYPE _8134_get_position(I16 AxisNo, F64 *pos);
I16 FNTYPE _8134_set_position(I16 AxisNo, F64 pos);
I16 FNTYPE _8134_get_target_pos(I16 AxisNo, F64 *pos);
I16 FNTYPE _8134_reset_target_pos(I16 AxisNo, F64 Pos);
I16 FNTYPE _8134_get_command(I16 AxisNo, I32 *cmd);
I16 FNTYPE _8134_set_command(I16 AxisNo, I32 cmd);

I16 FNTYPE _8134_get_error_counter(I16 AxisNo, I16 *error_counter);
I16 FNTYPE _8134_reset_error_counter(I16 AxisNo);
I16 FNTYPE _8134_set_feedback_error_detect(I16 AxisNo, I32 max_error);

// Interrupt Control Section 7.16
#if defined(_MYWIN32) || defined (_MYWINCE)
I16 FNTYPE _8134_int_enable(I16 CardNo,HANDLE *phEvent);
#elif defined(_MYLINUX)
I16 FNTYPE _8134_int_enable(I16 CardNo, void (*event_handler1)(I32), void (*event_handler2)(I32),void (*event_handler3)(I32), void (*event_handler4)(I32));
#endif
I16 FNTYPE _8134_int_disable(I16 CardNo);
I16 FNTYPE _8134_int_control(I16 CardNo, I16 intFlag);
I16 FNTYPE _8134_set_int_factor(I16 AxisNo, U32 int_factor);
I16 FNTYPE _8134_get_int_status(I16 AxisNo, U32 *int_status);
#ifdef _MYWIN32
I16 FNTYPE _8134_link_axis_interrupt(I16 AxisNo,void ( __stdcall *callbackAddr)( void ));
#endif

// Speed Profile Section
I16 FNTYPE _8134_get_tr_move_profile(I16 AxisNo, F64 Dist, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 *pStrVel, F64 *pMaxVel, F64 *pTacc, F64 *pTdec, F64 *pTconst );
I16 FNTYPE _8134_get_ta_move_profile(I16 AxisNo, F64 Pos, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 *pStrVel, F64 *pMaxVel, F64 *pTacc, F64 *pTdec, F64 *pTconst );
I16 FNTYPE _8134_get_sr_move_profile(I16 AxisNo, F64 Dist, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec,F64 *pStrVel, F64 *pMaxVel, F64 *pTacc, F64 *pTdec, F64 *pSVacc, F64 *pSVdec, F64 *pTconst);
I16 FNTYPE _8134_get_sa_move_profile(I16 AxisNo, F64 Pos, F64 StrVel, F64 MaxVel, F64 Tacc, F64 Tdec, F64 SVacc, F64 SVdec,F64 *pStrVel, F64 *pMaxVel, F64 *pTacc, F64 *pTdec, F64 *pSVacc, F64 *pSVdec, F64 *pTconst);

// New Function
I16 FNTYPE _8134_preset_tr_v_change(I16 AxisNo, I16 NumberOfChange, F64 Distance, F64 MaxVel, F64 Tacc, F64 Tdec, F64 *VChange_Offset_Array, F64 *VChange_Speed_Array, F64 *VChange_Tacc, I16 Compare_Method);
I16 FNTYPE _8134_preset_v_change_status(I16 AxisNo, I16 *Points_Compared);
F64 FNTYPE _8134_verify_preset_v_change(F64 StrVel, F64 MaxVel, F64 FixSpeedRange, F64 *minAccT, F64 *maxAccT, F64 *Resolution);
I16 FNTYPE _8134_set_axis_option(I16 AxisNo, I16 option);

// Reserved Functions
I16 FNTYPE _8134_set_sd_stop_mode(I16 AxisNo, I16 sd_mode);
I16 FNTYPE _8134_set_step_unit(I16 AxisNo, I16 UnitNo);
I16 FNTYPE _8134_set_to_single_mode(I16 AxisX,I16 AxisY);
I16 FNTYPE _8134_set_sw_limit(I16 axisno,F64 p_limit, F64 n_limit);
I16 FNTYPE _8134_unset_sw_limit(I16 axisno);
I16 FNTYPE _8134_set_rdp_mode(I16 AxisNO, I16 Mode);

#ifdef __cplusplus
}
#endif

#endif
