unit GlobalVar;

interface

uses
  SysUtils, Classes , Windows,  Forms,Messages ,Dialogs,gtfunc;

const
  cstErrName = 'ErrorCmdFile.txt';

  LetterSet = ['A'..'Z'];
  DigitsSet = ['0'..'9','-','+',#8,'.'];
  SymbolSet = ['.','+','-'];
  ModeGCode = [00,01,02,03,32,33,70,71,72,73,74,75,76,77,78,79];//模态G指令集
  NoCoordGCode = [04,17,18,19,20,21,28,90,91,94,95{,71,72}];//可不跟坐标字的G指令集

  cmLine = 1;       //曲线模式为“直线”
  cmCircle = 2;     //曲线模式为“圆弧”

type  TCoordRec = record    //坐标记录
    X,Y,Z,A: Double;
  end;

  {错误信息}
  TErrorInfo = record
    ErrorType: PChar;           //错误信息
    ErrorLine: LongWord;        //错误行号
  end;

var
  NCSource: TStringList;
  AppCaptionStr: string;
  FileNameStr:string;
  ErrorLineNo: Integer = 0;
  ErrorInfo: TErrorInfo;
  CurLineNo: Integer;   //当前程序行号
  NCSeg,BufSeg: SmallInt;        //NC段号和Buffer运行段号
  SegFile: TextFile;    //段号文件
  CurrentCoord: TCoordRec;      //当前坐标
  X_End,Y_End,Z_End,r: Double;            //直线终点
  X_Center,Y_Center,Z_Center,angle: Double;   //圆弧圆心坐标
  Dir: Integer;                         //圆弧方向
  IsCmdModify,IsRunModify:Boolean; //true---Only Read ;flase---Write //OnlyReadFlag,
  MvStartX,MvStartY,MvStartZ,SynVel,SynAcc:Double;
  StrtVel,MaxVel,StpAcc:Double;
  lang:Integer=1;
  rtn:SmallInt;
  LmtVal:Word;
  ExOpt:Word;
  filterStr:Array [0..3] of String;
  MsgString:String;
  ErrFileName: string = cstErrName;
  Limit1Sts,Limit2Sts,Limit3Sts:Integer;
  Ctrl1Sts,Ctrl2Sts,Ctrl3Sts:Integer;
  Step1Mod,Step2Mod,Step3Mod:Integer;
  Alarm1Sts,Alarm2Sts,Alarm3Sts:Integer;
  OverrideG1,OverrideG0:Double;
  bOpenControl:Boolean;
 
 procedure VerifyParameter(s:String;nReal:Integer);overload;
 procedure VerifyParameter(s:String;nReal:Integer;nMax:Integer);overload;
 procedure ShowErrorMsg(rtn:SmallInt); overload;
 procedure ShowErrorMsg(rtn:SmallInt;var ErrorMsgStr:String);Overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para:integer); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para:double); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3:double;para4:Integer); overload; 
 procedure ShowResult(Rtn:smallInt;FuncName:string;para1:integer;para2,para3,para4,para5,para6:double); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3,para4:double); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3,para4,para5:double); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3,para4,para5,para6:double); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2:double); overload;
 procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3:double); overload;
 procedure execute_gtcmd(memo_line:String;var RRtn:integer); 


implementation

uses DemoMain;

procedure ShowErrorMsg(rtn:SmallInt);Overload;
begin
  if (lang=1) then
  begin
     case rtn of
     -1: Messagebox(application.Handle,'运动控制器通讯出错','板卡错误信息',MB_OK);
     0:  exit;
     1:  Messagebox(application.Handle,'命令出错,调用GT_GetCmdSts()命令，确定出错原因，予以改正','板卡错误信息',MB_OK);
     2,3,4,5,7: MessageBox(Application.Handle,'参数错误','板卡错误信息',MB_OK);
     6: Messagebox(application.Handle,'映射错误','板卡错误信息',MB_OK);
     end;
  end else begin
     case rtn of
     -1: Messagebox(application.Handle,'Communciation Error','Error Message',MB_OK);
     0:  exit;
     1:  Messagebox(application.Handle,'Command Error','Error Message',MB_OK);
     2..5,7: MessageBox(Application.Handle,'Parameter error','Error Message',MB_OK);
     6: Messagebox(application.Handle,'Map is error','Error Message',MB_OK);
     end;
  end;
end;

procedure ShowErrorMsg(rtn:SmallInt;var ErrorMsgStr:String);Overload;
begin
  if (lang=1) then
  begin
     case rtn of
     -1: ErrorMsgStr:=ErrorMsgStr+' 运动控制器通讯出错';
     0:  exit;
     1:  ErrorMsgStr:=ErrorMsgStr+' 命令出错,调用GT_GetCmdSts()命令,确定出错原因,予以改正';
     2:  ErrorMsgStr:=ErrorMsgStr+' 圆弧插补半径不正确';
     3:  ErrorMsgStr:=ErrorMsgStr+' 直线插补长度为零或超出控制器处理范围';
     4:  ErrorMsgStr:=ErrorMsgStr+' 速度或加速度为零或为负数或超出控制器处理范围。';
     5:  ErrorMsgStr:=ErrorMsgStr+' 圆弧终点或半径描述错误';
     7:  ErrorMsgStr:=ErrorMsgStr+' 一般参数错误';
     6: ErrorMsgStr:=ErrorMsgStr+' 映射错误';
     end;
  end else begin
     case rtn of
     -1: ErrorMsgStr:=ErrorMsgStr+' error message';
     0:  exit;
     1:  ErrorMsgStr:=ErrorMsgStr+' command error,please call GT_GetCmdSts() to check the error';
     2..5,7: ErrorMsgStr:=ErrorMsgStr+' parameter error';
     6: ErrorMsgStr:=ErrorMsgStr+' map is error';
     end;
  end;
end;


procedure ShowResult(Rtn:smallInt;FuncName:string); overload;
var temp:string;
begin
    if rtn<>0 then begin
       temp:=format('%d=%s()',[rtn,FuncName]);
       ShowErrorMsg(Rtn,temp);
       demoform.CmdStsMemo.lines.Append(temp);
       demoform.PageControl1.ActivePageIndex:=2;
    end
    else begin
        temp:=format('%s()',[FuncName]);
        demoform.CmdMemo.lines.Append(temp);
    end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para:integer); overload;
var temp:string;
begin
    if rtn<>0 then begin
       temp:=format('%d=%s(%d)',[rtn,FuncName,para]);
       ShowErrorMsg(Rtn,temp);
       demoform.CmdStsMemo.lines.Append(temp);
       demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%d)',[FuncName,para]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para:double); overload;
var temp:string;
begin
    if rtn<>0 then begin
        temp:=format('%d=%s(%g)',[rtn,FuncName,para]);
        ShowErrorMsg(Rtn,temp);
        demoform.CmdStsMemo.lines.Append(temp);
        demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%g)',[FuncName,para]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para1:integer;para2,para3,para4,para5,para6:double); overload;
var temp:string;
begin
    if rtn<>0 then begin
        temp:=format('%d=%s(%d,%g,%g,%g,%g,%g)',[rtn,FuncName,para1,para2,para3,para4,para5,para6]);
        ShowErrorMsg(Rtn,temp);
        demoform.CmdStsMemo.lines.Append(temp);
        demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%d,%g,%g,%g,%g,%g)',[FuncName,para1,para2,para3,para4,para5,para6]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3,para4:double); overload;
var temp:string;
begin
    if rtn<>0 then begin
        temp:=format('%d=%s(%g,%g,%g,%g)',[rtn,FuncName,para1,para2,para3,para4]);
        ShowErrorMsg(Rtn,temp);
        demoform.CmdStsMemo.lines.Append(temp);
        demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%g,%g,%g,%g)',[FuncName,para1,para2,para3,para4]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3:double;para4:Integer); overload;
var temp:string;
begin
    if rtn<>0 then begin
        temp:=format('%d=%s(%g,%g,%g,%d)',[rtn,FuncName,para1,para2,para3,para4]);
        ShowErrorMsg(Rtn,temp);
        demoform.CmdStsMemo.lines.Append(temp);
        demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%g,%g,%g,%d)',[FuncName,para1,para2,para3,para4]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3,para4,para5:double); overload;
var temp:string;
begin
    if rtn<>0 then begin
        temp:=format('%d=%s(%g,%g,%g,%g,%g)',[rtn,FuncName,para1,para2,para3,para4,para5]);
        ShowErrorMsg(Rtn,temp);
        demoform.CmdStsMemo.lines.Append(temp);
        demoform.PageControl1.ActivePageIndex:=2;
    end else begin
        temp:=format('%s(%g,%g,%g,%g,%g)',[FuncName,para1,para2,para3,para4,para5]);
        demoform.CmdMemo.lines.Append(temp);
    end;

end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3,para4,para5,para6:double); overload;
var temp:string;
begin
    if rtn<>0 then begin
        temp:=format('%d=%s(%g,%g,%g,%g,%g,%g)',[rtn,FuncName,para1,para2,para3,para4,para5,para6]);
        ShowErrorMsg(Rtn,temp);
        demoform.CmdStsMemo.lines.Append(temp);
        demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%g,%g,%g,%g,%g,%g)',[FuncName,para1,para2,para3,para4,para5,para6]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2:double); overload;
var temp:string;
begin
    if rtn<>0 then begin
       temp:=format('%d=%s(%g,%g)',[rtn,FuncName,para1,para2]);
       ShowErrorMsg(Rtn,temp);
       demoform.CmdStsMemo.lines.Append(temp);
       demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%g,%g)',[FuncName,para1,para2]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure ShowResult(Rtn:smallInt;FuncName:string;para1,para2,para3:double); overload;
var temp:string;
begin
    if rtn<>0 then begin
       temp:=format('%d=%s(%g,%g,%g)',[rtn,FuncName,para1,para2,para3]);
       ShowErrorMsg(Rtn,temp);
       demoform.CmdStsMemo.lines.Append(temp);
       demoform.PageControl1.ActivePageIndex:=2;
     end
     else begin
        temp:=format('%s(%g,%g,%g)',[FuncName,para1,para2,para3]);
        demoform.CmdMemo.lines.Append(temp);
     end;
end;

procedure VerifyParameter(s:String;nReal:Integer);overload;
begin
  if lang=1 then
  begin
    if 0<nReal then
        raise ERangeError.CreateFmt('参数太多，命令终止:%s',[s])
    else if 0>nReal then
        raise ERangeError.CreateFmt('参数太少，命令终止:%s',[s]);
  end else begin
    if 0<nReal then
        raise ERangeError.CreateFmt('Too much parameters，Command terminated:%s',[s])
    else if 0>nReal then
        raise ERangeError.CreateFmt('Lack of parameter，Command terminated:%s',[s]);
  end;
end;

procedure VerifyParameter(s:String;nReal:Integer;nMax:Integer);overload;
begin
  if lang=1 then
  begin
     if nMax<nReal then
        raise ERangeError.CreateFmt('参数太多，命令终止:%s',[s])
    else if nMax>nReal then
        raise ERangeError.CreateFmt('参数太少，命令终止:%s',[s]);
  end else begin
     if nMax<nReal then
        raise ERangeError.CreateFmt('Too much parameters，Command terminated:%s',[s])
    else if nMax>nReal then
        raise ERangeError.CreateFmt('Lack of parameter，Command terminated:%s',[s])
  end;
end;

procedure execute_gtcmd(memo_line:String;var RRtn:integer);
var
    tt,ss,s:string;  i,j:integer;
    pos1,pos2:integer;
    nIndex:Integer;
    nWord:Word;
    nCardinal:Cardinal;
    nSmallInt:SmallInt;
    nInteger:Integer;
    nDouble:array[1..10] of Double;
    nLong:array[1..10] of LongInt;    
    pCommandString:String;
    para:array[1..10] of String;
label sstart;
begin
    ss:=memo_line;
    if ss='' then begin RRtn:=0;exit;end;
    tt:='';
    i:=1;

    if ss[i]=';' then begin RRtn:=0;exit;end;
    while ss[i]<>';' do begin
       tt:=tt+ss[i];
       inc(i);
       if ss[i]='' then  break;
    end;

    ss:='';
    for i:=1 to length(tt) do begin
       if tt[i]<>' ' then ss:=ss+tt[i];
    end;

    if ss='' then begin RRtn:=0;exit;end;


    tt:='';
    for i:=1 to length(ss) do begin
       if (ss[i]='(') or(ss[i]=')') then
          tt:=tt+ss[i];
    end;

    if tt<>'()' then begin
        pCommandstring:='命令错误!';
        goto sstart;
    end;

    if ss[length(ss)]<>')' then begin
        pCommandstring:='命令错误!';
        goto sstart;
    end;
    tt:='';
    i:=1;
    while ss[i]<>'(' do begin
          tt:=tt+ss[i];
          inc(i);
          if ss[i]='' then  break;
    end;

    s:=ss; ss:='';
    pos1:=0;pos2:=0;
    for i:=1 to length(s) do begin
        if s[i]='(' then pos1:=i+1;;
        if s[i]=')' then pos2:=i-1;
    end;
    for i:=pos1 to pos2 do ss:=ss+s[i];

    pCommandString:=tt;
//step5: make para[1..10] and nIndex
    for i:=1 to 10 do para[i]:='';
    nIndex:=0;
    if ss='' then goto sstart;
    nIndex:=1;
    for i:=1 to length(ss) do if ss[i]=',' then inc(nIndex);
    if nIndex>10 then begin
          pCommandstring:='命令错误!';
          goto sstart;
    end;
    ss:=','+ss;
    j:=0;
    for i:=1 to length(ss) do begin
        if ss[i]=',' then inc(j);
        if ss[i]<>',' then para[j]:=para[j]+ss[i];
    end;


   s:=memo_line;
sstart:
        if pCommandString = 'GT_AddList' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_AddList();
	   exit;
	end;
        if pCommandString = 'GT_EndList' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_EndList();
	   exit;
	end;
        if pCommandString = 'GT_EStpMtn' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_EStpMtn();
	   exit;
	end;
        if pCommandString = 'GT_StpMtn' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_StpMtn();
	   exit;
	end;
        if pCommandString = 'GT_AlarmOn' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_AlarmOn(StrToInt(para[1]));
	   exit;
        end;
        if pCommandString = 'GT_AlarmOff' then begin
           VerifyParameter(s,nIndex,2);
	   RRtn:=GT_AlarmOff(StrToInt(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_Open' then begin
           VerifyParameter(s,nIndex,2);
	   RRtn:=GT_Open(StrToInt(para[1]),StrToInt(para[2])); sleep(10);
           if (RRtn=0) then  bOpenControl:=true;
	   exit;
	end;
        if pCommandString = 'GT_Close' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_Close();
	   exit;
	end;
        if pCommandString = 'GT_SetAtlPos' then begin
           VerifyParameter(s,nIndex,2);
	   RRtn:=GT_SetAtlPos(StrToInt(para[1]),StrToInt(para[2]));
	   exit;
	end;
        if pCommandString = 'GT_ZeroPos' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_ZeroPos(StrToInt(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_StrtMtn' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_StrtMtn();
	   exit;
	end;
        if pCommandString = 'GT_RestoreMtn' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_RestoreMtn();
	   exit;
	end;
      	if pCommandString = 'GT_LnXY' then begin
           VerifyParameter(s,nIndex,2);
	   RRtn:=GT_LnXY(StrToFloat(para[1]),StrToFloat(para[2]));
	   exit;
	end;
	if pCommandString = 'GT_LnXYZ' then begin
           VerifyParameter(s,nIndex,3);
	   RRtn:=GT_LnXYZ(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]));
	   exit;
	end;
      	if pCommandString = 'GT_LnXYG0' then begin
           VerifyParameter(s,nIndex,2);
	   RRtn:=GT_LnXYG0(StrToFloat(para[1]),StrToFloat(para[2]));
	   exit;
	end;
	if pCommandString = 'GT_LnXYZG0' then begin
           VerifyParameter(s,nIndex,3);
	   RRtn:=GT_LnXYZG0(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]));
	   exit;
	end;
	if pCommandString = 'GT_ArcXY' then begin
           VerifyParameter(s,nIndex,3);
	   RRtn:=GT_ArcXY(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]));
	   exit;
	end;
	if pCommandString = 'GT_ArcXYP' then begin
          VerifyParameter(s,nIndex,4);
	  RRtn:=GT_ArcXYP(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]),StrToInt(para[4]));
	  exit;
	end;
	if pCommandString = 'GT_ArcYZ' then begin
          VerifyParameter(s,nIndex,3);
	  RRtn:=GT_ArcYZ(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]));
	  exit;
	end;
	if pCommandString = 'GT_ArcYZP' then begin
          VerifyParameter(s,nIndex,4);
	  RRtn:=GT_ArcYZP(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]),StrToInt(para[4]));
	  exit;
	end;
	if pCommandString = 'GT_ArcZX' then begin
          VerifyParameter(s,nIndex,3);
	  RRtn:=GT_ArcZX(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]));
	  exit;
	end;
	if pCommandString = 'GT_ArcZXP' then begin
          VerifyParameter(s,nIndex,4);
	  RRtn:=GT_ArcZXP(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]),StrToInt(para[4]));
	  exit;
	end;
	if pCommandString = 'GT_AxisOff' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_AxisOff(StrToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_AxisOn' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_AxisOn(StrToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_CaptHome' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_CaptHome(StrToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_CaptIndex' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_CaptIndex(StrToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_MvXY' then begin
          VerifyParameter(s,nIndex,4);
	  RRtn:=GT_MvXY(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]),StrToFloat(para[4]));
	  exit;
	end;
	if pCommandString = 'GT_MvXYZ' then begin
          VerifyParameter(s,nIndex,5);
	  RRtn:=GT_MvXYZ(StrToFloat(para[1]),StrToFloat(para[2]),StrToFloat(para[3]),StrToFloat(para[4]),StrToFloat(para[5]));
          exit;
	end;
        if pCommandString = 'GT_Override' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_Override(StrToFloat(para[1]));
	  exit;
        end;
        if pCommandString = 'GT_OverrideG0' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_OverrideG0(StrToFloat(para[1]));
	  exit;
        end;
	if pCommandString = 'GT_ClrSts' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_ClrSts(strToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_HardRst' then begin
          VerifyParameter(s,nIndex,0);
	  RRtn:=GT_HardRst;  sleep(1000);
	  exit;
	end;
	if pCommandString = 'GT_Reset' then begin
          VerifyParameter(s,nIndex,0);
	  RRtn:=GT_Reset;    sleep(500);
          exit;
	end;
	if pCommandString = 'GT_DrvRst' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_DrvRst(StrToInt(para[1]));  sleep(500);
	  exit;
	end;
	if pCommandString = 'GT_LmtSns' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_LmtSns(StrToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_LmtsOn' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_LmtsOn(StrToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_LmtsOff' then begin
          VerifyParameter(s,nIndex,1);
	  RRtn:=GT_LmtsOff(StrToInt(para[1]));
	  exit;
	end;
	if pCommandString = 'GT_RstSts' then begin
          VerifyParameter(s,nIndex,2);
	  RRtn:=GT_RstSts(StrToInt(para[1]),StrToInt(para[2]));
	  exit;
	end;

        if pCommandString = 'GT_SetDccFlag' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_SetDccFlag();
	   exit;
	end;
        if pCommandString = 'GT_SetMaxVel' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_SetMaxVel(StrToFloat(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_SetSynVel' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_SetSynVel(StrToFloat(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_SetSynAcc' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_SetSynAcc(StrToFloat(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_SetStrtVel' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_SetStrtVel(StrToFloat(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_SetStpAcc' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_SetStpAcc(StrToFloat(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_StepDir' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_StepDir(StrToInt(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_StepPulse' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_StepPulse(StrToInt(para[1]));
	   exit;
	end;
        if pCommandString = 'GT_StrtList' then begin
           VerifyParameter(s,nIndex,0);
	   RRtn:=GT_StrtList();
	   exit;
	end;


	if pCommandString = 'GT_GetBrkPnt' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetBrkPnt(@nLong[1]);
	   exit;
	end;
	if pCommandString = 'GT_GetCapt' then begin
           if nIndex<1 then
             raise ERangeError.CreateFmt('参数太少，命令终止:%s',[s]);
	   RRtn:=GT_GetCapt(StrToInt(para[1]),@nInteger);
           exit;
	end;
	if pCommandString = 'GT_GetCmdSts' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetCmdSts(@nWord);
	   exit;
	end;
	if pCommandString = 'GT_GetCrdSts' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetCrdSts(@nWord);
	   exit;
	end;
	if pCommandString = 'GT_GetLmtSwt' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetLmtSwt(@nWord);
	   exit;
	end;
	if pCommandString = 'GT_GetMtnNm' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetMtnNm(@nWord);
	   exit;
	end;
	if pCommandString = 'GT_GetPrfVel' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetPrfVel(@nDouble[1]);
	   exit;
	end;
	if pCommandString = 'GT_GetPrfPnt' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetPrfPnt(@nLong[1]);
	   exit;
	end;
	if pCommandString = 'GT_GetSegPnt' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_GetSegPnt(@nLong[1]);
	   exit;
	end;
	if pCommandString = 'GT_GetSts' then begin
//         VerifyParameter(s,nIndex,0);
           if nIndex<1 then
             raise ERangeError.CreateFmt('参数太少，命令终止:%s',[s]);
	   RRtn:=GT_GetSts(StrToInt(para[1]),@nWord);
	   exit;
	end;
	if pCommandString = 'GT_ExInpt' then begin
//         VerifyParameter(s,nIndex,0);
	   RRtn:=GT_ExInpt(@nWord);
	   exit;
	end;
	if pCommandString = 'GT_ExOpt' then begin
           VerifyParameter(s,nIndex,1);
	   RRtn:=GT_ExOpt(StrToInt(para[1]));
	   exit;
	end;

    raise ERangeError.CreateFmt('没有该指令,指令错误:%s',[s]);
end;

end.
