/// <summary> /// Event handler for monitoring unpublished samples. /// </summary> /// <param name="sender">Event source reference to adapter, typically an action adapter, that is reporting the number of unpublished data samples.</param> /// <param name="e">Event arguments containing number of samples, in seconds of data, of unpublished data in the source adapter.</param> /// <remarks> /// Time-series framework uses this handler to monitor the number of unpublished samples, in seconds of data, in action adapters.<br/> /// This method is typically called once every five seconds. /// </remarks> public virtual void UnpublishedSamplesHandler(object sender, EventArgs <int> e) { int secondsOfData = e.Argument; int threshold = m_defaultSampleSizeWarningThreshold; int processingInterval = -1; ConcentratorBase concentrator = sender as ConcentratorBase; IAdapter adapter = sender as IAdapter; // Most action adapters will be based on a concentrator, if so we monitor the unpublished sample queue size compared to the defined // lag time - if the queue size is over twice the lag size, the action adapter could be falling behind if ((object)concentrator != null) { threshold = (int)(2 * Math.Ceiling(concentrator.LagTime)); } // Get processing interval for adapter if ((object)adapter != null) { processingInterval = adapter.ProcessingInterval; } // Allow much more time before warning for when a fast processing interval has been defined if (processingInterval > -1 && processingInterval < 100) { threshold *= 4; } if (secondsOfData > threshold) { OnStatusMessage(sender, "[{0}] There are {1} seconds of unpublished data in the action adapter concentration queue.", UpdateType.Warning, GetDerivedName(sender), secondsOfData); } // Bubble message up to any event subscribers OnUnpublishedSamples(sender, e.Argument); }
internal ImmediateMeasurements(ConcentratorBase parent) : this() { m_parent = parent; if (m_parent != null) { m_parent.LagTimeUpdated += OnLagTimeUpdated; m_parent.LeadTimeUpdated += OnLeadTimeUpdated; m_realTimeFunction = () => m_parent.RealTime; } }
/// <summary> /// Releases the unmanaged resources used by the <see cref="ImmediateMeasurements"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { if (m_parent != null) { m_parent.LagTimeUpdated -= OnLagTimeUpdated; m_parent.LeadTimeUpdated -= OnLagTimeUpdated; } m_parent = null; if (m_measurements != null) { m_measurements.Clear(); } m_measurements = null; if (m_taggedMeasurements != null) { m_taggedMeasurements.Clear(); } m_taggedMeasurements = null; } } finally { m_disposed = true; // Prevent duplicate dispose. } } }