Esempio n. 1
0
        private void GraphDifference(BinData series1BinData, BinData series2BinData)
        {
            if (series1BinData != null && series2BinData != null && series1BinData.numberOfFrames > 0 && series2BinData.numberOfFrames > 0 && series1BinData.size == series2BinData.size)
            {
                chart2.Series["Series3"].Points.Clear();

                if (radioButton2.Checked)
                {
                    chart2.Series["Series3"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
                }
                else
                {
                    chart2.Series["Series3"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
                }

                double dif;
                for (int i = 0; i < totalBinCount; i++)
                {
                    dif = series2BinData.avgBinArray[i] - series1BinData.avgBinArray[i];

                    if (!checkBox1.Checked || dif >= difThreshold)
                    {
                        difBinArray[i] = (float)dif;
                    }
                    else
                    {
                        difBinArray[i] = -9999;
                    }
                }

                AxisViewChanged(chart2, "Series3", difBinArray, ref graph2LowerFrequency, ref graph2UpperFrequency, ref graph2BinFreqInc);
                chart2.Refresh();
            }
        }
Esempio n. 2
0
        private void GraphData(BinData binData)
        {
            if (binData.dataSeries == "Series1")
            {
                textBox5.Text = binData.numberOfFrames.ToString();
            }
            else
            {
                textBox6.Text = binData.numberOfFrames.ToString();
            }

            AxisViewChanged(chart1, binData.dataSeries, binData.binArray, ref graph1LowerFrequency, ref graph1UpperFrequency, ref graph1BinFreqInc);
            chart1.Refresh();

            AxisViewChanged(chart2, binData.dataSeries, binData.avgBinArray, ref graph2LowerFrequency, ref graph2UpperFrequency, ref graph2BinFreqInc);
            chart2.Refresh();


            if (resetGraph && newData)
            {
                difBinArray = new float[totalBinCount];

                resetGraph = false;
                newData    = false;
            }
        }
Esempio n. 3
0
 public void Flush(BinData farSeries, BinData nearSeries, BinData indeterminateSeries)
 {
     for (int i = 0; i < bufferFramesObjects.Count; i++)
     {
         bufferFramesObjects[i].Flush(farSeries, nearSeries, indeterminateSeries);
     }
 }
Esempio n. 4
0
        private void LoadSeries(string filename, ref BinData series, string seriesString)
        {
            using (FileStream stream = new FileStream(filename, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    dataLowerFrequency = reader.ReadUInt32();
                    dataUpperFrequency = reader.ReadUInt32();
                    stepSize           = reader.ReadUInt32();
                    totalBinCount      = reader.ReadUInt32();

                    series = new BinData(totalBinCount, seriesString);
                    series.numberOfFrames = reader.ReadUInt32();

                    if (seriesString == "Series1")
                    {
                        textBox5.Text = series.numberOfFrames.ToString();
                    }
                    else
                    {
                        textBox6.Text = series.numberOfFrames.ToString();
                    }

                    binSize = (double)(dataUpperFrequency - dataLowerFrequency) / totalBinCount;

                    graph1LowerFrequency = dataLowerFrequency;
                    graph1UpperFrequency = dataUpperFrequency;

                    graph2LowerFrequency = dataLowerFrequency;
                    graph2UpperFrequency = dataUpperFrequency;

                    graph1BinFreqInc = binSize;
                    graph2BinFreqInc = binSize;

                    double value;
                    for (int i = 0; i < series.avgBinArray.Length; i++)
                    {
                        value = reader.ReadSingle();

                        series.totalBinArray[i] = (float)value;

                        value /= series.numberOfFrames;

                        series.binArray[i]    = (float)value;
                        series.avgBinArray[i] = (float)value;
                    }

                    reader.Close();
                }
            }

            resetGraph = true;
            newData    = true;
        }
Esempio n. 5
0
        private void GraphAverageStrength(BinData binData)
        {
            float averageStrength = 0;

            for (int i = 0; i < binData.avgBinArray.Length; i++)
            {
                averageStrength += binData.avgBinArray[i];
            }

            averageStrength /= binData.avgBinArray.Length;

            if (binData.dataSeries == "Series1")
            {
                textBox7.Text = averageStrength.ToString();
            }

            if (binData.dataSeries == "Series2")
            {
                textBox8.Text = averageStrength.ToString();
            }
        }
Esempio n. 6
0
        private void SaveSeries(string filename, BinData series)
        {
            if (series != null)
            {
                using (FileStream stream = new FileStream(filename, FileMode.Create))
                {
                    using (BinaryWriter writer = new BinaryWriter(stream))
                    {
                        writer.Write(dataLowerFrequency);
                        writer.Write(dataUpperFrequency);
                        writer.Write(stepSize);
                        writer.Write(totalBinCount);
                        writer.Write(series.numberOfFrames);

                        for (int i = 0; i < series.avgBinArray.Length; i++)
                        {
                            writer.Write(series.totalBinArray[i]);
                        }

                        writer.Close();
                    }
                }
            }
        }
Esempio n. 7
0
        public void Flush(BinData farSeries, BinData nearSeries, BinData indeterminateSeries)
        {
            if (farSeries != null || nearSeries != null || indeterminateSeries != null)
            {
                BinData targetBinData;

                if (farSeries.totalBinArray.Length == 0)
                {
                    farSeries.totalBinArray = new float[nearSeries.totalBinArray.Length];
                    farSeries.totalBinArrayNumberOfFrames = new float[nearSeries.totalBinArrayNumberOfFrames.Length];
                }

                minFrameIndex = bufferFramesArray.Count;

                BufferFramesObject zoomedOutBufferObject = mainForm.bufferFramesArray.GetBufferFramesObject(0);

                long lowerIndex = (long)((parent.lowerFrequency - zoomedOutBufferObject.lowerFrequency) / zoomedOutBufferObject.binSize);
                long upperIndex = (long)((parent.upperFrequency - zoomedOutBufferObject.lowerFrequency) / zoomedOutBufferObject.binSize);

                for (int i = 0; i < bufferFramesArray.Count; i++)
                {
                    bufferFramesArray[i].stackedFrames = 0;

                    if (bufferFramesArray[i].mode == BinDataMode.Far)
                    {
                        targetBinData = farSeries;
                    }
                    else
                    if (bufferFramesArray[i].mode == BinDataMode.Near)
                    {
                        targetBinData = nearSeries;
                    }
                    else
                    if (bufferFramesArray[i].mode == BinDataMode.Indeterminate)
                    {
                        targetBinData = indeterminateSeries;
                    }
                    else
                    {
                        targetBinData = null;
                    }

                    if (targetBinData != null)
                    {
                        int k = 0;

                        for (long j = lowerIndex; j < upperIndex; j++)
                        {
                            targetBinData.totalBinArray[j] += bufferFramesArray[i].bufferArray[k];
                            targetBinData.totalBinArrayNumberOfFrames[j]++;

                            k++;
                        }

                        targetBinData.bufferFrames--;
                    }
                }
            }

            bufferFramesArray.Clear();

            currentBufferIndex = -1;
            ////currentBufferIndex = 0;
            startBufferIndex = 1;

            transitions = 0;

            minFrameIndex = -1;

            bufferFilled = false;
        }
Esempio n. 8
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                dataLowerFrequency = uint.Parse(textBox1.Text);
                dataUpperFrequency = uint.Parse(textBox2.Text);

                if (dataUpperFrequency <= dataLowerFrequency)
                {
                    MessageBox.Show("End frequency must be greater than start frequency");
                }
                else
                {
                    stepSize = uint.Parse(textBox3.Text);

                    difThreshold = double.Parse(textBox4.Text);

                    SaveConfig();

                    int result = 0;

                    try
                    {
                        result = NativeMethods.Initialize(dataLowerFrequency, dataUpperFrequency, stepSize);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    if (result < 0)
                    {
                        MessageBox.Show("Could not initialize. Is a device connected and not being used by another program?");
                    }
                    else
                    {
                        totalBinCount = NativeMethods.GetBufferSize();

                        binSize = (double)(dataUpperFrequency - dataLowerFrequency) / totalBinCount;

                        graph1BinFreqInc = binSize;
                        graph2BinFreqInc = binSize;

                        graph1LowerFrequency = dataLowerFrequency;
                        graph1UpperFrequency = dataUpperFrequency;

                        graph2LowerFrequency = dataLowerFrequency;
                        graph2UpperFrequency = dataUpperFrequency;

                        //if (series1BinData == null)
                        series1BinData = new BinData(0, "Series1");

                        //if (series2BinData == null)
                        series2BinData = new BinData(0, "Series2");

                        button3.Enabled = true;
                        button5.Enabled = true;

                        resetGraph = true;

                        radioButton3.Checked = true;
                        radioButton4.Enabled = false;

                        textBox5.Text = "0";
                        textBox6.Text = "0";

                        textBox7.Text = "0";
                        textBox8.Text = "0";

                        button3.Enabled = false;
                        button5.Enabled = false;

                        chart1.Series["Series1"].Points.Clear();
                        chart2.Series["Series1"].Points.Clear();

                        chart1.Series["Series2"].Points.Clear();
                        chart2.Series["Series2"].Points.Clear();

                        button3.Enabled = true;
                        button5.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 9
0
        private void RecordData(ref BinData binData, ref double averageCurrentFrameStrength, ref double averageTotalFramesStrength)
        {
            if (binData.binArray.Length == 0)
            {
                binData = new BinData(totalBinCount, binData.dataSeries);
            }

            double value;

            averageCurrentFrameStrength = 0;

            averageTotalFramesStrength = 0;

            NativeMethods.GetBins(binData.binArray);

            for (int j = 0; j < binData.size; j++)
            {
                value = binData.binArray[j];

                if (Double.IsNaN(value) || value > 100 || value < -100)
                {
                    value = -25;
                }

                binData.totalBinArray[j] += (float)value;

                averageCurrentFrameStrength += value;
            }

            binData.numberOfFrames++;

            for (int j = 0; j < binData.size; j++)
            {
                binData.avgBinArray[j] = binData.totalBinArray[j] / binData.numberOfFrames;

                averageTotalFramesStrength += binData.avgBinArray[j];
            }

            averageCurrentFrameStrength /= binData.size;
            averageTotalFramesStrength  /= binData.size;

            if (binData.numberOfFrames % 100 == 0)
            {
                minAvgStrength = 9999;
                maxAvgStrength = -9999;
            }

            if (averageTotalFramesStrength > maxAvgStrength)
            {
                maxAvgStrength = averageTotalFramesStrength;
            }

            if (averageTotalFramesStrength < minAvgStrength)
            {
                minAvgStrength = averageTotalFramesStrength;
            }

            if (resetGraph)
            {
                newData = true;
            }
        }
Esempio n. 10
0
 public void Flush(BinData farSeries, BinData nearSeries, BinData indeterminateSeries)
 {
     bufferFrames.Flush(farSeries, nearSeries, indeterminateSeries);
 }