C# Класс 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.
Наследование: AdapterBase, IOutputAdapter
Показать файл Открыть проект

Private Properties

Свойство Тип Описание
AttemptConnectionOperation void
RefreshMetadata void
m_connectionTimer_Elapsed void
m_measurementQueue_ProcessException void
m_monitorTimer_Elapsed void

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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(); } }

Приватные методы

Метод Описание
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

Описание методов

AttemptConnection() защищенный абстрактный Метод

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
Результат void

AttemptDisconnection() защищенный абстрактный Метод

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
Результат void

Dispose() защищенный Метод

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.
Результат void

ExecuteMetadataRefresh() защищенный Метод

Executes the metadata refresh in a synchronous fashion.
protected ExecuteMetadataRefresh ( ) : void
Результат void

Flush() публичный Метод

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
Результат void

Initialize() публичный Метод

Initializes OutputAdapterBase.
public Initialize ( ) : void
Результат void

OnConnected() защищенный Метод

Called when data output source connection is established.
Derived classes should call this method manually if UseAsyncConnect is true.
protected OnConnected ( ) : void
Результат void

OnDisconnected() защищенный Метод

Called when data input source is disconnected.
Derived classes should call this method manually if UseAsyncConnect is true.
protected OnDisconnected ( ) : void
Результат void

OnUnprocessedMeasurements() защищенный Метод

Raises the UnprocessedMeasurements event.
protected OnUnprocessedMeasurements ( int unprocessedMeasurements ) : void
unprocessedMeasurements int Total measurements in the queue that have not been processed.
Результат void

OutputAdapterBase() защищенный Метод

Constructs a new instance of the OutputAdapterBase.
protected OutputAdapterBase ( ) : System
Результат System

ProcessMeasurements() защищенный абстрактный Метод

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
Результат void

QueueMeasurementForProcessing() публичный Метод

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.
Результат void

QueueMeasurementsForProcessing() публичный Метод

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.
Результат void

RemoveMeasurements() публичный Метод

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
Результат void

Start() публичный Метод

Starts this OutputAdapterBase and initiates connection cycle to data output stream.
public Start ( ) : void
Результат void

Stop() публичный Метод

Stops this OutputAdapterBase and disconnects from data output stream.
public Stop ( ) : void
Результат void