using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ges
{
class GES
{
public struct TDoublePnt
{
public double X;
public double Y;
public double Z;
public double W;
}
#region 设置运动控制器
/// <summary>
/// 打开运动控制器
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_Open(int address = 65535);
/// <summary>
/// 关闭运动控制器
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_Close();
/// <summary>
/// 复位运动控制器
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_Reset();
/// <summary>
/// 硬件复位运动控制器
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_HardRst();
/// <summary>
/// 挂接用户自定义处理函数
/// </summary>
/// <param name="TCommandHandle">所挂接的指令处理程序的地址</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_HookCommand(int TCommandHandle);
#endregion
#region 设置控制轴在这里插入代码片
/// <summary>
/// 控制轴驱动报警有效
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_AlarmOn(short axis);
/// <summary>
/// 控制轴驱动报警信号无效
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_AlarmOff(short axis);
/// <summary>
/// 控制轴限位信号有效
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LmtsOn(short axis);
/// <summary>
/// 控制轴限位无效
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LmtsOff(short axis);
/// <summary>
/// 设置运动控制器各轴限位开关触发电平(默认为0,高电平触发 )
/// </summary>
/// <param name="sense">电平信号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LmtSns(short sense);
/// <summary>
/// 控制轴编码器的记数方向
/// </summary>
/// <param name="sense">记数方向</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_EncSns(short sense);
/// <summary>
/// 运动控制器各轴Home信号触发沿(默认为0,下降沿触发)
/// </summary>
/// <param name="sense">电平方向</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_HomeSns(short sense);
/// <summary>
/// 轴为模拟量输出或脉冲输出
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="mode">模式</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_CtrlMode(short axis, short mode);
/// <summary>
/// 轴的脉冲输出模式设置为“脉冲+方向”
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_StepDir(short axis);
/// <summary>
/// 将指定控制轴的脉冲输出方式设置为“正负脉冲”
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_StepPulse(short axis);
/// <summary>
/// 消除指定控制轴的伺服报警信号
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_DrvRst(short axis);
/// <summary>
/// 打开控制轴的编码器输入
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_EncOn(short axis);
/// <summary>
/// 关闭控制轴的编码器输入
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_EncOff(short axis);
#endregion
#region 设置控制轴运动参数
/// <summary>
/// 将指定控制轴的实际位置、目标位置和规划位置设置为 0
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ZeroPos(short axis);
/// <summary>
/// 将指定控制轴的实际位置、目标位置和规划位置设置为指定值
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="pos"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetAtlPos(short axis, double pos);
/// <summary>
/// 读取指定控制轴的实际位置
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="pos">读取指定控制轴的实际位置</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetAtlPos(short axis, out int pos);
/// <summary>
/// 获得轨迹运动中各轴的规划位置值
/// </summary>
/// <param name="point">各轴的内部计数值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetPrfPnt(out TDoublePnt point);
/// <summary>
/// 读取断点位置信息
/// </summary>
/// <param name="point">断点的位置</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetBrkPnt(out TDoublePnt point);
/// <summary>
/// 读取指定控制轴的规划速度
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="vel">读取指定控制轴的规划速度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetPrfVel(short axis, out double vel);
#endregion
#region 设置控制轴控制参数
/// <summary>
/// 设置指定控制轴的误差比例增益
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kp">设置指定控制轴的误差比例增益</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetKp(short axis, double kp);
/// <summary>
/// 读取指定控制轴的误差增益
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kp">读取指定控制轴的误差比例增益</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetKp(short axis, out double kp);
/// <summary>
/// 设置指定控制轴的误差积分增益
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="ki">设置指定控制轴的误差积分增益</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetKi(short axis, double ki);
/// <summary>
/// 读取指定控制轴的误差积分增益
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="ki">读取指定控制轴的误差积分增益</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetKi(short axis, out double ki);
/// <summary>
/// 设置指定控制轴的误差微分增益
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kd">设置指定控制轴的误差微分增益</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetKd(short axis, double kd);
/// <summary>
/// 设置指定控制轴的误差微分增益
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kd">设置指定控制轴的误差微分增益</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetKd(short axis, out double kd);
/// <summary>
/// 设置指定控制轴的速度前馈系数
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kvff">设置指定控制轴的速度前馈系数</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetKvff(short axis, double kvff);
/// <summary>
/// 设置指定控制轴的速度前馈系数
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kvff">设置指定控制轴的速度前馈系数</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetKvff(short axis, out double kvff);
/// <summary>
/// 设置指定控制轴的加速度前馈系数
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kaff">设置指定控制轴的加速度前馈系数</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetKaff(short axis, double kaff);
/// <summary>
/// 读取指定控制轴的加速度前馈系数
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="kaff">读取指定控制轴的加速度前馈系数</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetKaff(short axis, out double kaff);
/// <summary>
/// 设置指定控制轴的零漂电压补偿
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="bi">设置指定控制轴的零漂电压补偿值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetMtrBias(short axis, short bias);
/// <summary>
/// 读取指定控制轴的零漂电压补偿
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="bias">读取指定控制轴的零漂电压补偿值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetMtrBias(short axis, out short bias);
/// <summary>
/// 读取指定控制轴的零漂电压补偿
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="limit">读取指定控制轴的零漂电压补偿值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetMtrLmt(short axis, short limit);
/// <summary>
/// 读取指定控制轴的输出电压饱和极限
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="limit">读取指定控制轴的输出电压饱和极限</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetMtrLmt(short axis, out short limit);
/// <summary>
/// 设置指定控制轴的误差积分饱和极限
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="limit">设置指定控制轴的误差积分饱和极限</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetILmt(short axis, short limit);
/// <summary>
/// 读取指定控制轴的误差积分极限
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="limit">读取指定控制轴的误差积分饱和极限</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetILmt(short axis, out short limit);
/// <summary>
/// 设置指定控制轴的跟随误差极限
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="err">设置指定控制轴的跟随误差极限</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetPosErr(short axis, short err);
/// <summary>
/// 读取指定控制轴的跟随误差极限
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="err">读取指定控制轴的跟随误差极限</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetPosErr(short axis, out short err);
#endregion
#region 控制轴运动控制指令
/// <summary>
/// 使能指定控制轴
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_AxisOn(short axis);
/// <summary>
/// 关闭指定控制轴所连电机的伺服使能信号
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_AxisOff(short axis);
/// <summary>
/// 使指定控制轴参数生效
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_Update(short axis);
/// <summary>
/// 多个控制轴参数(包括运动参数和控制参数)刷新
/// </summary>
/// <param name="mk">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_MltiUpdt(short mk);
#endregion
#region 连续轨迹运动指令
/// <summary>
/// 实现二维直线插补运动
/// </summary>
/// <param name="X"></param>
/// <param name="y"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LnXY(double X, double y);
/// <summary>
/// 实现二维直线插补运动
/// </summary>
/// <param name="X"></param>
/// <param name="y"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LnXYG0(double X, double y);
/// <summary>
/// 实现三维直线插补运动
/// </summary>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LnXYZ(double X, double Y, double Z);
/// <summary>
/// 实现三维直线插补运动
/// </summary>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LnXYZG0(double X, double Y, double Z);
/// <summary>
/// 实现四维直线插补运动
/// </summary>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
/// <param name="a"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LnXYZA(double X, double Y, double Z, double a);
/// <summary>
/// 四维直线插补
/// </summary>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
/// <param name="a"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_LnXYZAG0(double X, double Y, double Z, double a);
/// <summary>
/// 实现 XOY 平面内的两轴圆弧插补
/// </summary>
/// <param name="x_center">圆弧</param>
/// <param name="y_center">圆心</param>
/// <param name="angle">旋转角度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ArcXY(double x_center, double y_center, double angle);
/// <summary>
/// 实现 XOY 平面内的两轴圆弧插补
/// </summary>
/// <param name="x_end">圆弧终点位置</param>
/// <param name="y_end">圆弧终点位置</param>
/// <param name="R">圆弧半径并带符号</param>
/// <param name="Direction">圆弧旋转方向</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ArcXYP(double x_end, double y_end, double R, short Direction);
/// <summary>
/// 令实现 YOZ 平面内的两轴圆弧插补
/// </summary>
/// <param name="y_center">圆弧圆心位置</param>
/// <param name="z_center">圆弧圆心位置</param>
/// <param name="angle">旋转角度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ArcYZ(double y_center, double z_center, double angle);
/************GE300SX only***************/
/// <summary>
/// 实现 YOZ 平面内的两轴圆弧插补
/// </summary>
/// <param name="y_end">圆弧圆心位置</param>
/// <param name="z_end">圆弧圆心位置</param>
/// <param name="R">圆弧半径并带符号</param>
/// <param name="dirction">圆弧旋转方向</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ArcYZP(double y_end, double z_end, double R, short dirction);
/// <summary>
/// 实现 ZOX 平面内的两轴圆弧插补
/// </summary>
/// <param name="z_center">圆弧圆心位置</param>
/// <param name="x_center">圆弧圆心位置</param>
/// <param name="angle">旋转角度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ArcZX(double z_center, double x_center, double angle);
/// <summary>
/// 实现 ZOX 平面内的两轴圆弧插补
/// </summary>
/// <param name="z_end">圆弧终点位置</param>
/// <param name="x_end">圆弧终点位置</param>
/// <param name="R">圆弧半径并带符号</param>
/// <param name="dirction">圆弧旋转方向</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ArcZXP(double z_end, double x_end, double R, short dirction);
/// <summary>
/// 设置轨迹段的进给速度
/// </summary>
/// <param name="vel">设定的轨迹运动的进给速度值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetSynVel(double vel);
/// <summary>
/// 设置连续轨迹运动的进给加速度
/// </summary>
/// <param name="acc">设定的进给加速度值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetSynAcc(double acc);
/// <summary>
/// 设定连续轨迹运动的启动速度
/// </summary>
/// <param name="vel">启动速度值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetStrtVel(double vel);
/// <summary>
/// 设定系统的停止加速度
/// </summary>
/// <param name="acc">停止加速度值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetStpAcc(double acc);
/// <summary>
/// 设定系统最高运行速度
/// </summary>
/// <param name="vel">设定控制卡最高运行速度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetMaxVel(double vel);
/// <summary>
/// 设置除 GT_LnXYG0、GT_LnXYZG0、GT_LnXYZAG0 以及定位指令以外的轨迹描述指令所产生运动的速度倍率
/// </summary>
/// <param name="override1">设置的速度倍率</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_Override(double override1);
/// <summary>
/// 设置 GT_LnXYG0、GT_LnXYZG0、GT_LnXYZAG0 以及定位指令的速度倍率
/// </summary>
/// <param name="override1">设置的速度倍率</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_OverrideG0(double override1);
/// <summary>
/// 按照设定的进给加速度停止轨迹运动
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_StpMtn();
/// <summary>
/// 紧急停止连续轨迹运动
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_EStpMtn();
/// <summary>
/// 设置坐标偏移量
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="count">设定要偏移的脉冲数</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_MapCnt(short axis, double count);
#endregion
#region 缓冲区管理指令
/// <summary>
/// 打开并清空缓冲区
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_StrtList();
/// <summary>
/// 定义二维连续轨迹的缓冲区命令的起点位置
/// </summary>
/// <param name="X">起点位置</param>
/// <param name="Y">起点位置</param>
/// <param name="vel">设定进给速度</param>
/// <param name="acc">设定进给加速度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_MvXY(double X, double Y, double vel, double acc);
/// <summary>
/// 定义三维连续轨迹的缓冲区命令的起点位置
/// </summary>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
/// <param name="vel">设定进给速度</param>
/// <param name="acc">设定进给加速度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_MvXYZ(double X, double Y, double Z, double vel, double acc);
/// <summary>
/// 定义四维连续轨迹的缓冲区命令的起点位置
/// </summary>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
/// <param name="a"></param>
/// <param name="vel">设定进给速度</param>
/// <param name="acc">设定进给加速度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_MvXYZA(double X, double Y, double Z, double a, double vel, double acc);
/// <summary>
/// 在缓冲区命令输入状态下,调用本指令结束缓冲区命令输入状态
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_EndList();
/// <summary>
/// 重新打开被关闭的缓冲区
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_AddList();
/// <summary>
/// 启动缓冲区连续轨迹运动
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_StrtMtn();
/// <summary>
/// 在缓冲区运动暂停后,使用此命令可使中断的运动从断点处继续运动
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_RestoreMtn();
/// <summary>
/// 返回当前缓冲区中正在执行的轨迹段编号
/// </summary>
/// <param name="number">返回轨迹段编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetMtnNm(out short number);
#endregion
#region 状态检测
/// <summary>
/// 读取指定控制轴的状态寄存器
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="status">读取指定控制轴的状态寄存器</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetSts(short axis, out short status);
/// <summary>
/// 确定指令执行出错的原因
/// </summary>
/// <param name="status">读取指令执行出错原因</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetCmdSts(out short status);
/// <summary>
/// 该指令获得轨迹运动状态
/// </summary>
/// <param name="status">返回该状态</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetCrdSts(out short status);
/// <summary>
/// 将指定控制轴状态寄存器的 bit0~7 清 0,其它状态位不受影响
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ClrSts(short axis);
/// <summary>
/// 将指定控制轴状态寄存器的指定状态位清 0
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="mk">指定清除指定控制轴状态寄存器的哪些状态位</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_RstSts(short axis, short mk);
#endregion
#region Home/Index捕获
/// <summary>
/// 将指定控制轴的位置捕获设置为由 Home 信号触发
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_CaptHome(short axis);
/// <summary>
/// 将指定控制轴的位置捕获设置为由编码器 C 相脉冲信号或者光栅尺的Index 信号触发
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_CaptIndex(short axis);
/// <summary>
/// 该函数设置捕获探针输入信号事件
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_CaptProb();
/// <summary>
/// 读取指定控制轴的 Home 信号或者 Index 信号触发时,其实际位置捕获值
/// </summary>
/// <param name="axis">指定控制轴编号</param>
/// <param name="pos">读取指定控制轴的捕获位置</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetCapt(short axis, out int pos);
#endregion
#region 数字I/O
/// <summary>
/// 读取 16 路通用数字量输入
/// </summary>
/// <param name="ninput">读取 16 路通用数字 I/O 的输入信号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern int GT_ExInpt(out int ninput);
/// <summary>
/// 设置 16 路通用数字量输出
/// </summary>
/// <param name="value">设置 16 路通用数字 I/O 的输出信号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ExOpt(ushort value);
/// <summary>
/// 设置 16 路通用数字量单个I/O输出
/// </summary>
/// <param name="bit">I/O引脚</param>
/// <param name="value">设置单个数字 I/O 的输出信号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ExOptBit(short bit, ushort value);
/// <summary>
/// 读取运动控制器 Home 开关的状态
/// </summary>
/// <param name="home">读取各轴原点开关的电平状态</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetHomeSwt(out short home);
/// <summary>
/// 读取运动控制器各轴的限位开关状态
/// </summary>
/// <param name="limit">读取各轴正负限位开关的电平状态</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetLmtSwt(out short limit);
/// <summary>
/// 在缓冲区方式下,控制通用 IO 的输出
/// </summary>
/// <param name="value">表示 16 位通用 IO 输出的状态</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_BufIO(short value);
/// <summary>
/// 在缓冲区方式下,设置指定的通用输出端口的高低电平状态
/// </summary>
/// <param name="bit">表示指定的通用输出位通道</param>
/// <param name="status">表示指定的通用输出的状态(只能为“0”或者“1”</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_BufIOBit(short bit, short status);
#endregion
#region 运动速度控制指令
/// <summary>
/// 设定线段的终点位置
/// </summary>
/// <param name="vel">设定轨迹段终点速度</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetDccVel(double vel);
#endregion
#region 前瞻预处理指令
/// <summary>
/// 将数据发送到预处理缓冲区
/// </summary>
/// <param name="Code">曲线类型</param>
/// <param name="PlaneGroup">平面代码</param>
/// <param name="R">圆弧半径</param>
/// <param name="X">坐标X位置</param>
/// <param name="Y">坐标Y位置</param>
/// <param name="Z">坐标Z位置</param>
/// <param name="vel">当前段目标速度</param>
/// <param name="Cx">圆弧位置</param>
/// <param name="Cy">圆心位置</param>
/// <param name="i">压入到缓冲区的具体位置</param>
/// <param name="n">当前段的标识</param>
/// <param name="flag">当前段是否降速到0</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_AddLookData(byte Code, byte PlaneGroup, double R, double X, double Y, double Z, double vel, double Cx, double Cy, short i, int n, short flag);
/// <summary>
/// 计算预处理缓冲区中当前轨迹段的终点速度
/// </summary>
/// <param name="vel">返回终点速度</param>
/// <param name="number">对应的用户加工代码段号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_CalVel(out double vel, out int number);
/// <summary>
/// 初始化预处理功能模块的各项参数
/// </summary>
/// <param name="T">拐弯时间</param>
/// <param name="acc_max">系统能承受的最大加速度</param>
/// <param name="acc">系统设定加速度</param>
/// <param name="vel">用户加工的目标速度</param>
/// <param name="n">需预处理的段数</param>
/// <param name="con">脉冲数与标准长度单位对应值</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_InitLookAhead(double T, double acc_max, double acc, double vel, short n, double con);
#endregion
#region 辅助编码器指令
/// <summary>
/// 该指令用来读取辅助编码器实际位置值
/// </summary>
/// <param name="axis">表示需要读取的辅助编码器号</param>
/// <param name="pos">读取指定辅助编码器的实际位置</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_EncPos(short axis, out int pos);
/// <summary>
/// 获取当前运动控制器的卡号
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetCurrentCardNo();
/// <summary>
/// 该指令用于切换当前运动控制器卡号
/// </summary>
/// <param name="number">将被设为当前运动控制器的卡号</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SwitchtoCardNo(short number);
#endregion
#region 手脉控制指令(可选)
/// <summary>
/// 手脉功能
/// </summary>
/// <param name="axis">指定要跟随手脉运动的轴号</param>
/// <param name="value">设定跟随轴的倍率</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_HandWheel(short axis, double value);
/// <summary>
/// 使处于手脉控制模式的控制轴退出手脉控制模式
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_ExitHWheel();
#endregion
#region 主轴控制指令(可选)
/// <summary>
/// 关闭主轴信号输出
/// </summary>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_CloseSpindle();
/// <summary>
/// 设定主轴转速并开始主轴运动
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetSpindleVel(short value);
#endregion
#region A/D(可选)
/// <summary>
/// 运动控制器提供了 8 路 12 位精度的外部模拟电压输入通道
/// </summary>
/// <param name="channel">指定模拟电压输入通道</param>
/// <param name="D_data">读取指定输入通道的模拟电压</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_GetAdc(short channel, out short D_data);
/// <summary>
/// 设置 A/D 通道数目,用来提高 A/D 的采样频率
/// </summary>
/// <param name="value">通道数</param>
/// <returns></returns>
[DllImport("ges.dll")]
public static extern short GT_SetAdcChn(short value);
#endregion
}
}
固高运动控制卡C#函数库 GE400
最新推荐文章于 2024-08-05 15:55:51 发布