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;
}
#endregion