コード例 #1
0
        internal static Output Execute(Input inputData, _InputMeta inputMeta)
        {
            Output output = Output.CreateNew();


            return(output);
        }
コード例 #2
0
        public static string GetStatusWordsStatisticsMessage(Input inputData, _InputMeta inputMeta)
        {
            int nonEmptyStatusWordCount       = 0;
            int statusWordsWithoutErrorsCount = 0;
            int validStatusWordsForLSECount   = 0;

            for (int i = 0; i < inputMeta.StatusWords.Values.Length; i++)
            {
                if (inputMeta.StatusWords.Values[i].ID != Guid.Empty)
                {
                    nonEmptyStatusWordCount++;
                    if (inputData.StatusWords.Values[i] == 0.0)
                    {
                        statusWordsWithoutErrorsCount++;
                    }
                    StatusWord statusWord = new StatusWord();
                    statusWord.BinaryValue = inputData.StatusWords.Values[i];
                    if (!(statusWord.DataIsValid || statusWord.SynchronizationIsValid))
                    {
                        validStatusWordsForLSECount++;
                    }
                }
            }

            return($"R{nonEmptyStatusWordCount}-G{statusWordsWithoutErrorsCount}-V{validStatusWordsForLSECount}/{inputMeta.StatusWords.Values.Length} ");
        }
コード例 #3
0
        internal static Output Execute(Input inputData, _InputMeta inputMeta)
        {
            RuntimeTimer.Reset();
            RuntimeTimer.Start();

            Output output = Output.CreateNew();

            m_frameIndex += 1;

            try
            {
                if (m_network == null || m_network.Model == null)
                {
                    MainWindow.WriteError(new NullReferenceException($"Network or NetworkModel is null"));
                }
                else
                {
                    ClearMeasurements();
                    MapInput(inputData, inputMeta);
                    AcknowledgeMeasurements();
                    ExecuteObservabilityAnalysis();
                    ComputeSystemState();
                    PostProcessSystemState();
                    MapOutput(output);
                }
            }
            catch (Exception ex)
            {
                // Display exceptions to the main window
                MainWindow.WriteError(new InvalidOperationException($"Algorithm exception: {ex.Message}", ex));
            }

            return(output);
        }
コード例 #4
0
 private static void MapInput(Input inputData, _InputMeta inputMeta)
 {
     PerformanceTimer.Reset();
     PerformanceTimer.Start();
     MapVoltagePhasorInput(inputData, inputMeta);
     MapCurrentPhasorInput(inputData, inputMeta);
     MapStatusWordInput(inputData, inputMeta);
     MapDigitalsInput(inputData, inputMeta);
     PerformanceTimer.Stop();
     m_network.PerformanceMetrics.ParsingExecutionTime = PerformanceTimer.ElapsedTicks;
 }
コード例 #5
0
 /// <summary>
 /// Maps the incoming digital values to their appropriate measurements in the network model.
 /// </summary>
 /// <param name="inputData">The frame of input data as provided by the openECA.</param>
 /// <param name="inputMeta">The metadata for the frame of input data as provided by the openECA</param>
 private static void MapDigitalsInput(Input inputData, _InputMeta inputMeta)
 {
     for (int i = 0; i < inputMeta.Digitals.Values.Length; i++)
     {
         Guid   key   = inputMeta.Digitals.Values[i].ID;
         double value = inputData.Digitals.Values[i];
         if (key != Guid.Empty)
         {
             m_network.Model.InputKeyValuePairs.Add(key.ToString(), value);
         }
     }
 }
コード例 #6
0
        public static string GetDigialsStatisticsMessage(Input inputData, _InputMeta inputMeta)
        {
            int nonEmptyDigitalsCount = 0;

            for (int i = 0; i < inputMeta.Digitals.Values.Length; i++)
            {
                if (inputMeta.Digitals.Values[i].ID != Guid.Empty)
                {
                    nonEmptyDigitalsCount++;
                }
            }

            return($"RD: {nonEmptyDigitalsCount}/{inputMeta.Digitals.Values.Length} ");
        }
コード例 #7
0
        public static string GetCurrentPhasorStatisticsMessage(Input inputData, _InputMeta inputMeta)
        {
            int nonEmptyCurrentPhasorsCount = 0;

            for (int i = 0; i < inputMeta.CurrentPhasors.Phasors.Length; i++)
            {
                if (inputMeta.CurrentPhasors.Phasors[i].Magnitude.ID != Guid.Empty && inputMeta.CurrentPhasors.Phasors[i].Angle.ID != Guid.Empty)
                {
                    nonEmptyCurrentPhasorsCount++;
                }
            }

            return($"RI: {nonEmptyCurrentPhasorsCount}/{inputMeta.CurrentPhasors.Phasors.Length} ");
        }
コード例 #8
0
 /// <summary>
 /// Maps the incoming PMU status flags to their appropriate measurements in the network model.
 /// </summary>
 /// <param name="inputData">The frame of input data as provided by the openECA.</param>
 /// <param name="inputMeta">The metadata for the frame of input data as provided by the openECA</param>
 private static void MapStatusWordInput(Input inputData, _InputMeta inputMeta)
 {
     // Add the measurements to the model here
     // m_network.Model.InputKeyValuePairs.Add(angleKey, phasor.Angle);
     for (int i = 0; i < inputMeta.StatusWords.Values.Length; i++)
     {
         Guid   key   = inputMeta.StatusWords.Values[i].ID;
         double value = inputData.StatusWords.Values[i];
         if (key != Guid.Empty)
         {
             m_network.Model.InputKeyValuePairs.Add(key.ToString(), value);
         }
     }
 }
コード例 #9
0
        private _InputMeta CreateLSE_InputMeta(TypeMapping typeMapping)
        {
            Dictionary <string, FieldMapping> fieldLookup = typeMapping.FieldMappings.ToDictionary(mapping => mapping.Field.Identifier);
            _InputMeta obj = new _InputMeta();

            {
                // Create _DigitalsMeta UDT for "Digitals" field
                FieldMapping fieldMapping  = fieldLookup["Digitals"];
                TypeMapping  nestedMapping = GetTypeMapping(fieldMapping);

                PushRelativeFrame(fieldMapping);
                obj.Digitals = CreateECA_DigitalsMeta(nestedMapping);
                PopRelativeFrame(fieldMapping);
            }

            {
                // Create _StatusWordsMeta UDT for "StatusWords" field
                FieldMapping fieldMapping  = fieldLookup["StatusWords"];
                TypeMapping  nestedMapping = GetTypeMapping(fieldMapping);

                PushRelativeFrame(fieldMapping);
                obj.StatusWords = CreateECA_StatusWordsMeta(nestedMapping);
                PopRelativeFrame(fieldMapping);
            }

            {
                // Create _PhasorCollectionMeta UDT for "VoltagePhasors" field
                FieldMapping fieldMapping  = fieldLookup["VoltagePhasors"];
                TypeMapping  nestedMapping = GetTypeMapping(fieldMapping);

                PushRelativeFrame(fieldMapping);
                obj.VoltagePhasors = CreateECA_PhasorCollectionMeta(nestedMapping);
                PopRelativeFrame(fieldMapping);
            }

            {
                // Create _PhasorCollectionMeta UDT for "CurrentPhasors" field
                FieldMapping fieldMapping  = fieldLookup["CurrentPhasors"];
                TypeMapping  nestedMapping = GetTypeMapping(fieldMapping);

                PushRelativeFrame(fieldMapping);
                obj.CurrentPhasors = CreateECA_PhasorCollectionMeta(nestedMapping);
                PopRelativeFrame(fieldMapping);
            }

            return(obj);
        }
コード例 #10
0
        public static Output Execute(Input inputData, _InputMeta inputMeta)
        {
            Output output = new Output();

            try
            {
                // Output Testing Message in openECA Client MainWindow
                string _message = String.Format("\n=============== MainWindowTempLog_{0:yyyy-MM-dd_hh:mm:ss.fff} ===============\n", DateTime.UtcNow);
                foreach (VcTransformer Transformer in vca.InputFrame.ControlTransformers)
                {
                    _message += String.Format("\n\t- ControlTransformers_{0}_{1}\t| TapV: {2:00} \t VoltsV: {3}", Transformer.DeviceId, Transformer.LtcCtlId, Transformer.TapV, Transformer.VoltsV);
                }

                foreach (VcCapacitorBank CapBank in vca.InputFrame.ControlCapacitorBanks)
                {
                    _message += String.Format("\n\t- ControlCapBanks_{0}\t| CapBkrV: {1} \t VoltsV: {2}  Clov:{3} Chiv:{4}", CapBank.CapBkrId, CapBank.CapBkrV, CapBank.LockvV, CapBank.Clov, CapBank.Chiv);
                }

                MainWindow.WriteMessage(_message);


                // Extract inputData from openECA then Call SubRoutine
                vca.GetData(inputData, inputMeta, PreviousFrame);
                MainWindow.WriteMessage("%%\t" + vca.LogMessage.Replace("|", "\n = "));
                //System.Threading.Thread.Sleep(800);     //Threading: Suspends the current thread for MainWindow Output.

                // Append to tempLog File
                //string tempLogPath = (@"C:\Users\Chetan\Documents\openECA Projects\Zhijie\LVC20170203\CtrlDecisionLog_170206_test1.txt");
                //File.AppendAllText(tempLogPath, _message + "\n%%\t" + vca.LogMessage.Replace("|", "\n = "));

                // Logging control decision to *.xml files
                string   logsfolder   = (@"C:\Users\Chetan\Documents\openECA Projects\Zhijie\LVC20170203\Logs\\");
                string[] logsfilestr  = Directory.GetFiles(logsfolder, "CtrlDecisionLog_*.xml");
                string   logsFileName = logsfolder + "CtrlDecisionLog" + String.Format("_{0:000}_{1:yyyyMMdd_hhmmssfff}", (logsfilestr.Length + 1), DateTime.UtcNow) + ".xml";
                vca.SerializeToXml(logsFileName);

                // Store Current vca.InputFrame to previous.InputFrame for the next InputFrame
                PreviousFrame = vca.InputFrame;
            }
            catch (Exception ex)
            {
                // Display exceptions to the main window
                MainWindow.WriteError(new InvalidOperationException($"Algorithm exception: {ex.Message}", ex));
            }

            return(output);
        }
コード例 #11
0
        //public override void Map(IDictionary<MeasurementKey, IMeasurement> measurements)
        //{
        //    SignalLookup.UpdateMeasurementLookup(measurements);
        //    TypeMapping inputMapping = MappingCompiler.GetTypeMapping(InputMapping);

        //    Phasor inputData = CreateECAPhasor(inputMapping);
        //    KeyIndex = 0;
        //    _PhasorMeta inputMeta = CreateECA_PhasorMeta(inputMapping);
        //    Analytic.InputData = inputData;
        //    Analytic.InputMeta = inputMeta;
        //    Analytic.TakeSample();
        //    (Analytic.Host as IAlgorithmHost).SpecialStatus = $"Processing {inputData.Magnitude}";
        //    Algorithm.Output algorithmOutput = Algorithm.Execute(inputData, inputMeta);
        //    Subscriber.SendMeasurements(m_unmapper.Unmap(algorithmOutput.OutputData, algorithmOutput.OutputMeta));
        //}

        #region [ Methods ]

        public override void Map(IDictionary <MeasurementKey, IMeasurement> measurements)
        {
            SignalLookup.UpdateMeasurementLookup(measurements);
            TypeMapping inputMapping = MappingCompiler.GetTypeMapping(InputMapping);

            Reset();
            Input inputData = CreateLSEInput(inputMapping);

            Reset();
            _InputMeta inputMeta = CreateLSE_InputMeta(inputMapping);

            Analytic.InputData = inputData;
            Analytic.InputMeta = inputMeta;
            Analytic.Execute();
            Algorithm.Output algorithmOutput = Algorithm.Execute(inputData, inputMeta);
            Subscriber.SendMeasurements(m_unmapper.Unmap(algorithmOutput.OutputData, algorithmOutput.OutputMeta));
        }
コード例 #12
0
 /// <summary>
 /// Maps the incoming current phasors to their appropriate series and shunt elements in the network model.
 /// </summary>
 /// <param name="inputData">The frame of input data as provided by the openECA.</param>
 /// <param name="inputMeta">The metadata for the frame of input data as provided by the openECA</param>
 private static void MapCurrentPhasorInput(Input inputData, _InputMeta inputMeta)
 {
     // Add the measurements to the model here
     // m_network.Model.InputKeyValuePairs.Add(angleKey, phasor.Angle);
     for (int i = 0; i < inputMeta.CurrentPhasors.Phasors.Length; i++)
     {
         Guid   magnitudeKey = inputMeta.CurrentPhasors.Phasors[i].Magnitude.ID;
         Guid   angleKey     = inputMeta.CurrentPhasors.Phasors[i].Angle.ID;
         double magnitude    = inputData.CurrentPhasors.Phasors[i].Magnitude;
         double angle        = inputData.CurrentPhasors.Phasors[i].Angle;
         if (magnitudeKey != Guid.Empty)
         {
             m_network.Model.InputKeyValuePairs.Add(magnitudeKey.ToString(), magnitude);
         }
         if (angleKey != Guid.Empty)
         {
             m_network.Model.InputKeyValuePairs.Add(angleKey.ToString(), angle);
         }
     }
 }
コード例 #13
0
        public void GetData(Input inputData, _InputMeta inputMeta, VoltVarController PreviousFrame)
        {
            #region [ openECA inputData Extraction ]
            // Extract inputData from openECA
            //m_inputFrame.ControlTransformers[0].TapV = inputData.TapVTx4;
            m_inputFrame.ControlTransformers[0].MwV    = inputData.MwVTx4;
            m_inputFrame.ControlTransformers[0].MvrV   = inputData.MvrVTx4;
            m_inputFrame.ControlTransformers[0].VoltsV = inputData.VoltsVTx4;

            //m_inputFrame.ControlTransformers[1].TapV = inputData.TapVTx5;
            m_inputFrame.ControlTransformers[1].MwV    = inputData.MwVTx5;
            m_inputFrame.ControlTransformers[1].MvrV   = inputData.MvrVTx5;
            m_inputFrame.ControlTransformers[1].VoltsV = inputData.VoltsVTx5;

            m_inputFrame.ControlCapacitorBanks[0].BusBkrV = inputData.BusBkrVCap1;
            //m_inputFrame.ControlCapacitorBanks[0].CapBkrV = inputData.CapBkrVCap1;
            m_inputFrame.ControlCapacitorBanks[0].LockvV = inputData.LocKvVCap1;

            m_inputFrame.ControlCapacitorBanks[1].BusBkrV = inputData.BusBkrVCap2;
            //m_inputFrame.ControlCapacitorBanks[1].CapBkrV = inputData.CapBkrVCap2;
            m_inputFrame.ControlCapacitorBanks[1].LockvV = inputData.LocKvVCap2;

            m_inputFrame.SubstationInformation.G1Mw  = inputData.G1Mw;
            m_inputFrame.SubstationInformation.G1Mvr = inputData.G1Mvr;
            m_inputFrame.SubstationInformation.G2Mw  = inputData.G2Mw;
            m_inputFrame.SubstationInformation.G2Mvr = inputData.G2Mvr;

            #endregion

            SubRoutine         sub            = new SubRoutine();
            ReadCurrentControl ReadCurrentCon = new ReadCurrentControl();

            VoltVarController Frame = new VoltVarController();

            #region [ Measurements Mapping ]

            m_inputFrame.OnNewMeasurements();

            #endregion

            #region [ Read The Previous Run ]

            m_inputFrame.ReadPreviousRun(PreviousFrame);

            #endregion

            #region [ Verify Program Controls ]

            ReadCurrentCon.VerifyProgramControl(m_inputFrame.SubstationAlarmDevice.LtcProgram);

            #endregion

            #region [ Adjust Control Delay Counters ]

            //#-----------------------------------------------------------------------#
            //# adjust the cap bank control delay counter, which is used to ensure:	#
            //# a. we don't do two cap bank control within 30 minutes of each other.	#
            //# b. we don't do a tap control within a minute of a cap bank control.	#
            //#-----------------------------------------------------------------------#

            if (m_inputFrame.SubstationInformation.Ncdel < m_inputFrame.SubstationInformation.Zcdel)
            {
                m_inputFrame.SubstationInformation.Ncdel = m_inputFrame.SubstationInformation.Ncdel + 1;
            }


            //#-----------------------------------------------------------------------#
            //# Adjust the tap control delay counter, which is used to ensure we	#
            //# don't do a cap bank control within a minute of a tap control.		#
            //#-----------------------------------------------------------------------#


            if (m_inputFrame.SubstationInformation.Ntdel < m_inputFrame.SubstationInformation.Zdel)
            {
                m_inputFrame.SubstationInformation.Ntdel = m_inputFrame.SubstationInformation.Ntdel + 1;
            }


            #endregion

            #region [ Read Curren Tx Values and Voltages ]

            m_inputFrame = ReadCurrentCon.ReadCurrentTransformerValuesAndVoltages(m_inputFrame);

            #endregion

            #region [ Check if the Previous Control Reults can Meet Our Expectation ]

            m_inputFrame = ReadCurrentCon.CheckPreviousControlResults(m_inputFrame);

            #endregion

            #region [ Call Sub Taps ]

            m_inputFrame = sub.Taps(m_inputFrame);

            #endregion

            #region [CapBank]

            m_inputFrame = sub.CapBank(m_inputFrame);

            #endregion

            #region [ Save before Exit ]

            m_logMessage  = ReadCurrentCon.MessageInput;
            m_logMessage += sub.MessageInput;
            m_inputFrame.LtcStatus.Avv    = 0;
            m_inputFrame.LtcStatus.Nins   = 0;
            m_inputFrame.LtcStatus.MinVar = 99999;
            m_inputFrame.LtcStatus.MaxVar = -99999;

            #endregion
        }