//****************************************************************************************************** // ChannelSetting.cs - Gbtc // // Copyright © 2015, 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://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: // ---------------------------------------------------------------------------------------------------- // 09/11/2015 - Stephen C. Wills // Generated original version of source code. // //****************************************************************************************************** using System; using System.Linq; using GSF.PQDIF.Physical; namespace GSF.PQDIF.Logical { /// /// Represents a channel setting in a PQDIF file. A channel setting /// resides in an , and is defined by /// a inside the observation record's /// . /// public class ChannelSetting { #region [ Members ] // Fields private CollectionElement m_physicalStructure; private MonitorSettingsRecord m_monitorSettingsRecord; #endregion #region [ Constructors ] /// /// Creates a new instance of the class. /// /// The collection element which is the physical structure of the channel setting. /// The monitor settings record in which the channel setting resides. public ChannelSetting(CollectionElement physicalStructure, MonitorSettingsRecord monitorSettingsRecord) { m_physicalStructure = physicalStructure; m_monitorSettingsRecord = monitorSettingsRecord; } #endregion #region [ Properties ] /// /// Gets the physical structure of the channel setting. /// public CollectionElement PhysicalStructure { get { return m_physicalStructure; } } /// /// Gets the monitor settings record in which the channel setting resides. /// public MonitorSettingsRecord MonitorSettingsRecord { get { return m_monitorSettingsRecord; } } /// /// Gets the index of the /// which defines the channel instance. /// public uint ChannelDefinitionIndex { get { return m_physicalStructure .GetScalarByTag(ChannelDefinition.ChannelDefinitionIndexTag) .GetUInt4(); } set { ScalarElement channelDefinitionIndexElement = m_physicalStructure.GetOrAddScalar(ChannelDefinition.ChannelDefinitionIndexTag); channelDefinitionIndexElement.TypeOfValue = PhysicalType.UnsignedInteger4; channelDefinitionIndexElement.SetUInt4(value); } } /// /// Gets the system-side part of the transducer ratio. /// public double XDSystemSideRatio { get { ScalarElement xdSystemSideRatioElement = m_physicalStructure.GetScalarByTag(XDSystemSideRatioTag); if ((object)xdSystemSideRatioElement == null) return 1.0D; return xdSystemSideRatioElement.GetReal8(); } set { ScalarElement xdSystemSideRatioElement = m_physicalStructure.GetOrAddScalar(XDSystemSideRatioTag); xdSystemSideRatioElement.TypeOfValue = PhysicalType.Real8; xdSystemSideRatioElement.SetReal8(value); } } /// /// Gets the monitor-side part of the transducer ratio. /// public double XDMonitorSideRatio { get { ScalarElement xdMonitorSideRatioElement = m_physicalStructure.GetScalarByTag(XDMonitorSideRatioTag); if ((object)xdMonitorSideRatioElement == null) return 1.0D; return xdMonitorSideRatioElement.GetReal8(); } set { ScalarElement xdMonitorSideRatioElement = m_physicalStructure.GetOrAddScalar(XDMonitorSideRatioTag); xdMonitorSideRatioElement.TypeOfValue = PhysicalType.Real8; xdMonitorSideRatioElement.SetReal8(value); } } #endregion #region [ Methods ] /// /// Determines whether an element identified by the /// given tag exists in this object's physical structure. /// /// The tag of the element to search for. /// True if the element exists; false otherwise. public bool HasElement(Guid tag) { return m_physicalStructure.GetElementsByTag(tag).Any(); } #endregion #region [ Static ] // Static Fields /// /// Tag that identifies the system side ratio. /// public static readonly Guid XDSystemSideRatioTag = new Guid("62f2818a-f9c4-11cf-9d89-0080c72e70a3"); /// /// Tag that identifies the monitor side ratio. /// public static readonly Guid XDMonitorSideRatioTag = new Guid("62f2818b-f9c4-11cf-9d89-0080c72e70a3"); #endregion } }