/// <summary> /// Updates the display with a new value for a monitored variable. /// </summary> private void MonitoredItem_Notification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new MonitoredItemNotificationEventHandler(MonitoredItem_Notification), monitoredItem, e); return; } try { EventFieldList notification = e.NotificationValue as EventFieldList; if (notification == null) { return; } // check the type of event. NodeId eventTypeId = ClientUtils.FindEventType(monitoredItem, notification); // ignore unknown events. if (NodeId.IsNull(eventTypeId)) { return; } // construct the audit object. SystemCycleStatusEventState status = ClientUtils.ConstructEvent( m_session, monitoredItem, notification, m_knownEventTypes, m_eventTypeMappings) as SystemCycleStatusEventState; if (e == null) { return; } ListViewItem item = new ListViewItem(String.Empty); item.SubItems.Add(String.Empty); // Source item.SubItems.Add(String.Empty); // Type item.SubItems.Add(String.Empty); // CycleId item.SubItems.Add(String.Empty); // Step item.SubItems.Add(String.Empty); // Time item.SubItems.Add(String.Empty); // Message // look up the condition type metadata in the local cache. INode type = m_session.NodeCache.Find(status.TypeDefinitionId); // Source if (status.SourceName != null) { item.SubItems[0].Text = Utils.Format("{0}", status.SourceName.Value); } else { item.SubItems[0].Text = null; } // Type if (type != null) { item.SubItems[1].Text = Utils.Format("{0}", type); } else { item.SubItems[1].Text = null; } // CycleId if (status.CycleId != null) { item.SubItems[2].Text = Utils.Format("{0}", status.CycleId.Value); } else { item.SubItems[2].Text = null; } // Step if (status.CurrentStep != null && status.CurrentStep.Value != null) { item.SubItems[3].Text = Utils.Format("{0}", status.CurrentStep.Value.Name); } else { item.SubItems[3].Text = null; } // Time if (status.Time != null) { item.SubItems[4].Text = Utils.Format("{0:HH:mm:ss.fff}", status.Time.Value.ToLocalTime()); } else { item.SubItems[4].Text = null; } // Message if (status.Message != null) { item.SubItems[5].Text = Utils.Format("{0}", status.Message.Value); } else { item.SubItems[5].Text = null; } item.Tag = status; EventsLV.Items.Add(item); // adjust the width of the columns. for (int ii = 0; ii < EventsLV.Columns.Count; ii++) { EventsLV.Columns[ii].Width = -2; } } catch (Exception exception) { ClientUtils.HandleException(this.Text, exception); } }