/// <summary> /// Shows an event in the control. /// </summary> private void ShowValue(ref int index, ref bool overwrite, EventFieldList value, int fieldIndex) { // ignore children that are not elements. object field = value.EventFields[fieldIndex].Value; if (field == null) { return; } // get the name of the element. string name = null; if (m_monitoredItem != null) { name = m_monitoredItem.GetFieldName(fieldIndex); } // get the type name. string type = value.GetType().Name; // update the list view. UpdateList( ref index, ref overwrite, value, field, fieldIndex, name, type); }
/// <summary> /// Convert to Datavalue /// </summary> /// <param name="eventFields"></param> /// <param name="monitoredItem"></param> /// <returns></returns> public static DataValue ToDataValue(this EventFieldList eventFields, MonitoredItem monitoredItem) { if (eventFields == null) { return(new DataValue(StatusCodes.BadNoData)); } return(new DataValue { ServerPicoseconds = 0, ServerTimestamp = eventFields.GetEventValue <DateTime>( BrowseNames.Time, monitoredItem), SourcePicoseconds = 0, SourceTimestamp = eventFields.GetEventValue <DateTime>( BrowseNames.ReceiveTime, monitoredItem), StatusCode = eventFields.GetEventValue <StatusCode>( BrowseNames.StatusCode, monitoredItem), Value = new EncodeableDictionary { Fields = new KeyValuePairCollection(eventFields.EventFields .Select((value, i) => new Opc.Ua.KeyValuePair { Key = monitoredItem.GetFieldName(i), Value = value })) } }); }