//******************************************************************************************************// MetadataRecord.cs - Gbtc//// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.//// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See// the NOTICE file distributed with this work for additional information regarding copyright ownership.// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may// not use this file except in compliance with the License. You may obtain a copy of the License at://// http://www.opensource.org/licenses/MIT//// Unless agreed to in writing, the subject software distributed under the License is distributed on an// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the// License for the specific language governing permissions and limitations.//// Code Modification History:// ----------------------------------------------------------------------------------------------------// 05/03/2006 - Pinal C. Patel// Generated original version of code based on DatAWare system specifications by Brian B. Fox, GSF.// 04/20/2009 - Pinal C. Patel// Converted to C#.// 09/15/2009 - Stephen C. Wills// Added new header and license agreement.// 10/11/2010 - Mihir Brahmbhatt// Updated header and license agreement.// 11/30/2011 - J. Ritchie Carroll// Modified to support buffer optimized ISupportBinaryImage.// 12/14/2012 - Starlynn Danyelle Gilliam// Modified Header.////****************************************************************************************************** using System;using System.IO;using System.Text;using GSF.Parsing; namespace GSF.Historian.Files{ /// <summary> /// Represents a record in the <see cref="MetadataFile"/> that contains the various attributes associates to a <see cref="HistorianID"/>. /// </summary> /// <seealso cref="MetadataFile"/> /// <seealso cref="MetadataRecordAlarmFlags"/> /// <seealso cref="MetadataRecordGeneralFlags"/> /// <seealso cref="MetadataRecordSecurityFlags"/> /// <seealso cref="MetadataRecordAnalogFields"/> /// <seealso cref="MetadataRecordComposedFields"/> /// <seealso cref="MetadataRecordConstantFields"/> /// <seealso cref="MetadataRecordDigitalFields"/> /// <seealso cref="MetadataRecordSummary"/> public class MetadataRecord : ISupportBinaryImage, IComparable { // ************************************************************************************************** // * Binary Structure * // ************************************************************************************************** // * # Of Bytes Byte Index Data Type Property Name * // * ---------- ---------- ---------- --------------------------------------------------------------* // * 512 0-511 Char(512) Remarks * // * 512 512-1023 Char(512) HardwareInfo * // * 512 1024-1535 Char(512) EmailAddresses * // * 80 1536-1615 Char(80) Description * // * 80 1616-1695 Char(80) CurrentData * // * 40 1696-1735 Char(40) Name * // * 40 1736-1775 Char(40) Synonym1 * // * 40 1776-1815 Char(40) Synonym2 * // * 40 1816-1855 Char(40) Synonym3 * // * 40 1856-1895 Char(40) PagerNumbers * // * 40 1896-1935 Char(40) PhoneNumbers * // * 24 1936-1959 Char(24) PlantCode * // * 24 1960-1983 Char(24) System * // * 40 1984-2023 Char(40) EmailTime * // * 40 2024-2063 Char(40) [Spare string field 1] * // * 40 2064-2103 Char(40) [Spare string field 2] * // * 4 2104-2107 Single ScanRate * // * 4 2108-2111 Int32 UnitNumber * // * 4 2112-2115 Int32 SecurityFlags * // * 4 2116-2119 Int32 GeneralFlags * // * 4 2120-2123 Int32 AlarmFlags * // * 4 2124-2127 Int32 CompressionMinTime * // * 4 2128-2131 Int32 CompressionMaxTime * // * 4 2132-2135 Int32 SourceID * // * 4 2136-2139 Int32 [Spare 32-bit field 1] * // * 4 2140-2143 Int32 [Spare 32-bit field 2] * // * 4 2144-2147 Int32 [Spare 32-bit field 3] * // * 4 2148-2151 Int32 [Spare 32-bit field 4] * // * 512 2152-2663 Byte(512) (Analog | Digital| Composed |Constant)Fields * // ************************************************************************************************** #region [ Members ] // Constants /// <summary> /// Specifies the number of bytes in the binary image of <see cref="MetadataRecord"/>. /// </summary> public const int FixedLength = 2664; // Fields private string m_remarks; private string m_hardwareInfo; private string m_emailAddresses; private string m_description; private string m_currentData; private string m_name; private string m_synonym1; private string m_synonym2; private string m_synonym3; private string m_pagerNumbers; private string m_phoneNumbers; private string m_plantCode; private string m_system; private string m_emailTime; private MetadataRecordSecurityFlags m_securityFlags; private MetadataRecordGeneralFlags m_generalFlags; private MetadataRecordAlarmFlags m_alarmFlags; private int m_sourceID; private MetadataRecordAnalogFields m_analogFields; private MetadataRecordDigitalFields m_digitalFields; private MetadataRecordComposedFields m_composedFields; private MetadataRecordConstantFields m_constantFields; private readonly MetadataFileLegacyMode m_legacyMode; #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the <see cref="MetadataRecord"/> class. /// </summary> /// <param name="historianID">Historian identifier of <see cref="MetadataRecord"/>.</param> /// <param name="legacyMode">Legacy mode of <see cref="MetadataFile"/>.</param> public MetadataRecord(int historianID, MetadataFileLegacyMode legacyMode) { if (historianID < 0) throw new ArgumentOutOfRangeException(nameof(historianID)); HistorianID = historianID; m_remarks = string.Empty; m_hardwareInfo = string.Empty; m_emailAddresses = string.Empty; m_description = string.Empty; m_currentData = string.Empty; m_name = string.Empty; m_synonym1 = string.Empty; m_synonym2 = string.Empty; m_synonym3 = string.Empty; m_pagerNumbers = string.Empty; m_phoneNumbers = string.Empty; m_plantCode = string.Empty; m_system = string.Empty; m_emailTime = string.Empty; m_securityFlags = new MetadataRecordSecurityFlags(); m_generalFlags = new MetadataRecordGeneralFlags(); m_alarmFlags = new MetadataRecordAlarmFlags(); m_analogFields = new MetadataRecordAnalogFields(legacyMode); m_digitalFields = new MetadataRecordDigitalFields(legacyMode); m_composedFields = new MetadataRecordComposedFields(legacyMode); m_constantFields = new MetadataRecordConstantFields(); m_legacyMode = legacyMode; } /// <summary> /// Initializes a new instance of the <see cref="MetadataRecord"/> class. /// </summary> /// <param name="historianID">Historian identifier of <see cref="MetadataRecord"/>.</param> /// <param name="legacyMode">Legacy mode of <see cref="MetadataFile"/>.</param> /// <param name="buffer">Binary image to be used for initializing <see cref="MetadataRecord"/>.</param> /// <param name="startIndex">0-based starting index of initialization data in the <paramref name="buffer"/>.</param> /// <param name="length">Valid number of bytes in <paramref name="buffer"/> from <paramref name="startIndex"/>.</param> public MetadataRecord(int historianID, MetadataFileLegacyMode legacyMode, byte[] buffer, int startIndex, int length) : this(historianID, legacyMode) { ParseBinaryImage(buffer, startIndex, length); } internal MetadataRecord(BinaryReader reader) { HistorianID = reader.ReadInt32(); m_remarks = reader.ReadString(); m_hardwareInfo = reader.ReadString(); m_emailAddresses = reader.ReadString(); m_description = reader.ReadString(); m_currentData = reader.ReadString(); m_name = reader.ReadString(); m_synonym1 = reader.ReadString(); m_synonym2 = reader.ReadString(); m_synonym3 = reader.ReadString(); m_pagerNumbers = reader.ReadString(); m_phoneNumbers = reader.ReadString(); m_plantCode = reader.ReadString(); m_system = reader.ReadString(); m_emailTime = reader.ReadString(); ScanRate = reader.ReadSingle(); UnitNumber = reader.ReadInt32(); m_securityFlags = new MetadataRecordSecurityFlags { Value = reader.ReadInt32() }; m_generalFlags = new MetadataRecordGeneralFlags { Value = reader.ReadInt32() }; m_alarmFlags = new MetadataRecordAlarmFlags { Value = reader.ReadInt32() }; CompressionMinTime = reader.ReadInt32(); CompressionMaxTime = reader.ReadInt32(); m_sourceID = reader.ReadInt32(); switch (m_generalFlags.DataType) { case DataType.Analog: m_analogFields = new MetadataRecordAnalogFields(reader); m_digitalFields = new MetadataRecordDigitalFields(MetadataFileLegacyMode.Disabled); m_composedFields = new MetadataRecordComposedFields(MetadataFileLegacyMode.Disabled); m_constantFields = new MetadataRecordConstantFields(); break; case DataType.Digital: m_digitalFields = new MetadataRecordDigitalFields(reader); m_analogFields = new MetadataRecordAnalogFields(MetadataFileLegacyMode.Disabled); m_composedFields = new MetadataRecordComposedFields(MetadataFileLegacyMode.Disabled); m_constantFields = new MetadataRecordConstantFields(); break; case DataType.Composed: m_composedFields = new MetadataRecordComposedFields(reader); m_analogFields = new MetadataRecordAnalogFields(MetadataFileLegacyMode.Disabled); m_digitalFields = new MetadataRecordDigitalFields(MetadataFileLegacyMode.Disabled); m_constantFields = new MetadataRecordConstantFields(); break; case DataType.Constant: m_constantFields = new MetadataRecordConstantFields(reader); m_analogFields = new MetadataRecordAnalogFields(MetadataFileLegacyMode.Disabled); m_digitalFields = new MetadataRecordDigitalFields(MetadataFileLegacyMode.Disabled); m_composedFields = new MetadataRecordComposedFields(MetadataFileLegacyMode.Disabled); break; default: throw new ArgumentOutOfRangeException(); } } #endregion #region [ Properties ] /// <summary> /// Gets or sets any remarks associated with the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Remarks"/> is 512 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Remarks { get => m_remarks; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_remarks = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(512) : value; } } /// <summary> /// Gets or sets hardware information associated with the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="HardwareInfo"/> is 512 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string HardwareInfo { get => m_hardwareInfo; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_hardwareInfo = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(512) : value; } } /// <summary> /// Gets or sets a comma-separated list of email addresses that will receive alarm notification email messages based /// on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="AlarmEmails"/> is 512 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string AlarmEmails { get => m_emailAddresses; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_emailAddresses = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(512) : value; } } /// <summary> /// Gets or sets the description associated with the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Description"/> is 80 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Description { get => m_description; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_description = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(80) : value; } } /// <summary> /// Gets or sets the time, value and quality of the most current data received for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="CurrentData"/> is 80 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string CurrentData { get => m_currentData; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_currentData = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(80) : value; } } /// <summary> /// Gets or sets a alpha-numeric name for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Name"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Name { get => m_name; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_name = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets an alternate <see cref="Name"/> for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Synonym1"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Synonym1 { get => m_synonym1; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_synonym1 = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets an alternate <see cref="Name"/> for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Synonym2"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Synonym2 { get => m_synonym2; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_synonym2 = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets an alternate <see cref="Name"/> for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Synonym3"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Synonym3 { get => m_synonym3; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_synonym3 = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets a comma-separated list of pager numbers that will receive alarm notification text messages based /// on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="AlarmPagers"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string AlarmPagers { get => m_pagerNumbers; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_pagerNumbers = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets a comma-separated list of phone numbers that will receive alarm notification voice messages based /// on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="AlarmPhones"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string AlarmPhones { get => m_phoneNumbers; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_phoneNumbers = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets the name of the plant to which the <see cref="HistorianID"/> is associated. /// </summary> /// <remarks> /// Maximum length for <see cref="PlantCode"/> is 24 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string PlantCode { get => m_plantCode; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_plantCode = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(24) : value; } } /// <summary> /// Gets or sets the alpha-numeric system identifier for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="SystemName"/> is 24 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string SystemName { get => m_system; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_system = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(24) : value; } } /// <summary> /// Gets or sets the data and time when an alarm notification is sent based on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="EmailTime"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string EmailTime { get => m_emailTime;Lines 1–500 of 843. Load more
//****************************************************************************************************** // MetadataRecord.cs - Gbtc // // Copyright © 2012, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 05/03/2006 - Pinal C. Patel // Generated original version of code based on DatAWare system specifications by Brian B. Fox, GSF. // 04/20/2009 - Pinal C. Patel // Converted to C#. // 09/15/2009 - Stephen C. Wills // Added new header and license agreement. // 10/11/2010 - Mihir Brahmbhatt // Updated header and license agreement. // 11/30/2011 - J. Ritchie Carroll // Modified to support buffer optimized ISupportBinaryImage. // 12/14/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.IO; using System.Text; using GSF.Parsing; namespace GSF.Historian.Files { /// <summary> /// Represents a record in the <see cref="MetadataFile"/> that contains the various attributes associates to a <see cref="HistorianID"/>. /// </summary> /// <seealso cref="MetadataFile"/> /// <seealso cref="MetadataRecordAlarmFlags"/> /// <seealso cref="MetadataRecordGeneralFlags"/> /// <seealso cref="MetadataRecordSecurityFlags"/> /// <seealso cref="MetadataRecordAnalogFields"/> /// <seealso cref="MetadataRecordComposedFields"/> /// <seealso cref="MetadataRecordConstantFields"/> /// <seealso cref="MetadataRecordDigitalFields"/> /// <seealso cref="MetadataRecordSummary"/> public class MetadataRecord : ISupportBinaryImage, IComparable { // ************************************************************************************************** // * Binary Structure * // ************************************************************************************************** // * # Of Bytes Byte Index Data Type Property Name * // * ---------- ---------- ---------- --------------------------------------------------------------* // * 512 0-511 Char(512) Remarks * // * 512 512-1023 Char(512) HardwareInfo * // * 512 1024-1535 Char(512) EmailAddresses * // * 80 1536-1615 Char(80) Description * // * 80 1616-1695 Char(80) CurrentData * // * 40 1696-1735 Char(40) Name * // * 40 1736-1775 Char(40) Synonym1 * // * 40 1776-1815 Char(40) Synonym2 * // * 40 1816-1855 Char(40) Synonym3 * // * 40 1856-1895 Char(40) PagerNumbers * // * 40 1896-1935 Char(40) PhoneNumbers * // * 24 1936-1959 Char(24) PlantCode * // * 24 1960-1983 Char(24) System * // * 40 1984-2023 Char(40) EmailTime * // * 40 2024-2063 Char(40) [Spare string field 1] * // * 40 2064-2103 Char(40) [Spare string field 2] * // * 4 2104-2107 Single ScanRate * // * 4 2108-2111 Int32 UnitNumber * // * 4 2112-2115 Int32 SecurityFlags * // * 4 2116-2119 Int32 GeneralFlags * // * 4 2120-2123 Int32 AlarmFlags * // * 4 2124-2127 Int32 CompressionMinTime * // * 4 2128-2131 Int32 CompressionMaxTime * // * 4 2132-2135 Int32 SourceID * // * 4 2136-2139 Int32 [Spare 32-bit field 1] * // * 4 2140-2143 Int32 [Spare 32-bit field 2] * // * 4 2144-2147 Int32 [Spare 32-bit field 3] * // * 4 2148-2151 Int32 [Spare 32-bit field 4] * // * 512 2152-2663 Byte(512) (Analog | Digital| Composed |Constant)Fields * // ************************************************************************************************** #region [ Members ] // Constants /// <summary> /// Specifies the number of bytes in the binary image of <see cref="MetadataRecord"/>. /// </summary> public const int FixedLength = 2664; // Fields private string m_remarks; private string m_hardwareInfo; private string m_emailAddresses; private string m_description; private string m_currentData; private string m_name; private string m_synonym1; private string m_synonym2; private string m_synonym3; private string m_pagerNumbers; private string m_phoneNumbers; private string m_plantCode; private string m_system; private string m_emailTime; private MetadataRecordSecurityFlags m_securityFlags; private MetadataRecordGeneralFlags m_generalFlags; private MetadataRecordAlarmFlags m_alarmFlags; private int m_sourceID; private MetadataRecordAnalogFields m_analogFields; private MetadataRecordDigitalFields m_digitalFields; private MetadataRecordComposedFields m_composedFields; private MetadataRecordConstantFields m_constantFields; private readonly MetadataFileLegacyMode m_legacyMode; #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the <see cref="MetadataRecord"/> class. /// </summary> /// <param name="historianID">Historian identifier of <see cref="MetadataRecord"/>.</param> /// <param name="legacyMode">Legacy mode of <see cref="MetadataFile"/>.</param> public MetadataRecord(int historianID, MetadataFileLegacyMode legacyMode) { if (historianID < 0) throw new ArgumentOutOfRangeException(nameof(historianID)); HistorianID = historianID; m_remarks = string.Empty; m_hardwareInfo = string.Empty; m_emailAddresses = string.Empty; m_description = string.Empty; m_currentData = string.Empty; m_name = string.Empty; m_synonym1 = string.Empty; m_synonym2 = string.Empty; m_synonym3 = string.Empty; m_pagerNumbers = string.Empty; m_phoneNumbers = string.Empty; m_plantCode = string.Empty; m_system = string.Empty; m_emailTime = string.Empty; m_securityFlags = new MetadataRecordSecurityFlags(); m_generalFlags = new MetadataRecordGeneralFlags(); m_alarmFlags = new MetadataRecordAlarmFlags(); m_analogFields = new MetadataRecordAnalogFields(legacyMode); m_digitalFields = new MetadataRecordDigitalFields(legacyMode); m_composedFields = new MetadataRecordComposedFields(legacyMode); m_constantFields = new MetadataRecordConstantFields(); m_legacyMode = legacyMode; } /// <summary> /// Initializes a new instance of the <see cref="MetadataRecord"/> class. /// </summary> /// <param name="historianID">Historian identifier of <see cref="MetadataRecord"/>.</param> /// <param name="legacyMode">Legacy mode of <see cref="MetadataFile"/>.</param> /// <param name="buffer">Binary image to be used for initializing <see cref="MetadataRecord"/>.</param> /// <param name="startIndex">0-based starting index of initialization data in the <paramref name="buffer"/>.</param> /// <param name="length">Valid number of bytes in <paramref name="buffer"/> from <paramref name="startIndex"/>.</param> public MetadataRecord(int historianID, MetadataFileLegacyMode legacyMode, byte[] buffer, int startIndex, int length) : this(historianID, legacyMode) { ParseBinaryImage(buffer, startIndex, length); } internal MetadataRecord(BinaryReader reader) { HistorianID = reader.ReadInt32(); m_remarks = reader.ReadString(); m_hardwareInfo = reader.ReadString(); m_emailAddresses = reader.ReadString(); m_description = reader.ReadString(); m_currentData = reader.ReadString(); m_name = reader.ReadString(); m_synonym1 = reader.ReadString(); m_synonym2 = reader.ReadString(); m_synonym3 = reader.ReadString(); m_pagerNumbers = reader.ReadString(); m_phoneNumbers = reader.ReadString(); m_plantCode = reader.ReadString(); m_system = reader.ReadString(); m_emailTime = reader.ReadString(); ScanRate = reader.ReadSingle(); UnitNumber = reader.ReadInt32(); m_securityFlags = new MetadataRecordSecurityFlags { Value = reader.ReadInt32() }; m_generalFlags = new MetadataRecordGeneralFlags { Value = reader.ReadInt32() }; m_alarmFlags = new MetadataRecordAlarmFlags { Value = reader.ReadInt32() }; CompressionMinTime = reader.ReadInt32(); CompressionMaxTime = reader.ReadInt32(); m_sourceID = reader.ReadInt32(); switch (m_generalFlags.DataType) { case DataType.Analog: m_analogFields = new MetadataRecordAnalogFields(reader); m_digitalFields = new MetadataRecordDigitalFields(MetadataFileLegacyMode.Disabled); m_composedFields = new MetadataRecordComposedFields(MetadataFileLegacyMode.Disabled); m_constantFields = new MetadataRecordConstantFields(); break; case DataType.Digital: m_digitalFields = new MetadataRecordDigitalFields(reader); m_analogFields = new MetadataRecordAnalogFields(MetadataFileLegacyMode.Disabled); m_composedFields = new MetadataRecordComposedFields(MetadataFileLegacyMode.Disabled); m_constantFields = new MetadataRecordConstantFields(); break; case DataType.Composed: m_composedFields = new MetadataRecordComposedFields(reader); m_analogFields = new MetadataRecordAnalogFields(MetadataFileLegacyMode.Disabled); m_digitalFields = new MetadataRecordDigitalFields(MetadataFileLegacyMode.Disabled); m_constantFields = new MetadataRecordConstantFields(); break; case DataType.Constant: m_constantFields = new MetadataRecordConstantFields(reader); m_analogFields = new MetadataRecordAnalogFields(MetadataFileLegacyMode.Disabled); m_digitalFields = new MetadataRecordDigitalFields(MetadataFileLegacyMode.Disabled); m_composedFields = new MetadataRecordComposedFields(MetadataFileLegacyMode.Disabled); break; default: throw new ArgumentOutOfRangeException(); } } #endregion #region [ Properties ] /// <summary> /// Gets or sets any remarks associated with the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Remarks"/> is 512 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Remarks { get => m_remarks; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_remarks = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(512) : value; } } /// <summary> /// Gets or sets hardware information associated with the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="HardwareInfo"/> is 512 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string HardwareInfo { get => m_hardwareInfo; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_hardwareInfo = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(512) : value; } } /// <summary> /// Gets or sets a comma-separated list of email addresses that will receive alarm notification email messages based /// on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="AlarmEmails"/> is 512 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string AlarmEmails { get => m_emailAddresses; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_emailAddresses = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(512) : value; } } /// <summary> /// Gets or sets the description associated with the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Description"/> is 80 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Description { get => m_description; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_description = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(80) : value; } } /// <summary> /// Gets or sets the time, value and quality of the most current data received for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="CurrentData"/> is 80 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string CurrentData { get => m_currentData; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_currentData = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(80) : value; } } /// <summary> /// Gets or sets a alpha-numeric name for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Name"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Name { get => m_name; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_name = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets an alternate <see cref="Name"/> for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Synonym1"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Synonym1 { get => m_synonym1; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_synonym1 = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets an alternate <see cref="Name"/> for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Synonym2"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Synonym2 { get => m_synonym2; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_synonym2 = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets an alternate <see cref="Name"/> for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="Synonym3"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string Synonym3 { get => m_synonym3; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_synonym3 = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets a comma-separated list of pager numbers that will receive alarm notification text messages based /// on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="AlarmPagers"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string AlarmPagers { get => m_pagerNumbers; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_pagerNumbers = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets a comma-separated list of phone numbers that will receive alarm notification voice messages based /// on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="AlarmPhones"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string AlarmPhones { get => m_phoneNumbers; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_phoneNumbers = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(40) : value; } } /// <summary> /// Gets or sets the name of the plant to which the <see cref="HistorianID"/> is associated. /// </summary> /// <remarks> /// Maximum length for <see cref="PlantCode"/> is 24 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string PlantCode { get => m_plantCode; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_plantCode = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(24) : value; } } /// <summary> /// Gets or sets the alpha-numeric system identifier for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="SystemName"/> is 24 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string SystemName { get => m_system; set { if (value is null) throw new ArgumentNullException(nameof(value)); m_system = m_legacyMode == MetadataFileLegacyMode.Enabled ? value.TruncateRight(24) : value; } } /// <summary> /// Gets or sets the data and time when an alarm notification is sent based on the <see cref="AlarmFlags"/> settings for the <see cref="HistorianID"/>. /// </summary> /// <remarks> /// Maximum length for <see cref="EmailTime"/> is 40 characters. /// </remarks> /// <exception cref="ArgumentNullException">The value being assigned is a null string.</exception> public string EmailTime { get => m_emailTime;