From 91a6f3e66ee9ac8acad37637a17fc3589e5df571 Mon Sep 17 00:00:00 2001 From: Stephen Loftus-Mercer Date: Tue, 2 Nov 2021 12:17:01 -0500 Subject: [PATCH 1/2] Add support for three optional attributes of the SeriesDefinition that are in the IEEE spec but not supported by the C# libraries. --- .../GSF.PQDIF/Logical/SeriesDefinition.cs | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs b/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs index 111e8221140..e44783c6979 100755 --- a/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs +++ b/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs @@ -255,6 +255,114 @@ public enum QuantityUnits : uint AmpsPerVolt = 39u } + /// + /// List of Greek prefixes to use for units when displaying series data. + /// These do not affect how the values are stored -- they should not be applied + /// as scaling factors when reading data. + /// + public enum GreekPrefix : uint + { + /// + /// Indicates display may choose the prefix freely. + /// + DoNotCare = 0, + /// + /// f 10^-15 (quadrillionth) + /// + Femto, + /// + /// p 10^-12 (trillionth) + /// + Pico, + /// + /// n 10^-9 (billionth) + /// + Nano, + /// + /// μ 10^-6 (millionth) + /// + Micro, + /// + /// m 10^-3 (thousandth) + /// + Milli, + /// + /// "" 10^0 (unit) + /// + None, + /// + /// k 10^3 (thousand) + /// + Kilo, + /// + /// M 10^6 (million) + /// + Mega, + /// + /// G 10^9 (billion) + /// + Giga, + /// + /// T 10^12 (trillion) + /// + Tera + } + + /// + /// List of styles of units to use when displaying series data. + /// + public enum PreferredUnit : uint + { + /// + /// Engineering units + /// + PreferENG, + /// + /// Percentage units. + /// + PreferPCT, + /// + /// Per unit. https://en.wikipedia.org/wiki/Per-unit_system + /// + /// + /// In this display format, different types of quantities are labeled with the same + /// symbol (pu). The display should be clear whether the quantity is a voltage, + /// current, or other measured quanity. + /// + PreferPU + } + + /// + /// List of aspects of data to prioritize showing when displaying series data. + /// + public enum DefaultDisplay : uint + { + /// + /// Indicates display may choose the prefix freely. + /// + DoNotCare, + /// + /// Display the magnitude of the values. + /// + Magnitude, + /// + /// Display the angle of the values. + /// + Angle, + /// + /// Display the real portion of complex values. + /// + Real, + /// + /// Display the imaginary portion of complex values. + /// + Imaginary, + /// + /// Display the RX of the values. + /// + RX + } + #endregion /// @@ -430,6 +538,67 @@ public double SeriesNominalQuantity } } + /// + /// Gets or sets the hint about which Greek prefix is most useful for displaying the data in the series. + /// This hint does not affect how the values are stored -- prefixes should not be applied + /// as scaling factors when reading data. Data is assumed to be stored in unprefixed units, but + /// you can use the property to change how the data + /// is actually saved. + /// + public GreekPrefix HintGreekPrefix + { + get + { + return (GreekPrefix)m_physicalStructure + .GetScalarByTag(HintGreekPrefixIDTag) + .GetUInt4(); + } + set + { + ScalarElement quantityUnitsIDElement = m_physicalStructure.GetOrAddScalar(HintGreekPrefixIDTag); + quantityUnitsIDElement.TypeOfValue = PhysicalType.UnsignedInteger4; + quantityUnitsIDElement.SetUInt4((uint)value); + } + } + + /// + /// Gets or sets the hint about which unit style to use when displaying the data in the series. + /// + public PreferredUnit HintPreferredUnit + { + get + { + return (PreferredUnit)m_physicalStructure + .GetScalarByTag(HintPreferredUnitsIDTag) + .GetUInt4(); + } + set + { + ScalarElement quantityUnitsIDElement = m_physicalStructure.GetOrAddScalar(HintPreferredUnitsIDTag); + quantityUnitsIDElement.TypeOfValue = PhysicalType.UnsignedInteger4; + quantityUnitsIDElement.SetUInt4((uint)value); + } + } + + /// + /// Gets or sets the hint about which aspect of data to prioritize when displaying the data in the series. + /// + public DefaultDisplay HintDefaultDisplay + { + get + { + return (DefaultDisplay)m_physicalStructure + .GetScalarByTag(HintDefaultDisplayIDTag) + .GetUInt4(); + } + set + { + ScalarElement quantityUnitsIDElement = m_physicalStructure.GetOrAddScalar(HintDefaultDisplayIDTag); + quantityUnitsIDElement.TypeOfValue = PhysicalType.UnsignedInteger4; + quantityUnitsIDElement.SetUInt4((uint)value); + } + } + #endregion #region [ Methods ] @@ -515,6 +684,21 @@ public override int GetHashCode() /// public static readonly Guid SeriesNominalQuantityTag = new Guid("0fa118c8-cb4a-11d2-b30b-fe25cb9a1760"); + /// + /// Tag that identifies the preferred scaling prefix to use when displaying the series. + /// + public static readonly Guid HintGreekPrefixIDTag = new Guid("b48d859e-f5f5-11cf-9d89-0080c72e70a3"); + + /// + /// Tag that identifies the preferred unit style to use when displaying the series. + /// + public static readonly Guid HintPreferredUnitsIDTag = new Guid("b48d859f-f5f5-11cf-9d89-0080c72e70a3"); + + /// + /// Tag that identifies the preferred format string to use when displaying the series. + /// + public static readonly Guid HintDefaultDisplayIDTag = new Guid("b48d85a0-f5f5-11cf-9d89-0080c72e70a3"); + #endregion } } From 6b33a08627eb8f7e810390cdfa02eb49904511b7 Mon Sep 17 00:00:00 2001 From: Stephen Loftus-Mercer Date: Tue, 2 Nov 2021 12:23:47 -0500 Subject: [PATCH 2/2] Ammend value of enum to match IEEE spec. --- Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs b/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs index e44783c6979..f3e1f0f7bb9 100755 --- a/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs +++ b/Source/Libraries/GSF.PQDIF/Logical/SeriesDefinition.cs @@ -316,7 +316,7 @@ public enum PreferredUnit : uint /// /// Engineering units /// - PreferENG, + PreferENG = 1, /// /// Percentage units. ///