/// <summary> /// Constructor -- initializes all members /// </summary> /// <param name="wszSource"></param> /// <param name="wszCondition"></param> /// <param name="cond"></param> public OnEventClass(string wszSource, string wszCondition, OPCCondition cond) { m_oes.pEventAttributes = IntPtr.Zero; m_oes.dwNumEventAttrs = 0; m_oes.wChangeMask = cond.ChangeMask; m_oes.wNewState = cond.NewState; m_oes.szSource = wszSource; m_oes.ftTime = ComUtils.GetFILETIME(cond.Time); m_oes.szMessage = cond.Message; m_oes.dwEventType = cond.EventType; m_oes.dwEventCategory = cond.EventCategory; m_oes.dwSeverity = cond.Severity; m_oes.szConditionName = wszCondition; m_oes.szSubconditionName = cond.SubconditionName; m_oes.wQuality = cond.Quality; m_oes.bAckRequired = cond.AckRequired ?1:0; m_oes.ftActiveTime = ComUtils.GetFILETIME(cond.SubconditionTime); m_oes.dwCookie = cond.Cookie; m_oes.szActorID = cond.ActorID; m_EventAttributes = (Dictionary <int, object>)DeepCopy(cond.EventAttributes); }
/// <summary> /// Marshals an event for return to the client. /// </summary> private OpcRcw.Ae.ONEVENTSTRUCT Translate(AeEvent e) { OpcRcw.Ae.ONEVENTSTRUCT e2 = new ONEVENTSTRUCT(); e2.wNewState = 0; e2.wChangeMask = 0xFF; e2.szSource = e.SourceName; e2.wQuality = ComUtils.GetQualityCode(e.Quality); e2.dwEventType = e.Category.EventType; e2.dwEventCategory = (int)e.Category.LocalId; e2.bAckRequired = 0; e2.dwSeverity = e.Severity; e2.ftTime = ComUtils.GetFILETIME(e.Time); e2.szMessage = (e.Message != null) ? e.Message.Text : null; e2.szActorID = e.AuditUserId; e2.dwCookie = e.Cookie; if (e.AttributeValues != null && e.AttributeValues.Length > 0) { e2.dwNumEventAttrs = e.AttributeValues.Length; e2.pEventAttributes = ComUtils.GetVARIANTs(e.AttributeValues, true); } if ((e2.dwEventType & OpcRcw.Ae.Constants.CONDITION_EVENT) != 0) { e2.szConditionName = e.ConditionName; e2.ftActiveTime = ComUtils.GetFILETIME(e.ActiveTime); e2.bAckRequired = (e.AckedState)?0:1; // set the condition state. e2.wNewState = 0; if (e.EnabledState) { e2.wNewState |= OpcRcw.Ae.Constants.CONDITION_ENABLED; } if (e.AckedState) { e2.wNewState |= OpcRcw.Ae.Constants.CONDITION_ACKED; } if (e.ActiveState) { e2.wNewState |= OpcRcw.Ae.Constants.CONDITION_ACTIVE; } // set the subcondition if available. if (!LocalizedText.IsNullOrEmpty(e.LowState)) { e2.szSubconditionName = e.LowState.Text; } if (!LocalizedText.IsNullOrEmpty(e.HighState)) { e2.szSubconditionName = e.HighState.Text; } if (!LocalizedText.IsNullOrEmpty(e.LowLowState)) { e2.szSubconditionName = e.LowLowState.Text; } if (!LocalizedText.IsNullOrEmpty(e.HighHighState)) { e2.szSubconditionName = e.HighHighState.Text; } if (!LocalizedText.IsNullOrEmpty(e.LimitState)) { e2.szSubconditionName = e.LimitState.Text; } } if (e2.szMessage == null) { e2.szMessage = String.Empty; } if (e2.szSource == null) { e2.szSource = String.Empty; } if (e2.szConditionName == null) { e2.szConditionName = String.Empty; } if (e2.szSubconditionName == null) { e2.szSubconditionName = String.Empty; } if (e2.szActorID == null) { e2.szActorID = String.Empty; } return(e2); }