/// <summary> /// Gets meta-data from the <paramref name="connectionString" /> waiting no longer than the specified <paramref name="timeout"/>. /// </summary> /// <param name="gepHost">GEP publication host and port, e.g., "192.168.1.1:6175", to connect to for meta-data.</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 retriever = new MetadataRetriever(connectionString)) { return(retriever.GetMetadata(timeout)); } }
private void BtnGetMetadata_Click(object sender, EventArgs e) { // 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, ParentAcronym, ProtocolName, FramesPerSecond, Enabled FROM DeviceDetail WHERE IsConcentrator = 0 // 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; DataTable phasorTable = null; string server = "Server=" + TxtServerIP.Text.Trim() + "; Port=" + TxtGEPPort.Text.Trim() + "; Interface=0.0.0.0"; try { DataSet metadata = MetadataRetriever.GetMetadata(server); // Reference meta-data tables measurementTable = metadata.Tables["MeasurementDetail"]; deviceTable = metadata.Tables["DeviceDetail"]; phasorTable = metadata.Tables["PhasorDetail"]; } catch (Exception ex) { MessageBox.Show("Exception retrieving meta-data: " + ex.Message); } SortedDictionary <ulong, Tuple <Guid, string, string, string> > pointData = new SortedDictionary <ulong, Tuple <Guid, string, string, string> >(); if ((object)measurementTable != null) { // Could filter measurements if desired (e.g., no stats) DataRow[] measurements = measurementTable.Select("SignalAcronym <> 'STAT' and SignalAcronym <> 'DIGI'"); m_settings.MyData.Tables["Measurements"].Rows.Clear(); // Do something with measurement records foreach (DataRow measurement in measurements) { Guid signalID; MeasurementKey measurementKey; Guid.TryParse(measurement["SignalID"].ToString(), out signalID); MeasurementKey.TryParse(measurement["ID"].ToString(), out measurementKey); pointData[measurementKey.ID] = new Tuple <Guid, string, string, string>(signalID, measurement["DeviceAcronym"].ToString(), measurement["SignalAcronym"].ToString(), measurement["Description"].ToString()); } foreach (KeyValuePair <ulong, Tuple <Guid, string, string, string> > kvp in pointData) { m_settings.MyData.Tables["Measurements"].Rows.Add((int)kvp.Key, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, kvp.Value.Item4); } } }
/// <summary> /// Gets meta-data from the <paramref name="connectionString" /> waiting no longer than the specified <paramref name="timeout"/>. /// </summary> /// <param name="gepHost">GEP publication host and port, e.g., "192.168.1.1:6175", to connect to for meta-data.</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 retriever = new MetadataRetriever(connectionString)) { return retriever.GetMetadata(timeout); } }