using Community; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model.MotionControl { /// /// 雷赛运动控制卡 /// public class LeiSaiCard : FeiYuCard { /// /// 返回模拟量 /// /// /// /// /// /// /// /// public string GetAD(ushort card, ushort chan, double aVal_Low, double aVal_High, double dVal_Low, double dVal_High) { //实际输出模拟量-最低输出模拟值底数=实际模拟输出 double adVal = LTSMC.smc_get_ain(card, chan) - aVal_Low; //最大模拟上限-最小模拟下限=有效模拟区间 double atemp = aVal_High - aVal_Low; //实际模拟输出/有效模拟区间=模拟输出指数坐标比例 double vtemp = adVal / atemp; //实模拟输出指数坐标比例*(最大数字上限-最小数字下限)=实际输出数字值 double dTemp = vtemp * (dVal_High - dVal_Low); return dTemp.ToString("f3"); } public double Get_ain(ushort channel) { //实际输出模拟量-最低输出模拟值底数=实际模拟输出 return LTSMC.smc_get_ain(this.CardID, channel); } #region 获取轴数量 /// /// 获取轴数量 /// public override bool GetCradInfo() { try { //获取卡轴数 if (InterfaceType == 0) { uint axisNumber = 0; LTDMC.dmc_get_total_axes(this.CardID, ref axisNumber); this.TotalAxis = axisNumber; } else { uint a = 0; LTSMC.smc_get_total_axes(CardID, ref a); this.TotalAxis = a; } if (this.TotalAxis < 1 || TotalAxis > 8) { return false; } else { return true; } } catch (Exception) { return false; } } #endregion #region 连接控制器 /// /// 连接控制器 /// /// public override bool Connect() { try { if (InterfaceType == 0) { int num = LTDMC.dmc_board_init(); //初始化控制卡 if (num < 1 || num > 8) { CardID = 100; return true; } else { CardID = 0; return false; } } else { short a = LTSMC.smc_board_init(CardID, this.InterfaceType, this.PconnectString, this.Baud); if (a == 0) { if (ShaftList != null) { foreach (FeiYuShaft sf in ShaftList) { //sf.CardID = this.CardID; sf.Initialize(); } } return true; } else { return false; } } } catch (Exception) { return false; } } #endregion #region 关闭控制器 /// /// 关闭控制器 /// public override void close() { if (InterfaceType == 0) { return; } LTSMC.smc_board_close(CardID); } #endregion #region 所有轴紧急停止 /// /// 所有轴紧急停止 /// /// 卡ID public override void MoveFunction_Estop() { LTSMC.smc_emg_stop(this.CardID); } #endregion } }