using Community; using Model.MotionControl; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model { /// /// 数入信号类 /// public class InputSignal : NotificationObject { /// /// 链接返回的句柄,可以作为卡号 众为兴控制卡 /// public IntPtr g_handle; /// /// 对应的运行控制卡 /// public FeiYuCard MyCard { get; set; } public int ID { get; set; } /// /// 卡ID /// public ushort CardID { get; set; } /// /// 输入端口号 /// public ushort IoNumber { get; set; } private int myType; /// /// 输出信号类型 0:机架信号 1:点胶模块信号 2:锁螺丝模块信号 /// public int MyType { get { return myType; } set { myType = value; this.RaisePropertyChanged("MyType"); } } private int levelState; /// /// 输入端口电平输入状态 /// public int LevelState { get { return levelState; } set { levelState = value; if(MyCard==null) { this.InputColor = ColorStr.Gray; return; } switch (MyCard.Brand) { case 1: if (HightEff) { if (value == 0) { this.InputColor = ColorStr.Gray; } else { this.InputColor = ColorStr.Green; } } else { if (value == 1) { this.InputColor = ColorStr.Gray; } else { this.InputColor = ColorStr.Green; } } break; case 2: if (HightEff) { if (value == 0) { this.InputColor = ColorStr.Green; } else { this.InputColor = ColorStr.Gray; } } else { if (value == 1) { this.InputColor = ColorStr.Green; } else { this.InputColor = ColorStr.Gray; } } break; } //if (MyCard.Brand==1) //{ // if (HightEff) // { // if (value == 0) // { // this.InputColor = ColorStr.Gray; // } // else // { // this.InputColor = ColorStr.Green; // } // } // else // { // if (value == 1) // { // this.InputColor = ColorStr.Gray; // } // else // { // this.InputColor = ColorStr.Green; // } // } //}else //{ // if (HightEff) // { // if (value == 0) // { // this.InputColor = ColorStr.Green; // } // else // { // this.InputColor = ColorStr.Gray; // } // } // else // { // if (value == 1) // { // this.InputColor = ColorStr.Green; // } // else // { // this.InputColor = ColorStr.Gray; // } // } //} } } /// /// 输入信号的含义 /// public string InputMeaning { get; set; } /// /// 是否属于运动控制卡 /// public bool ToRunControlCard { get; set; } private string inputColor; /// /// 表示显色 /// public string InputColor { get { return inputColor; } set { inputColor = value; LightUp = value == ColorStr.Green ? true : false; this.RaisePropertyChanged("InputColor"); } } /// /// 信号是否点亮 /// public bool LightUp { get; set; } /// /// 高电平有效 /// public bool HightEff { get; set; } public InputSignal() { LevelState = 0; ToRunControlCard = false; } /// /// 获取输入电平状态 /// public void GetInputLever() { if (this.ToRunControlCard) { //获取运动控制卡输入电平 //LevelState = LTDMC.dmc_read_inbit(CardID, IoNumber); //LevelState = LTSMC.smc_read_inbit(CardID, IoNumber); if (MyCard!=null) { //确认运动控制的品牌 switch (MyCard.Brand) { case 1: //根据品牌的不同,选择相应的状态获取方式 if (MyCard.InterfaceType == 2) { LevelState = LTSMC.smc_read_inbit(MyCard.CardID, IoNumber); } else { LevelState = LTSMC.smc_read_inbit(MyCard.CardID, IoNumber); } break; case 2: if (MyCard.InterfaceType == 2) { uint state = 0; zmcaux.ZAux_Direct_GetIn(MyCard.g_handle, IoNumber, ref state); LevelState = Convert.ToInt32(state); } else { int state = 100; ADTMC.adt_read_inbit(MyCard.CardID, IoNumber, out state); LevelState = state; } break; } } } else { //获取独立IO卡输入电平 LevelState = IOC0640.ioc_read_inbit(CardID, IoNumber); } } } }