C++源码:
#include "stdafx.h"
#include "windows.h"
#include "conio.h"
#include "gts.h"
#define AXIS 1
void
commandhandler(
char
*command,
short
error)
{
if
(error)
{
printf(
"%s = %d\n"
, command, error);
}
}
int
main(
int
argc,
char
* argv[])
{
short
sRtn;
TTrapPrm trap;
long
sts;
double
prfPos;
sRtn = GT_Open();
commandhandler(
"GT_Open"
, sRtn);
sRtn = GT_LoadConfig(
"test.cfg"
);
commandhandler(
"GT_LoadConfig "
, sRtn);
sRtn = GT_ClrSts(1, 8);
commandhandler(
"GT_ClrSts"
, sRtn);
sRtn = GT_AxisOn(AXIS);
commandhandler(
"GT_AxisOn"
, sRtn);
sRtn = GT_ZeroPos(AXIS);
commandhandler(
"GT_ZeroPos"
, sRtn);
sRtn = GT_SetPrfPos(AXIS, 0);
commandhandler(
"GT_SetPrfPos"
, sRtn);
sRtn = GT_PrfTrap(AXIS);
commandhandler(
"GT_PrfTrap"
, sRtn);
sRtn = GT_GetTrapPrm(AXIS, &trap);
commandhandler(
"GT_GetTrapPrm"
, sRtn);
trap.acc = 0.25;
trap.dec = 0.125;
trap.smoothTime = 25;
sRtn = GT_SetTrapPrm(AXIS, &trap);
commandhandler(
"GT_SetTrapPrm"
, sRtn);
sRtn = GT_SetPos(AXIS, 50000L);
commandhandler(
"GT_SetPos"
, sRtn);
sRtn = GT_SetVel(AXIS, 50);
commandhandler(
"GT_SetVel"
, sRtn);
sRtn = GT_Update(1<<(AXIS-1));
commandhandler(
"GT_Update"
, sRtn);
do
{
sRtn = GT_GetSts(AXIS, &sts);
sRtn = GT_GetPrfPos(AXIS, &prfPos);
printf(
"sts=0x%-10lxprfPos=%-10.1lf\r"
, sts, prfPos);
}
while
(sts&0x400);
sRtn = GT_AxisOff(AXIS);
printf(
"\nGT_AxisOff()=%d\n"
, sRtn);
getch();
return
0;
}