Inheritance: FrequencyValueBase
コード例 #1
0
        /// <summary>
        /// Creates a new <see cref="DataCell"/>.
        /// </summary>
        /// <param name="parent">The reference to parent <see cref="IDataFrame"/> of this <see cref="DataCell"/>.</param>
        /// <param name="configurationCell">The <see cref="IConfigurationCell"/> associated with this <see cref="DataCell"/>.</param>
        public DataCell(IDataFrame parent, IConfigurationCell configurationCell)
            : base(parent, configurationCell, 0x0000, Common.MaximumPhasorValues, Common.MaximumAnalogValues, Common.MaximumDigitalValues)
        {
            // Initialize single phasor value and frequency value with an empty value
            PhasorValues.Add(new PhasorValue(this, configurationCell.PhasorDefinitions[0]));

            // Initialize frequency and df/dt
            FrequencyValue = new FrequencyValue(this, configurationCell.FrequencyDefinition);
        }
コード例 #2
0
ファイル: DataCell.cs プロジェクト: rmc00/gsf
        /// <summary>
        /// Creates a new <see cref="DataCell"/>.
        /// </summary>
        /// <param name="parent">The reference to parent <see cref="IDataFrame"/> of this <see cref="DataCell"/>.</param>
        /// <param name="configurationCell">The <see cref="IConfigurationCell"/> associated with this <see cref="DataCell"/>.</param>
        public DataCell(IDataFrame parent, IConfigurationCell configurationCell)
            : base(parent, configurationCell, 0x0000, Common.MaximumPhasorValues, Common.MaximumAnalogValues, Common.MaximumDigitalValues)
        {
            // Initialize single phasor value and frequency value with an empty value
            PhasorValues.Add(new PhasorValue(this, configurationCell.PhasorDefinitions[0]));

            // Initialize frequency and df/dt
            FrequencyValue = new FrequencyValue(this, configurationCell.FrequencyDefinition);
        }
コード例 #3
0
        /// <summary>
        /// Parses the binary body image.
        /// </summary>
        /// <param name="buffer">Binary image to parse.</param>
        /// <param name="startIndex">Start index into <paramref name="buffer"/> to begin parsing.</param>
        /// <param name="length">Length of valid data within <paramref name="buffer"/>.</param>
        /// <returns>The length of the data that was parsed.</returns>
        /// <remarks>
        /// The longitude, latitude and number of satellites arrive at the top of minute in F-NET data as the analog
        /// data in a single row, each on their own row, as sample 1, 2, and 3 respectively.
        /// </remarks>
        protected override int ParseBodyImage(byte[] buffer, int startIndex, int length)
        {
            DataFrame         parent       = Parent;
            CommonFrameHeader commonHeader = parent.CommonHeader;

            string[]          data = commonHeader.DataElements;
            ConfigurationCell configurationCell = ConfigurationCell;
            uint sampleIndex;

            // Attempt to parse sample index
            if (uint.TryParse(data[Element.SampleIndex], out sampleIndex))
            {
                parent.SampleIndex = sampleIndex;

                // Get timestamp of data record
                parent.Timestamp = configurationCell.TimeOffset + ParseTimestamp(data[Element.Date], data[Element.Time], parent.SampleIndex, configurationCell.FrameRate);

                // Parse out first analog value (can be long/lat at top of minute)
                m_analogValue = double.Parse(data[Element.Analog]);

                if (data[Element.Time].Length >= 7 && int.Parse(data[Element.Time].Substring(4, 2)) == 0)
                {
                    switch (parent.SampleIndex)
                    {
                    case 1:
                        configurationCell.Latitude = m_analogValue;
                        break;

                    case 2:
                        configurationCell.Longitude = m_analogValue;
                        break;

                    case 3:
                        configurationCell.NumberOfSatellites = (int)m_analogValue;
                        break;
                    }
                }

                // Update (or create) frequency value
                double frequency = double.Parse(data[Element.Frequency]);

                if (FrequencyValue != null)
                {
                    FrequencyValue.Frequency = frequency;
                }
                else
                {
                    FrequencyValue = new FrequencyValue(this, configurationCell.FrequencyDefinition as FrequencyDefinition, frequency, 0.0D);
                }

                // Update (or create) phasor value
                Angle       angle     = double.Parse(data[Element.Angle]);
                double      magnitude = double.Parse(data[Element.Voltage]);
                PhasorValue phasor    = null;

                if (PhasorValues.Count > 0)
                {
                    phasor = PhasorValues[0] as PhasorValue;
                }

                if (phasor != null)
                {
                    phasor.Angle     = angle;
                    phasor.Magnitude = magnitude;
                }
                else
                {
                    phasor = new PhasorValue(this, configurationCell.PhasorDefinitions[0] as PhasorDefinition, angle, magnitude);
                    PhasorValues.Add(phasor);
                }
            }

            return(commonHeader.ParsedLength);
        }
コード例 #4
0
ファイル: DataCell.cs プロジェクト: rmc00/gsf
        /// <summary>
        /// Parses the binary body image.
        /// </summary>
        /// <param name="buffer">Binary image to parse.</param>
        /// <param name="startIndex">Start index into <paramref name="buffer"/> to begin parsing.</param>
        /// <param name="length">Length of valid data within <paramref name="buffer"/>.</param>
        /// <returns>The length of the data that was parsed.</returns>
        /// <remarks>
        /// The longitude, latitude and number of satellites arrive at the top of minute in F-NET data as the analog
        /// data in a single row, each on their own row, as sample 1, 2, and 3 respectively.
        /// </remarks>
        protected override int ParseBodyImage(byte[] buffer, int startIndex, int length)
        {
            DataFrame parent = Parent;
            CommonFrameHeader commonHeader = parent.CommonHeader;
            string[] data = commonHeader.DataElements;
            ConfigurationCell configurationCell = ConfigurationCell;
            uint sampleIndex;

            // Attempt to parse sample index
            if (uint.TryParse(data[Element.SampleIndex], out sampleIndex))
            {
                parent.SampleIndex = sampleIndex;

                // Get timestamp of data record
                parent.Timestamp = configurationCell.TimeOffset + ParseTimestamp(data[Element.Date], data[Element.Time], parent.SampleIndex, configurationCell.FrameRate);

                // Parse out first analog value (can be long/lat at top of minute)
                m_analogValue = double.Parse(data[Element.Analog]);

                if (data[Element.Time].Length >= 7 && int.Parse(data[Element.Time].Substring(4, 2)) == 0)
                {
                    switch (parent.SampleIndex)
                    {
                        case 1:
                            configurationCell.Latitude = m_analogValue;
                            break;
                        case 2:
                            configurationCell.Longitude = m_analogValue;
                            break;
                        case 3:
                            configurationCell.NumberOfSatellites = (int)m_analogValue;
                            break;
                    }
                }

                // Update (or create) frequency value
                double frequency = double.Parse(data[Element.Frequency]);

                if (FrequencyValue != null)
                    FrequencyValue.Frequency = frequency;
                else
                    FrequencyValue = new FrequencyValue(this, configurationCell.FrequencyDefinition as FrequencyDefinition, frequency, 0.0D);

                // Update (or create) phasor value
                Angle angle = double.Parse(data[Element.Angle]);
                double magnitude = double.Parse(data[Element.Voltage]);
                PhasorValue phasor = null;

                if (PhasorValues.Count > 0)
                    phasor = PhasorValues[0] as PhasorValue;

                if (phasor != null)
                {
                    phasor.Angle = angle;
                    phasor.Magnitude = magnitude;
                }
                else
                {
                    phasor = new PhasorValue(this, configurationCell.PhasorDefinitions[0] as PhasorDefinition, angle, magnitude);
                    PhasorValues.Add(phasor);
                }
            }

            return commonHeader.ParsedLength;
        }