/// <summary> /// 参数:[0板卡,1扩展模块],[板卡号0-2],[模块号0-3],[输出端口号0-15] /// </summary> /// <param name="CardType"></param> /// <param name="CardNum"></param> /// <param name="Mdl"></param> /// <param name="Index"></param> /// <returns></returns> /// <remarks></remarks> public static bool NSetDO(int CardType, int CardNum, int Mdl, int Index) { try { switch (CardType) { case 0: if (Gg.GetDo((short)CardNum, (short)Index) == 1) { Gg.SetDo((short)CardNum, (short)Index, (short)0); } else { Gg.SetDo((short)CardNum, (short)Index, (short)1); } break; case 1: if (Gg.GetExDo((short)CardNum, (short)Mdl, (short)Index) == 1) { Gg.SetExDo((short)CardNum, (short)Mdl, (short)Index, (short)0); } else { Gg.SetExDo((short)CardNum, (short)Mdl, (short)Index, (short)1); } break; } } catch (Exception) { return(false); } return(true); }
public static short mGetDO(int CardTag, int index) { // CardIndex CardInfo //控件 TabIndex 代表卡类型, Tag(A,B) A代表卡号,B代表模块序号(0-15); //CardType=0 固高卡自带IO,CardType=1 固高卡扩展IO。 int CardType = 0; string CardInfo = "0,0"; int CardIndex = 0; int CardNum = 0; int ReturnStr = 0; switch (CardTag) { case 0: //0号输入单元 CardType = 0; CardInfo = "0,0"; break; case 1: //1号输入单元 CardType = 0; CardInfo = "1,0"; break; case 2: //3号输入单元 CardType = 1; CardInfo = "0,0"; break; case 3: //3号输入单元 CardType = 1; CardInfo = "0,1"; break; case 4: //3号输入单元 CardType = 1; CardInfo = "0,2"; break; } CardNum = System.Convert.ToInt32(CardInfo.Substring(0, 1)); CardIndex = System.Convert.ToInt32(CardInfo.Substring(CardInfo.Length - 1, 1)); try { switch (CardType) { case 0: ReturnStr = Math.Abs(Gg.GetDo((short)CardNum, (short)index)); break; case 1: ReturnStr = Math.Abs(Gg.GetExDo((short)CardNum, (short)CardIndex, (short)index)); break; } } catch (Exception) { ReturnStr = 0; } return((short)ReturnStr); }