固高GTS控制卡

using gts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GtsDemon2
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
            //mc.GT_Open(0, 1);
            this.Load += FrmMain_Load;
        }

        private CancellationTokenSource cts = new CancellationTokenSource();

        private void FrmMain_Load(object sender, EventArgs e)
        {
            short rtn;
            // 打开运动控制器
            rtn = mc.GT_Open(0, 1);
            Commandhandler("GT_Open", rtn);
            // 复位
            rtn = mc.GT_Reset();
            Commandhandler("GT_Reset", rtn);

            //cmb_Axis.SelectedIndex = 0;
            timer1.Interval = 100; //定时器间隔100ms
            timer1.Start();        //启动定时器
        }

        public void Commandhandler(string cmd, short rtn)
        {
            if (rtn != 0)
            {
                MessageBox.Show(cmd + " = " + rtn.ToString());
            }
        }


        private void Ini_Click(object sender, EventArgs e)
        {
            short rtn;
            rtn = mc.GT_AlarmOff(1); //1轴关报警
            Commandhandler("GT_AlarmOff", rtn);
            rtn = mc.GT_LmtsOff(1, -1);//1轴关闭所有限位
            Commandhandler("GT_LmtsOff", rtn);
            rtn = mc.GT_ClrSts(1, 1);//1轴状态刷新
            Commandhandler("GT_ClrSts", rtn);
            rtn =mc.GT_AxisOn(1);//1轴使能
            Commandhandler("GT_AxisOn", rtn);
            //以此处为原点
            rtn = mc.GT_ZeroPos(1, 1); //需要位置清零的起始轴号,正整数。需要位置清零的轴数
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            short rtn,axis, run;
            int sts, space, seg;
            uint clk;
            //double prfPos;

            double[] prfPos = new double[2];
            double[] enfPos = new double[2];

            axis = 3;
            //axis = Convert.ToInt16(cmb_Axis.SelectedIndex + 1);

            //获取轴状态:
            //rtn = mc.GT_GetSts(1, out sts,1, out clk); //sts显示报警状态
            rtn = mc.GT_GetSts(axis, out sts, 1, out clk); //sts显示报警状态

            //读取规划位置。
            //起始规划轴号,规划位置,读取的轴数,读取控制器时钟
            //rtn = mc.GT_GetPrfPos(1, out prfPos, 1, out clk);
            rtn = mc.GT_GetPrfPos(axis, out prfPos[0], 2, out clk); //读取2个轴
            rtn = mc.GT_CrdSpace(axis, out space, 0);
            rtn = mc.GT_CrdStatus(axis, out run, out seg, 0);

            lbl_Space.Text = space.ToString();
            lbl_Seg.Text = seg.ToString();

            //(short crd, short *pRun, long *pSegment, short fifo=0)
            //crd  坐标系号。正整数,取值范围:[1, 2]。
            //pRun 读取插补运动状态。
            //0:该坐标系的该 FIFO 没有在运动;1:该坐标系的该 FIFO 正在进行插补运动。

            // pSegment读取当前已经完成的插补段数。
            // 当重新建立坐标系或者调用 GT_CrdClear 指令后,该值会被清零。
            //fifo  所要查询运动状态的插补缓存区号。正整数,取值范围:[0, 1],默认值为:0
            

            lbl_XPrfPos.Text = Convert.ToInt32(prfPos[0]).ToString();
            lbl_YPrfPos.Text = Convert.ToInt32(prfPos[1]).ToString();


            //lbl_XPrfPos.Text = Convert.ToInt32(prfPos).ToString(); //读取规划位置

            //读取编码器位置
            /*
             指令原型
                short GT_GetEncPos (short encoder, double *pValue, short count=1, unsigned long
                *pClock=NULL)
                指令说明  读取编码器位置。
                指令类型  立即指令,调用后立即生效。  章节页码  108
                指令参数  该指令共有 4 个参数,参数的详细信息如下。
                encoder
                编码器起始轴号。正整数。
                对于 14 轴控制器,取值范围:[1, 14],硬件上没有编码器接口的轴资源,软件上读不到
                编码器值。
                pValue  编码器位置。
                count
                读取的轴数。默认为 1。
                1 次最多可以读取 8 个编码器轴。
                pClock  读取控制器时钟。
             */
            rtn = mc.GT_GetEncPos(axis, out enfPos[0], 2, out clk);
            lbl_XEncPos.Text = Convert.ToInt32(enfPos[0]).ToString();
            lbl_YEncPos.Text = Convert.ToInt32(enfPos[1]).ToString();

        }

        private void btn_Trap_Click(object sender, EventArgs e)
        {
            short rtn = 0;
            uint clk = 0;
            double prfPos; //位置
            mc.TTrapPrm trap; //结构体对象
            double vel, acc, dec;
            int pos;
            vel = double.Parse(tb_Vel.Text.Trim());
            acc = double.Parse(tb_Acc.Text.Trim());
            dec = double.Parse(tb_Dec.Text.Trim());
            pos = int.Parse(tb_Pos.Text.Trim());



            rtn = mc.GT_PrfTrap(1); // 将 1 轴设为点位模式
            Commandhandler("GT_PrfTrap", rtn);
            rtn = mc.GT_GetTrapPrm(1,out trap); //读取点位运动参数(需要读取所有运动参数到上位机变量)
            Commandhandler("GT_GetTrapPrm", rtn);
            trap.acc = acc;
            trap.dec = dec;
            //trap.acc = 1;
            //trap.dec = 1;
            trap.smoothTime = 20;//范围0-50

            rtn = mc.GT_SetTrapPrm(1, ref trap); //设置点位运动参数
            Commandhandler("GT_SetTrapPrm", rtn);

            rtn = mc.GT_SetVel(1, vel);
            //rtn = mc.GT_SetVel(1, 10); //10脉冲每毫秒
            Commandhandler("GT_SetVel", rtn);

            rtn = mc.GT_GetPrfPos(1, out prfPos, 1, out clk);//获取当前位置

            //从当前位置运动, 当前位置+1000
            //rtn = mc.GT_SetPos(1, Convert.ToInt32(prfPos)+1000); //1轴 走到1000脉冲

            //设置速度
            rtn = mc.GT_SetPos(1, pos);

            Commandhandler("GT_SetPos", rtn);
            //1 << 0; // 0001 -> 0001   =  1
            //1 << 1; // 0001 -> 0010   =  2
            //1 << 2; // 0001 -> 0100   =  4

            //按位指示需要启动点位运动或 Jog 运动的轴号,bit0~bit13 分别对应 1~14 轴。
            // Axis 轴号,如果是1轴不偏移(bit0), 2轴偏移一位(000 0000 0000 0010)
            //给1号轴参数

            rtn = mc.GT_Update(1 << (1 - 1));  //mc.GT_Update(1 << (Axis - 1)); 
            Commandhandler("GT_Update", rtn);
        }

        private void btn_Stop_Click(object sender, EventArgs e)
        {
            short rtn;
            short axis;
            axis = (short)(cmb_Axis.SelectedIndex + 1);
            //停止运动
            //short GT_Stop(long mask, long option)
            //mask 按位指示需要停止运动的轴号或者坐标系号。当 bit 位为 1 时表示停止对应的轴或者坐标系。

            //option 按位指示停止方式。当 bit 位为 0 时表示平滑停止对应的轴或坐标系,
            //当 bit 位为 1 时表示急停对应的轴或坐标系。
            rtn = mc.GT_Stop(1 << (axis - 1), 0);
        }


        public short jog(short axis, double vel, double acc, double dec)
        {
            short rtn;

            rtn = mc.GT_PrfJog(axis);
            Commandhandler("GT_PrfJog", rtn);
            mc.TJogPrm jogPrm;
            rtn += mc.GT_GetJogPrm(axis, out jogPrm);
            Commandhandler("GT_GetJogPrm", rtn);
            jogPrm.acc = acc;
            jogPrm.dec = dec;
            jogPrm.smooth = 0.5;
            rtn += mc.GT_SetJogPrm(axis, ref jogPrm);
            Commandhandler("GT_SetJogPrm", rtn);
            rtn += mc.GT_SetVel(axis, vel);
            Commandhandler("GT_SetVel", rtn);
            rtn += mc.GT_Update(1 << (axis - 1));
            Commandhandler("GT_Update", rtn);
            return rtn;
        }

        private void btn_Crd_Click(object sender, EventArgs e)
        {
            mc.TCrdPrm crd = new mc.TCrdPrm(); //定义坐标系

            /*
             坐标系与规划器的映射关系。Profile[0..7]对应规划轴 1~8,如果规划轴没有对
            应到该坐标系,则 profile[x]的值为 0;如果对应到了 X 轴,则 profile[x]为 1,Y 轴对应
            为 2,Z 轴对应为 3,A 轴对应为 4。不允许多个规划轴映射到相同坐标系的相同坐标轴,
            也不允许把相同规划轴对应到不同的坐标系,否则该指令将会返回错误值。每个元素的
            取值范围:[0, 4]。
             */
            short[] profile = new short[8]; //起始规划轴号
            int[] originPos = new int[8];   //原点
           
            short rtn;
            rtn = mc.GT_GetCrdPrm(1, out crd); //查询坐标系参数
            crd.dimension = 2; //二维坐标系
            crd.evenTime = 10; //最小匀速时间 单位: 毫秒ms 每个插补段的最小匀速段时间。取值范围:[0, 32767)。单位:ms。
            crd.synAccMax = 10; //最大加速度  单位:pulse/ms²
            crd.synVelMax = 100; //最大速度   单位:pulse/ms
            for (short i = 0; i < 8; i++)
            {
                profile[i] = 0;
                originPos[i] = 0;
            }
            profile[2] = 1;   //3轴为x轴
            profile[3] = 2;  //4轴为y轴
            crd.profile = profile;      //设置xy对应轴号
            crd.setOriginFlag = 1;     //手动设置坐标原点
            crd.originPos = originPos; //设置坐标原点偏移量
            //short crd, ref TCrdPrm pCrdPrm, short crd 坐标系号,取值范围:[1, 2]。
            rtn = mc.GT_SetCrdPrm(1, ref crd); //建立坐标系  

            //XY 平面二维直线插补。
            /*
             short GT_LnXY (short crd, long x, long y, 
            double synVel, double synAcc, double velEnd=0,short fifo=0)
             
            crd  坐标系号。正整数,取值范围:[1, 2]。
            x  插补段 x 轴终点坐标值。取值范围:[-1073741823, 1073741823],单位:pulse。
            y  插补段 y 轴终点坐标值。取值范围:[-1073741823, 1073741823],单位:pulse。
            synVel  插补段的目标合成速度。取值范围:(0, 32767),单位:pulse/ms。
            synAcc  插补段的合成加速度。取值范围:(0, 32767),单位:pulse/ms 2 。
            velEnd
            插补段的终点速度。取值范围:[0, 32767),单位:pulse/ms。该值只有在没有使用前瞻预
            处理功能时才有意义,否则该值无效。默认值为:0。
            fifo  插补缓存区号。取值范围:[0, 1],默认值为:0。
            指令返回值  若返回值为 1:
             */
            //(short crd, long x, long y, double synVel, double synAcc, double velEnd = 0,short fifo = 0)
            rtn = mc.GT_LnXY(1, 1000, 2000, 1, 1, 10, 0); //直线插补
            rtn = mc.GT_LnXY(1, 2000, 2000, 1, 1, 0, 0);

            /*
             crd  坐标系号。正整数,取值范围:[1, 2]。
            x  圆弧插补 x 轴的终点坐标值。取值范围:[-1073741823, 1073741823],单位:pulse。
            y  圆弧插补 y 轴的终点坐标值。取值范围:[-1073741823, 1073741823],单位:pulse。
            xCenter  圆弧插补的圆心 x 方向相对于起点位置的偏移量。
            yCenter  圆弧插补的圆心 y 方向相对于起点位置的偏移量。
            circleDir
            圆弧的旋转方向。
            0:顺时针圆弧。
            1:逆时针圆弧。
            synVel  插补段的目标合成速度。取值范围:(0, 32767),单位:pulse/ms。
            synAcc  插补段的合成加速度。取值范围:(0, 32767),单位:pulse/ms 2 。
            velEnd
            插补段的终点速度。取值范围:[0, 32767),单位:pulse/ms。该值只有在没有使用前瞻
            预处理功能时才有意义,否则该值无效。默认值为:0。
            fifo  插补缓存区号。正整数,取值范围:[0, 1],默认值为:0。
            指令返回值
            若返回值为 1:
            (1) 检查当前坐标系是否映射了相关轴。
            (2) 检查是否向 fifo1 中传递数据,若是,则检查 fifo0 是否使用并运动,若运动,则返
            回错误。
            (3) 检查相应的 fifo 是否已满。
            其他返回值:请参照指令返回值列表。
             (short crd, long x, long y, double xCenter, double yCenter, short circleDir,double synVel, double synAcc, double velEnd=0, short fifo=0)
             */
            rtn = mc.GT_ArcXYC(1, 2000, 2000, 0, 1000, 1, 1, 1, 0, 0);//圆弧插补,x的偏移量是0,y轴偏移量1000,逆时针画圆circleDir = 1
            rtn = mc.GT_CrdStart(1, 0);
            //启动插补运动 mask:从bit0到bit1对应坐标系号。0:不启动该坐标系,1:启动该坐标系
            //option:从bit0到bit1对应缓存区编号。bit0 对应坐标系 1,bit1 对应坐标系 2。  0:启动坐标系中 FIFO0 的运动,1:启动坐标系中 FIFO1 的运动。
        }

        //连续插补
        private void continual_Click(object sender, EventArgs e)
        {
            mc.TCrdPrm crd = new mc.TCrdPrm();
            short[] profile = new short[8];
            int[] originPos = new int[8];
            short rtn;
            int space;


            rtn = mc.GT_GetCrdPrm(1, out crd);
            crd.dimension = 2;  //二维坐标系
            crd.evenTime = 10;  //最小匀速时间 ms
            crd.synAccMax = 10;  //最大加速度  pluse/ms^2
            crd.synVelMax = 100; //最大速度  pluse/ms

            for (int i = 0; i < 8; i++)
            {
                profile[i] = 0;      //坐标系与规划器的关系
                originPos[i] = 0;    //坐标原点
            }

            profile[2] = 1; //3轴为X轴
            profile[3] = 2; //4轴为Y轴
            crd.profile = profile; //设置XY轴对应的轴号
            crd.setOriginFlag = 1; //需要 /手动设置坐标原点
            crd.originPos = originPos; //设置坐标原点偏移量
            rtn = mc.GT_SetCrdPrm(1, ref crd); //建立坐标系

            //crd  坐标系号。正整数,取值范围:[1, 2]。
            //fifo 所要清除的插补缓存区号。正整数,取值范围:[0, 1],默认值为:0。
            //若返回值为 1:
            //(1) 检查当前坐标系是否映射了相关轴。
            //(2) 检查是否向 fifo1 中传递数据,若是,则检查 fifo0 是否使用并运动,若运动,则返
            //回错误。
            rtn = mc.GT_CrdClear(1, 0);//每个坐标系有0和1两个4096的fifo,每个fifo又有2个小fifo
            

            //2个缓存区,共4096条数据。每个缓存区2048,
            //启动后先启动一个缓存区的2048,压数据会压入另外一个缓存区
            //压入2048条数据的时间一定要小于运动时间。如果大于,就会数据跑空,运动停止
            for (int i = 0; i < 4096; i++) //i:插补段号
            {
                rtn = mc.GT_LnXY(1, 1000 + i * 100, 2000 + i * 10, 1, 1, 1, 0);
            }

            rtn = mc.GT_LnXY(1, 1000, 2000, 1, 1, 1, 0); //直线插补 此时内存已满 插不如进去数据
            rtn = mc.GT_CrdStart(1, 0); //启动的坐标系, 缓存区号

            //判断,有fifo空间时候才能继续压入数据
            Task.Run(()=>
            {
                while (!cts.IsCancellationRequested)
                {
                    //short crd, long *pSpace, short fifo=0 查询插补缓存区剩余空间
                    //crd  坐标系号。正整数,取值范围:[1, 2]。
                    //pSpace  读取插补缓存区中的剩余空间。
                    //fifo  插补缓存区号。正整数,取值范围:[0, 1],默认值为:0。
                    rtn = mc.GT_CrdSpace(1, out space, 0);
                    if (space != 0)
                        break;
                    Application.DoEvents();
                }
            },cts.Token);

            //space 不为0 才继续执行
            rtn = mc.GT_LnXY(1, 1000, 2000, 1, 1, 1, 0); //直线插补
        }

        private void btnOldFront_Click(object sender, EventArgs e)
        {
            mc.TCrdPrm crd = new mc.TCrdPrm();
            short[] profile = new short[8];
            int[] originPos = new int[8];
            short rtn;
            int space;


            rtn = mc.GT_GetCrdPrm(1, out crd);
            crd.dimension = 2;  //二维坐标系
            crd.evenTime = 10;  //最小匀速时间 ms
            crd.synAccMax = 10;  //最大加速度  pluse/ms^2
            crd.synVelMax = 100; //最大速度  pluse/ms

            for (int i = 0; i < 8; i++)
            {
                profile[i] = 0;      //坐标系与规划器的关系
                originPos[i] = 0;    //坐标原点
            }

            profile[2] = 1; //3轴为X轴
            profile[3] = 2; //4轴为Y轴
            crd.profile = profile; //设置XY轴对应的轴号
            crd.setOriginFlag = 1; //需要 /手动设置坐标原点
            crd.originPos = originPos; //设置坐标原点偏移量
            rtn = mc.GT_SetCrdPrm(1, ref crd); //建立坐标系
            rtn = mc.GT_CrdClear(1, 0);

            mc.TCrdData[] crdData = new mc.TCrdData[200]; //前瞻缓存区
            //short crd,short fifo,double T,double accMax,short n,ref TCrdData pLookAheadBuf
            rtn = mc.GT_InitLookAhead(1, 0, 5, 1, 200, ref crdData[0]); //初始化前瞻. 200:前瞻缓存区大小。取值范围:[0, 32767)。 必须大于200才能启动,200为自定义

            //压入数据大于了200条, 可以先启动GT_CrdStart, 后把前瞻缓存区的数据压入插补缓存区GT_CrdData
            //如果压入数据小于了200条,需要先GT_CrdData,再去启动GT_CrdStart
            for (int i = 0; i < 4096; i++) //i:插补段号
            {
                rtn = mc.GT_LnXY(1, 1000 + i * 100, 2000 + i * 10, 1, 1, 1, 0);
            }

            rtn = mc.GT_LnXY(1, 1000, 2000, 1, 1, 1, 0); //直线插补 此时内存已满 插不如进去数据
            rtn = mc.GT_CrdStart(1, 0); //启动的坐标系, 缓存区号

            while (true)
            {
                //用于在使用前瞻时。调用该指令表示后续没有新的数据,
                //将会一次性把前瞻缓存区的数据压入运动缓存区。
                rtn = mc.GT_CrdData(1, IntPtr.Zero, 0);
                Application.DoEvents();
                if (rtn == 0)
                    break;
            }
            //14分15
            //https://www.bilibili.com/video/BV1mu411v7ta?spm_id_from=333.999.0.0
        }
    }
}


using System.Runtime.InteropServices;

namespace gts
{
    public class mc
    {
        public const short DLL_VERSION_0 = 2;
        public const short DLL_VERSION_1 = 1;
        public const short DLL_VERSION_2 = 0;

        public const short DLL_VERSION_3 = 1;
        public const short DLL_VERSION_4 = 5;
        public const short DLL_VERSION_5 = 0;
        public const short DLL_VERSION_6 = 6;
        public const short DLL_VERSION_7 = 0;
        public const short DLL_VERSION_8 = 7;

        public const short MC_NONE = -1;

        public const short MC_LIMIT_POSITIVE = 0;
        public const short MC_LIMIT_NEGATIVE = 1;
        public const short MC_ALARM = 2;
        public const short MC_HOME = 3;
        public const short MC_GPI = 4;
        public const short MC_ARRIVE = 5;
        public const short MC_MPG = 6;

        public const short MC_ENABLE = 10;
        public const short MC_CLEAR = 11;
        public const short MC_GPO = 12;

        public const short MC_DAC = 20;
        public const short MC_STEP = 21;
        public const short MC_PULSE = 22;
        public const short MC_ENCODER = 23;
        public const short MC_ADC = 24;

        public const short MC_AXIS = 30;
        public const short MC_PROFILE = 31;
        public const short MC_CONTROL = 32;

        public const short CAPTURE_HOME = 1;
        public const short CAPTURE_INDEX = 2;
        public const short CAPTURE_PROBE = 3;
        public const short CAPTURE_HSIO0 = 6;
        public const short CAPTURE_HSIO1 = 7;
        public const short CAPTURE_HOME_GPI = 8;

        public const short PT_MODE_STATIC = 0;
        public const short PT_MODE_DYNAMIC = 1;

        public const short PT_SEGMENT_NORMAL = 0;
        public const short PT_SEGMENT_EVEN = 1;
        public const short PT_SEGMENT_STOP = 2;

        public const short GEAR_MASTER_ENCODER = 1;
        public const short GEAR_MASTER_PROFILE = 2;
        public const short GEAR_MASTER_AXIS = 3;

        public const short FOLLOW_MASTER_ENCODER = 1;
        public const short FOLLOW_MASTER_PROFILE = 2;
        public const short FOLLOW_MASTER_AXIS = 3;

        public const short FOLLOW_EVENT_START = 1;
        public const short FOLLOW_EVENT_PASS = 2;

        public const short GEAR_EVENT_START = 1;
        public const short GEAR_EVENT_PASS = 2;
        public const short GEAR_EVENT_AREA = 5;

        public const short FOLLOW_SEGMENT_NORMAL = 0;
        public const short FOLLOW_SEGMENT_EVEN = 1;
        public const short FOLLOW_SEGMENT_STOP = 2;
        public const short FOLLOW_SEGMENT_CONTINUE = 3;

        public const short INTERPOLATION_AXIS_MAX = 4;
        public const short CRD_FIFO_MAX = 4096;
        public const short FIFO_MAX = 2;
        public const short CRD_MAX = 2;
        public const short CRD_OPERATION_DATA_EXT_MAX = 2;

        public const short CRD_OPERATION_TYPE_NONE = 0;
        public const short CRD_OPERATION_TYPE_BUF_IO_DELAY = 1;
        public const short CRD_OPERATION_TYPE_LASER_ON = 2;
        public const short CRD_OPERATION_TYPE_LASER_OFF = 3;
        public const short CRD_OPERATION_TYPE_BUF_DA = 4;
        public const short CRD_OPERATION_TYPE_LASER_CMD = 5;
        public const short CRD_OPERATION_TYPE_LASER_FOLLOW = 6;
        public const short CRD_OPERATION_TYPE_LMTS_ON = 7;
        public const short CRD_OPERATION_TYPE_LMTS_OFF = 8;
        public const short CRD_OPERATION_TYPE_SET_STOP_IO = 9;
        public const short CRD_OPERATION_TYPE_BUF_MOVE = 10;
        public const short CRD_OPERATION_TYPE_BUF_GEAR = 11;
        public const short CRD_OPERATION_TYPE_SET_SEG_NUM = 12;
        public const short CRD_OPERATION_TYPE_STOP_MOTION = 13;
        public const short CRD_OPERATION_TYPE_SET_VAR_VALUE = 14;
        public const short CRD_OPERATION_TYPE_JUMP_NEXT_SEG = 15;
        public const short CRD_OPERATION_TYPE_SYNCH_PRF_POS = 16;
        public const short CRD_OPERATION_TYPE_VIRTUAL_TO_ACTUAL = 17;
        public const short CRD_OPERATION_TYPE_SET_USER_VAR = 18;
        public const short CRD_OPERATION_TYPE_SET_DO_BIT_PULSE = 19;
        public const short CRD_OPERATION_TYPE_BUF_COMPAREPULSE = 20;
        public const short CRD_OPERATION_TYPE_LASER_ON_EX = 21;
        public const short CRD_OPERATION_TYPE_LASER_OFF_EX = 22;
        public const short CRD_OPERATION_TYPE_LASER_CMD_EX = 23;
        public const short CRD_OPERATION_TYPE_LASER_FOLLOW_RATIO_EX = 24;
        public const short CRD_OPERATION_TYPE_LASER_FOLLOW_MODE = 25;
        public const short CRD_OPERATION_TYPE_LASER_FOLLOW_OFF = 26;
        public const short CRD_OPERATION_TYPE_LASER_FOLLOW_OFF_EX = 27;
        public const short CRD_OPERATION_TYPE_LASER_FOLLOW_SPLINE = 28;
        public const short CRD_OPERATION_TYPE_MOTION_DATA = 29;
        
        public const short CRD_OPERATION_TYPE_BUF_TREND = 50;
        
        public const short CRD_OPERATION_TYPE_BUF_EVENT_ON = 70;
        public const short CRD_OPERATION_TYPE_BUF_EVENT_OFF = 71;

        public const short INTERPOLATION_MOTION_TYPE_LINE = 0;
        public const short INTERPOLATION_MOTION_TYPE_CIRCLE = 1;
        public const short INTERPOLATION_MOTION_TYPE_HELIX = 2;
        public const short INTERPOLATION_MOTION_TYPE_CIRCLE_3D = 3;

        public const short INTERPOLATION_CIRCLE_PLAT_XY = 0;
        public const short INTERPOLATION_CIRCLE_PLAT_YZ = 1;
        public const short INTERPOLATION_CIRCLE_PLAT_ZX = 2;

        public const short INTERPOLATION_HELIX_CIRCLE_XY_LINE_Z = 0;
        public const short INTERPOLATION_HELIX_CIRCLE_YZ_LINE_X = 1;
        public const short INTERPOLATION_HELIX_CIRCLE_ZX_LINE_Y = 2;

        public const short INTERPOLATION_CIRCLE_DIR_CW = 0;
        public const short INTERPOLATION_CIRCLE_DIR_CCW = 1;

        public const short COMPARE_PORT_HSIO = 0;
        public const short COMPARE_PORT_GPO = 1;

        public const short COMPARE2D_MODE_2D = 1;
        public const short COMPARE2D_MODE_1D = 0;

        public const short INTERFACEBOARD20 = 2;
        public const short INTERFACEBOARD30 = 3;

        public const short AXIS_LASER = 7;
        public const short AXIS_LASER_EX = 8;

        public const short LASER_CTRL_MODE_PWM1 = 0;
        public const short LASER_CTRL_FREQUENCY = 1;
        public const short LASER_CTRL_VOLTAGE = 2;
        public const short LASER_CTRL_MODE_PWM2 = 3;
        
        public const short CRD_BUFFER_MODE_DYNAMIC_DEFAULT = 0;
        public const short CRD_BUFFER_MODE_DYNAMIC_KEEP = 1;
        public const short CRD_BUFFER_MODE_STATIC_INPUT = 11;
        public const short CRD_BUFFER_MODE_STATIC_READY = 12;
        public const short CRD_BUFFER_MODE_STATIC_START = 13;
        
        public const short CRD_SMOOTH_MODE_NONE = 0;
        public const short CRD_SMOOTH_MODE_PERCENT = 1;
        public const short CRD_SMOOTH_MODE_JERK = 2;

        public const short ELLIPSE_AUX_POINT_COUNT = 5;

        public struct TTrapPrm
        {
            public double acc;
            public double dec;
            public double velStart;
            public short  smoothTime;
        }

        public struct TJogPrm
        {
            public double acc;
            public double dec;
            public double smooth;
        }

        public struct TPid
        {
            public double kp;
            public double ki;
            public double kd;
            public double kvff;
            public double kaff;

            public int integralLimit;
            public int derivativeLimit;
            public short  limit;
        }

        public struct TThreadSts
        {
            public short run;
            public short error;
            public double result;
            public short line;
        }

        public struct TVarInfo
        {
            public short id;
            public short dataType;
            public double dumb0;
            public double dumb1;
            public double dumb2;
            public double dumb3;
        }
        public struct TCompileInfo
        {
            public string pFileName;
            public short pLineNo1;
            public short pLineNo2;
            public string pMessage;
        }
        public struct TCrdPrm
        {
            public short dimension;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public short[] profile;
            //public short profile1;
            //public short profile2;
            //public short profile3;
            //public short profile4;
            //public short profile5;
            //public short profile6;
            //public short profile7;
            //public short profile8;

            public double synVelMax;
            public double synAccMax;
            public short evenTime;
            public short setOriginFlag;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public int[] originPos;
            //public int originPos1;
            //public int originPos2;
            //public int originPos3;
            //public int originPos4;
            //public int originPos5;
            //public int originPos6;
            //public int originPos7;
            //public int originPos8;
        }

        public struct TCrdBufOperation
        {
            public short flag;
            public ushort delay;
            public short doType;
            public ushort doMask;
            public ushort doValue;
            public ushort dataExt1;
            public ushort dataExt2;
        }

        public struct TCrdData
        {
            public short motionType;
            public short circlePlat;
            public int pos1;
            public int pos2;
            public int pos3;
            public int pos4;
            public int pos5;
            public int pos6;
            public int pos7;
            public int pos8;
            public double radius;
            public short circleDir;
            public double lCenterX;
            public double lCenterY;
            public double lCenterZ;
            public double vel;
            public double acc;
            public short velEndZero;
            public TCrdBufOperation operation;

            public double cos1;
            public double cos2;
            public double cos3;
            public double cos4;
            public double cos5;
            public double cos6;
            public double cos7;
            public double cos8;
            public double velEnd;
            public double velEndAdjust;
            public double r;
        }

        public struct TTrigger
        {
            public short encoder;
            public short probeType;
            public short probeIndex;
            public short offset;
            public short windowOnly;
            public int firstPosition;
            public int lastPosition;
        }

        public struct TTriggerStatus
        {
            public short execute;
            public short done;
            public int position;
        }
        
        public struct TTriggerStatusEx
        {
        		public short execute;
        		public short done;
        		public int position;
        		public int clock;
        		public int loopCount;
        }

        public struct T2DCompareData
        {
            public int px;
            public int py;
        }

        public struct T2DComparePrm
        {
            public short encx;
            public short ency;
            public short source;
            public short outputType;
            public short startLevel;
            public short time;
            public short maxerr;
            public short threshold; 
        }
        
      	public struct TCrdTime
      	{
      			public double time;
      			public int segmentUsed;
      			public int segmentHead;
      			public int segmentTail;
      	}
      	
      	public struct TCrdSmoothInfo
      	{
      			public short enable;
      			public short smoothMode;
      			public short percent;
      			public short accStartPercent;
      			public short decEndPercent;
      			public double jerkMax;
      	}
      	
      	public struct TCrdSmooth
      	{
      			public short percent;
      			public short accStartPercent;
      			public short decEndPercent;
      			public double reserve;
      	}
      	
	public struct TBufFollowMaster
	{
			public short crdAxis;
			public short masterIndex; 
			public short masterType; 
	}
	public struct TBufFollowEventCross
	{
			public int masterPos;
			public int pad;
	}
	public struct TBufFollowEventTrigger
	{
			public short triggerIndex;
			public int triggerOffset;
			public int pad;
	}
	public struct TCrdFollowStatus
	{
			public short stage;
			public double slavePos;
			public double slaveVel;
			public long loopCount; 
	}
	public struct TCrdFollowPrm
	{
			public double velRatioMax;
			public double accRatioMax;
			public int masterLead;
			public int masterEven;
			public int slaveEven;
			public short dir;
			public short smoothPercent;
			public short synchAlign;
	}
        [DllImport("gts.dll")]
        public static extern short GT_GetDllVersion(out string pDllVersion);
        [DllImport("gts.dll")]
        public static extern short GT_SetCardNo(short index);
        [DllImport("gts.dll")]
        public static extern short GT_GetCardNo(out short index);

        [DllImport("gts.dll")]
        public static extern short GT_GetVersion(out string pVersion);
        [DllImport("gts.dll")]
        public static extern short GT_GetInterfaceBoardSts(out short pStatus);
        [DllImport("gts.dll")]
        public static extern short GT_SetInterfaceBoardSts(short type);

        [DllImport("gts.dll")]
        public static extern short GT_Open(short channel,short param);
        [DllImport("gts.dll")]
        public static extern short GT_Close();

        [DllImport("gts.dll")]
        public static extern short GT_LoadConfig(string pFile);

        [DllImport("gts.dll")]
        public static extern short GT_AlarmOff(short axis);
        [DllImport("gts.dll")]
        public static extern short GT_AlarmOn(short axis);
        [DllImport("gts.dll")]
        public static extern short GT_LmtsOn(short axis, short limitType);
        [DllImport("gts.dll")]
        public static extern short GT_LmtsOff(short axis, short limitType);
        [DllImport("gts.dll")]
        public static extern short GT_ProfileScale(short axis, short alpha, short beta);
        [DllImport("gts.dll")]
        public static extern short GT_EncScale(short axis, short alpha, short beta);
        [DllImport("gts.dll")]
        public static extern short GT_StepDir(short step);
        [DllImport("gts.dll")]
        public static extern short GT_StepPulse(short step);
        [DllImport("gts.dll")]
        public static extern short GT_SetMtrBias(short dac, short bias);
        [DllImport("gts.dll")]
        public static extern short GT_GetMtrBias(short dac, out short pBias);
        [DllImport("gts.dll")]
        public static extern short GT_SetMtrLmt(short dac, short limit);
        [DllImport("gts.dll")]
        public static extern short GT_GetMtrLmt(short dac, out short pLimit);
        [DllImport("gts.dll")]
        public static extern short GT_EncSns(ushort sense);
        [DllImport("gts.dll")]
        public static extern short GT_EncOn(short encoder);
        [DllImport("gts.dll")]
        public static extern short GT_EncOff(short encoder);
        [DllImport("gts.dll")]
        public static extern short GT_SetPosErr(short control, int error);
        [DllImport("gts.dll")]
        public static extern short GT_GetPosErr(short control, out int pError);
        [DllImport("gts.dll")]
        public static extern short GT_SetStopDec(short profile, double decSmoothStop, double decAbruptStop);
        [DllImport("gts.dll")]
        public static extern short GT_GetStopDec(short profile, out double pDecSmoothStop, out double pDecAbruptStop);
        [DllImport("gts.dll")]
        public static extern short GT_LmtSns(ushort sense);
        [DllImport("gts.dll")]
        public static extern short GT_CtrlMode(short axis, short mode);
        [DllImport("gts.dll")]
        public static extern short GT_SetStopIo(short axis, short stopType, short inputType, short inputIndex);
        [DllImport("gts.dll")]
        public static extern short GT_GpiSns(ushort sense);
        [DllImport("gts.dll")]
        public static extern short GT_SetAdcFilter(short adc,short filterTime);
        [DllImport("gts.dll")]
        public static extern short GT_SetAxisPrfVelFilter(short axis,short filterNumExp);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisPrfVelFilter(short axis,out short pFilterNumExp);
        [DllImport("gts.dll")]
        public static extern short GT_SetAxisEncVelFilter(short axis,short filterNumExp);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisEncVelFilter(short axis,out short pFilterNumExp);
        [DllImport("gts.dll")]
        public static extern short GT_SetAxisInputShaping(short axis, short enable, short count, double k);

        [DllImport("gts.dll")]
        public static extern short GT_SetDo(short doType,int value);
        [DllImport("gts.dll")]
        public static extern short GT_SetDoBit(short doType,short doIndex,short value);
        [DllImport("gts.dll")]
        public static extern short GT_GetDo(short doType,out int pValue);
        [DllImport("gts.dll")]
        public static extern short GT_SetDoBitReverse(short doType,short doIndex,short value,short reverseTime);
        [DllImport("gts.dll")]
        public static extern short GT_SetDoMask(short doType,ushort doMask,int value);
        [DllImport("gts.dll")]
        public static extern short GT_EnableDoBitPulse(short doType,short doIndex,ushort highLevelTime,ushort lowLevelTime,int pulseNum,short firstLevel);
        [DllImport("gts.dll")]
        public static extern short GT_DisableDoBitPulse(short doType, short doIndex);

        [DllImport("gts.dll")]
        public static extern short GT_GetDi(short diType,out int pValue);
        [DllImport("gts.dll")]
        public static extern short GT_GetDiReverseCount(short diType,short diIndex,out uint reverseCount,short count);
        [DllImport("gts.dll")]
        public static extern short GT_SetDiReverseCount(short diType,short diIndex,ref uint reverseCount,short count);
        [DllImport("gts.dll")]
        public static extern short GT_GetDiRaw(short diType,out int pValue);

        [DllImport("gts.dll")]
        public static extern short GT_SetDac(short dac,ref short value,short count);
        [DllImport("gts.dll")]
        public static extern short GT_GetDac(short dac,out short value,short count,out uint pClock);

        [DllImport("gts.dll")]
        public static extern short GT_GetAdc(short adc,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetAdcValue(short adc,out short pValue,short count,out uint pClock);

        [DllImport("gts.dll")]
        public static extern short GT_SetEncPos(short encoder,int encPos);
        [DllImport("gts.dll")]
        public static extern short GT_GetEncPos(short encoder,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetEncPosPre(short encoder,out double pValue,short count,uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetEncVel(short encoder,out double pValue,short count,out uint pClock);

        [DllImport("gts.dll")]
        public static extern short GT_SetCaptureMode(short encoder,short mode);
        [DllImport("gts.dll")]
        public static extern short GT_GetCaptureMode(short encoder,out short pMode,short count);
        [DllImport("gts.dll")]
        public static extern short GT_StopCapture(short encoder);
        [DllImport("gts.dll")]
        public static extern short GT_GetCaptureStatus(short encoder,out short pStatus,out int pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_SetCaptureSense(short encoder, short mode,short sense);
        [DllImport("gts.dll")]
        public static extern short GT_ClearCaptureStatus(short encoder);
        [DllImport("gts.dll")]
        public static extern short GT_SetCaptureRepeat(short encoder,short count);
        [DllImport("gts.dll")]
        public static extern short GT_GetCaptureRepeatStatus(short encoder,out short pCount);
        [DllImport("gts.dll")]
        public static extern short GT_GetCaptureRepeatPos(short encoder, out int pValue, short startNum, short count);
        [DllImport("gts.dll")]
        public static extern short GT_SetCaptureEncoder(short trigger,short encoder);
        [DllImport("gts.dll")]
        public static extern short GT_GetCaptureWidth(short trigger,out short pWidth,short count);
        [DllImport("gts.dll")]
        public static extern short GT_GetCaptureHomeGpi(short trigger,out short pHomeSts,out short pHomePos,out short pGpiSts,out short pGpiPos,short count);

        [DllImport("gts.dll")]
        public static extern short GT_Reset();
        [DllImport("gts.dll")]
        public static extern short GT_GetClock(out uint pClock,out uint pLoop);
        [DllImport("gts.dll")]
        public static extern short GT_GetClockHighPrecision(out uint pClock);

        [DllImport("gts.dll")]
        public static extern short GT_GetSts(short axis,out int pSts,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_ClrSts(short axis,short count);
        [DllImport("gts.dll")]
        public static extern short GT_AxisOn(short axis);
        [DllImport("gts.dll")]
        public static extern short GT_AxisOff(short axis);
        [DllImport("gts.dll")]
        public static extern short GT_Stop(int mask,int option);
        [DllImport("gts.dll")]
        public static extern short GT_SetPrfPos(short profile,int prfPos);
        [DllImport("gts.dll")]
        public static extern short GT_SynchAxisPos(int mask);
        [DllImport("gts.dll")]
        public static extern short GT_ZeroPos(short axis,short count);

        [DllImport("gts.dll")]
        public static extern short GT_SetSoftLimit(short axis,int positive,int negative);
        [DllImport("gts.dll")]
        public static extern short GT_GetSoftLimit(short axis,out int pPositive,out int pNegative);
        [DllImport("gts.dll")]
        public static extern short GT_SetAxisBand(short axis,int band,int time);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisBand(short axis,out int pBand,out int pTime);
        [DllImport("gts.dll")]
        public static extern short GT_SetBacklash(short axis,int compValue,double compChangeValue,int compDir);
        [DllImport("gts.dll")]
        public static extern short GT_GetBacklash(short axis,out int pCompValue,out double pCompChangeValue,out int pCompDir);
        [DllImport("gts.dll")]
        public static extern short GT_SetLeadScrewComp(short axis,short n,int startPos,int lenPos,out int pCompPos,out int pCompNeg);
        [DllImport("gts.dll")]
        public static extern short GT_EnableLeadScrewComp(short axis,short mode);
        [DllImport("gts.dll")]
        public static extern short GT_GetCompensate(short axis, out double pPitchError, out double pCrossError, out double pBacklashError, out double pEncPos, out double pPrfPos);
        
        [DllImport("gts.dll")]
        public static extern short GT_EnableGantry(short gantryMaster,short gantrySlave,double masterKp,double slaveKp);
        [DllImport("gts.dll")]
        public static extern short GT_DisableGantry();
        [DllImport("gts.dll")]
        public static extern short GT_SetGantryErrLmt(int gantryErrLmt);
        [DllImport("gts.dll")]
        public static extern short GT_GetGantryErrLmt(out int pGantryErrLmt);
        [DllImport("gts.dll")]
        public static extern short GT_ZeroGantryPos(short gantryMaster,short gantrySlave);

        [DllImport("gts.dll")]
        public static extern short GT_GetPrfPos(short profile,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetPrfVel(short profile,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetPrfAcc(short profile,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetPrfMode(short profile,out int pValue,short count,out uint pClock);

        [DllImport("gts.dll")]
        public static extern short GT_GetAxisPrfPos(short axis,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisPrfVel(short axis,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisPrfAcc(short axis,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisEncPos(short axis,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisEncVel(short axis,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisEncAcc(short axis,out double pValue,short count,out uint pClock);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisError(short axis,out double pValue,short count,out uint pClock);

        [DllImport("gts.dll")]
        public static extern short GT_SetLongVar(short index,int value);
        [DllImport("gts.dll")]
        public static extern short GT_GetLongVar(short index,out int pValue);
        [DllImport("gts.dll")]
        public static extern short GT_SetDoubleVar(short index,double pValue);
        [DllImport("gts.dll")]
        public static extern short GT_GetDoubleVar(short index, out double pValue);

        [DllImport("gts.dll")]
        public static extern short GT_SetControlFilter(short control,short index);
        [DllImport("gts.dll")]
        public static extern short GT_GetControlFilter(short control,out short pIndex);

        [DllImport("gts.dll")]
        public static extern short GT_SetPid(short control,short index,ref TPid pPid);
        [DllImport("gts.dll")]
        public static extern short GT_GetPid(short control,short index,out TPid pPid);

        [DllImport("gts.dll")]
        public static extern short GT_SetKvffFilter(short control,short index,short kvffFilterExp,double accMax);
        [DllImport("gts.dll")]
        public static extern short GT_GetKvffFilter(short control, short index, out short pKvffFilterExp, out double pAccMax);

        [DllImport("gts.dll")]
        public static extern short GT_Update(int mask);
        [DllImport("gts.dll")]
        public static extern short GT_SetPos(short profile,int pos);
        [DllImport("gts.dll")]
        public static extern short GT_GetPos(short profile,out int pPos);
        [DllImport("gts.dll")]
        public static extern short GT_SetVel(short profile,double vel);
        [DllImport("gts.dll")]
        public static extern short GT_GetVel(short profile,out double pVel);

        [DllImport("gts.dll")]
        public static extern short GT_PrfTrap(short profile);
        [DllImport("gts.dll")]
        public static extern short GT_SetTrapPrm(short profile,ref TTrapPrm pPrm);
        [DllImport("gts.dll")]
        public static extern short GT_GetTrapPrm(short profile,out TTrapPrm pPrm);

        [DllImport("gts.dll")]
        public static extern short GT_PrfJog(short profile);
        [DllImport("gts.dll")]
        public static extern short GT_SetJogPrm(short profile,ref TJogPrm pPrm);
        [DllImport("gts.dll")]
        public static extern short GT_GetJogPrm(short profile,out TJogPrm pPrm);

        [DllImport("gts.dll")]
        public static extern short GT_PrfPt(short profile,short mode);
        [DllImport("gts.dll")]
        public static extern short GT_SetPtLoop(short profile,int loop);
        [DllImport("gts.dll")]
        public static extern short GT_GetPtLoop(short profile,out int pLoop);
        [DllImport("gts.dll")]
        public static extern short GT_PtSpace(short profile,out short pSpace,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_PtData(short profile,double pos,int time,short type,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_PtDataWN(short profile,double pos,int time,short type,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_PtClear(short profile,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_PtStart(int mask,int option);
        [DllImport("gts.dll")]
        public static extern short GT_SetPtMemory(short profile,short memory);
        [DllImport("gts.dll")]
        public static extern short GT_GetPtMemory(short profile,out short pMemory);
        [DllImport("gts.dll")]
        public static extern short GT_PtGetSegNum(short profile, out int pSegNum);
        [DllImport("gts.dll")]
        public static extern short GT_SetPtPrecisionMode(short profile,short precisionMode);
        [DllImport("gts.dll")]
        public static extern short GT_GetPtPrecisionMode(short profile,out short pPrecisionMode);
        [DllImport("gts.dll")]
        public static extern short GT_SetPtVel(short profile,double velLast,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_SetPtLink(short profile,short fifo,short list);
        [DllImport("gts.dll")]
        public static extern short GT_GetPtLink(short profile,short fifo,out short pList);
        [DllImport("gts.dll")]
        public static extern short GT_PtDoBit(short profile,short doType,short index,short value,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_PtAo(short profile,short aoType,short index,double value,short fifo);

        [DllImport("gts.dll")]
        public static extern short GT_PrfGear(short profile,short dir);
        [DllImport("gts.dll")]
        public static extern short GT_SetGearMaster(short profile,short masterIndex,short masterType,short masterItem);
        [DllImport("gts.dll")]
        public static extern short GT_GetGearMaster(short profile,out short pMasterIndex,out short pMasterType,out short pMasterItem);
        [DllImport("gts.dll")]
        public static extern short GT_SetGearRatio(short profile,int masterEven,int slaveEven,int masterSlope);
        [DllImport("gts.dll")]
        public static extern short GT_GetGearRatio(short profile,out int pMasterEven,out int pSlaveEven,out int pMasterSlope);
        [DllImport("gts.dll")]
        public static extern short GT_GearStart(int mask);
        [DllImport("gts.dll")]
        public static extern short GT_SetGearEvent(short profile,short gearEvent,int startPara0,int startPara1);
        [DllImport("gts.dll")]
        public static extern short GT_GetGearEvent(short profile, out short pEvent,out int pStartPara0, out int pStartPara1);

        [DllImport("gts.dll")]
        public static extern short GT_PrfFollow(short profile,short dir);
        [DllImport("gts.dll")]
        public static extern short GT_SetFollowMaster(short profile,short masterIndex,short masterType,short masterItem);
        [DllImport("gts.dll")]
        public static extern short GT_GetFollowMaster(short profile,out short pMasterIndex,out short pMasterType,out short pMasterItem);
        [DllImport("gts.dll")]
        public static extern short GT_SetFollowLoop(short profile,int loop);
        [DllImport("gts.dll")]
        public static extern short GT_GetFollowLoop(short profile,out int pLoop);
        [DllImport("gts.dll")]
        public static extern short GT_SetFollowEvent(short profile,short followEvent,short masterDir,int pos);
        [DllImport("gts.dll")]
        public static extern short GT_GetFollowEvent(short profile,out short pFollowEvent,out short pMasterDir,out int pPos);
        [DllImport("gts.dll")]
        public static extern short GT_FollowSpace(short profile,out short pSpace,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_FollowData(short profile,int masterSegment,double slaveSegment,short type,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_FollowClear(short profile,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_FollowStart(int mask,int option);
        [DllImport("gts.dll")]
        public static extern short GT_FollowSwitch(int mask);
        [DllImport("gts.dll")]
        public static extern short GT_SetFollowMemory(short profile,short memory);
        [DllImport("gts.dll")]
        public static extern short GT_GetFollowMemory(short profile,out short memory);
        [DllImport("gts.dll")]
        public static extern short GT_GetFollowStatus(short profile, out short pFifoNum, out short pSwitchStatus);
        [DllImport("gts.dll")]
        public static extern short GT_SetFollowPhasing(short profile, short profilePhasing);
        [DllImport("gts.dll")]
        public static extern short GT_GetFollowPhasing(short profile, out short pProfilePhasing);

        [DllImport("gts.dll")]
        public static extern short GT_BufFollowMaster(short crd,ref TBufFollowMaster pBufFollowMaster,short fifo=0);
	[DllImport("gts.dll")]
        public static extern short GT_BufFollowEventCross(short crd,ref TBufFollowEventCross pEventCross,short fifo=0);
	[DllImport("gts.dll")]
        public static extern short GT_BufFollowEventTrigger(short crd,ref TBufFollowEventTrigger pEventTrigger,short fifo=0);
	[DllImport("gts.dll")]
        public static extern short GT_BufFollowStart(short crd,int masterSegment,int slaveSegment,int masterFrameWidth,short fifo=0);
	[DllImport("gts.dll")]
        public static extern short GT_BufFollowReturn(short crd,double vel,double acc,short smoothPercent,short fifo=0);
	[DllImport("gts.dll")]
        public static extern short GT_BufFollowNext(short crd,int width,short fifo=0);
	[DllImport("gts.dll")]
        public static extern short GT_GetCrdFollowStatus(short crd,out TCrdFollowStatus pStatus);
	[DllImport("gts.dll")]
        public static extern short GT_SetCrdFollowLoop(short crd, long loop);
	[DllImport("gts.dll")]
        public static extern short GT_GetCrdFollowLoop(short crd,out long pLoop);
	[DllImport("gts.dll")]
        public static extern short GT_SetCrdFollowPrm(short crd,ref TCrdFollowPrm pPrm);
	[DllImport("gts.dll")]
        public static extern short GT_GetCrdFollowPrm(short crd,out TCrdFollowPrm pPrm);
        [DllImport("gts.dll")]
        public static extern short GT_Compile(string pFileName, out TCompileInfo pWrongInfo);
        [DllImport("gts.dll")]
        public static extern short GT_Download(string pFileName);

        [DllImport("gts.dll")]
        public static extern short GT_GetFunId(string pFunName,out short pFunId);
        [DllImport("gts.dll")]
        public static extern short GT_Bind(short thread,short funId, short page);

        [DllImport("gts.dll")]
        public static extern short GT_RunThread(short thread);
        [DllImport("gts.dll")]
        public static extern short GT_StopThread(short thread);
        [DllImport("gts.dll")]
        public static extern short GT_PauseThread(short thread);

        [DllImport("gts.dll")]
        public static extern short GT_GetThreadSts(short thread,out TThreadSts pThreadSts);

        [DllImport("gts.dll")]
        public static extern short GT_GetVarId(string pFunName,string pVarName,out TVarInfo pVarInfo);
        [DllImport("gts.dll")]
        public static extern short GT_SetVarValue(short page,ref TVarInfo pVarInfo,ref double pValue,short count);
        [DllImport("gts.dll")]
        public static extern short GT_GetVarValue(short page,ref TVarInfo pVarInfo,out double pValue,short count);

        [DllImport("gts.dll")]
        public static extern short GT_SetCrdMapBase(short crd,short mapBase);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdMapBase(short crd,out short pMapBase);
        [DllImport("gts.dll")]
        public static extern short GT_SetCrdSmooth(short crd,ref TCrdSmooth pCrdSmooth);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdSmooth(short crd,out TCrdSmooth pCrdSmooth);
        [DllImport("gts.dll")]
        public static extern short GT_SetCrdJerk(short crd,double jerkMax);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdJerk(short crd,out double pJerkMax);
        [DllImport("gts.dll")]
        public static extern short GT_SetCrdPrm(short crd, ref TCrdPrm pCrdPrm);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdPrm(short crd,out TCrdPrm pCrdPrm);
        [DllImport("gts.dll")]
        public static extern short GT_SetArcAllowError(short crd,double error);
        [DllImport("gts.dll")]
        public static extern short GT_CrdSpace(short crd,out int pSpace,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_CrdData(short crd,System.IntPtr pCrdData,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_CrdDataCircle(short crd, ref TCrdData pCrdData, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXY(short crd, int x, int y, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZ(short crd, int x, int y, int z, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZA(short crd, int x, int y, int z, int a, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYG0(short crd, int x, int y, double synVel, double synAcc, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZG0(short crd, int x, int y, int z, double synVel, double synAcc, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZAG0(short crd, int x, int y, int z, int a, double synVel, double synAcc, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYR(short crd, int x, int y, double radius, short circleDir, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYC(short crd, int x, int y, double xCenter, double yCenter, short circleDir, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZR(short crd, int y, int z, double radius, short circleDir, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZC(short crd, int y, int z, double yCenter, double zCenter, short circleDir, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXR(short crd, int z, int x, double radius, short circleDir, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXC(short crd, int z, int x, double zCenter, double xCenter, short circleDir, double synVel, double synAcc, double velEnd, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYZ(short crd,int x,int y,int z,double interX,double interY,double interZ,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYOverride2(short crd,int x,int y,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZOverride2(short crd,int x,int y,int z,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZAOverride2(short crd,int x,int y,int z,int a,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYG0Override2(short crd,int x,int y,double synVel,double synAcc,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZG0Override2(short crd,int x,int y,int z,double synVel,double synAcc,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZAG0Override2(short crd,int x,int y,int z,int a,double synVel,double synAcc,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYROverride2(short crd,int x,int y,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYCOverride2(short crd,int x,int y,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZROverride2(short crd,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZCOverride2(short crd,int y,int z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXROverride2(short crd,int z,int x,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXCOverride2(short crd,int z,int x,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYRZ(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYCZ(short crd,int x,int y,int z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZRX(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZCX(short crd,int x,int y,int z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXRY(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXCY(short crd,int x,int y,int z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYRZOverride2(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYCZOverride2(short crd,int x,int y,int z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZRXOverride2(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZCXOverride2(short crd,int x,int y,int z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXRYOverride2(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXCYOverride2(short crd,int x,int y,int z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYWN(short crd,int x,int y,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZWN(short crd,int x,int y,int z,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZAWN(short crd,int x,int y,int z,int a,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYG0WN(short crd,int x,int y,double synVel,double synAcc,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZG0WN(short crd,int x,int y,int z,double synVel,double synAcc,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZAG0WN(short crd,int x,int y,int z,int a,double synVel,double synAcc,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYRWN(short crd,int x,int y,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYCWN(short crd,int x,int y,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZRWN(short crd,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZCWN(short crd,int y,int z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXRWN(short crd,int z,int x,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXCWN(short crd,int z,int x,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYZWN(short crd,int x,int y,int z,double interX,double interY,double interZ,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYOverride2WN(short crd,int x,int y,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZOverride2WN(short crd,int x,int y,int z,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZAOverride2WN(short crd,int x,int y,int z,int a,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYG0Override2WN(short crd,int x,int y,double synVel,double synAcc,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZG0Override2WN(short crd,int x,int y,int z,double synVel,double synAcc,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_LnXYZAG0Override2WN(short crd,int x,int y,int z,int a,double synVel,double synAcc,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYROverride2WN(short crd,int x,int y,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcXYCOverride2WN(short crd,int x,int y,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZROverride2WN(short crd,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcYZCOverride2WN(short crd,int y,int z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXROverride2WN(short crd,int z,int x,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_ArcZXCOverride2WN(short crd,int z,int x,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYRZWN(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYCZWN(short crd,int x,int y,int z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZRXWN(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZCXWN(short crd,int x,int y,int z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXRYWN(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXCYWN(short crd,int x,int y,int z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYRZOverride2WN(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixXYCZOverride2WN(short crd,int x,int y,int z,double xCenter,double yCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZRXOverride2WN(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixYZCXOverride2WN(short crd,int x,int y,int z,double yCenter,double zCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXRYOverride2WN(short crd,int x,int y,int z,double radius,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_HelixZXCYOverride2WN(short crd,int x,int y,int z,double zCenter,double xCenter,short circleDir,double synVel,double synAcc,double velEnd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufTrend(short crd,uint trendSegNum,double trendDistance,double trendVelEnd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufIO(short crd, ushort doType, ushort doMask, ushort doValue, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufEnableDoBitPulse(short crd,short doType,short doIndex,ushort highLevelTime,ushort lowLevelTime,int pulseNum,short firstLevel,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufDisableDoBitPulse(short crd,short doType,short doIndex,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufDelay(short crd, ushort delayTime, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufComparePulse(short crd,short level,short outputType,short time,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufDA(short crd, short chn, short daValue, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufLmtsOn(short crd, short axis, short limitType, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufLmtsOff(short crd, short axis, short limitType, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufSetStopIo(short crd, short axis, short stopType, short inputType, short inputIndex, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufMove(short crd, short moveAxis, int pos, double vel, double acc, short modal, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufGear(short crd, short gearAxis, int pos, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufGearPercent(short crd,short gearAxis,int pos,short accPercent,short decPercent,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufStopMotion(short crd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufSetVarValue(short crd,short pageId,out TVarInfo pVarInfo,double value,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufJumpNextSeg(short crd,short axis,short limitType,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufSynchPrfPos(short crd,short encoder,short profile,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufVirtualToActual(short crd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufSetLongVar(short crd,short index,int value,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufSetDoubleVar(short crd,short index,double value,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_CrdStart(short mask,short option);
        [DllImport("gts.dll")]
        public static extern short GT_CrdStartStep(short mask, short option);
        [DllImport("gts.dll")]
        public static extern short GT_CrdStepMode(short mask, short option);
        [DllImport("gts.dll")]
        public static extern short GT_SetOverride(short crd,double synVelRatio);
        [DllImport("gts.dll")]
        public static extern short GT_SetOverride2(short crd, double synVelRatio);
        [DllImport("gts.dll")]
        public static extern short GT_InitLookAhead(short crd,short fifo,double T,double accMax,short n,ref TCrdData pLookAheadBuf);
        [DllImport("gts.dll")]
        public static extern short GT_GetLookAheadSpace(short crd,out int pSpace,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_GetLookAheadSegCount(short crd,out int pSegCount,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_CrdClear(short crd,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_CrdStatus(short crd,out short pRun,out int pSegment,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_SetUserSegNum(short crd,int segNum,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_GetUserSegNum(short crd,out int pSegment,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_GetUserSegNumWN(short crd,out int pSegment,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_GetRemainderSegNum(short crd,out int pSegment,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_SetCrdStopDec(short crd,double decSmoothStop,double decAbruptStop);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdStopDec(short crd,out double pDecSmoothStop,out double pDecAbruptStop);
        [DllImport("gts.dll")]
        public static extern short GT_SetCrdLmtStopMode(short crd,short lmtStopMode);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdLmtStopMode(short crd,out short pLmtStopMode);
        [DllImport("gts.dll")]
        public static extern short GT_GetUserTargetVel(short crd,out double pTargetVel);
        [DllImport("gts.dll")]
        public static extern short GT_GetSegTargetPos(short crd,out int pTargetPos);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdPos(short crd,out double pPos);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdVel(short crd,out double pSynVel);
        [DllImport("gts.dll")]
        public static extern short GT_SetCrdSingleMaxVel(short crd,ref double pMaxVel);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdSingleMaxVel(short crd,out double pMaxVel);
        [DllImport("gts.dll")]
        public static extern short GT_GetCmdCount(short crd, out short pResult, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_BufLaserOn(short crd,short fifo,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_BufLaserOff(short crd,short fifo,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_BufLaserPrfCmd(short crd,double laserPower,short fifo,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_BufLaserFollowRatio(short crd,double ratio,double minPower,double maxPower,short fifo,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_BufLaserFollowMode(short crd,short source ,short fifo,short channel,double startPower );
        [DllImport("gts.dll")]
        public static extern short GT_BufLaserFollowOff(short crd,short fifo,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_BufLaserFollowSpline(short crd,short tableId,double minPower,double maxPower,short fifo,short channel);                     
        
        [DllImport("gts.dll")]
        public static extern short GT_PrfPvt(short profile);
        [DllImport("gts.dll")]
        public static extern short GT_SetPvtLoop(short profile,int loop);
        [DllImport("gts.dll")]
        public static extern short GT_GetPvtLoop(short profile,out int pLoopCount,out int pLoop);
        [DllImport("gts.dll")]
        public static extern short GT_PvtStatus(short profile,out short pTableId,out double pTime,short count);
        [DllImport("gts.dll")]
        public static extern short GT_PvtStart(int mask);
        [DllImport("gts.dll")]
        public static extern short GT_PvtTableSelect(short profile,short tableId);

        [DllImport("gts.dll")]
        public static extern short GT_PvtTable(short tableId,int count,ref double pTime,ref double pPos,ref double pVel);
        [DllImport("gts.dll")]
        public static extern short GT_PvtTableEx(short tableId,int count,ref double pTime,ref double pPos,ref double pVelBegin,ref double pVelEnd);
        [DllImport("gts.dll")]
        public static extern short GT_PvtTableComplete(short tableId,int count,ref double pTime,ref double pPos,ref double pA,ref double pB,ref double pC,double velBegin,double velEnd);
        [DllImport("gts.dll")]
        public static extern short GT_PvtTablePercent(short tableId,int count,ref double pTime,ref double pPos,ref double pPercent,double velBegin);
        [DllImport("gts.dll")]
        public static extern short GT_PvtPercentCalculate(int n,ref double pTime,ref double pPos,ref double pPercent,double velBegin,ref double pVel);
        [DllImport("gts.dll")]
        public static extern short GT_PvtTableContinuous(short tableId,int count,ref double pPos,ref double pVel,ref double pPercent,ref double pVelMax,ref double pAcc,ref double pDec,double timeBegin);
        [DllImport("gts.dll")]
        public static extern short GT_PvtContinuousCalculate(int n,ref double pPos,ref double pVel,ref double pPercent,ref double pVelMax,ref double pAcc,ref double pDec,ref double pTime);
        [DllImport("gts.dll")]
        public static extern short GT_PvtTableMovePercent(short tableId, int distance, double vm, double acc, double pa1, double pa2, double dec, double pd1, double pd2, out double pVel, out double pAcc, out double pDec, out double pTime);
        [DllImport("gts.dll")]
        public static extern short GT_PvtTableMovePercentEx(short tableId,int distance,double vm,double acc,double pa1,double pa2,double ma,double dec,double pd1,double pd2,double md,out double pVel,out double pAcc,out double pDec,out double pTime);

        [DllImport("gts.dll")]
        public static extern short GT_HomeInit();
        [DllImport("gts.dll")]
        public static extern short GT_Home(short axis,int pos,double vel,double acc,int offset);
        [DllImport("gts.dll")]
        public static extern short GT_Index(short axis,int pos,int offset);
        [DllImport("gts.dll")]
        public static extern short GT_HomeStop(short axis,int pos,double vel,double acc);
        [DllImport("gts.dll")]
        public static extern short GT_HomeSts(short axis,out ushort pStatus);

        [DllImport("gts.dll")]
        public static extern short GT_HandwheelInit();
        [DllImport("gts.dll")]
        public static extern short GT_SetHandwheelStopDec(short slave,double decSmoothStop,double decAbruptStop);
        [DllImport("gts.dll")]
        public static extern short GT_StartHandwheel(short slave,short master,short masterEven,short slaveEven,short intervalTime,double acc,double dec,double vel,short stopWaitTime);
        [DllImport("gts.dll")]
        public static extern short GT_EndHandwheel(short slave);

        [DllImport("gts.dll")]
        public static extern short GT_SetTrigger(short i,ref TTrigger pTrigger);
        [DllImport("gts.dll")]
        public static extern short GT_GetTrigger(short i,out TTrigger pTrigger);
        [DllImport("gts.dll")]
        public static extern short GT_GetTriggerStatus(short i,out TTriggerStatus pTriggerStatus,short count);
        [DllImport("gts.dll")]
        public static extern short GT_GetTriggerStatusEx(short i,out TTriggerStatusEx pTriggerStatusEx,short count);
        [DllImport("gts.dll")]
        public static extern short GT_ClearTriggerStatus(short i);

        [DllImport("gts.dll")]
        public static extern short GT_SetComparePort(short channel,short hsio0,short hsio1);

        [DllImport("gts.dll")]
        public static extern short GT_ComparePulse(short level,short outputType,short time);
        [DllImport("gts.dll")]
        public static extern short GT_CompareStop();
        [DllImport("gts.dll")]
        public static extern short GT_CompareStatus(out short pStatus,out int pCount);
        [DllImport("gts.dll")]
        public static extern short GT_CompareData(short encoder,short source,short pulseType,short startLevel,short time,int[] pBuf1,short count1,int[] pBuf2,short count2);
        [DllImport("gts.dll")]
        public static extern short GT_CompareLinear(short encoder,short channel,int startPos,int repeatTimes,int interval,short time,short source);
        [DllImport("gts.dll")]
        public static extern short GT_CompareContinuePulseMode(short mode, short count, short standTime);

        [DllImport("gts.dll")]
        public static extern short GT_SetEncResponseCheck(short control, short dacThreshold, double minEncVel, int time);
        [DllImport("gts.dll")]
        public static extern short GT_GetEncResponseCheck(short control, out short pDacThreshold, out double pMinEncVel, out int pTime);
        [DllImport("gts.dll")]
        public static extern short GT_EnableEncResponseCheck(short control);
        [DllImport("gts.dll")]
        public static extern short GT_DisableEncResponseCheck(short control);

        [DllImport("gts.dll")]
        public static extern short GT_2DCompareMode(short chn, short mode);
        [DllImport("gts.dll")]
        public static extern short GT_2DComparePulse(short chn, short level, short outputType, short time);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareStop(short chn);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareClear(short chn);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareStatus(short chn, out short pStatus, out int pCount, out short pFifo, out short pFifoCount, out short pBufCount);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareSetPrm(short chn, ref T2DComparePrm pPrm);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareData(short chn, short count, ref T2DCompareData pBuf, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareStart(short chn);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareClearData(short chn);
        [DllImport("gts.dll")]
        public static extern short GT_2DCompareSetPreOutTime(short chn,double preOutputTime);

        [DllImport("gts.dll")]
        public static extern short GT_SetAxisMode(short axis, short mode);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisMode(short axis, out short pMode);
        [DllImport("gts.dll")]
        public static extern short GT_SetHSIOOpt(ushort value, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_GetHSIOOpt(out ushort pValue, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_LaserPowerMode(short laserPowerMode, double maxValue, double minValue, short channel, short delaymode);
        [DllImport("gts.dll")]
        public static extern short GT_LaserPrfCmd(double outputCmd, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_LaserOutFrq(double outFrq, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetPulseWidth(uint width, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetWaitPulse(ushort mode, double waitPulseFrq, double waitPulseDuty, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetPreVltg(ushort mode, double voltageValue, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetLevelDelay(ushort offDelay, ushort onDelay, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_EnaFPK(ushort time1, ushort time2, ushort laserOffDelay, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_DisFPK(short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserDisMode(short mode, short source, ref int pPos, ref double pScale, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserDisRatio(ref double pRatio, double minPower, double maxPower, short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetWaitPulseEx(ushort mode, double waitPulseFrq, double waitPulseDuty);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserMode(short mode);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserFollowSpline(short tableId,int n,ref double pX,ref double pY,double beginValue,double endValue,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_GetLaserFollowSpline(short tableId,int n,out double pX,out double pY,out double pA,out double pB,out double pC,out int pCount,short channel);
        
        //ExtMdl
        [DllImport("gts.dll")]
        public static extern short GT_OpenExtMdl(string pDllName);
        [DllImport("gts.dll")]
        public static extern short GT_CloseExtMdl();
        [DllImport("gts.dll")]
        public static extern short GT_SwitchtoCardNoExtMdl(short card);
        [DllImport("gts.dll")]
        public static extern short GT_ResetExtMdl();
        [DllImport("gts.dll")]
        public static extern short GT_LoadExtConfig(string pFileName);
        [DllImport("gts.dll")]
        public static extern short GT_SetExtIoValue(short mdl,ushort value);
        [DllImport("gts.dll")]
        public static extern short GT_GetExtIoValue(short mdl,out ushort pValue);
        [DllImport("gts.dll")]
        public static extern short GT_SetExtIoBit(short mdl,short index,ushort value);
        [DllImport("gts.dll")]
        public static extern short GT_GetExtIoBit(short mdl,short index,out ushort pValue);
        [DllImport("gts.dll")]
        public static extern short GT_GetExtAdValue(short mdl,short chn,out ushort pValue);
        [DllImport("gts.dll")]
        public static extern short GT_GetExtAdVoltage(short mdl,short chn,out double pValue);
        [DllImport("gts.dll")]
        public static extern short GT_SetExtDaValue(short mdl,short chn,ushort value);
        [DllImport("gts.dll")]
        public static extern short GT_SetExtDaVoltage(short mdl,short chn,double value);
        [DllImport("gts.dll")]
        public static extern short GT_GetStsExtMdl(short mdl,short chn,out ushort pStatus);
        [DllImport("gts.dll")]
        public static extern short GT_GetExtDoValue(short mdl,out ushort pValue);
        [DllImport("gts.dll")]
        public static extern short GT_GetExtMdlMode(out short pMode);
        [DllImport("gts.dll")]
        public static extern short GT_SetExtMdlMode(short mode);
        [DllImport("gts.dll")]
        public static extern short GT_UploadConfig();
        [DllImport("gts.dll")]
        public static extern short GT_DownloadConfig();
        [DllImport("gts.dll")]
        public static extern short GT_GetUuid(out char pCode,short count);
				[DllImport("gts.dll")]
        public static extern short GT_SetUuid(ref char pCode,short count);
        
        //2D Compensate
        public struct TCompensate2DTable
        {      
            public short count1;
            public short count2;
            public int posBegin1;
            public int posBegin2;   
            public int step1;
            public int step2;
        } 
        public struct TCompensate2D 
        {
	        public short enable;                                 
	        public short tableIndex;                              
	        public short axisType1;	
            public short axisType2;              
	        public short axisIndex1;
            public short axisIndex2;              
        } 
        [DllImport("gts.dll")]
        public static extern short GT_SetCompensate2DTable(short tableIndex,ref TCompensate2DTable pTable,ref int pData,short externComp);
        [DllImport("gts.dll")]
        public static extern short GT_GetCompensate2DTable(short tableIndex,out TCompensate2DTable pTable,out short pExternComp);
        [DllImport("gts.dll")]
        public static extern short GT_SetCompensate2D(short axis, ref TCompensate2D pComp2d);
        [DllImport("gts.dll")]
        public static extern short GT_GetCompensate2D(short axis, out TCompensate2D pComp2d);
        [DllImport("gts.dll")]
        public static extern short GT_GetCompensate2DValue(short axis, out double pValue);

        //Smart Home
        public const short HOME_STAGE_IDLE=0;
        public const short HOME_STAGE_START=1;
        public const short HOME_STAGE_ON_HOME_LIMIT_ESCAPE=2;
        public const short HOME_STAGE_SEARCH_LIMIT=10;
        public const short HOME_STAGE_SEARCH_LIMIT_STOP=11;
        public const short HOME_STAGE_SEARCH_LIMIT_ESCAPE = 13;
        public const short HOME_STAGE_SEARCH_LIMIT_RETURN=15;
        public const short HOME_STAGE_SEARCH_LIMIT_RETURN_STOP=16;
        public const short HOME_STAGE_SEARCH_HOME=20;
        public const short HOME_STAGE_SEARCH_HOME_STOP=22;
        public const short HOME_STAGE_SEARCH_HOME_RETURN=25;
        public const short HOME_STAGE_SEARCH_INDEX=30;
        public const short HOME_STAGE_SEARCH_GPI=40;
        public const short HOME_STAGE_SEARCH_GPI_RETURN=45;
        public const short HOME_STAGE_GO_HOME=80;
        public const short HOME_STAGE_END=100;
        public const short HOME_ERROR_NONE=0;
        public const short HOME_ERROR_NOT_TRAP_MODE=1;
        public const short HOME_ERROR_DISABLE=2;
        public const short HOME_ERROR_ALARM=3;
        public const short HOME_ERROR_STOP=4;
        public const short HOME_ERROR_STAGE=5;
        public const short HOME_ERROR_HOME_MODE=6;
        public const short HOME_ERROR_SET_CAPTURE_HOME=7;
        public const short HOME_ERROR_NO_HOME=8;
        public const short HOME_ERROR_SET_CAPTURE_INDEX=9;
        public const short HOME_ERROR_NO_INDEX=10;
        public const short HOME_MODE_LIMIT=10;
        public const short HOME_MODE_LIMIT_HOME=11;
        public const short HOME_MODE_LIMIT_INDEX=12;
        public const short HOME_MODE_LIMIT_HOME_INDEX=13;
        public const short HOME_MODE_HOME=20;
        public const short HOME_MODE_HOME_INDEX=22;
        public const short HOME_MODE_INDEX = 30;
        public const short HOME_MODE_FORCED_HOME=40;
        public const short HOME_MODE_FORCED_HOME_INDEX=41;
        public struct THomePrm
        {
	        public short mode;						
	        public short moveDir;					
	        public short indexDir;					
	        public short edge;					
	        public short triggerIndex;			
			public short pad1_1;
	        public short pad1_2;
            public short pad1_3;
	        public double velHigh;				
	        public double velLow;				
	        public double acc;					
	        public double dec;
	        public short smoothTime;
			public short pad2_1;
		    public short pad2_2;
            public short pad2_3;
	        public int homeOffset;				
	        public int searchHomeDistance;	
	        public int searchIndexDistance;	
	        public int escapeStep;			
            public int pad3_1;
            public int pad3_2;
            public int pad3_3;
        } 
        public struct THomeStatus
        {
	        public short run;
	        public short stage;
            public short error;
            public short pad1;
	        public int capturePos;
	        public int targetPos;
        }
        [DllImport("gts.dll")]
        public static extern short GT_GoHome(short axis, ref THomePrm pHomePrm);
        [DllImport("gts.dll")]
        public static extern short GT_GetHomePrm(short axis, out THomePrm pHomePrm);
        [DllImport("gts.dll")]
        public static extern short GT_GetHomeStatus(short axis, out THomeStatus pHomeStatus);

        //Extern Control
        public struct TControlConfigEx
        {
	        public short refType;
            public short refIndex;
            public short feedbackType;
            public short feedbackIndex;
            public int errorLimit;
            public short feedbackSmooth;
            public short controlSmooth;	
        }
        [DllImport("gts.dll")]
        public static extern short GT_SetControlConfigEx(short control, ref TControlConfigEx pControl);
        [DllImport("gts.dll")]
        public static extern short GT_GetControlConfigEx(short control, out TControlConfigEx pControl);

        //Adc filter
        public struct TAdcConfig
        {
	        public short active;
            public short reverse;
            public double a;
            public double b;
            public short filterMode;	
        }
        [DllImport("gts.dll")]
        public static extern short GT_SetAdcConfig(short adc, ref TAdcConfig pAdc);
        [DllImport("gts.dll")]
        public static extern short GT_GetAdcConfig(short adc, out TAdcConfig pAdc);
        [DllImport("gts.dll")]
        public static extern short GT_SetAdcFilterPrm(short adc, double k);
        [DllImport("gts.dll")]
        public static extern short GT_GetAdcFilterPrm(short adc, out double pk);

        //Superimposed
        [DllImport("gts.dll")]
        public static extern short GT_SetControlSuperimposed(short control, short superimposedType, short superimposedIndex);
        [DllImport("gts.dll")]
        public static extern short GT_GetControlSuperimposed(short control, out short pSuperimposedType, out short pSuperimposedIndex);

        
        [DllImport("gts.dll")]
        public static extern short GT_ZeroLaserOnTime(short channel);
        [DllImport("gts.dll")]
        public static extern short GT_GetLaserOnTime(short channel,out uint pTime);
        
				[DllImport("gts.dll")]
        public static extern short GT_SetProfileScale(short axis,int alpha,int beta);
        [DllImport("gts.dll")]
        public static extern short GT_GetProfileScale(short axis,out int pAlpha,out int pBeta);
        [DllImport("gts.dll")]
        public static extern short GT_SetEncoderScale(short encoder,int alpha,int beta);
        [DllImport("gts.dll")]
        public static extern short GT_GetEncoderScale(short encoder,out int pAlpha,out int pBeta);
        [DllImport("gts.dll")]
        public static extern short GT_MultiAxisOn(uint mask);
        [DllImport("gts.dll")]
        public static extern short GT_MultiAxisOff(uint mask);
        [DllImport("gts.dll")]
        public static extern short GT_SetAxisOnDelayTime(ushort ms);
        [DllImport("gts.dll")]
        public static extern short GT_GetAxisOnDelayTime(out ushort pMs);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserDisTable1D(short count,ref double pRatio,ref int pPos,double minPower,double maxPower,ref double pLimitPower,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserDisTable2D(short[] axisIndex,short[] count,ref double pRatio,ref int pXPos,ref int pYPos, 
							 																						double minPower,double maxPower,ref double pLimitPower,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserDisTable2DEx(short[] axisIndex,short[] count,ref double pRatio,int[] posBegin,int[] posStep, 
							   																						double minPower,double maxPower,ref double pLimitPower,short channel);
        [DllImport("gts.dll")]
        public static extern short GT_SetLaserCrdMap(short channel,short map);
        [DllImport("gts.dll")]
        public static extern short GT_GetLaserCrdMap(short channel,ref short pMap);
        
        //
				//AutoFocus
				//
        [DllImport("gts.dll")]
        public static extern short GT_AutoFocus(ushort mode,double kp,short reverse,short chanel);
        [DllImport("gts.dll")]
        public static extern short GT_SetAutoFocusRefVol(double refVol,double maxVol,double minVol,short chanel);
        [DllImport("gts.dll")]
        public static extern short GT_GetAutoFocusStatus(out ushort pStatus,short count);
        [DllImport("gts.dll")]
        public static extern short GT_ConfigAutoFocus(short chnAdc,short chanel);
        [DllImport("gts.dll")]
        public static extern short GT_SetAutoFocusAuxPrm(double kf,double kd,double limitKd,short chanel);
        
        
        [DllImport("gts.dll")]
        public static extern short GT_Delay(ushort time);
        [DllImport("gts.dll")]
        public static extern short GT_DelayHighPrecision(ushort time);
        
        [DllImport("gts.dll")]
        public static extern short GT_SetCrdBufferMode(short crd,short bufferMode,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdBufferMode(short crd,out short pBufferMode,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdSegmentTime(short crd,int segmentIndex,out double pSegmentTime,out int pSegmentNumber,short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_GetCrdTime(short crd,out TCrdTime pTime,short fifo);
        
        [DllImport("gts.dll")]
        public static extern short GT_SetLeadScrewLink(short axis,short link);
        [DllImport("gts.dll")]
        public static extern short GT_GetLeadScrewLink(short axis,out short pLink);
        
        public const short GANTRY_MODE_NONE = -1;
        public const short GANTRY_MODE_OPEN_LOOP_GANTRY	= 1;
        public const short GANTRY_MODE_DECOUPLE_POSITION_LOOP = 2;
        [DllImport("gts.dll")]
        public static extern short GT_SetGantryMode(short group,short master,short slave,short mode,int syncErrorLimit);
        [DllImport("gts.dll")]
        public static extern short GT_GetGantryMode(short group, out short pMaster, out short pSlave, out short pMode, out int pSyncErrorLimit);
        [DllImport("gts.dll")]
        public static extern short GT_SetGantryPid(short group, ref TPid pGantryPid, ref TPid pYawPid);
        [DllImport("gts.dll")]
        public static extern short GT_GetGantryPid(short group, out TPid pGantryPid, out TPid pYawPid);
        [DllImport("gts.dll")]
        public static extern short GT_GantryAxisOn(short group);
        [DllImport("gts.dll")]
        public static extern short GT_GantryAxisOff(short group);
        [DllImport("gts.dll")]
        public static extern short GT_GantryHoming();

        //
        //Standard Home
        //

        public const short STANDARD_HOME_STAGE_IDLE = 0;
        public const short STANDARD_HOME_STAGE_START = 1;
        public const short STANDARD_HOME_STAGE_SEARCH_HOME = 20;
        public const short STANDARD_HOME_STAGE_SEARCH_INDEX = 30;
        public const short STANDARD_HOME_STAGE_GO_HOME = 80;
        public const short STANDARD_HOME_STAGE_END = 100;
        public const short STANDARD_HOME_STAGE_START_CHECK = -1;
        public const short STANDARD_HOME_STAGE_CHECKING = -2;


        public const short STANDARD_HOME_ERROR_NONE	= 0;
        public const short STANDARD_HOME_ERROR_DISABLE = 10;
        public const short STANDARD_HOME_ERROR_ALARM = 20;
        public const short STANDARD_HOME_ERROR_STOP = 30;
        public const short STANDARD_HOME_ERROR_ON_LIMIT = 40;
        public const short STANDARD_HOME_ERROR_NO_HOME = 50;
        public const short STANDARD_HOME_ERROR_NO_INDEX = 60;
        public const short STANDARD_HOME_ERROR_NO_LIMIT = 70;
        public const short STANDARD_HOME_ERROR_ENCODER_DIR_SCALE = -1;


        public struct TStandardHomePrm
        {
	        public short mode;		 // 回原点模式取值范围1~36
	        public double highSpeed; // 搜索Home的速度,单位pulse/ms
	        public double lowSpeed;	 // 搜索Index的速度,单位pulse/ms
	        public double acc;		 // 回零加速度,单位pulse/ms^2
	        public int offset;       // 回零偏移量,单位pulse
	        public short check; // 是否启用自检功能,1-启用,其它值-不启用
	        public short autoZeroPos; // 回零完毕是否自动清零,1-自动清零,其它值-不清零
	        public int motorStopDelay; //电机到位延时,单位:控制周期
	        public short pad1;	 // 保留(不需要设置)
            public short pad2;
            public short pad3;
        };

        public struct TStandardHomeStatus
        {
	        public short run;     // 是正在进行回原点,0—已停止运动,1-正在回原点
	        public short stage;   // 回原点运动的阶段
	        public short error;    // 回原点过程的发生的错误
	        public short pad1;       // 保留(无具体含义)
            public short pad2;
            public short pad3;
	        public int capturePos;  // 捕获到Home或Index时刻的编码器位置
	        public int targetPos;    // 需要运动到的目标位置(原点位置或者原点位置+偏移量),在搜索Limit时或者搜索Home或Index时,设置的搜索距离为0,那么该值显示为805306368
        };
        [DllImport("gts.dll")]
        public static extern short GT_ExecuteStandardHome(short axis,ref TStandardHomePrm pHomePrm);
        [DllImport("gts.dll")]
        public static extern short GT_GetStandardHomePrm(short axis,out TStandardHomePrm pHomePrm);
        [DllImport("gts.dll")]
        public static extern short GT_GetStandardHomeStatus(short axis,out TStandardHomeStatus pHomeStatus);
        
        //DMA
        [DllImport("gts.dll")]
        public static extern short GT_CrdHsOn(short crd,short fifo,short link,ushort threshold,short lookAheadInMc);
        [DllImport("gts.dll")]
        public static extern short GT_CrdHsOff(short crd,short fifo);

        [DllImport("gts.dll")]
        public static extern short GT_SetFlagVar(short index, short mode, short value);
        [DllImport("gts.dll")]
        public static extern short GT_GetFlagVar(short index, out short pMode, out short pValue);



        //
        //椭圆插补
        //
        //public const short ELLIPSE_AUX_POINT_COUNT = 5;

        public const short ELLIPSE_MODE_AUX_POINT_2D = 0;
        public const short ELLIPSE_MODE_STANDARD_2D = 1;
        //-------------------------------------------------------
        //功能说明:椭圆插补描述参数,模式:ELLIPSE_MODE_AUX_POINT_2D
        //plane-------------椭圆平面选择,INTERPOLATION_CIRCLE_PLAT_XY(0):XY;INTERPOLATION_CIRCLE_PLAT_YZ(1):YZ;INTERPOLATION_CIRCLE_PLAT_ZX(2):ZX
        //dir---------------椭圆方向,0:顺时针;1:逆时针
        //overrideSelect----速度倍率选择,0:第1组倍率;1:第2组倍率
        //pad---------------占位变量,不需要传入
        //endPoint1----------终点坐标1,意义根据plane来定,如果palne为XY平面,则endPoint1、pos1为X坐标,endPoint2、pos2为Y坐标
        //endPoint2----------终点坐标2
        //pos1--------------椭圆上辅助点坐标1
        //pos2--------------椭圆上辅助点坐标2
        //-------------------------------------------------------
        public struct TEllipseAuxPoint2D
        {
            public short plane;
            public short dir;
            public short overrideSelect;
            public short pad;

            public double endPoint1;
            public double endPoint2;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = ELLIPSE_AUX_POINT_COUNT)]
            public double[] pos1;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = ELLIPSE_AUX_POINT_COUNT)]
            public double[] pos2;
        };

        //-------------------------------------------------------
        //功能说明:椭圆插补描述参数,模式:ELLIPSE_MODE_STANDARD_2D
        //plane--------------椭圆平面选择,INTERPOLATION_CIRCLE_PLAT_XY(0):XY;INTERPOLATION_CIRCLE_PLAT_YZ(1):YZ;INTERPOLATION_CIRCLE_PLAT_ZX(2):ZX
        //dir----------------椭圆方向,0:顺时针;1:逆时针
        //overrideSelect-----速度倍率选择,0:第1组倍率;1:第2组倍率
        //pad----------------占位变量,不需要传入
        //endPoint1----------终点坐标1,意义根据plane来定,如果palne为XY平面,则endPoint1为X坐标,endPoint2为Y坐标
        //endPoint2----------终点坐标2
        //centerPoint1-------椭圆圆心坐标1,意义根据plane来定,如果palne为XY平面,则centerPoint1为X坐标,centerPoint2为Y坐标
        //centerPoint2-------椭圆圆心坐标2
        //theta--------------椭圆旋转角度,单位:度
        //a------------------椭圆长轴
        //b------------------椭圆短轴,短轴必须比长轴短
        //-------------------------------------------------------
        public struct TEllipseStandard2D
        {
            public short plane;
            public short dir;
            public short overrideSelect;
            public short pad;

            public double endPoint1;
            public double endPoint2;

            public double centerPoint1;
            public double centerPoint2;

            public double theta;
            public double a;
            public double b;
        };

        //-------------------------------------------------------
        //功能说明:椭圆插补
        //input:crd-------坐标系号
        //input:mode------椭圆描述模式,椭圆模式
        //input:pData-----椭圆描述的参数,mode = ELLIPSE_MODE_AUX_POINT_2D,传入TEllipseAuxPoint2D,mode = ELLIPSE_MODE_STANDARD_2D,传入TEllipseStandard2D
        //input:synVel----椭圆插补合成速度
        //input:synAcc----椭圆插补合成加速度
        //input:velEnd----椭圆插补终点速度
        //input:segNum----椭圆插补段号
        //input:fifo------椭圆插补缓冲区号
        //-------------------------------------------------------
        [DllImport("gts.dll")]
        public static extern short GT_EllipsePro(short crd, short mode, System.IntPtr pData, double synVel, double synAcc, double velEnd, long segNum, short fifo);
        [DllImport("gts.dll")]
        public static extern short GT_EllipseProEx(short crd, short mode, System.IntPtr pData, double synVel, double synAcc, double velEnd, long segNum, short fifo);
    }
}

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潘诺西亚的火山

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值