openPQDIF Usage Example

This example shows how to use the GSF.PQDIF library by loading a PQDIF file and accessing different elements of the PQDIF file structure.

First, we need to include the following reference in our project code:

using GSF.PQDIF.Logical;


We can parse the information contained in the file and store it as a list of observation records.

List<ObservationRecord> observationRecords = new List<ObservationRecord>();

using (LogicalParser logicalParser = new LogicalParser(dialog.FileName))

    while (logicalParser.HasNextObservationRecord())


Observation records have references to their data source and monitor settings records, and various elements can be accessed via properties to those objects.

ObservationRecord observation = observationRecords[0];
DataSourceRecord dataSource = observation.DataSource;
MonitorSettingsRecord monitorSettings = observation.Settings;

DateTime startTime = observation.StartTime;
string sourceName = dataSource.DataSourceName;
double nominalFrequency = monitorSettings.NominalFrequency;


Channel instances can also be accessed through the observation record, and series instances can be accessed through channel instances.

IList<ChannelInstance> channels = observation.ChannelInstances;
IList<SeriesInstance> series = channels[0].SeriesInstances;


Finally, the values for a particular series can be obtained through the OriginalValues property of the series instances. The type of these original values depends on the physical type of the values, scale, and offset defined in the PQDIF file and are thus returned as a list of objects, but most types can be safely converted to double.

IList<object> originalValues = series[0].OriginalValues;
IEnumerable<double> values = originalValues.Select(Convert.ToDouble);

Last edited May 27, 2015 at 5:14 PM by staphen, version 2