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"); }
public Thread JustPICO(string FilePath, Oscyloskop.Form1 oscillo, int NumberOfMeasures = 500, int Averages = 10, bool Trigger = false) { if (TriggerBtnOn.Checked) { NumberOfMeasures = 1000000; } Measure = new Thread(() => measurements.PicoMeasures(FilePath, oscillo, NumberOfMeasures, Averages, TriggerBtnOn.Checked)); Measure.Start(); return(Measure); }
public Form1() { PPLsignal = new PointPairList(); PPLIntegralCorrect = new PointPairList(); PPLIntegralWrong = new PointPairList(); PPLInterferometer = new PointPairList(); InitializeComponent(); DA = new DataAnalysis(); oscillo = new Oscyloskop.Form1(); ZedSignal.GraphPane.XAxis.Title.Text = "Number of points"; ZedSignal.GraphPane.YAxis.Title.Text = "Signal"; OscilloSignal.GraphPane.XAxis.Title.Text = "Number of point"; OscilloSignal.GraphPane.YAxis.Title.Text = "Voltage (mV)"; WavemeterSignal.GraphPane.XAxis.Title.Text = "Number of point"; WavemeterSignal.GraphPane.YAxis.Title.Text = "Intensity (a.u.)"; ZedBriefIntegral.GraphPane.XAxis.Title.Text = "Wavenumber (cm^-1)"; ZedBriefIntegral.GraphPane.YAxis.Title.Text = "Total integral (a.u.)"; OscilloSignal.GraphPane.Title.Text = "PicoScope"; WavemeterSignal.GraphPane.Title.Text = "Wavemeter"; DataSlider.BackColor = Color.LightGray; GRAPHDRAWER = new ThreadStart(GraphDrawer); Graphdrawer = new Thread(GRAPHDRAWER); ZedSignal.GraphPane.CurveList.Add(lineItem1); ZedSignal.GraphPane.CurveList.Add(lineItem2); ZedSignal.GraphPane.YAxis.Scale.Max = 5000; ZedSignal.GraphPane.YAxis.Scale.Min = -5000; ZedSignal.GraphPane.YAxis.Scale.MajorStep = 1000; ZedSignal.GraphPane.YAxis.Scale.MinorStep = 250; ZedIntegral.GraphPane.XAxis.Title.Text = "Time (ms)"; ZedIntegral.GraphPane.YAxis.Title.Text = "Counts (a.u.)"; ZedSignal.GraphPane.Title.Text = "Waveform"; ZedIntegral.GraphPane.Title.Text = "Spectrum"; WaveformArray = new List <List <double> >(); CurrentWave = new List <double>(); CurrentInteferometer = new List <double>(); AfterCutoff = new List <double>(); lineItem1.Label.IsVisible = false; lineItem2.Label.IsVisible = false; ZedSignal.Invalidate(); }
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"); }
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"); }
public Thread OnlyOscilloMeasures(string FilePath, Oscyloskop.Form1 oscillo, int NumberOfMeasures = 500, int Averages = 10, bool Trigger = false) // DO USUNIECIA { OscilloMeasure = new Thread(() => measurements.OnlyOscilloMeasurements(FilePath, oscillo, NumberOfMeasures, Averages, Trigger)); OscilloMeasure.Start(); return(OscilloMeasure); }