using Community; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model.MotionControl { /// /// 众为兴运动控制卡 /// public class ZmotionCard : FeiYuCard { #region 获取轴数量 /// /// 获取轴数量 /// /// public override bool GetCradInfo() { return true; } #endregion #region 连接运动控制器 /// /// 连接 /// /// public override bool Connect() { bool bl = false; //如果是运动控制器 if (InterfaceType == 2) { //链接控制器 zmcaux.ZAux_OpenEth(this.PconnectString, out g_handle); if (ShaftList != null) { foreach (ZmotionShaft sf in ShaftList) { sf.Initialize(); } } bl = true; } else //运动控制卡 { //int cra_count = 0; //ADTMC.adt_initial(out cra_count, 0); Int32 Result = adt8949.adt8949_initial(); //int m_cardNum = 0; //if (cra_count > 0 || cra_count <= 8) //{ // 控制卡初始化失败 // int[] cardids = new Int32[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // int res = ADTMC.adt_get_card_index(out m_cardNum, cardids); // int res = adt8949.adt8949_get_firmware_ver(m_cardNum); // CardID = (ushort)cardids[0]; // CardID = (ushort)res; // bl = true; if (Result != 0) { //获取卡信息失败! bl = true; } //} } return bl; } #endregion #region 关闭连接 /// /// 关闭连接 /// public override void close() { if (InterfaceType == 2) { zmcaux.ZAux_Close(g_handle); g_handle = (IntPtr)0; } else { ADTMC.adt_close_card(); } } #endregion #region 所有轴紧急制动 /// /// 所有轴紧急制动 /// public override void MoveFunction_Estop() { if (InterfaceType == 2) { zmcaux.ZAux_Direct_Rapidstop(g_handle, 2); } else if (InterfaceType == 0) { adt8949.adt8949_sudden_stop(CardID, 1); adt8949.adt8949_sudden_stop(CardID, 2); adt8949.adt8949_sudden_stop(CardID, 3); adt8949.adt8949_sudden_stop(CardID, 4); } else { ADTMC.adt_set_axis_stop(CardID, 0, 1); ADTMC.adt_set_axis_stop(CardID, 1, 1); ADTMC.adt_set_axis_stop(CardID, 2, 1); ADTMC.adt_set_axis_stop(CardID, 3, 1); ADTMC.adt_set_axis_stop(CardID, 4, 1); ADTMC.adt_set_axis_stop(CardID, 5, 1); ADTMC.adt_set_axis_stop(CardID, 6, 1); ADTMC.adt_set_axis_stop(CardID, 7, 1); } } #endregion } }