当前位置: 首页>>代码示例>>C#>>正文


C# IFrame.GetType方法代码示例

本文整理汇总了C#中IFrame.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IFrame.GetType方法的具体用法?C# IFrame.GetType怎么用?C# IFrame.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFrame的用法示例。


在下文中一共展示了IFrame.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssignMeasurementToFrame

        /// <summary>
        /// Assign <see cref="IMeasurement"/> to its <see cref="IFrame"/>.
        /// </summary>
        /// <param name="frame"><see cref="IFrame"/> to assign <paramref name="measurement"/> to.</param>
        /// <param name="measurement"><see cref="IMeasurement"/> to assign to <paramref name="frame"/>.</param>
        /// <returns><c>true</c> if <see cref="IMeasurement"/> was successfully assigned to its <see cref="IFrame"/>.</returns>
        /// <remarks>
        /// In simple concentration scenarios all you need to do is assign a measurement to its frame based on
        /// time. In the case of a phasor data concentrator you need to assign a measurement to its particular
        /// location in its <see cref="IDataFrame"/> - so this method overrides the default behavior in order
        /// to accomplish this task.
        /// </remarks>
        protected override void AssignMeasurementToFrame(IFrame frame, IMeasurement measurement)
        {
            ConcurrentDictionary<MeasurementKey, IMeasurement> measurements = frame.Measurements;

            // Make sure the measurement is a "SignalReferenceMeasurement" (it should be)
            SignalReferenceMeasurement signalMeasurement = measurement as SignalReferenceMeasurement;
            IDataFrame dataFrame = frame as IDataFrame;

            if ((object)signalMeasurement != null && (object)dataFrame != null)
            {
                PhasorValueCollection phasorValues;
                SignalReference signal = signalMeasurement.SignalReference;
                IDataCell dataCell = dataFrame.Cells[signal.CellIndex];
                int signalIndex = signal.Index;
                double signalValue = m_useAdjustedValue ? signalMeasurement.AdjustedValue : signalMeasurement.Value;

                // Assign measurement to its destination field in the data cell based on signal type
                switch (signal.Kind)
                {
                    case SignalKind.Angle:
                        // Assign "phase angle" measurement to data cell
                        phasorValues = dataCell.PhasorValues;
                        if (phasorValues.Count >= signalIndex)
                            phasorValues[signalIndex - 1].Angle = Angle.FromDegrees(signalValue);
                        break;
                    case SignalKind.Magnitude:
                        // Assign "phase magnitude" measurement to data cell
                        phasorValues = dataCell.PhasorValues;
                        if (phasorValues.Count >= signalIndex)
                            phasorValues[signalIndex - 1].Magnitude = signalValue;
                        break;
                    case SignalKind.Frequency:
                        // Assign "frequency" measurement to data cell
                        dataCell.FrequencyValue.Frequency = signalValue;
                        break;
                    case SignalKind.DfDt:
                        // Assign "dF/dt" measurement to data cell
                        dataCell.FrequencyValue.DfDt = signalValue;
                        break;
                    case SignalKind.Status:
                        // Assign "common status flags" measurement to data cell
                        dataCell.CommonStatusFlags = unchecked((uint)signalValue);

                        // Assign by arrival sorting flag for bad synchronization
                        if (!dataCell.SynchronizationIsValid && AllowSortsByArrival && !IgnoreBadTimestamps)
                            dataCell.DataSortingType = DataSortingType.ByArrival;
                        break;
                    case SignalKind.Digital:
                        // Assign "digital" measurement to data cell
                        DigitalValueCollection digitalValues = dataCell.DigitalValues;
                        if (digitalValues.Count >= signalIndex)
                            digitalValues[signalIndex - 1].Value = unchecked((ushort)signalValue);
                        break;
                    case SignalKind.Analog:
                        // Assign "analog" measurement to data cell
                        AnalogValueCollection analogValues = dataCell.AnalogValues;
                        if (analogValues.Count >= signalIndex)
                            analogValues[signalIndex - 1].Value = signalValue;
                        break;
                    case SignalKind.Quality:
                        // Assign "quality flags" measurement to data frame
                        dataFrame.QualityFlags = unchecked((uint)signalValue);
                        break;
                }

                // So that we can accurately track the total measurements that were sorted into this frame,
                // we also assign measurement to frame's measurement dictionary - this is important since
                // in down-sampling scenarios more than one of the same measurement can be sorted into a frame
                // but this only needs to be counted as "one" sort so that when preemptive publishing is
                // enabled you can compare expected measurements to sorted measurements...
                measurements[measurement.Key] = measurement;

                return;
            }

            // This is not expected to occur - but just in case
            if ((object)signalMeasurement == null && (object)measurement != null)
                OnProcessException(new InvalidCastException(string.Format("Attempt was made to assign an invalid measurement to phasor data concentration frame, expected a \"SignalReferenceMeasurement\" but received a \"{0}\"", measurement.GetType().Name)));

            if ((object)dataFrame == null)
                OnProcessException(new InvalidCastException(string.Format("During measurement assignment, incoming frame was not a phasor data concentration frame, expected a type derived from \"IDataFrame\" but received a \"{0}\"", frame.GetType().Name)));
        }
开发者ID:rmc00,项目名称:gsf,代码行数:94,代码来源:PhasorDataConcentratorBase.cs


注:本文中的IFrame.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。