using SKMC.Api.Motion.Model; using System.Text; namespace SKMC.Api.Motion.Driver { /// /// 运动控制卡基础控制接口 /// public interface IMotionDriver { /// /// 运动控制数据解析器接口 /// IMotionDriverParser MotionDriverParser { get; set; } /// /// 获取型号 /// /// string GetModelCode(); /// /// 初始化控制卡 /// void InitBoard(); /// /// 获取硬件句柄 /// /// ulong GetHandler(); /// /// 关闭控制卡 /// void CloseBoard(); /// /// 检测控制卡状态 /// /// bool CheckHealth(); /// /// 复位控制卡 /// void ResetBoard(); /// /// 获取控制卡Ethercat总线状态 /// /// 0为正常, 其他为异常 int GetEcatStatus(); /// /// 获取控制卡Ethercat总线错误码 /// /// 0为正常, 其他为错误码 int GetEcatErrorCode(); /// /// 获取Ethercat总线上的电机数量 /// /// 电机数量 int GetAxisNum(); /// /// 获取Ethercat总线上的IO输入数量 /// /// IO输入数量 int GetDiNum(); /// /// 获取Ethercat总线上的IO输出数量 /// /// IO输出数量 int GetDoNum(); /// /// 获取Ethercat总线上的AD输入数量 /// /// AD输入数量 int GetAdNum(); /// /// 获取Ethercat总线上的DA输出数量 /// /// DA输出数量 int GetDaNum(); /// /// 电机是否使能状态 /// /// 电机轴号 /// 是否使能状态 bool IsAxisEnable(short axisNo); /// /// 获取电机状态值 /// /// 电机轴号 /// 状态数值 void GetAxisStatus(short axisNo, ref int status); /// /// 获取多个电机状态值 /// /// /// void GetMultiAxisStatus(short count, ref int[] statusArr); /// /// 电机上使能 /// /// 电机轴号 void AxisEnable(short axisNo); /// /// 电机下使能 /// /// 电机轴号 void AxisDisable(short axisNo); /// /// 电机上使能或下使能 /// /// 电机轴号 /// true为上使能, false为下使能 void AxisEnabled(short axisNo, bool enabled); /// /// 设置运动参数(轴状态为到位isDone时生效) /// /// 电机轴号 /// 运动参数 void SetMoveProfile(short axisNo, AxisMoveParma moveParam); /// /// 更新绝对运动/相对运动时运动参数(轴状态为忙碌isBusy时生效) /// /// 电机轴号 /// 运动参数 void UpdateMoveTargetProfile(short axisNo, AxisMoveParma moveParam); /// /// 更新持续运动/Jog运动时运动参数(轴状态为忙碌isBusy时生效) /// /// 电机轴号 /// 运动参数 void UpdateMoveKeepProfile(short axisNo, AxisMoveParma moveParam); /// /// 相对运动 /// /// 电机轴号 /// 运动方向 /// 运行步距 /// 命令返回码 short MoveRel(short axisNo, ushort direction, double dist); /// /// 绝对运动 /// /// 电机轴号 /// 运动方向 /// 运行步距 /// 命令返回码 short MoveAbs(short axisNo, ushort direction, double dist); /// /// 中途更换目标位置 /// /// 电机轴号 /// /// /// 命令返回码 short MoveAbsUpdate(short axisNo, ushort direction, double dist); /// /// 持续运动 /// /// 电机轴号 /// /// /// 命令返回码 short MoveKeep(short axisNo, double vel, ushort direction); /// /// 停止运动(减速停止) /// /// 电机轴号 /// 命令返回码 short MoveStop(short axisNo); /// /// 暂停运动 /// /// 电机轴号 /// 命令返回码 short MovePause(short axisNo); /// /// 恢复运动 /// /// 电机轴号 /// 命令返回码 short MoveResume(short axisNo); /// /// 回零运动 /// /// 电机轴号 /// /// 命令返回码 short Home(short axisNo, AxisHomeParam homeParam); /// /// 获取回零状态 /// /// /// 0: 回零成功, 1: 回零中, 2: 回零异常 short GetHomeStatus(short axisNo); /// /// 退出回零运动 /// /// /// short EndHome(short axisNo); /// /// 获取编码器反馈值 /// /// 电机轴号 /// 反馈值 double GetEncPos(short axisNo); /// /// 获取运动目标值 /// /// 电机轴号 /// 目标值 double GetPrfPos(short axisNo); /// /// 设置当前编码器位置(慎用) /// 注意: 调用该方法时需要确认电机上使能并且是静止状态 /// 绝对值编码器不推荐使用 /// /// 电机轴号 /// 编码器位置 /// short SetEncPos(short axisNo, double encPos); /// /// 急停 /// /// 电机轴号 /// 命令返回码 short EmgStop(short axisNo); /// /// 清除反馈值及目标值 /// /// 电机轴号 void ClearCounter(short axisNo); /// /// 清除报错(是否有效取决于具体错误) /// /// 电机轴号 void ClearError(short axisNo); /// /// 获取一个DI点位数值 /// /// DI序号 /// 数值 byte GetDnoDi(short dno); /// /// 获取一个DI逻辑组中的数值集 /// /// /// 数值集 short GetGrpDi(short grpno); /// /// 获取多个DI包的数值集合, 每个包有16位数据 /// /// /// /// ushort[] GetPackDi(short packIndex, short packCnt); /// /// 获取一个DO点位数值 /// /// DO序号 /// 数值 byte GetDnoDo(short dno); /// /// 获取一个DO逻辑组中的数值集 /// /// /// 数值集 short GetGrpDo(short grpno); /// /// 获取多个DO包的数值集合, 每个包有16位数据 /// /// /// /// ushort[] GetPackDo(short packIndex, short packCnt); /// /// 设置一个DO点位数值 /// /// DO序号 /// /// 命令返回码 short SetDnoDo(short dno, short value); /// /// 获取一个AD点位数值 /// /// DO序号 /// 数值 short GetDnoAd(short dno); /// /// 批量获取多个AD点位数值 /// /// /// /// short[] GetGrpAd(short adIndex, short adCnt); /// /// 写入SDO数据 /// /// Sdo对象 /// 命令返回码 short WriteSdoData(MotionSdo motionSdo); /// /// 写入SDO数据 /// /// Sdo对象 /// 读取的SDO数据长度 int ReadSdoData(MotionSdo motionSdo); /// /// 初始化Pdo配置 /// /// short GetPdoConfig(); /// /// 写入PDO数据 /// /// Pdo对象 /// short WritePdoData(MotionPdo motionPdo); /// /// 读取Pdo数据 /// /// Pdo对象 /// 读取的PDO数据长度 int ReadPdoData(MotionPdo motionPdo); uint WriteUserCode(string data); uint CheckUserCode(string data); uint WriteUserData(string data); uint ReadUserData(ref StringBuilder dataBuilder, short len); } }