// This function reads and displays the temperature inputs by detecting // the buttons clicked, by detecting the value of the variable "check". // It runs a while loop to keep checking for button presses, and using // Thread.Sleep(), it checks buttons, reads and displays temperatures in // the selected scale at a set frequency (2 Hz). The loop ends when the // value of check is set to -1 by clicking the Exit button. Temperatures // are read using the TInScan function, and an array is passed to the // update_gui() function to display them using a delegate. private void TC_reader() { while (true) { if (check == 1 || check == 3) { MccBoard daq = new MccDaq.MccBoard(BoardNum); float[] TempData = new float[CHANCOUNT]; MccDaq.ErrorInfo RetVal; switch (T_Scale) { case "F": RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL, TempScale.Fahrenheit, out TempData[0], ThermocoupleOptions.Filter); IsError(RetVal); break; case "K": RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL, TempScale.Kelvin, out TempData[0], ThermocoupleOptions.Filter); IsError(RetVal); break; default: RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL, TempScale.Celsius, out TempData[0], ThermocoupleOptions.Filter); IsError(RetVal); break; } Update_Display update_del = new Update_Display(update_gui); Invoke(update_del, TempData); Thread.Sleep(500); } if (check == -1) { break; } } }
// This function reads and displays the temperature inputs by detecting // the buttons clicked, by detecting the value of the variable "check". // It runs a while loop to keep checking for button presses, and using // Thread.Sleep(), it checks buttons, reads and displays temperatures in // the selected scale at a set frequency (2 Hz). The loop ends when the // value of check is set to -1 by clicking the Exit button. Temperatures // are read using the TInScan function, and an array is passed to the // update_gui() function to display them using a delegate. private void TC_reader() { while (true) { if (check == 1 || check == 3) { MccBoard daq = new MccDaq.MccBoard(BoardNum); float[] TempData = new float[CHANCOUNT]; MccDaq.ErrorInfo RetVal; switch(T_Scale) { case "F": RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL, TempScale.Fahrenheit, out TempData[0], ThermocoupleOptions.Filter); IsError(RetVal); break; case "K": RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL, TempScale.Kelvin, out TempData[0], ThermocoupleOptions.Filter); IsError(RetVal); break; default: RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL, TempScale.Celsius, out TempData[0], ThermocoupleOptions.Filter); IsError(RetVal); break; } Update_Display update_del = new Update_Display(update_gui); Invoke(update_del, TempData); Thread.Sleep(500); } if (check == -1) { break; } } }