/****************************************************************************************************
* ZT Motion Library *
* Copyright (C) 2023 ZHITENG (Shenzhen) Motion Technology Co.,Ltd *
* *
* *
* @file ztm.cs *
* @brief defs of struct and function *
* *
* *
* @version 4.0.1R0(版本号) *
* @date 2023.03.10 *
* *
* *
****************************************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace CSZTM
{
public class ZTM
{
#region 函数返回值及其含义
public static short ZT_STAT_MC_OPENING = 2; /*正在打开控制器*/
public static short ZT_STAT_MC_OPEND = 1; /*控制器已打开*/
public static short ZT_ERR_OK = 0; /*无错误*/
public static short ZT_ERR_PMVAL = -1; /*参数值错误*/
public static short ZT_ERR_PULSEOVERFLOW = -2; /*脉冲发生器溢出*/
public static short ZT_ERR_PMID = -3; /*参数ID不存在,无此参数*/
public static short ZT_ERR_MCMAX = -4; /*控制器不存在,超出系统支持的最大控制器索引号*/
public static short ZT_ERR_CHMAX = -5; /*通道号不存在,超出系统最大通道数*/
public static short ZT_ERR_AXISMAX = -6; /*轴号不存在,超出系统最大轴数*/
public static short ZT_ERR_NOAUTH = -7; /*控制器无授权*/
public static short ZT_ERR_PLCADDROVERFLOW = -8; /*PLC地址溢出*/
public static short ZT_ERR_NOFLAG = -9; /*没有此状态或标志*/
public static short ZT_ERR_NONSTOPPED = -10; /*运动没有停止*/
public static short ZT_ERR_MCNOFILE = -11; /*文件号打开失败。文件号不存在,或SD卡不存在。*/
public static short ZT_ERR_HOSTNOFILE = -12; /*HOST打开文件失败*/
public static short ZT_ERR_AXISALM = -13; /*轴伺服报警*/
public static short ZT_ERR_AXISPOT = -14; /*轴正向硬限位*/
public static short ZT_ERR_AXISNOT = -15; /*轴负向硬限位*/
public static short ZT_ERR_AXISPSL = -16; /*轴正向软限位*/
public static short ZT_ERR_AXISNSL = -17; /*轴负向软限位*/
public static short ZT_ERR_AXISESTOP = -18; /*硬急停*/
public static short ZT_ERR_AXISOT = -19; /*轴硬限位*/
public static short ZT_ERR_AXISSL = -20; /*轴软限位*/
public static short ZT_ERR_HDBUSY = -51; /*大数据传送忙*/
public static short ZT_ERR_HDERROR = -52; /*大数据传送错误*/
public static short ZT_ERR_FILEOPEND = -61; /*文件已打开*/
public static short ZT_ERR_NOFILEOPEN = -62; /*文件未打开*/
public static short ZT_ERR_CMDBUFFFULL = -100; /*BLOCK指令缓冲区满*/
public static short ZT_ERR_COM_ADDR = -101; /*与HOST通讯的设备地址错误*/
public static short ZT_ERR_COM_CHECKSUM = -102; /*与HOST通讯的校验和错误*/
public static short ZT_ERR_COM_INVCMD = -103; /*与HOST通讯的命令ID错误*/
public static short ZT_ERR_SOCKET = -104; /*HOST库中,SOCKET初始化失败*/
public static short ZT_ERR_SHM = -105; /*HOST库中,SHM初始化失败*/
public static short ZT_ERR_PIPE = -106; /*HOST库中,PIPE初始化失败*/
public static short ZT_ERR_NOLIBINITD = -107; /*HOST库没有初始化*/
public static short ZT_ERR_NOMCOPEN = -108; /*HOST库中,控制器未打开*/
public static short ZT_ERR_MC_NONCONNECT = -110; /*HOST与控制器通讯超时,未连接*/
public static short ZT_ERR_THREAD = -112; /*HOST库中,线程初始化失败*/
public static short ZT_ERR_BUFFIDX = -113; /*命令缓冲区索引号错误*/
public static short ZT_ERR_BUFFFULL = -114; /*发送缓冲区满*/
public static short ZT_ERR_PREBUFFFULL = -115; /*BLOCK命令的预缓冲区满*/
public static short ZT_ERR_FB_TIMEOUT = -121; /*伺服现场总线超时*/
public static short ZT_ERR_FB_NCYCWNG = -122; /*伺服总线中非周期命令执行报警*/
public static short ZT_ERR_FB_CCYCERR = -123; /*伺服总线中非周期命令执行错误*/
public static short ZT_ERR_SERVICE_STOP = -230; /*控制器服务程序停止*/
public static short ZT_ERR_UPDATE = -255; /*内部使用,更新命令*/
#endregion 函数返回值及其含义
#region 函数接口
#region 控制器操作
///
/// 搜索IP段的控制器
///
/// 主机端IP地址
/// 搜索到的控制器的IP地址的第一段
/// 搜索到的控制器的IP地址的第二段
/// 搜索到的控制器的IP地址的第三段
/// 搜索到的控制器的IP地址的第四段
/// 搜索一个IP地址的超时时间,单位:ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SearchMc(char[] host_ip, ref char mc_ip_1, ref char mc_ip_2, ref char mc_ip_3, ref char mc_ip_4, short timeout = 500);
///
/// 打开控制器
///
/// 控制器的IP地址,是C类IP地址私有范围地址,192.168.0.0~192.168.255.255。
/// 服务分配并返回的控制器索引,作为其它接口函数的控制器索引参数,0表示无效控制器。
/// 服务与控制器通讯握手超时时间,单位是ms,0表示超时无穷大。
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_Open(char[] ip, ref short mc, short timeout = 500);
///
/// 利用索引号关闭控制器
///
/// 控制器索引
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_Close(short mc);
///
/// 利用IP关闭控制器
///
/// 控制器IP地址
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_CloseIP(char[] ip);
///
/// 控制器热复位
///
/// 控制器索引
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_Reset(short mc);
///
/// 读取控制器连接状态
///
/// 控制器的IP地址
/// 服务返回的IP地址对应的控制器索引,作为其它接口函数的控制器索引参数,0表示无效控制器
/// 返回控制器连接状态,0-未连接,1-已连接,2-正在连接
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetConnectionStatus(char[] ip, ref short mc);
///
/// 设置控制器的IP地址
///
/// 原来的IP地址
/// 新的IP地址
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetIP(char[] oldip, char[] newip);
///
/// 搜索IP地址对应的控制器是否存在
///
/// IP地址
/// 超时时间,单位:ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_FindIP(char[] ip, short timeout = 500);
#endregion 控制器操作
#region 回零操作
///
/// 设置回零参数
///
/// 控制器索引
/// 轴号
/// 回零方向,1-正向,0-负向
/// 回零模式,取值范围:
/// 0-无效
/// 1-HOME,零点开关一次回零
/// 2-LMT,限位开关一次回零
/// 3-Z,编码器Z相信号一次回零
/// 4-HOME+Z,原点与编码器Z相信号联合回零
/// 5-LMT+Z,限位开关与编码器Z相信号联合回零
/// 6-LMT+HOME,限位开关与零点开关联合回零
/// 7-LMT+HOME+Z,限位开关、零点开关与编码器Z相信号联合回零
/// 8-原地,仅仅将轴的位置清零
/// 12-Z2,二次编码器Z相信号回零,类似于一次零点回零
///
/// 回零低速,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.0
/// 回零高速,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.0
/// 回零加速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.0
/// 零点偏置,单位:p或物理量纲分辨率,取值范围:±2^31,默认值为0
/// 锁存方式回零时搜索距离,如果值大于零,表示锁存方式回零,单位:p或物理量纲分辨率,
/// 取值范围:0~2^31,默认值为0,表示低速搜索信号,立即停止。
///
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetHomeParam(short mc, short axis, short dir, short mode, float lo_vel, float hi_vel, float acc, int offset = 0, int latch_dist = 0);
///
/// 回零启动
///
/// 控制器索引
/// 按位掩码的轴选择
/// 回零时清零编码器位置,1-清零编码器位置,0-不清零编码器位置
/// 成功返回0
/// 对于各种伺服驱动器和步进驱动器,回零启动前,都要调用ZT_SetServoOn激活伺服使能, 以确保回零结束时回零完成信号有效
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_Home(short mc, uint axes, short rstenc = 1);
///
/// 设置轴正向软限位位置
///
/// 轴号,取值范围:控制器支持的轴号
/// 正向软限位,单位:p或物理量纲分辨率,取值范围:±2^31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPSL(short mc, short axis, int pos);
///
///
///
/// 轴号,取值范围:控制器支持的轴号
/// 负向软限位,单位:p或物理量纲分辨率,取值范围:±2^31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetNSL(short mc, short axis, int pos);
#endregion 回零操作
#region 点位运动
///
/// 绝对式P2P运动,单轴运动
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 绝对目标位置,单位:p或物理量纲分辨率,取值范围:±2^31
/// 起跳速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标加速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 目标减速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 截止速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 平滑时间,单位:ms,取值范围:0~65535,默认值0,表示梯形运动,大于0则为S曲线运动
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_MoveA(short mc, short axis, int pos, float str_vel, float max_vel, float acc, float dec, float end_vel, ushort smth = 0);
///
/// 相对式P2P运动,单轴运动
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 相对目标位置,单位:p或物理量纲分辨率,取值范围:±2^31
/// 起跳速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标加速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 目标减速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 截止速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 平滑时间,单位:ms,取值范围:0~65535,默认值0,表示梯形运动,大于0则为S曲线运动
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_MoveR(short mc, short axis, int pos, float str_vel, float max_vel, float acc, float dec, float end_vel, ushort smth = 0);
///
/// 正向JOG运动
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 起跳速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标加速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 目标减速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 截止速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 平滑时间,单位:ms,取值范围:0~65535,默认值0,表示梯形运动,大于0则为S曲线运动
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_JogP(short mc, short axis, float str_vel, float max_vel, float acc, float dec, float end_vel, ushort smth = 0);
///
/// 负向JOG运动
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 起跳速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 目标加速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 目标减速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.000
/// 截止速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.000
/// 平滑时间,单位:ms,取值范围:0~65535,默认值0,表示梯形运动,大于0则为S曲线运动
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_JogM(short mc, short axis, float str_vel, float max_vel, float acc, float dec, float end_vel, ushort smth = 0);
///
/// 轴运动平滑停止
///
/// 控制器索引
/// 按位掩码的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_Stop(short mc, uint axes);
///
/// 轴运动立即停止
///
/// 控制器索引
/// 按位掩码的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_EStop(short mc, uint axes);
///
/// 设置脉冲位置
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 命令位置,单位:p或物理量纲分辨率,取值范围:±2^31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPosPulse(short mc, short axis, int pos);
///
/// 设置编码器位置
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 编码器位置,单位:p或物理量纲分辨率,取值范围:±2^31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPosEncoder(short mc, short axis, int pos);
///
/// 读取轴运动的当前脉冲位置
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 命令位置,单位:p或物理量纲分辨率,取值范围:±2^31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetPosPulse(short mc, short axis, ref int pos);
///
/// 读取轴运动的当前编码器位置
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 编码器位置,单位:p或物理量纲分辨率,取值范围:±2^31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetPosEncoder(short mc, short axis, ref int pos);
///
/// 读取轴运动的当前脉冲速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 命令速度,单位:p(或物理量纲分辨率)/ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetVelPulse(short mc, short axis, ref float vel);
///
/// 读取轴运动的当前实际速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 实际速度,单位:p(或物理量纲分辨率)/ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetVelEncoder(short mc, short axis, ref float vel);
///
/// 读取轴运动的当前脉冲加速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 命令加速度,单位:p(或物理量纲分辨率)/ms^2
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetAccPulse(short mc, short axis, ref float acc);
///
/// 读取轴运动的当前编码器加速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 实际加速度,单位:p(或物理量纲分辨率)/ms^2
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetAccEncoder(short mc, short axis, ref float acc);
///
/// 设置轴运动的最大速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 轴最大速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetMaxVel(short mc, short axis, float vel);
///
/// 设置轴运动的最大加速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 最大加速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetMaxAcc(short mc, short axis, float acc);
///
/// 设置轴运动的最大减速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 最大减速度,单位:p(或物理量纲分辨率)/ms^2,取值范围:0.001~4000.0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetMaxDec(short mc, short axis, float dec);
///
/// 设值辅助编码器的初值
///
/// 控制器索引
/// 辅助编码器索引,取值范围:0,1
/// 初值,单位:p或物理量纲分辨率
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPosAux(short mc, short auxenc, int pos);
///
/// 读取辅助编码器的计数值
///
/// 控制器索引
/// 辅助编码器索引,取值范围:0,1
/// 计数值,单位:p或物理量纲分辨率
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetPosAux(short mc, short auxenc, ref int pos);
///
/// 绝对式P2P运动启动
///
/// 控制器序号
/// 按位掩码的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_JogA(short mc, uint axes);
///
/// 相对式P2P运动启动
///
/// 控制器序号
/// 按位掩码的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_JogR(short mc, uint axes);
///
/// 正向连续点动
///
/// 控制器索引
/// 按位掩码的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_JogPlus(short mc, uint axes);
///
/// 负向连续点动
///
/// 控制器索引
/// 按位掩码的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_JogMinus(short mc, uint axes);
///
/// 设置轴运动的目标位置
///
/// 控制器序号
/// 按位掩码的轴选择
/// 目标位置
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPosT(short mc, uint axes, int pos);
///
/// 设置轴运动的目标速度
///
/// 控制器序号
/// 按位掩码的轴选择
/// 目标速度,范围:0~4095.0 p/ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetVelT(short mc, uint axes, float vel);
///
/// 设置轴运动的目标加速度
///
/// 控制器序号
/// 按位掩码的轴选择
/// 目标加速度,范围:0~4095.0 p/ms^2
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetAccT(short mc, uint axes, float acc);
///
/// 设置轴运动的目标减速度
///
/// 控制器序号
/// 按位掩码的轴选择
/// 目标减速度,范围:0~4095.0 p/ms^2
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetDecT(short mc, uint axes, float dec);
///
/// 设置轴运动的速度平滑时间
///
/// 控制器序号
/// 按位掩码的轴选择
/// 平滑时间,范围:0~65535 ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetSmthT(short mc, uint axes, ushort tm);
///
/// 设置轴运动的启动速度
///
/// 控制器序号
/// 按位掩码的轴选择
/// 启动速度,范围:0~4095.0 p/ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetVelS(short mc, uint axes, float vel);
#endregion 点位运动
#region 插补运动
#region 通道操作
///
/// 通道启动
///
/// 控制器索引
/// 按位掩码的通道选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChStart(short mc, ushort chs);
///
/// 通道停止
///
/// 控制器索引
/// 按位掩码的通道选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChStop(short mc, ushort chs);
///
/// 通道紧急停止
///
/// 控制器索引
/// 按位掩码的通道选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChEStop(short mc, ushort chs);
///
/// 通道保持
///
/// 控制器索引
/// 按位掩码的通道选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChHold(short mc, ushort chs);
///
/// 通道复位
///
/// 控制器索引
/// 按位掩码的通道选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChReset(short mc, ushort chs);
///
/// 通道单步选项
///
/// 控制器索引
/// 按位掩码的通道选择
/// 单步选项方式,取值范围:1 - 通道按单步方式运行,0 - 通道按连续方式运行,默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChStepOption(short mc, ushort chs, short on = 0);
///
/// 设置通道对应的BLOCK命令缓冲器
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 缓冲器索引,取值范围:0~9
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChSetBuffer(short mc, short ch, short buff);
///
/// 读取通道正在执行的BLOCK命令的模式
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// BLOCK命令模式,取值范围:
/// 00 - 无效模式
/// 01 - 快速点定位
/// 02 - 直线插补
/// 03 - 空间圆弧插补
/// 04 - 坐标平面圆弧插补
/// 05 - 停留延时
/// 06 - 等待
/// 07 - 数字输出
/// 99 - 结束
///
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetBlockMode(short mc, short ch, ref short mode);
///
/// 读取通道的运行状态
///
/// 控制器索引
/// 按位掩码表示的通道运行标志
/// 按位掩码表示的通道中各轴运动停止标志
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetStatus(short mc, ref short running, ref short stopped);
///
/// 读取通道的实际进给速度
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 实际速度,单位:物理量纲,相当于mm(deg)/s,um(0.001deg)/ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetActualFeed(short mc, short ch, ref float feed);
///
/// 读取通道的当前插补块的命令进给速度
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 当前命令进给速度,单位:物理量纲,相当于mm(deg)/s,um(0.001deg)/ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetCommandFeed(short mc, short ch, ref float feed);
///
/// 读取通道当前执行块的块号
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 块号
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetBlockID(short mc, short ch, ref uint id);
///
/// 设置通道运动参数
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 加速度,取值范围:0.001~4000.0,单位:物理量纲,相当于m(Kdeg)/s^2,um(0.001deg)/ms^2
/// 起跳速度,取值范围:0.001~8000.0,单位:物理量纲,相当于mm(deg)/s, um(0.001deg)/ms
/// 截止速度,取值范围:0.001~8000.0,单位:物理量纲,相当于mm(deg)/s, um(0.001deg)/ms
/// 速度平滑时间,取值范围:0~65535, 单位:ms
/// 转角过渡时间,取值范围:0~65535,单位:ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChSetMoveParam(short mc, short ch, float acc, float str_vel, float end_vel, ushort smth = 0, ushort bldtm = 0);
///
/// 设置通道运动约束参数
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 最大速度,取值范围:0.001~8000.0,单位:物理量纲,相当于mm(deg)/s, um(0.001deg)/ms
/// 最大加速度,取值范围:0.001~4000.0,单位:物理量纲,相当于m(Kdeg)/s^2,um(0.001deg)/ms^2
/// 弓高误差,取值范围:0.001~100.0,单位:物理量纲,相当于mm(deg),默认值为1.0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChSetConstraints(short mc, short ch, float max_vel, float max_acc, float chord_err = 1.0f);
///
/// 设置通道的坐标
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 坐标数,取值范围:1~6
/// 通道的坐标与控制器的轴号的对应关系,最大6坐标
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChSetCoordinate(short mc, short ch, short num, short[] crd_map);
///
/// 读取通道的坐标
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 坐标数,取值范围:1~6
/// 通道的坐标与控制器的轴号的对应关系,最大6坐标
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetCoordinate(short mc, short ch, ref short num, short[] crd_map);
///
/// 设置坐标系的修调率
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 修调值,取值范围:0~200, 单位:%
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChSetOverride(short mc, short ch, short ovrd);
///
/// 读取通道的修调率
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// 修调值,单位:%
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetOverride(short mc, short ch, ref short ovrd);
///
/// 读取通道的M功能代码
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// M功能代码号
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChGetMCode(short mc, short ch, ref short code);
///
/// 设置通道的M功能代码的响应值
///
/// 控制器索引
/// 通道号,取值范围:0~3
/// M功能代码执行结束后,做出响应的代码
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChSetMCodeResponse(short mc, short ch, short code);
#endregion 通道操作
#region BLOCK(插补)命令缓冲区
///
/// BLOCK命令缓冲区复位
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BufferReset(short mc, short buff);
///
/// 设置BLOCK命令缓冲区属性
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// 缓冲区空间,取值范围:1~20000
/// 缓冲区模式,取值范围:0 - FIFO,1 - 循环队列(Round Robin),默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BufferSetParam(short mc, short buff, short size, short mode = 0);
///
/// 读取BLOCK命令缓冲区的空闲空间
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// 预缓冲区的空闲空间
/// 缓冲区的空闲空间
/// 成功返回0
/// 只要预缓冲区的空闲空间大于0,就可以调用BLOCK(插补)命令
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BufferGetSpace(short mc, short buff, ref short preb_free, ref short buff_free);
#endregion BLOCK(插补)命令缓冲区
#region BLOCK(插补)命令
///
/// BLOCK命令中的快速点位运动
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// 坐标系中的坐标位置数组,最多6个坐标,单位:物理量纲分辨率
/// 位掩码表示的通道中各坐标编程模式,取值范围:0-绝对坐标,1-相对坐标,默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockRapid(short mc, short buff, uint bid, int[] pos, ushort crdmode = 0);
///
/// BLOCK命令中的线性插补
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// 坐标系中的坐标位置数组,最多6个坐标,单位:物理量纲分辨率
/// 转角过渡模式,取值范围:0-减速至零停止,1-自动圆角过渡,2-起跳速度尖角过渡,3-截止速度尖角过渡,其它值-保留,默认值为0
/// 位掩码表示的通道中各坐标编程模式,取值范围:0-绝对坐标,1-相对坐标,默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockLinear(short mc, short buff, uint bid, int[] pos, short blend = 0, ushort crdmode = 0);
///
/// BLOCK命令中的任意平面圆弧插补
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// 圆弧终点坐标,单位:物理量纲分辨率
/// 圆弧的中间点坐标或中心坐标,单位:物理量纲分辨率
/// 圆弧表达方式,0 - 3点表达的圆弧,1 - 3点表达的整圆,2 - 圆心表达的顺时针圆弧或整圆,3 - 圆心表达的逆时针圆弧或整圆,默认值为0
/// 转角过渡模式,取值范围:0-减速至零停止,1-自动圆角过渡,2-起跳速度转角过渡,3-截止速度转角过渡,其它值-保留,默认值为0
/// 位掩码表示的通道中各坐标编程模式,取值范围:0-绝对坐标,1-相对坐标,默认值为0
/// 成功返回0
/// 3点方式的整圆表达时,终点与起点不能重合;3个坐标分别是通道坐标系中的前3个坐标
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockArc3(short mc, short buff, uint bid, int ep1, int ep2, int ep3, int mp1, int mp2, int mp3, short mode = 0, short blend = 0);
///
/// BLOCK命令中的坐标平面内圆弧插补
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// 圆弧终点坐标,单位:物理量纲分辨率
/// 中间点圆心坐标,单位:物理量纲分辨率
/// 两个坐标对应的通道坐标索引,默认值crd1=0,crd2=1
/// 圆弧表达方式,0 - 3点表达的圆弧,1 - 3点表达的整圆,2 - 圆心表达的顺时针圆弧或整圆,3 - 圆心表达的逆时针圆弧或整圆,默认值为0
/// 转角过渡模式,取值范围:0-减速至零停止,1-自动圆角过渡,2-起跳速度转角过渡,3-截止速度转角过渡,其它值-保留,默认值为0
/// 位掩码表示的通道中各坐标编程模式,取值范围:0-绝对坐标,1-相对坐标,默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockArc2(short mc, short buff, uint bid, int ep1, int ep2, int mp1, int mp2, short crd1 = 0, short crd2 = 1, short mode = 0, short blend = 0, short crdmode = 0);
///
/// BLOCK命令中的停留
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// 停留时间,取值范围:0~65535,单位:ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockDwell(short mc, short buff, uint bid, ushort tm);
///
/// BLOCK命令中的等待IO输入电平
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// IO控制器从站地址,取值范围:0~15,从站地址为0,表示运动控制器本地的IO;从站地址1~15,表示扩展的IO控制器
/// 站内输入位索引
/// 输入电平,取值范围:0 - 逻辑低,1 - 逻辑高
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockWait(short mc, short buff, uint bid, short node, short port, short level);
///
/// BLOCK命令中的数字IO输出
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// IO控制器从站,取值范围:0~15,从站地址为0,表示运动控制器本地的IO;从站地址1~15,表示扩展的IO控制器
/// 站内输出的位索引
/// 输出电平,取值范围:0-逻辑低,1-逻辑高
/// 输出持续时间,取值范围:-1~2^31,单位:us
/// 是否电平翻转,取值范围:0-不翻转,1-翻转
/// 翻转后持续时间,取值范围:-1~2^31,单位:us
/// 翻转计数,取值范围:1~2^31
/// 成功返回0
/// 持续时间取值为-1,表示永久时间
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockDOut(short mc, short buff, uint bid, short node, short index, short level, int qdelay, short toggle, int tdelay, int count);
///
/// BLOCK命令中的进给速度
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// 进给速度,取值范围:0.001~4000.0,单位:物理量纲,相当于mm/s,deg/s, um/ms, 0.001deg/ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockFeed(short mc, short buff, uint bid, float feed);
///
/// BLOCK命令中的M功能代码
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// M功能代码号,取值范围:0~32767
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockMCode(short mc, short buff, uint bid, short code);
///
/// BLOCK命令中的以方式A进行位置比较输出
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// 第一点或最后一点,取值范围:0 - 中间点;1 - 第一点;2 - 最后一点;3 - 只有一个点。默认值为0
/// 比较输出的矢量长度位置,单位:物理量纲分辨率
/// 输出端口,取值范围:0~15
/// 输出电平,取值范围:0-逻辑低,1-逻辑高
/// 位置源,取值范围:0-脉冲位置,1-编码器位置,默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockComparePosA(short mc, short buff, int pos, short port, short level, short firstorlast = 0, short possrc = 0);
///
/// BLOCK命令中的以方式B进行位置比较输出
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// 第一点或最后一点,取值范围:0 - 中间点;1 - 第一点;2 - 最后一点;3 - 只有一个点。默认值为0
/// 比较输出的矢量长度位置,单位:物理量纲分辨率
/// 输出端口,取值范围:0~15
/// 输出电平,取值范围:0-逻辑低,1-逻辑高
/// pwm输出方式时的周期时间,取值范围:1~2^31,单位:us
/// pwm输出方式时的前期时间,取值范围:1~2^31, 单位:us
/// pwm输出方式时的脉冲数,取值范围:1~2^31
/// 位置源,取值范围:0-脉冲位置,1-编码器位置,默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockComparePosB(short mc, short buff, short firstorlast, int pos, short port, short level, int pwmperiod, int pwmduty, int pwmcount, short possrc = 0);
///
/// BLOCK命令中的结束
///
/// 控制器索引
/// 缓冲区索引,取值范围:0~9
/// BLOCK命令的块号,无逻辑含义
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_BlockEnd(short mc, short buff, uint bid);
#endregion BLOCK(插补)命令
#endregion 插补运动
#region 位置锁存
///
/// 启动锁存功能
///
/// 控制器序号
/// 按位掩码的锁存单元选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_LatchBegin(short mc, uint units);
///
/// 结束锁存功能
///
/// 控制器序号
/// 按位掩码的锁存单元选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_LatchEnd(short mc, uint units);
///
/// 设置位置锁存的参数
///
/// 控制器索引
/// 锁存单元号,取值范围:0~7
/// 位置源,1-编码器位置,0-命令位置。
/// 位置源的轴号,取值范围:控制器支持的轴号
/// 触发信号源,取值范围:
/// 0-编码器Z相信号
/// 1-零点开关
/// 2-通用输入
/// 3-位置比较输出
///
/// 触发边沿:0-上升沿,1-下降沿,2-上升下降沿
/// 触发信号源的索引,取值范围:控制器支持的轴号或输入
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLatchParam(short mc, short unit, short src, short axis, short trigger, short edge, short index);
///
/// 读取轴的锁存的位置
///
/// 控制器索引
/// 锁存单元号,取值范围:0~7
/// 锁存位置数组,其大小取决于用户,锁存的最大位值数256
/// 本次锁存过程中,已锁存的位置数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetLatchPos(short mc, short unit, int[] pos, ref short numofcapt);
///
/// 读取轴的已锁存的位置个数
///
/// 控制器索引
/// 锁存单元号,取值范围:0~7
/// 已捕捉的位置个数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetLatchNum(short mc, short unit, ref short numofcapt);
#endregion 位置锁存
#region 位置比较
///
/// 启动位置比较功能
///
/// 控制器索引
/// 按位掩码的比较单元选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_CompareBegin(short mc, uint units);
///
/// 结束位置比较功能
///
/// 控制器索引
/// 按位掩码的比较单元选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_CompareEnd(short mc, uint units);
///
/// 设置位置比较的参数
///
/// 控制器索引
/// 比较单元号,取值范围:0~7
/// 位置源,0-命令位置,1-编码器位置
/// 位置源的轴号,取值范围:控制器支持的轴号
/// 比较输出端口选择,取值范围:0~15
/// 比较输出端口极性,1-正逻辑,上升沿;0-负逻辑,下降沿
/// 比较输出端口使能,1-比较输出,0-通用输出
/// 比较输出的宽度,取值范围:1~2^32,单位:us
/// 成功返回0
/// 位置比较单元可以关联不同的轴号
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetCompareParam(short mc, short unit, short src, short axis, short portbit, short portpol, short porten, uint width);
///
/// 设置比较的位置
///
/// 控制器索引
/// 比较单元选择,取值范围:0~7
/// 比较的位置数据数组
/// 比较位置的个数,取值范围:1~256
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetComparePos(short mc, short unit, int[] pos, short numtocmpr);
///
/// 读取轴的已完成的比较位置的个数
///
/// 控制器索引
/// 比较单元号,取值范围:0~7
/// 返回已完成比较位置的个数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetCompareNum(short mc, short unit, ref short numofcmpr);
#endregion 位置比较
#region 在线更改位置和速度
///
/// 在线更改位置
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 绝对位置,单位:p或物理量纲分辨率,取值范围:+/-2^31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChangeFlyPos(short mc, short axis, int pos);
///
/// 在线更改速度
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 速度,单位:p(或物理量纲分辨率)/ms,取值范围:0.001~8000.0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ChangeSpeedOnTheFly(short mc, short axis, float vel);
#endregion 在线更改位置和速度
#region 属性设置
///
/// 报警清除
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 复位信号,1-设置复位,0-关闭复位
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ResetAlarm(short mc, short axis, short on);
///
/// 伺服激活
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 伺服激活,1-激活,0-失效
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetServoOn(short mc, short axis, short on);
///
/// 配置EMG
///
/// 控制器索引
/// EMG使能,0-无效,仅作为通用输入
/// EMG的极性,0-正极性,1-负极性
/// EMG端口,取值范围:-1 - EMG专用端口,0~15 - 通用输入口0~15
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetEMGConfig(short mc, short en, short pol, short port = -1);
///
/// 设置零点开关极性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 零点开关极性,1-正,0-负
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetHomePol(short mc, short axis, short pol);
///
/// 设置正向限位开关有效性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 开关,1-开,0-关
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPOTOn(short mc, short axis, short on);
///
/// 设置负向限位开关有效性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 开关,1-开,0-关
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetNOTOn(short mc, short axis, short on);
///
/// 设置正向限位开关极性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 极性,1-正,0-负
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPOTPol(short mc, short axis, short pol);
///
/// 设置负向限位开关极性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 极性,1-正,0-负
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetNOTPol(short mc, short axis, short pol);
///
/// 设置编码器有效性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 有效性,1-有效,0-无效
/// 轴的脉冲当量是否无效,1-脉冲当量无效,0-脉冲当量有效
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetEncoderOn(short mc, short axis, short on, short peq_invalid = 0);
///
/// 设置编码器的计数极性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 极性,1-正,0-负
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetEncoderPol(short mc, short axis, short pol);
///
/// 设置编码器索引信号极性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 极性,1-正,0-负
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetEncoderIndexPol(short mc, short axis, short pol);
///
/// 设置报警信号有效性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 有效性,1-有效,0-无效
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetAlarmOn(short mc, short axis, short on);
///
/// 设置报警信号的极性
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 极性,1-正,0-负
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetAlarmPol(short mc, short axis, short pol);
///
/// 设置脉冲输出方式
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 模式,1-CCW+CW,0-PULSE+DIR
/// 边沿,0-上升沿,1-下降沿,默认值为0
/// 脉冲方向的极性,1-正极性,0-负极性,默认值为0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPulseMode(short mc, short axis, short mode, short edge = 0, short dirpol = 0);
///
/// 设置轴位移是按模数运动
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 是否按位移模数运动,1-按模数位移,0-按广义直线位移
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetModular(short mc, short axis, short mod);
///
/// 设置电子齿轮比
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 主动轮齿数,取值范围:1~2^32
/// 从动轮齿数,取值范围:1~2^32
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetGearRatio(short mc, short axis, uint master, uint slave);
///
/// 设置轴的脉冲当量
///
/// 控制器索引
/// 轴号,取值范围:控制器支持的轴号
/// 脉冲数,单位:p,取值范围:1~2^32
/// 位移,单位:物理量纲分辨率,取值范围:1~2^32
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPulseRatio(short mc, short axis, uint pulse, uint disp);
///
/// 设置辅助编码器的脉冲当量
///
/// 控制器索引
/// 辅助编码器索引,取值范围:0,1
/// 脉冲数,单位:p,取值范围:1~2^32
/// 位移,单位:物理量纲分辨率,取值范围:1~2^32
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetPulseRatioAux(short mc, short auxenc, uint pulse, uint disp);
#endregion 属性设置
#region 电子齿轮操作
///
/// 设置电子齿轮的属性
///
/// 控制器索引
/// 从动轴号,取值范围:控制器支持的轴号
/// 主动轴号,取值范围:控制器支持的轴号
/// 跟随方向,取值范围:0 - 同向,1 - 反向
/// 跟随位置源,取值范围:0 - 命令位置,1 - 实际位置
/// 电子齿轮跟随模式,取值范围:0 - 位置跟随,1 - 速度跟随
/// 飞行改变齿轮比的平滑过渡距离
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_EGearSetParam(short mc, short slave, short master, short dir, short possrc, short mode, int trans);
///
/// 启用电子齿轮
///
/// 控制器索引
/// 按位掩码表示的从动轴的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_EGearStart(short mc, uint axes);
///
/// 停止电子齿轮
///
/// 控制器索引
/// 按位掩码表示的从动轴的轴选择
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_EGearStop(short mc, uint axes);
///
/// 读取各轴的电子齿轮激活状态
///
/// 控制器索引
/// 按位掩码表示的各轴电子齿轮生效状态,各位含义:0-失效,1-激活
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_EGearGetStatus(short mc, ref uint stat);
#endregion 电子齿轮操作
#region 驱控一体A型
/****************************************************************************************
* @Begin 驱控一体A型
****************************************************************************************/
///
/// 驱控一体A型参数设置
///
/// 控制器索引
/// 轴号,取值范围:0~7,共8个轴
/// 细分,取值范围:1,2,4,8,16,32,64,128,256
/// 电流,取值范围:100~3200mA,间隔100mA
/// 堵转扭矩,取值范围:0%~100%
/// 工作模式,取值范围:0-位置模式,2-力矩模式
/// 空载扭矩参考值,取值范围:1~1000,无量纲,默认值为400
/// 扭矩检测灵敏度,取值范围:-10~63, 无量纲,默认值为10
/// 成功返回0
/// 当轴工作在力矩模式时,遇到堵转信号,轴就自动停止脉冲信号。其它模式下,遇到堵转信号,轴继续发送脉冲信号。
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetDCIAParam(short mc, short axis, short resolution, short current, short torque, short mode = 0, short noload = 400, short sgt = 10);
/**
* @brief 驱控一体A型状态
* @param mc: 控制器索引
* axis: 轴号,取值范围:0~7,共8个轴
* sg_flag: 堵转的保持标志,范围:0 - 无堵转,1 - 已堵转
* sg: 堵转的实时状态,范围:0 - 无堵转,1 - 已堵转
* sg_value: 实时力矩,范围:0 ~ 100%
* @return 成功返回0
* @remark 只有在轴运动停止时,查询的堵转的保持标志才有效。有P2P或Jog命令时,此标志自动清除。
*/
///
/// 驱控一体A型状态
///
/// 控制器索引
/// 轴号,取值范围:0~7,共8个轴
/// 堵转的保持标志,范围:0 - 无堵转,1 - 已堵转
/// 堵转的实时状态,范围:0 - 无堵转,1 - 已堵转
/// 实时力矩,范围:0 ~ 100%
/// 成功返回0
/// 只有在轴运动停止时,查询的堵转的保持标志才有效。有P2P或Jog命令时,此标志自动清除。
//[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
//public static extern short ZT_GetDCIAStatus(short mc, short axis, short* sg_flag, short* sg, short* sg_value);
/****************************************************************************************
* @End 驱控一体A型
****************************************************************************************/
#endregion 驱控一体A型
#region IO操作
///
/// 设置IO站的配置信息
///
/// 控制器索引
/// 站地址,取值范围:0-控制器本地,1~15:扩展站点
/// 站点IO类型,取值范围:0-数字IO,其它值-预留/param>
/// 站点的输入字节数
/// 站点输出字节数
/// 站点有效性,取值范围:1-本站点有效,0-本站点无效,默认值为1
///
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetIOConfig(short mc, short node, short type, short bytesofin, short bytesofout, short valid = 1);
///
/// 读取IO站的配置状态
///
/// 控制器索引
/// 站地址,取值范围:0-控制器本地,1~15:扩展站点
/// 站点IO类型,取值范围:0-数字IO,其它值-预留/param>
/// 站点的输入字节数
/// 站点输出字节数
/// 站点的配置状态,值含义:-1 - 站通讯超时;0 - 无效站点;1 - 站通讯正常
///
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetIOConfig(short mc, short node, ref short type, ref short bytesofin, ref short bytesofout, ref short stat);
///
/// 保存IO站的配置信息
///
/// 控制器索引
/// 成功返回
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SaveIOConfig(short mc);
///
/// 恢复出厂配置信息
///
/// 控制器索引
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ResetIOConfig(short mc);
///
/// 启动当前配置
///
/// 控制器索引
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_StartIOConfig(short mc);
///
/// 设置输出的位的状态
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口位索引
/// 输出值,取值范围:0,1
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetOutBit(short mc, short node, short index, ushort data);
///
/// 按位翻转输出的端口状态
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口位索引
/// 输出值,取值范围:0,1
/// 延时输出时间,取值范围:0~65535,单位:ms
/// 延时翻转时间,取值范围:0~65535,单位:ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ToggleOutBit(short mc, short node, short index, ushort data, ushort delay_time = 0, ushort toggle_time = 0);
///
/// 设置输出的字节的状态
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口的字节索引
/// 输出值,取值:0~0xFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetOutByte(short mc, short node, short index, ushort data);
///
/// 设置输出的字的状态
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口的字索引
/// 输出值,取值:0~0xFFFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetOutWord(short mc, short node, short index, ushort data);
///
/// 设置输出的双字的状态
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口的双字索引
/// 输出值,取值:0~0xFFFFFFFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetOutDWord(short mc, short node, short index, uint data);
///
/// 按位读取输出
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口的位索引
/// 端口状态值,返回值:0,1
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetOutBit(short mc, short node, short index, ref ushort data);
///
/// 按字节读取输出
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口的字节索引
/// 端口状态值,返回值:0~0xFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetOutByte(short mc, short node, short index, ref ushort data);
///
/// 按字读取输出
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内的输出端口的字索引
/// 端口状态值,返回值:0~0xFFFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetOutWord(short mc, short node, short index, ref ushort data);
///
/// 按双字读取输出
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 端口状态值双字索引
/// 端口状态值,返回值:0~0xFFFFFFFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetOutDWord(short mc, short node, short index, ref uint data);
///
/// 按位读取输入
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内输入端口的位索引
/// 端口状态值,返回值:0,1
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetInBit(short mc, short node, short index, ref ushort data);
///
/// 按字节读取输入
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内输入端口的字节索引
/// 端口状态值,返回值:0,1
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetInByte(short mc, short node, short index, ref ushort data);
///
/// 按字读取输入
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内输入端口的字索引
/// 端口状态值,返回值:0~0xFFFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetInWord(short mc, short node, short index, ref ushort data);
///
/// 按双字读取输入
///
/// 控制器索引
/// 站地址,取值范围:0~15
/// 本站内输入端口的双字索引
/// 端口状态值,返回值:0~0xFFFFFFFF
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetInDWord(short mc, short node, short index, ref uint data);
///
/// 读取EMG的状态
///
/// 控制器索引
/// 所选择的急停端口的电平
/// 急停的作用状态,0-无效,1-有效
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetEMG(short mc, ref short level, ref short status);
#endregion IO操作
#region 状态操作
///
/// 读取各轴正向超程开关状态
///
/// 控制器索引
/// 按位掩码表示的正向超程开关状态
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetPOT(short mc, ref uint POT);
///
/// 读取各轴负向超程开关状态
///
/// 控制器索引
/// 按位掩码表示的负向超程开关状态
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetNOT(short mc, ref uint NOT);
///
/// 读取各轴的零点开关状态
///
/// 控制器索引
/// 按位掩码表示的各轴零点开关状态
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetHome(short mc, ref uint home);
///
/// 读取各轴的正在运行状态
///
/// 控制器索引
/// 按位掩码表示的各轴运行状态,各位含义:1-运行中,0-停止
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetRunning(short mc, ref uint running);
///
/// 读取各轴运动到位状态
///
/// 控制器索引
/// 按位掩码表示的运动到位标志,各位含义:1-到位,0-未到位
/// 成功返回0
/// 此标志反映的是伺服驱动器输出的到位信号
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetReached(short mc, ref uint reached);
///
/// 读取各轴正在回零过程的状态
///
/// 控制器索引
/// 按位掩码表示的各轴正在回零状态,1-正在回零过程,0-未在回零过程
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetHoming(short mc, ref uint homing);
///
/// 读取各轴已完成回零的状态
///
/// 控制器索引
/// 按位掩码表示的各轴已完成回零的状态,1-已完成回零,0-未完成回零
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetHomed(short mc, ref uint homed);
///
/// 读取各轴电机报警信号状态
///
/// 控制器索引
/// 按位掩码表示的电机报警状态,1-已报警,0-未报警
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetAlarm(short mc, ref uint alm);
///
/// 读取各轴正向软限位标志
///
/// 控制器索引
/// 按位掩码表示的各轴正向软限位标志,1-处于正向软限位,0-未处于正向软限位
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetPSLFlag(short mc, ref uint psl);
///
/// 读取各轴负向软限位标志
///
/// 控制器索引
/// 按位掩码表示的各轴负向软限位标志,1-处于负向软限位,0-未处于负向软限位
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetNSLFlag(short mc, ref uint nsl);
///
/// 读取各轴伺服激活状态
///
/// 控制器索引
/// 按位掩码表示的各轴伺服激活状态,各位含义:1-使能,0-未使能
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetServoStatus(short mc, ref uint status);
#endregion 状态操作
#region 大数据传送状态检测
///
/// 大数据传送的一次往返循环是否结束
///
/// 控制器索引
/// 0:一次传送结束,1:一次传送未结束
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetHugeDataBusy(short mc);
///
/// 大数据传送的一次往返循环是否成功
///
/// 控制器索引
/// 0:成功,非0:错误
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetHugeDataError(short mc);
#endregion 大数据传送状态检测
#region 文件操作
///
/// 读取文件状态
///
/// 控制器索引
/// 文件索引,取值范围:
/// 文件状态,各位的含义:
/// bit0 - 文件打开标志,1:文件已打开,0:文件未打开
/// bit1 - 文件传送标志,1:文件正在传送,0:文件停止传送
/// bit2 - 文件头标志,1:文件头
/// bit3 - 文件尾标志,1:文件尾
/// bit4 - 保留
/// bit5 - 保留
/// bit6 - 文件错误标志,1:文件错误,0:文件正确
/// bit7 - 保留
/// bit8~15 - 保留
///
/// 已传送的字节数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_FileGetStatus(short mc, short index, ref ushort status, ref int bytesofrw);
///
/// 打开读写文件
///
/// 控制器索引
/// 文件索引,取值范围:
/// 文件缓冲区
/// 需要传送的字节数
/// 访问方式,取值范围:0(读) - 从控制器传送到服务,1(写)- 从服务传送到控制器
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_FileOpen(short mc, short index, char[] buf, int bytestorw, short access);
///
/// 文件传送启动
///
/// 控制器索引
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_FileRW(short mc);
///
/// 关闭读写文件
///
/// 控制器索引
/// 文件索引,取值范围:
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_FileClose(short mc, short index);
#endregion 文件操作
#region 串口通讯
///
/// 设置串口通讯的参数
///
/// 控制器索引
/// 串口索引,0-RS485,1-RS232A,2-RS232B
/// 串口波特率,2400,4800,9600,19200,38400,57600,115200,等
/// 串口数据位数,5,6,7,8
/// 串口数据停止位数,1,2
/// 串口数据奇偶校验,0-无校验,1-奇校验,2-偶校验
/// 串口工作模式,0-自由协议模式,1-Modebus RTU Slave,2-Modbus RTU Master,15-单指令运动命令
/// 串口通讯超时设定,0~65535
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetComParam(short mc, short com, int baud, short databits, short stopbits, short parity, short mode, ushort timeout);
///
/// 串口通讯中数据交换的字节读
///
/// 控制器索引
/// 需要读取的数据交换区的字节地址,范围:0~63
/// 需要读取的字节数
/// 用户声明的数据缓冲区
/// 已读取的字节数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetComDataByte(short mc, short bptr, short numtoread, short[] data, ref short numofread);
///
/// 串口通讯中数据交换的字读
///
/// 控制器索引
/// 需要读取的数据交换区的字地址,范围:0~31
/// 需要读取的字数
/// 用户声明的数据缓冲区
/// 已读取的字数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetComDataWord(short mc, short wptr, short numtoread, ushort[] data, ref short numofread);
///
/// 串口通讯中数据交换的双字读
///
/// 控制器索引
/// 需要读取的数据交换区的双字地址,范围:0~15
/// 需要读取的双字数
/// 用户声明的数据缓冲区
/// 已读取的双字数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetComDataDWord(short mc, short dwptr, short numtoread, uint[] data, ref short numofread);
///
/// 串口通讯中数据交换的浮点数读
///
/// 控制器索引
/// 需要读取的数据交换区的浮点数地址,范围:0~15
/// 需要读取的浮点数的数量
/// 用户声明的数据缓冲区
/// 已读取的浮点数的数量
///
///
///
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetComDataFloat(short mc, short fptr, short numtoread, float[] data, ref short numofread);
///
/// 串口通讯数据交换的字节写
///
/// 控制器索引
/// 需要写的数据交换区的字节地址,范围:0~63
/// 需要写的字节数
/// 用户声明的数据缓冲区
/// 已写的字节数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetComDataByte(short mc, short bptr, short numtowrite, short[] data, ref short numofwritten);
///
/// 串口通讯数据交换的字写
///
/// 控制器索引
/// 需要写的数据交换区的字地址,范围:0~31
/// 需要写的字数
/// 用户声明的数据缓冲区
/// 已写的字数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetComDataWord(short mc, short wptr, short numtowrite, ushort[] data, ref short numofwritten);
///
/// 串口通讯数据交换的双字写
///
/// 控制器索引
/// 需要写的数据交换区的双字地址,范围:0~15
/// 需要写的双字数
/// 用户声明的数据缓冲区
/// 已写的双字数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetComDataDWord(short mc, short dwptr, short numtowrite, uint[] data, ref short numofwritten);
///
/// 串口通讯数据交换的浮点数写
///
/// 控制器索引
/// 需要写的数据交换区的浮点数地址,范围:0~15
/// 需要写的浮点数的数量
/// 用户声明的数据缓冲区
/// 已写的浮点数的数量
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetComDataFloat(short mc, short fptr, short numtowrite, float[] data, ref short numofwritten);
///
/// Modbus寄存器(16bit)读命令
///
/// 控制器索引
/// 串口索引,0-RS485, 1-RS232A,2-RS232B
/// 从站地址
/// 寄存器起始地址
/// 寄存器数量
/// 数据交换区索引,范围:0~31字
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ModbusReadReg(short mc, short com, short addr, ushort reg, ushort num, short wptr);
///
/// Modbus寄存器(16bit)写命令
///
/// 控制器索引
/// 串口索引,0-RS485, 1-RS232A,2-RS232B
/// 从站地址
/// 寄存器起始地址
/// 寄存器数量
/// 数据交换区字索引,范围:0~31
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ModbusWriteReg(short mc, short com, short addr, ushort reg, ushort num, short wptr);
///
/// 启动串口通讯
///
/// 控制器索引
/// 串口索引,0-RS485, 1-RS232A,2-RS232B
/// 0-连续通讯方式,1-单次通讯方式
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ComStart(short mc, short com, short oneshot);
///
/// 停止串口通讯
///
/// 控制器索引
/// 串口索引,0-RS485, 1-RS232A,2-RS232B
/// 成功返回0
///
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_ComStop(short mc, short com);
///
/// 读串口通讯状态
///
/// 控制器索引
/// 串口索引,0-RS485,1-RS232A,2-RS232B
/// 串口通讯状态,状态值含义,
/// bit 0 - 串口运行状态,0:空闲,1:正在通讯
/// bit 1 -
/// bit 2 -
/// bit 3 - modbus校验错误,0:无错,1:CRC错误
/// bit 4 -
/// bit 5 -
/// bit 6 -
/// bit 7 - 串口通讯超时,0:无超时,1:超时
///
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetComStatus(short mc, short com, ref short stat);
#endregion 串口通讯
#region 锁附指令
///
/// 设置锁附轴号
///
/// 控制器索引
/// 锁附任务索引
/// R轴轴号
/// 光栅轴号
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairAxis(short mc, short index, short r_axis, short enc_axis);
///
/// 设置锁附速度
///
/// 控制器索引
/// 锁附任务索引
/// 锁附高速,单位p/ms,取值范围:0.001~8000.0
/// 锁附低速,单位p/ms,取值范围:0.001~8000.0
/// 锁附减速度,单位p/ms^2,取值范围:0.001~4000.0
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairVel(short mc, short index, float hivel, float lovel, float dec);
///
/// 设置锁附高度
///
/// 控制器索引
/// 锁附任务索引
/// 锁附高度,绝对高度,单位p
/// 对位高度,相对高度,单位p
/// 后段采集扭力高度,相对高度,单位p
/// 低速锁的起始高度,相对高度,单位p
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairHeight(short mc, short index, int lock_h, int align_h, int trqsamp_h, int lower_h);
///
/// 设置锁附高度偏差
///
/// 控制器索引
/// 锁附任务索引
/// 锁附高度上偏差,单位p
/// 锁附高度下偏差,单位p
/// 对位高度上偏差,单位p
/// 对位高度下偏差,单位p
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairHeightDeviation(short mc, short index, int lock_es, int lock_ei, int align_es, int align_ei);
///
/// 设置锁附扭力限制
///
/// 控制器索引
/// 锁附任务索引
/// 扭力通道
/// 扭力上限
/// 扭力下限
/// 是否启用扭力检测,取值:1-启用,0-不启用
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairTrq(short mc, short index, short ch, int upper, int lower, short ischecking);
///
/// 设置R轴反转角度
///
/// 控制器索引
/// 锁附任务索引
/// 锁附后反转角度,单位p
/// 对位前反转角度,单位p
/// 是否启用锁附后反转
/// 是否启用对位前反转
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairReverse(short mc, short index, int rev_aft_lock, int rev_bfr_align, int is_rev_aft_lock, int is_rev_bfr_align);
///
/// 设置锁附延时
///
/// 控制器索引
/// 锁附任务索引
/// 锁附反转停止后延时,单位ms
/// 对位反转停止后延时,单位ms
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairDelay(short mc, short index, int dly_aft_lockrev, int dly_aft_alignrev);
///
/// 设置锁附R轴旋转约束圈数
///
/// 控制器索引
/// 锁附任务索引
/// 高速锁附旋转圈数约束,单位p
/// 低速锁附旋转圈数约束,单位p
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairRestrictRev(short mc, short index, int hivel_rev, int lovel_rev);
///
/// 设置锁附Z轴参数
///
/// 控制器索引
/// 锁附任务索引
/// Z轴是否有效,1-有效,0-无效
/// Z轴轴号
/// Z轴高速,单位:p/ms
/// Z轴低速,单位:p/ms
/// Z轴减速度,单位:p/ms^2
/// Z轴减速高度,单位:p
/// Z轴触发R轴回转的高度,单位:p
/// Z轴锁附高度
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetLockPairZ(short mc, short index, short is_z_valid, short z_axis, float hivel, float lovel, float dec, int dec_h, int r_rev_h, int lock_h);
///
/// 启动锁附
///
/// 控制器索引
/// 锁附任务索引
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_LockPairStart(short mc, short index);
///
/// 停止锁附
///
/// 控制器索引
/// 锁附任务索引
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_LockPairStop(short mc, short index);
///
/// 读取锁附过程状态
///
/// 控制器索引
/// 锁附任务索引
/// 按位掩码表示的各锁附任务的过程状态,0-空闲状态,1-正在锁附。
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetLockPairRunning(short mc, ref uint running);
///
///
///
/// 控制器索引
/// 锁附任务索引
/// 锁附过程结果
/// 锁附完成的高度
/// 锁附完成的扭力
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetLockPairResult(short mc, short index, ref int res, ref int height, ref int trq);
#endregion 锁附指令
#region 系统信息指令
///
/// 读取控制器的控制周期计数
///
/// 控制器索引
/// 控制周期计数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetMcTicks(short mc, ref uint ticks);
///
/// 读取控制器的特性参数
///
/// 控制器索引
/// 控制周期,单位:ns
/// 控制器的最大轴数
/// 控制器的最大通道数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetMcProperty(short mc, ref uint period, ref short axis_num, ref short ch_max);
///
/// 读取控制器的接口资源
///
/// 控制器索引
/// 数字输入端口数
/// 数字输出端口数
/// 模拟输入端口数
/// 模拟输出端口数
/// 脉冲输入端口数
/// 脉冲输出端口数
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetMcIOResource(short mc, ref short di_num, ref short do_num, ref short ai_num, ref short ao_num, ref short pi_num, ref short po_num);
///
/// 读取控制器的型号
///
/// 控制器索引
/// 控制器型号
/// 控制器功能类型
/// 版本号
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetMcModel(short mc, ref short model, ref short type, ref ushort ver);
///
/// 读取控制器的型号
///
/// 控制器索引
/// 控制器型号
/// 控制器功能类型
/// 版本号
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetMcVersion(short mc, ref uint arm_ver, ref uint fpga_ver, ref uint service_ver);
///
/// 设置控制器时钟
///
/// 控制器索引
/// 年
/// 月
/// 日
/// 星期
/// 小时
/// 分
/// 秒
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_SetRTC(short mc, short year, short month, short mday, short wday, short hour, short min, short sec);
///
/// 读取控制器时钟
///
/// 控制器索引
/// 年
/// 月
/// 日
/// 星期
/// 小时
/// 分
/// 秒
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetRTC(short mc, ref short year, ref short month, ref short mday, ref short wday, ref short hour, ref short min, ref short sec);
///
/// 读取控制器动态握手周期
///
/// 控制器索引
/// 握手间隔,单位:us
/// 成功返回0
[DllImport("RS.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern short ZT_GetHandshakeSpan(short mc, ref int span);
#endregion 系统信息指令
#endregion 函数接口
}
}