コード例 #1
0
        /// <summary>
        /// Initializes the <see cref="AngleDifferenceCalculator"/> calculator.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            // Validate input measurements
            List <MeasurementKey> validInputMeasurementKeys = new List <MeasurementKey>();
            SignalType            keyType;

            for (int i = 0; i < InputMeasurementKeys.Length; i++)
            {
                keyType = InputMeasurementKeyTypes[i];

                // Make sure measurement key type is a phase angle
                if (keyType == SignalType.VPHA || keyType == SignalType.IPHA)
                {
                    validInputMeasurementKeys.Add(InputMeasurementKeys[i]);
                }
            }

            // Make sure only phase angles are used as input
            if (validInputMeasurementKeys.Count == 0)
            {
                throw new InvalidOperationException("No valid phase angles were specified as inputs to the angle difference calculator.");
            }

            if (InputMeasurementKeyTypes.Count(s => s == SignalType.VPHA) > 0 && InputMeasurementKeyTypes.Count(s => s == SignalType.IPHA) > 0)
            {
                throw new InvalidOperationException("A mixture of voltage and current phase angles were specified as inputs to the angle difference calculator - you must specify one or the other: only voltage phase angles or only current phase angles.");
            }

            if (validInputMeasurementKeys.Count != 2)
            {
                throw new InvalidOperationException($"Expected exactly two phase angles as inputs to the angle difference calculator, got {validInputMeasurementKeys.Count}.");
            }

            InputMeasurementKeys = validInputMeasurementKeys.ToArray();

            // Validate output measurements
            if (OutputMeasurements.Length < 1)
            {
                throw new InvalidOperationException("An output measurement was not specified for the angle difference calculator - one measurement is expected to represent the \"Calculated Angle Difference\" value.");
            }

            Dictionary <string, string> settings = Settings;
            string setting;

            if (settings.TryGetValue("AlwaysProduceResult", out setting))
            {
                AlwaysProduceResult = setting.ParseBoolean();
            }

            // Initialize member fields
            m_lastAngles             = new double[2];
            m_unwrapOffsets          = new double[2];
            m_latestCalculatedAngles = new List <double>();

            // Set last angles as uninitialized
            m_lastAngles[0] = double.NaN;
            m_lastAngles[1] = double.NaN;
        }
コード例 #2
0
        /// <summary>
        /// Initializes the <see cref="ReferenceAngle"/> calculator.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            // Validate input measurements
            List <MeasurementKey> validInputMeasurementKeys = new List <MeasurementKey>();
            SignalType            keyType;

            for (int i = 0; i < InputMeasurementKeys.Length; i++)
            {
                keyType = InputMeasurementKeyTypes[i];

                // Make sure measurement key type is a phase angle
                if (keyType == SignalType.VPHA || keyType == SignalType.IPHA)
                {
                    validInputMeasurementKeys.Add(InputMeasurementKeys[i]);
                }
            }

            if (validInputMeasurementKeys.Count == 0)
            {
                throw new InvalidOperationException("No valid phase angles were specified as inputs to the reference angle calculator.");
            }

            if (InputMeasurementKeyTypes.Count(s => s == SignalType.VPHA) > 0 && InputMeasurementKeyTypes.Count(s => s == SignalType.IPHA) > 0)
            {
                throw new InvalidOperationException("A mixture of voltage and current phase angles were specified as inputs to the reference angle calculator - you must specify one or the other: only voltage phase angles or only current phase angles.");
            }

            // Make sure only phase angles are used as input
            InputMeasurementKeys = validInputMeasurementKeys.ToArray();

            // Validate output measurements
            if (OutputMeasurements.Length < 1)
            {
                throw new InvalidOperationException("An output measurement was not specified for the reference angle calculator - one measurement is expected to represent the \"Calculated Reference Angle\" value.");
            }

            // Initialize member fields
            m_lastAngles             = new Dictionary <MeasurementKey, double>();
            m_unwrapOffsets          = new Dictionary <MeasurementKey, double>();
            m_latestCalculatedAngles = new List <double>();
            m_phaseResetAngle        = MinimumMeasurementsToUse * 360.0D;
        }
コード例 #3
0
        /// <summary>
        /// Initializes the <see cref="ReferenceMagnitude"/> calculator.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            // Validate input measurements
            List <MeasurementKey> validInputMeasurementKeys = new List <MeasurementKey>();
            SignalType            keyType;

            for (int i = 0; i < InputMeasurementKeys.Length; i++)
            {
                keyType = InputMeasurementKeyTypes[i];

                // Make sure measurement key type is a phase magnitude
                if (keyType == SignalType.VPHM || keyType == SignalType.IPHM)
                {
                    validInputMeasurementKeys.Add(InputMeasurementKeys[i]);
                }
            }

            if (validInputMeasurementKeys.Count == 0)
            {
                throw new InvalidOperationException("No valid phase magnitudes were specified as inputs to the reference magnitude calculator.");
            }

            if (InputMeasurementKeyTypes.Count(s => s == SignalType.VPHM) > 0 && InputMeasurementKeyTypes.Count(s => s == SignalType.IPHM) > 0)
            {
                throw new InvalidOperationException("A mixture of voltage and current phase magnitudes were specified as inputs to the reference magnitude calculator - you must specify one or the other: only voltage phase magnitudes or only current phase magnitudes.");
            }

            // Make sure only phase magnitudes are used as input
            InputMeasurementKeys = validInputMeasurementKeys.ToArray();

            // Validate output measurements
            if (OutputMeasurements.Length < 1)
            {
                throw new InvalidOperationException("An output measurement was not specified for the reference magnitude calculator - one measurement is expected to represent the \"Calculated Reference Magnitude\" value.");
            }
        }