Exemple #1
0
        private static void parser_ReceivedDataFrame(object sender, EventArgs <IDataFrame> e)
        {
            IDataFrame dataFrame = e.Argument;

            if (WriteLogs)
            {
                m_exportFile.WriteLine(dataFrame.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff") + string.Concat(dataFrame.Cells.Select(cell => "," + cell.FrequencyValue.Frequency.ToString())));
            }

            // Pass frame measurements to concentrator...
            if (TestConcentrator)
            {
                ExtractFrameMeasurements(dataFrame);
            }

            // Increase the frame count each time a frame is received
            frameCount++;

            //IDataCell device = dataFrame.Cells[0];
            //Console.Write(device.FrequencyValue.Frequency.ToString("0.000Hz "));

            // Print information each time we receive 60 frames (every 2 seconds for 30 frames per second)
            // Also check to assure the DataFrame has at least one Cell
            if (frameCount % 60 == 0)
            {
                Console.WriteLine("Received {0} data frames so far - parsed timesatmp = \"{1}\"...", frameCount, dataFrame.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff"));

                if (dataFrame.Cells.Count > 0)
                {
                    IDataCell device = dataFrame.Cells[0];
                    Console.WriteLine("    Last frequency: {0}Hz", device.FrequencyValue.Frequency);

                    for (int x = 0; x < device.PhasorValues.Count; x++)
                    {
                        Console.WriteLine("      PMU {0} Phasor {1} Angle = {2}", device.IDCode, x, device.PhasorValues[x].Angle);
                        Console.WriteLine("      PMU {0} Phasor {1} Magnitude = {2}", device.IDCode, x, device.PhasorValues[x].Magnitude);
                    }

                    Console.WriteLine("    Last Timestamp: {0}", device.GetStatusFlagsMeasurement().Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                }

                if ((object)concentrator != null)
                {
                    Console.WriteLine(concentrator.Status);
                }
            }
        }