/// <summary> /// Values of existing CONDITION events are updated the forwarded to TheGlobal for further processing /// per subscription per server instance /// </summary> /// <param name="EventNotification"></param> /// <param name="areas"></param> /// <param name="newCond"></param> private void ProcessCondition(EventNotification EventNotification, string[] areas, OPCCondition newCond) { try { newCond.ClearChangeMask(); newCond.SetMessage(EventNotification.Message); newCond.SetSeverity(EventNotification.Severity); newCond.SetSubconditionName(EventNotification.SubConditionName); newCond.SetActive((EventNotification.NewState & OpcRcw.Ae.Constants.CONDITION_ACTIVE) != 0); // The UA server generates unique identifiers in the form of guids. how to map these to COM-style cookies? // For now, just increment a static DWORD counter from the OPCCondition constructor and assign //newCond.Cookie = EventNotification.Cookie; newCond.SetTime(EventNotification.ActiveTime); newCond.EventId = EventNotification.EventId; newCond.EventCategory = EventNotification.EventCategory; newCond.SetQuality((short)EventNotification.Quality); newCond.ActorID = EventNotification.EventType == OpcRcw.Ae.Constants.TRACKING_EVENT ? EventNotification.ActorID : ""; newCond.SetEnable((EventNotification.NewState & OpcRcw.Ae.Constants.CONDITION_ENABLED) != 0); newCond.SetIsAcked((EventNotification.NewState & OpcRcw.Ae.Constants.CONDITION_ACKED) != 0); newCond.SetAckRequired(EventNotification.AckRequired); newCond.ConditionId = EventNotification.ConditionId; newCond.AcknowledgeMethod = EventNotification.AcknowledgeMethod; OPCSubcondition subCond = new OPCSubcondition(newCond.SubconditionName, newCond.Message, "", newCond.Severity); newCond.push_back_subcondition(subCond); for (int i = 0; i < areas.Length; i++) { newCond.push_back_area(areas[i]); } // Insert standard attribute "AckComment" newCond.push_back_attrval(Global.TheGlobal.StdAttrIds[0], newCond.AckComment); // Insert standard attribute "Areas" newCond.push_back_attrval(Global.TheGlobal.StdAttrIds[1], areas); foreach (KeyValuePair <int, object> kvp in EventNotification.EventAttributes) { newCond.push_back_attrval(kvp.Key, kvp.Value); } if (newCond.IsEnabled()) { lock (Global.TheGlobal) { Global.TheGlobal.NotifyClients(EventNotification.SourceID, EventNotification.ConditionName, newCond); } } } catch (Exception e) { Utils.Trace(e, "Unexpected error in ProcessCondition"); } // Utils.Trace("ProcessCondition - END Source: {0}, condition: {1}, conditionstate: {2}", // EventNotification.SourceID, EventNotification.ConditionName, newCond.NewState); }
/// <summary> /// Required override /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(Object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } OPCSubcondition sub = (OPCSubcondition)obj; return(m_wsName == sub.m_wsName); }
/// <summary> /// Insertas a subcondition into the subconditions list /// </summary> /// <param name="sub"></param> public void push_back_subcondition(OPCSubcondition sub) { m_Subconditions.AddUnique(sub); }