Represents a set of 3-phase line-to-neutral and line-to-line time-domain power data.
Esempio n. 1
0
        /// <summary>
        /// Populates the cycle data set by calculating cycle
        /// data based on the given measurement data sets.
        /// </summary>
        /// <param name="frequency">The frequency of the measured system, in Hz.</param>
        /// <param name="voltageDataSet">Data set containing voltage waveform measurements.</param>
        /// <param name="currentDataSet">Data set containing current waveform measurements.</param>
        public void Populate(double frequency, MeasurementDataSet voltageDataSet, MeasurementDataSet currentDataSet)
        {
            List <MeasurementData> measurementDataList;
            int sampleRateDivisor;
            int numberOfCycles;

            measurementDataList = new List <MeasurementData>()
            {
                voltageDataSet.AN, voltageDataSet.BN, voltageDataSet.CN,
                currentDataSet.AN, currentDataSet.BN, currentDataSet.CN
            };

            sampleRateDivisor = measurementDataList
                                .Select(measurementData => measurementData.SampleRate)
                                .GreatestCommonDenominator();

            numberOfCycles = measurementDataList
                             .Select(measurementData => (measurementData.Measurements.Length - measurementData.SampleRate + 1) / (measurementData.SampleRate / sampleRateDivisor))
                             .Min();

            for (int i = 0; i < numberOfCycles; i++)
            {
                m_cycles.Add(new CycleData(i, sampleRateDivisor, frequency, voltageDataSet, currentDataSet));
            }
        }
Esempio n. 2
0
        // Static Methods

        /// <summary>
        /// Writes all measurement data to a CSV file.
        /// </summary>
        /// <param name="fileName">Export file name.</param>
        /// <param name="voltageData">The voltage measurement data to be written to the file.</param>
        /// <param name="currentData">The current measurement data to be written to the file.</param>
        public static void ExportToCSV(string fileName, MeasurementDataSet voltageData, MeasurementDataSet currentData)
        {
            const string Header = "Time,AN V,BN V,CN V,AB V,BC V,CA V,AN I,BN I,CN I";

            using (FileStream fileStream = File.Create(fileName))
            {
                using (TextWriter fileWriter = new StreamWriter(fileStream))
                {
                    // Write the CSV header to the file
                    fileWriter.WriteLine(Header);

                    // Write the data to the file
                    for (int i = 0; i < voltageData.AN.Times.Length; i++)
                    {
                        string time = new DateTime(voltageData.AN.Times[i]).ToString(DateTimeFormat);

                        double vAN = voltageData.AN.Measurements[i];
                        double vBN = voltageData.BN.Measurements[i];
                        double vCN = voltageData.CN.Measurements[i];

                        double iAN = currentData.AN.Measurements[i];
                        double iBN = currentData.BN.Measurements[i];
                        double iCN = currentData.CN.Measurements[i];

                        fileWriter.Write("{0},{1},{2},{3},", time, vAN, vBN, vCN);
                        fileWriter.Write("{0},{1},{2},", vAN - vBN, vBN - vCN, vCN - vAN);
                        fileWriter.WriteLine("{0},{1},{2}", iAN, iBN, iCN);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new instance of the <see cref="FaultLocationDataSet"/> class.
        /// </summary>
        public FaultLocationDataSet()
        {
            m_voltages  = new MeasurementDataSet();
            m_currents  = new MeasurementDataSet();
            m_cycles    = new CycleDataSet();
            m_frequency = 60.0D;

            m_values = new Dictionary <string, object>();
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new instance of the <see cref="CycleData"/> class.
        /// </summary>
        /// <param name="cycleIndex">The index of the cycle being created.</param>
        /// <param name="sampleRateDivisor">The value to divide from the sample rate to determine the index of the sample at the start of the cycle.</param>
        /// <param name="frequency">The frequency of the measured system, in Hz.</param>
        /// <param name="voltageDataSet">The data set containing voltage measurements.</param>
        /// <param name="currentDataSet">The data set containing current measurements.</param>
        public CycleData(int cycleIndex, int sampleRateDivisor, double frequency, MeasurementDataSet voltageDataSet, MeasurementDataSet currentDataSet)
        {
            int sampleIndex;

            AN = new Conductor(cycleIndex, sampleRateDivisor, frequency, voltageDataSet.AN, currentDataSet.AN);
            BN = new Conductor(cycleIndex, sampleRateDivisor, frequency, voltageDataSet.BN, currentDataSet.BN);
            CN = new Conductor(cycleIndex, sampleRateDivisor, frequency, voltageDataSet.CN, currentDataSet.CN);

            sampleIndex = cycleIndex * (voltageDataSet.AN.SampleRate / sampleRateDivisor);
            StartTime   = new DateTime(voltageDataSet.AN.Times[sampleIndex]);
        }
Esempio n. 5
0
 /// <summary>
 /// Creates a new instance of the <see cref="CycleDataSet"/> class.
 /// </summary>
 /// <param name="frequency">The frequency of the measured system, in Hz.</param>
 /// <param name="voltageDataSet">The data set containing voltage data points.</param>
 /// <param name="currentDataSet">The data set containing current data points.</param>
 public CycleDataSet(double frequency, MeasurementDataSet voltageDataSet, MeasurementDataSet currentDataSet)
 {
     Populate(frequency, voltageDataSet, currentDataSet);
 }
        // Static Methods
        public static void ExportToCSV(string fileName, MeasurementDataSet voltageData, MeasurementDataSet currentData)
        {
            const string Header = "Time,AN V,BN V,CN V,AB V,BC V,CA V,AN I,BN I,CN I";

            using (FileStream fileStream = File.Create(fileName))
            {
                using (TextWriter fileWriter = new StreamWriter(fileStream))
                {
                    // Write the CSV header to the file
                    fileWriter.WriteLine(Header);

                    // Write the data to the file
                    for (int i = 0; i < voltageData.AN.Times.Length; i++)
                    {
                        string time = new DateTime(voltageData.AN.Times[i]).ToString(DateTimeFormat);

                        double vAN = voltageData.AN.Measurements[i];
                        double vBN = voltageData.BN.Measurements[i];
                        double vCN = voltageData.CN.Measurements[i];

                        double iAN = currentData.AN.Measurements[i];
                        double iBN = currentData.BN.Measurements[i];
                        double iCN = currentData.CN.Measurements[i];

                        fileWriter.Write("{0},{1},{2},{3},", time, vAN, vBN, vCN);
                        fileWriter.Write("{0},{1},{2},", vAN - vBN, vBN - vCN, vCN - vAN);
                        fileWriter.WriteLine("{0},{1},{2}", iAN, iBN, iCN);
                    }
                }
            }
        }
        /// <summary>
        /// Creates a new instance of the <see cref="CycleData"/> class.
        /// </summary>
        /// <param name="cycleIndex">The index of the cycle being created.</param>
        /// <param name="sampleRateDivisor">The value to divide from the sample rate to determine the index of the sample at the start of the cycle.</param>
        /// <param name="frequency">The frequency of the measured system, in Hz.</param>
        /// <param name="voltageDataSet">The data set containing voltage measurements.</param>
        /// <param name="currentDataSet">The data set containing current measurements.</param>
        public CycleData(int cycleIndex, int sampleRateDivisor, double frequency, MeasurementDataSet voltageDataSet, MeasurementDataSet currentDataSet)
        {
            int sampleIndex;

            AN = new Conductor(cycleIndex, sampleRateDivisor, frequency, voltageDataSet.AN, currentDataSet.AN);
            BN = new Conductor(cycleIndex, sampleRateDivisor, frequency, voltageDataSet.BN, currentDataSet.BN);
            CN = new Conductor(cycleIndex, sampleRateDivisor, frequency, voltageDataSet.CN, currentDataSet.CN);

            sampleIndex = cycleIndex * (voltageDataSet.AN.SampleRate / sampleRateDivisor);
            StartTime = new DateTime(voltageDataSet.AN.Times[sampleIndex]);
        }
        /// <summary>
        /// Creates a new instance of the <see cref="FaultLocationDataSet"/> class.
        /// </summary>
        public FaultLocationDataSet()
        {
            m_voltages = new MeasurementDataSet();
            m_currents = new MeasurementDataSet();
            m_cycles = new CycleDataSet();
            m_frequency = 60.0D;

            m_values = new Dictionary<string, object>();
        }