/// <summary> /// Gets meta-data from the <paramref name="connectionString" /> waiting no longer than the specified <paramref name="timeout"/>. /// </summary> /// <param name="connectionString">GEP connection string.</param> /// <param name="timeout">Specifies how long to wait, in milliseconds, for meta-data.</param> /// <returns>The meta-data received from the GEP publisher in <see cref="DataSet"/> format.</returns> public static DataSet GetMetadata(string connectionString, int timeout = Timeout.Infinite) { using (MetadataRetriever receiver = new MetadataRetriever(connectionString)) { return(receiver.GetMetadata(timeout)); } }
public Metadata(Settings settings) { Measurements = new List <MeasurementDetail>(); Devices = new List <DeviceDetail>(); // Do the following on button click or missing configuration, etc: // Note that openHistorian internal publisher controls how many tables / fields to send as meta-data to subscribers (user controllable), // as a result, not all fields in associated database views will be available. Below are the default SELECT filters the publisher // will apply to the "MeasurementDetail", "DeviceDetail" and "PhasorDetail" database views: // "SELECT NodeID, UniqueID, OriginalSource, IsConcentrator, Acronym, Name, AccessID, ParentAcronym, ProtocolName, FramesPerSecond, CompanyAcronym, VendorAcronym, VendorDeviceName, Longitude, Latitude, InterconnectionName, ContactList, Enabled, UpdatedOn FROM DeviceDetail WHERE IsConcentrator = 0;" + // "SELECT DeviceAcronym, ID, SignalID, PointTag, SignalReference, SignalAcronym, PhasorSourceIndex, Description, Internal, Enabled, UpdatedOn FROM MeasurementDetail;" + // "SELECT ID, DeviceAcronym, Label, Type, Phase, DestinationPhasorID, SourceIndex, UpdatedOn FROM PhasorDetail;" + // "SELECT VersionNumber FROM SchemaVersion"; // SELECT Internal, DeviceAcronym, DeviceName, SignalAcronym, ID, SignalID, PointTag, SignalReference, Description, Enabled FROM MeasurementDetail // SELECT DeviceAcronym, Label, Type, Phase, SourceIndex FROM PhasorDetail DataTable measurementTable = null; DataTable deviceTable = null; try { DataSet metadata = MetadataRetriever.GetMetadata($"server={settings.HostAddress}; port={settings.Port}; interface=0.0.0.0"); // Reference meta-data tables measurementTable = metadata.Tables["MeasurementDetail"]; deviceTable = metadata.Tables["DeviceDetail"]; } catch (Exception ex) { MessageBox.Show("Exception retrieving meta-data: " + ex.Message); } if ((object)measurementTable != null) { // Load measurement records foreach (DataRow row in measurementTable.Select("SignalAcronym <> 'STAT' and SignalAcronym <> 'DIGI'")) { Measurements.Add(new MeasurementDetail(row)); } } if ((object)deviceTable != null) { // Load device records foreach (DataRow row in deviceTable.Rows) { Devices.Add(new DeviceDetail(row)); } } }