C# Class GSF.TimeSeries.Adapters.OutputAdapterBase

Represents the base class for any outgoing data stream.
This base class acts as a measurement queue so that output adapters can temporarily go offline without losing any measurements to be processed. Derived classes are expected to override ProcessMeasurements to handle queued measurements.
Inheritance: AdapterBase, IOutputAdapter
Afficher le fichier Open project: GridProtectionAlliance/gsf

Private Properties

Свойство Type Description
AttemptConnectionOperation void
RefreshMetadata void
m_connectionTimer_Elapsed void
m_measurementQueue_ProcessException void
m_monitorTimer_Elapsed void

Méthodes publiques

Méthode Description
Flush ( ) : void

Blocks the current thread, if the OutputAdapterBase is connected, until all items in OutputAdapterBase queue are processed, and then stops processing.

It is possible for items to be added to the queue while the flush is executing. The flush will continue to process items as quickly as possible until the queue is empty. Unless the user stops queuing items to be processed, the flush call may never return (not a happy situation on shutdown).

The OutputAdapterBase does not clear queue prior to destruction. If the user fails to call this method before the class is destructed, there may be items that remain unprocessed in the queue.

Initialize ( ) : void

Initializes OutputAdapterBase.

QueueMeasurementForProcessing ( IMeasurement measurement ) : void

Queues a single measurement for processing. Measurement is automatically filtered to the defined IAdapter.InputMeasurementKeys.

QueueMeasurementsForProcessing ( IEnumerable measurements ) : void

Queues a collection of measurements for processing. Measurements are automatically filtered to the defined IAdapter.InputMeasurementKeys.

RemoveMeasurements ( int total ) : void

This removes a range of measurements from the internal measurement queue.

This method is typically only used to curtail size of measurement queue if it's getting too large. If more points are requested than there are points available - all points in the queue will be removed.

Start ( ) : void

Starts this OutputAdapterBase and initiates connection cycle to data output stream.

Stop ( ) : void

Stops this OutputAdapterBase and disconnects from data output stream.

Méthodes protégées

Méthode Description
AttemptConnection ( ) : void

Attempts to connect to data output stream.

Derived classes should attempt connection to data output stream here. Any exceptions thrown by this implementation will result in restart of the connection cycle.

AttemptDisconnection ( ) : void

Attempts to disconnect from data output stream.

Derived classes should attempt disconnect from data output stream here. Any exceptions thrown by this implementation will be reported to host via AdapterBase.ProcessException event.

Dispose ( bool disposing ) : void

Releases the unmanaged resources used by the OutputAdapterBase object and optionally releases the managed resources.

ExecuteMetadataRefresh ( ) : void

Executes the metadata refresh in a synchronous fashion.

OnConnected ( ) : void

Called when data output source connection is established.

Derived classes should call this method manually if UseAsyncConnect is true.

OnDisconnected ( ) : void

Called when data input source is disconnected.

Derived classes should call this method manually if UseAsyncConnect is true.

OnUnprocessedMeasurements ( int unprocessedMeasurements ) : void

Raises the UnprocessedMeasurements event.

OutputAdapterBase ( ) : System

Constructs a new instance of the OutputAdapterBase.

ProcessMeasurements ( IMeasurement measurements ) : void

Serializes measurements to data output stream.

Derived classes must implement this function to process queued measurements. For example, this function would "archive" measurements if output adapter is for a historian.

It is important that consumers "resume" connection cycle if processing fails (e.g., connection to archive is lost). Here is an example: protected virtual void ProcessMeasurements(IMeasurement[] measurements) { try { // Process measurements... foreach (IMeasurement measurement in measurement) { ArchiveMeasurement(measurement); } } catch (Exception) { // So long as user hasn't requested to stop, restart connection cycle if (Enabled) Start(); } }

Private Methods

Méthode Description
AttemptConnectionOperation ( ) : void
RefreshMetadata ( ) : void
m_connectionTimer_Elapsed ( object sender, EventArgs e ) : void
m_measurementQueue_ProcessException ( object sender, EventArgs e ) : void
m_monitorTimer_Elapsed ( object sender, EventArgs e ) : void

Method Details

AttemptConnection() protected abstract méthode

Attempts to connect to data output stream.
Derived classes should attempt connection to data output stream here. Any exceptions thrown by this implementation will result in restart of the connection cycle.
protected abstract AttemptConnection ( ) : void
Résultat void

AttemptDisconnection() protected abstract méthode

Attempts to disconnect from data output stream.
Derived classes should attempt disconnect from data output stream here. Any exceptions thrown by this implementation will be reported to host via AdapterBase.ProcessException event.
protected abstract AttemptDisconnection ( ) : void
Résultat void

Dispose() protected méthode

Releases the unmanaged resources used by the OutputAdapterBase object and optionally releases the managed resources.
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
Résultat void

ExecuteMetadataRefresh() protected méthode

Executes the metadata refresh in a synchronous fashion.
protected ExecuteMetadataRefresh ( ) : void
Résultat void

Flush() public méthode

Blocks the current thread, if the OutputAdapterBase is connected, until all items in OutputAdapterBase queue are processed, and then stops processing.

It is possible for items to be added to the queue while the flush is executing. The flush will continue to process items as quickly as possible until the queue is empty. Unless the user stops queuing items to be processed, the flush call may never return (not a happy situation on shutdown).

The OutputAdapterBase does not clear queue prior to destruction. If the user fails to call this method before the class is destructed, there may be items that remain unprocessed in the queue.

public Flush ( ) : void
Résultat void

Initialize() public méthode

Initializes OutputAdapterBase.
public Initialize ( ) : void
Résultat void

OnConnected() protected méthode

Called when data output source connection is established.
Derived classes should call this method manually if UseAsyncConnect is true.
protected OnConnected ( ) : void
Résultat void

OnDisconnected() protected méthode

Called when data input source is disconnected.
Derived classes should call this method manually if UseAsyncConnect is true.
protected OnDisconnected ( ) : void
Résultat void

OnUnprocessedMeasurements() protected méthode

Raises the UnprocessedMeasurements event.
protected OnUnprocessedMeasurements ( int unprocessedMeasurements ) : void
unprocessedMeasurements int Total measurements in the queue that have not been processed.
Résultat void

OutputAdapterBase() protected méthode

Constructs a new instance of the OutputAdapterBase.
protected OutputAdapterBase ( ) : System
Résultat System

ProcessMeasurements() protected abstract méthode

Serializes measurements to data output stream.

Derived classes must implement this function to process queued measurements. For example, this function would "archive" measurements if output adapter is for a historian.

It is important that consumers "resume" connection cycle if processing fails (e.g., connection to archive is lost). Here is an example: protected virtual void ProcessMeasurements(IMeasurement[] measurements) { try { // Process measurements... foreach (IMeasurement measurement in measurement) { ArchiveMeasurement(measurement); } } catch (Exception) { // So long as user hasn't requested to stop, restart connection cycle if (Enabled) Start(); } }

protected abstract ProcessMeasurements ( IMeasurement measurements ) : void
measurements IMeasurement
Résultat void

QueueMeasurementForProcessing() public méthode

Queues a single measurement for processing. Measurement is automatically filtered to the defined IAdapter.InputMeasurementKeys.
public QueueMeasurementForProcessing ( IMeasurement measurement ) : void
measurement IMeasurement Measurement to queue for processing.
Résultat void

QueueMeasurementsForProcessing() public méthode

Queues a collection of measurements for processing. Measurements are automatically filtered to the defined IAdapter.InputMeasurementKeys.
public QueueMeasurementsForProcessing ( IEnumerable measurements ) : void
measurements IEnumerable Measurements to queue for processing.
Résultat void

RemoveMeasurements() public méthode

This removes a range of measurements from the internal measurement queue.
This method is typically only used to curtail size of measurement queue if it's getting too large. If more points are requested than there are points available - all points in the queue will be removed.
public RemoveMeasurements ( int total ) : void
total int
Résultat void

Start() public méthode

Starts this OutputAdapterBase and initiates connection cycle to data output stream.
public Start ( ) : void
Résultat void

Stop() public méthode

Stops this OutputAdapterBase and disconnects from data output stream.
public Stop ( ) : void
Résultat void