/// <summary> /// Runs the spectra /// </summary> /// <param name="i"></param> public static void Thread1(int i) { //ushort[] DataArray = new ushort[2048]; SpecThread objThread1 = new SpecThread(); SpecTake(i); }
/// <summary> /// Turns on the laser, takes and saves spectra, turns laser off /// </summary> /// <param name="i">iteration number</param> /// <param name="formObject"></param> internal void takeSpectrum(int i, Form1 formObject) { Form1 form1 = formObject; LaserSet(form1.laserOn, form1.spfc[2], form1.spfc[3], form1.spfc[1], form1); //laserOn Thread tid1 = new Thread(new ThreadStart(() => SpecThread.Thread1(i))); //takes spectra using a secondary thread, seems to be quicker tid1.Start(); tid1.Join(); //waits for thread to complete before turning laser off LaserSet(form1.laserOff, form1.spfc[2], form1.spfc[3], form1.spfc[1], form1); //Laser Off }
/// <summary> /// Takes Spectrum /// </summary> /// <param name="i">Spectrum number</param> private static void SpecTake(int i) { //variable initialisation int ret = 0; SpecThread objThread1 = new SpecThread(); ret = Spectrometer.bwtekDSPDataReadUSB(1, 0, 0, 0, objThread1.DataArray, 0); //read data from spectrometer if (ret < 0) { MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; result = MessageBox.Show("Spectrum take failed, check USB connections and power supply for instabilities", "Program will close", buttons); //this.Close(); } SpecSave(objThread1.DataArray, i); //Saves Spectrum from data }