//****************************************************************************************************** // ConfigurationFrameBase.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: // ---------------------------------------------------------------------------------------------------- // 01/14/2005 - J. Ritchie Carroll // Generated original version of source code. // 09/15/2009 - Stephen C. Wills // Added new header and license agreement. // 10/5/2012 - Gavin E. Holden // Added new header and license agreement. // 12/17/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.Collections.Generic; using System.Runtime.Serialization; using GSF.Units.EE; // ReSharper disable VirtualMemberCallInConstructor namespace GSF.PhasorProtocols { /// /// Represents the protocol independent common implementation of any that can be sent or received. /// [Serializable] public abstract class ConfigurationFrameBase : ChannelFrameBase, IConfigurationFrame { #region [ Members ] // Fields private ushort m_frameRate; private decimal m_ticksPerFrame; #endregion #region [ Constructors ] /// /// Creates a new from specified parameters. /// /// The ID code of this . /// The reference to the collection of cells for this . /// The exact timestamp, in , of the data represented by this . /// The defined frame rate of this . protected ConfigurationFrameBase(ushort idCode, ConfigurationCellCollection cells, Ticks timestamp, ushort frameRate) : base(idCode, cells, timestamp) { FrameRate = frameRate; } /// /// Creates a new from serialization parameters. /// /// The with populated with data. /// The source for this deserialization. protected ConfigurationFrameBase(SerializationInfo info, StreamingContext context) : base(info, context) { // Deserialize configuration frame FrameRate = info.GetUInt16("frameRate"); } #endregion #region [ Properties ] /// /// Gets the for this . /// public override FundamentalFrameType FrameType => FundamentalFrameType.ConfigurationFrame; /// /// Gets flag that determines if frame image can be queued for publication or should be processed immediately. /// /// /// Configuration frames are not queued for publication by default. /// public override bool AllowQueuedPublication => false; /// /// Gets reference to the for this . /// public new virtual ConfigurationCellCollection Cells => base.Cells as ConfigurationCellCollection; /// /// Gets or sets the parsing state for the this . /// public new virtual IConfigurationFrameParsingState State { get => base.State as IConfigurationFrameParsingState; set => base.State = value; } /// /// Gets or sets defined frame rate of this . /// public virtual ushort FrameRate { get => m_frameRate; set { m_frameRate = value; if (m_frameRate != 0) m_ticksPerFrame = Ticks.PerSecond / (decimal)m_frameRate; else m_ticksPerFrame = 0; } } /// /// Gets the defined per frame of this . /// public virtual decimal TicksPerFrame => m_ticksPerFrame; /// /// of string based property names and values for the object. /// public override Dictionary Attributes { get { Dictionary baseAttributes = base.Attributes; baseAttributes.Add("Frame Rate", FrameRate.ToString()); baseAttributes.Add("Ticks Per Frame", TicksPerFrame.ToString()); return baseAttributes; } } #endregion #region [ Methods ] /// /// Sets a new nominal for all elements of each in the collection. /// /// New nominal for elements. public virtual void SetNominalFrequency(LineFrequency value) { foreach (IConfigurationCell cell in Cells) cell.NominalFrequency = value; } /// /// Populates a with the data needed to serialize the target object. /// /// The to populate with data. /// The destination for this serialization. public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); // Serialize configuration frame info.AddValue("frameRate", m_frameRate); } #endregion } }