Beispiel #1
0
        // commit a line
        public static void Commit(Vector3 a, Vector3 b, Color color)
        {
            // create a new line
            Line_data line = new Line_data
            {
                a     = a,
                b     = b,
                color = color
            };

            // commit it
            lines.Add(line);
        }
Beispiel #2
0
        /// <summary>
        /// Default data processing entry point for <see cref="Algorithm"/>.
        /// </summary>
        /// <param name="timestamp">Timestamp of <paramref name="dataBlock"/>.</param>
        /// <param name="dataBlock">Points values read at current timestamp.</param>
        public void Execute(DateTime timestamp, DataPoint[] raw_dataBlock, int lineNumber)
        {
            DataPoint[] dataBlock = raw_dataBlock;

            if (m_rawDataSet.TimeStamps[0].Year == 1969)
            {
                m_rawDataSet.TimeStamps[0] = timestamp;
            }
            else
            {
                m_rawDataSet.TimeStamps.Add(timestamp);
            }

            // Check dataBlock completeness
            if (dataBlock.Count() < (lineNumber * 8))
            {
                for (int idx0 = 0; idx0 < (lineNumber * 8 - 1); idx0++)
                {
                    if (idx0 >= (dataBlock.Count() - 1))
                    {
                        DataPoint[] TempDataBlock = new DataPoint[dataBlock.Count() + 1];

                        for (int idx1 = 0; idx1 < dataBlock.Count(); idx1++)
                        {
                            TempDataBlock[idx1] = dataBlock[idx1];
                        }

                        int       idx2      = dataBlock.Count() - 1;
                        DataPoint TempPoint = new DataPoint();
                        TempPoint.PointID   = dataBlock[idx2].PointID + 1;
                        TempPoint.Timestamp = dataBlock[idx2].Timestamp;
                        TempPoint.Value     = 0;
                        TempPoint.Flags     = dataBlock[idx2].Flags;
                        TempDataBlock[dataBlock.Count()] = TempPoint;

                        TempDataBlock[dataBlock.Count()] = TempPoint;
                        dataBlock = TempDataBlock;
                    }
                    else
                    {
                        if ((dataBlock[idx0 + 1].PointID != (dataBlock[idx0].PointID + 1)))
                        {
                            DataPoint TempPoint = new DataPoint();
                            TempPoint.PointID   = dataBlock[idx0].PointID + 1;
                            TempPoint.Timestamp = dataBlock[idx0].Timestamp;
                            TempPoint.Value     = 0;
                            TempPoint.Flags     = dataBlock[idx0].Flags;

                            dataBlock = InsertPoint(dataBlock, TempPoint, (idx0 + 1), lineNumber);
                        }
                    }
                }
                //dataBlock = TempDataBlock;
            }

            int             AssignValueCount           = 0;
            Measurement_set CurrentFrameMeasurementSet = new Measurement_set();

            do
            {
                Phasor FromBusVTemp = new Phasor();
                Phasor FromBusITemp = new Phasor();
                Phasor ToBusVTemp   = new Phasor();
                Phasor ToBusITemp   = new Phasor();

                VI_data FromBusVITemp = new VI_data();
                VI_data ToBusVITemp   = new VI_data();

                Line_data CurrentLineDataTemp = new Line_data();

                FromBusVTemp.Magnitude = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount      += 1;
                FromBusVTemp.Angle     = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount      += 1;
                FromBusVITemp.Voltage  = FromBusVTemp;

                FromBusITemp.Magnitude = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount      += 1;
                FromBusITemp.Angle     = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount      += 1;
                FromBusVITemp.Current  = FromBusITemp;

                ToBusVTemp.Magnitude = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount    += 1;
                ToBusVTemp.Angle     = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount    += 1;
                ToBusVITemp.Voltage  = ToBusVTemp;

                ToBusITemp.Magnitude = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount    += 1;
                ToBusITemp.Angle     = dataBlock[AssignValueCount].ValueAsSingle;
                AssignValueCount    += 1;
                ToBusVITemp.Current  = ToBusITemp;

                CurrentLineDataTemp.From_bus = FromBusVITemp;
                CurrentLineDataTemp.To_bus   = ToBusVITemp;

                if (CurrentFrameMeasurementSet.Measurements[0].From_bus == null)
                {
                    CurrentFrameMeasurementSet.Measurements[0] = CurrentLineDataTemp;
                }
                else
                {
                    CurrentFrameMeasurementSet.Measurements.Add(CurrentLineDataTemp);
                }
            } while (AssignValueCount < (dataBlock.Count() - 7));

            if (m_rawDataSet.RawDataSet[0].Measurements[0].From_bus == null)
            {
                m_rawDataSet.RawDataSet[0] = CurrentFrameMeasurementSet;
            }
            else
            {
                m_rawDataSet.RawDataSet.Add(CurrentFrameMeasurementSet);
            }

            m_processedDataBlocks++;
            //string message = $"Analyzed {m_processedDataBlocks:N0} timestamps so far.{Environment.NewLine}";
            //Console.WriteLine(message);
        }