//复制实例 public CVarAlarm Clone() { CVarAlarm obj = (CVarAlarm)this.MemberwiseClone(); return(obj); }
public void SetDIAlarm(string sType, string sValue) { if (sType == "") { if (nVarAlarm == null) { return; } nVarAlarm.ListVarState.Clear(); if (nVarAlarm.GetNull() == 0) { nVarAlarm = null; return; } } if (nVarAlarm == null) { nVarAlarm = new CVarAlarm(); } nVarAlarm.ListVarState.Clear(); int iRp = Convert.ToInt32(sType.Substring(0, 1)); string sAlarm = ""; if (iRp == 2) { sAlarm = "警告"; } else { sAlarm = "报警"; } nVarAlarm.VarStatepriority = iRp; sValue = sValue.Replace(':', ','); sValue = sValue.Replace(';', ','); sValue = sValue.Replace(';', ','); sValue = sValue.Replace(':', ','); sValue = sValue.Replace('.', ','); string[] str2 = sValue.Split(','); for (int i = 0; i < str2.Length; i++) { try { int iNew = Math.Abs(Convert.ToInt32(str2[i])); int iOld = 1 - iNew; if (iOld < 0) { continue; } bool bAdd = true; foreach (CVarState node in nVarAlarm.ListVarState) { if (node.oldvalue == iOld && node.newvalue == iNew) { bAdd = false; break; } } if (bAdd) { CVarState nState = new CVarState(); nState.oldvalue = iOld; nState.newvalue = iNew; nState.text = Name + "." + Description + " " + iOld.ToString() + "-" + iNew.ToString() + sAlarm; nVarAlarm.ListVarState.Add(nState); } } catch { } } }