コード例 #1
0
        public void OnlyOscilloMeasurements(string FilePath1, Oscyloskop.Form1 oscillo, int NumberOfMeasures = 10000, int Averages = 10, bool TriggerBtn = false)
        {
            int  MeasureLoopIndicator;
            int  i;
            bool WARNING, Ender = false;

            WaveformArray = new List <List <double> >();
            List <double> temp = new List <double>();
            StringBuilder SB = new StringBuilder();
            StringBuilder SBWSU = new StringBuilder();
            Stopwatch     Stopwatch = new Stopwatch();
            double        Wavenumber = 0, SUMPICO;
            long          SW1, SW2;

            Stopwatch.Start();
            for (MeasureLoopIndicator = 0; MeasureLoopIndicator < NumberOfMeasures; MeasureLoopIndicator++)
            {
                for (int j = 0; j < Averages; j++)
                {
                    SW1 = Stopwatch.ElapsedMilliseconds;
                    WaveformArray.Add(oscillo.odczyt()[0]);
                    SW2 = Stopwatch.ElapsedMilliseconds;
                    PPLPIC.Clear();
                    SB.Append(SW1 + ":" + SW2 + ":");
                    for (i = 0; i < WaveformArray[0].Count; i++)
                    {
                        SB.Append(WaveformArray[0][i] + ":");
                        PPLPIC.Add(i, WaveformArray[0][i]);
                    }
                    SUMPICO = WaveformArray[0].Sum();
                    WaveformArray.Clear();
                    SB.Append("\r\n");
                    i            = 0;
                    DrawTheGraph = true;
                    if (EWHbreak.WaitOne(1) || EWHendoftuning.WaitOne(1))
                    {
                        Ender = true;
                    }
                    if (MeasureLoopIndicator % 5 == 0 || NumberOfMeasures - MeasureLoopIndicator < 50 || Ender == true)
                    {
                        using (StreamWriter SW = new StreamWriter(FilePath1 + "PICO", true))
                        {
                            SW.Write(SB);
                            SW.Flush();
                        }
                        SB.Clear();
                    }
                }
                if (Ender == true)
                {
                    MessageBox.Show("Koniec pomiaru");
                    break;
                }
            }
            Stopwatch.Stop();
            MessageBox.Show("Koniec");
        }
コード例 #2
0
        public void PicoMeasures(string FilePath, Oscyloskop.Form1 oscillo, int NumberOfMeasures = 10000, int Averages = 10, bool TriggerBtn = false)
        {
            EWHustawiono   = new EventWaitHandle(false, EventResetMode.AutoReset, "USTAWIONO");
            EWHprzestroj   = new EventWaitHandle(false, EventResetMode.AutoReset, "PRZESTROJ");
            EWHbreak       = new EventWaitHandle(false, EventResetMode.AutoReset, "ZATRZYMAJ");
            EWHendoftuning = new EventWaitHandle(false, EventResetMode.AutoReset, "KONIEC");
            PICOready      = new EventWaitHandle(false, EventResetMode.AutoReset, "PICOready");
            WSUready       = new EventWaitHandle(false, EventResetMode.AutoReset, "WSUready");
            // EWHstart = new EventWaitHandle(false, EventResetMode.AutoReset, "START");
            int  MeasureLoopIndicator;
            int  i;
            bool WARNING, Ender = false;

            WaveformArray = new List <List <double> >();
            List <double> temp      = new List <double>();
            StringBuilder SB        = new StringBuilder();
            Stopwatch     Stopwatch = new Stopwatch();
            double        SUMPICO;
            long          SW1, SW2, SW3;

            Stopwatch.Start();
            for (MeasureLoopIndicator = 0; MeasureLoopIndicator < NumberOfMeasures || TriggerBtn == true; MeasureLoopIndicator++)
            {
                if (TriggerBtn == true)
                {
                    EWHprzestroj.Set();
                    EWHustawiono.WaitOne();
                }
                for (int j = 0; j < Averages; j++)
                {
                    SW1 = Stopwatch.ElapsedMilliseconds;
                    if (TriggerBtn == true)
                    {
                        PICOready.Set();
                        WSUready.WaitOne();
                    }
                    WaveformArray.Add(oscillo.odczyt()[0]);
                    IntegralPico = WaveformArray[0].Sum();
                    SW2          = Stopwatch.ElapsedMilliseconds;
                    PPLPIC.Clear();
                    SB.Append(SW1 + ":" + SW2 + ":");
                    for (i = 0; i < WaveformArray[0].Count; i++)
                    {
                        SB.Append(WaveformArray[0][i] + ":");
                        PPLPIC.Add(i, WaveformArray[0][i]);
                    }
                    WaveformArray.Clear();
                    SB.Append("\r\n");
                    i            = 0;
                    DrawTheGraph = true;
                    if (EWHbreak.WaitOne(1) || EWHendoftuning.WaitOne(1))
                    {
                        Ender = true;
                    }
                    if (MeasureLoopIndicator % 5 == 0 || NumberOfMeasures - MeasureLoopIndicator < 50 || Ender == true)
                    {
                        using (StreamWriter SW = new StreamWriter(FilePath + "PICO", true))
                        {
                            SW.Write(SB);
                            SW.Flush();
                        }
                        SB.Clear();
                    }
                }
                if (Ender == true)
                {
                    MessageBox.Show("Koniec pomiaru");
                    break;
                }
            }
            Stopwatch.Stop();
            MessageBox.Show("Koniec");
        }
コード例 #3
0
        public void GatherWaveforms(string FilePath1, Oscyloskop.Form1 oscillo, int NumberOfMeasures = 10000, int Averages = 10, bool TriggerBtn = false)
        {
            EWHustawiono   = new EventWaitHandle(false, EventResetMode.AutoReset, "USTAWIONO");
            EWHprzestroj   = new EventWaitHandle(false, EventResetMode.AutoReset, "PRZESTROJ");
            EWHbreak       = new EventWaitHandle(false, EventResetMode.AutoReset, "ZATRZYMAJ");
            EWHendoftuning = new EventWaitHandle(false, EventResetMode.AutoReset, "KONIEC");
            // EWHstart = new EventWaitHandle(false, EventResetMode.AutoReset, "START");
            int  MeasureLoopIndicator;
            int  i;
            bool WARNING, Ender = false;

            WaveformArray = new List <List <double> >();
            List <double> temp = new List <double>();
            StringBuilder SB = new StringBuilder();
            StringBuilder SBWSU = new StringBuilder();
            Stopwatch     Stopwatch = new Stopwatch();
            double        Wavenumber = 0;
            long          SW1, SW2, SW3;

            Stopwatch.Start();
            for (MeasureLoopIndicator = 0; MeasureLoopIndicator < NumberOfMeasures || TriggerBtn == true; MeasureLoopIndicator++)
            {
                if (TriggerBtn == true)
                {
                    EWHprzestroj.Set();
                    EWHustawiono.WaitOne();
                }
                for (int j = 0; j < Averages; j++)
                {
                    SW1 = Stopwatch.ElapsedMilliseconds;
                    WaveformArray.Add(oscillo.odczyt()[0]);
                    SW2 = Stopwatch.ElapsedMilliseconds;
                    var x = obslugaNW.odczytajPrazkiPierwszyIntenf();
                    SW3 = Stopwatch.ElapsedMilliseconds;
                    PPLWSU.Clear();
                    PPLPIC.Clear();
                    SB.Append(SW1 + ":" + SW2 + ":");
                    SBWSU.Append(SW2 + ":" + SW3 + ":");
                    for (i = 0; i < WaveformArray[0].Count; i++)
                    {
                        SB.Append(WaveformArray[0][i] + ":");
                        PPLPIC.Add(i, WaveformArray[0][i]);
                    }
                    SUMPICO = WaveformArray[0].Sum();
                    WaveformArray.Clear();
                    SB.Append("\r\n");
                    SBWSU.Append(obslugaNW.odczytNowegoWMcm(false) + ":" + obslugaNW.odczytszerokosci() + ":");
                    i = 0;
                    foreach (var z in x)
                    {
                        SBWSU.Append(z.ToString() + ":");
                        PPLWSU.Add(i, z);
                        i++;
                    }
                    if (obslugaNW.odczytNowegoWMcm(false) > 0 && obslugaNW.odczytNowegoWMcm(false) < 20000)// usunac true jak działa
                    {
                        PPLSPEC.Add(obslugaNW.odczytNowegoWMcm(false), SUMPICO);
                    }
                    DrawTheGraph = true;
                    SBWSU.Append("\r\n");
                    if (EWHbreak.WaitOne(1) || EWHendoftuning.WaitOne(1))
                    {
                        Ender = true;
                    }
                    if (MeasureLoopIndicator % 5 == 0 || NumberOfMeasures - MeasureLoopIndicator < 50 || Ender == true)
                    {
                        using (StreamWriter SW = new StreamWriter(FilePath1 + "PICO", true))
                        {
                            SW.Write(SB);
                            SW.Flush();
                        }
                        using (StreamWriter SW = new StreamWriter(FilePath1 + "WSU", true))
                        {
                            SW.Write(SBWSU);
                            SW.Flush();
                        }
                        SB.Clear();
                        SBWSU.Clear();
                    }
                }
                if (Ender == true)
                {
                    MessageBox.Show("Koniec pomiaru");
                    break;
                }
            }
            Stopwatch.Stop();
            MessageBox.Show("Koniec");
        }