public void gotoTemp(int nController, double temperature, int millisecondsAtTemp) { logger.Debug("gotoTempAndStay: temperature = {0} time = {1} ms", temperature.ToString(), millisecondsAtTemp.ToString()); _theModel.ProtocolDescLine = string.Format(" over temperature to {0}", temperature.ToString()); // _theModel.DevicePCRCycler.Temperature = temperature; //_theModel.DevicePCRCycler.Temperature2 = temperature; // Wait for the device to reach the appointed temperature. if (temperature != 0) { float temp = 0; temp = _tecBoard.GetTemperature(nController, 0); //_theModel.DevicePCRCycler.Temperature = temperature; this[nController] = temperature; this[nController - 1] = temperature; if (temp > temperature) { while (temp > (temperature + 10)) { temp = _tecBoard.GetTemperature(nController, 0); Thread.Sleep(1000); } } else { while (temp < (temperature - 2)) { temp = _tecBoard.GetTemperature(nController, 0); Thread.Sleep(1000); } } // We're at temperature. Clear out the information on the current plan. /* * _rampingLowTemp[nController] = double.MaxValue; * _rampingHighTemp[nController] = double.MinValue; * _bAtTemp[nController] = true; * * _rampingLowTemp[nController + 1] = double.MaxValue; * _rampingHighTemp[nController + 1] = double.MinValue; * _bAtTemp[nController + 1] = true; * * logger.Debug("At temperature.");*/ } _theModel.ProtocolDescLine = string.Format(" at temperature; {0}", temperature.ToString()); logger.Debug("gotoTempAndStay: at temperature = {0}, sleeping ...", temperature.ToString()); }
public devicePCRCycler(tecBoardModel modelIn, Configuration.CTEC_Channel_Configuration tecConfig) { _setPoint = new double[6]; _prev_setPoint = new double[6]; _rampingLowTemp = new double[6]; _rampingHighTemp = new double[6]; _bAtTemp = new bool[6]; _theModel = ((HelixGen.App)(App.Current)).Model; _tecBoard = modelIn.theBoard; for (int ndx = 0; ndx < 6; ndx++) { _setPoint[ndx] = _tecBoard.GetTemperature(ndx, 0); _prev_setPoint[ndx] = 0; //_prev_setPoint[ndx] = _tecBoard.GetTemperature(ndx, 0); _rampingLowTemp[ndx] = NO_SETPOINT; _rampingHighTemp[ndx] = NO_SETPOINT; _bAtTemp[ndx] = false; _theModel.bUnderTempPlan[ndx] = true; } _nChannel = (int)(tecConfig.m_uiTECAddress) - 1; _tecConfig = tecConfig; // Stash a reference to the model while we're at it. }
/// <summary> /// Executes the current script. /// </summary> public async void RunScript(string scriptName = "") { if (!string.IsNullOrEmpty(scriptName)) { bool bLoadSucceeded = true; // Load the specified protocol. try { Task <bool> loadResult = _protocol.Load(scriptName); await loadResult; } catch (Exception ex) { bLoadSucceeded = false; } if (bLoadSucceeded) { CurrentScript = scriptName; // Put out a status message. if (ProtocolExecutionStepped != null) { ProtocolExecutionStepped(string.Format("Starting execution of {0}", Path.GetFullPath(scriptName))); } bStopScript = false; //await InitializeMoto(); try { // Create the results subdirectory. resultsDir = Path.Combine(HelixGen.CSystem_Defns.strDefaultMeasurementLogPath, DateTime.Now.ToString("yyy_MM_dd_HH_mm_ss") ); Directory.CreateDirectory(resultsDir); ProtocolDescLine = string.Format("Results will be stored in: {0}", Path.GetFullPath(resultsDir)); // Start off a process logging the temperatures for the duration of // the protocol execution. bStopTempResults = false; // _deviceOpticsMotor.ZeroOptic(); string TemperatureFileName = Path.Combine(resultsDir, "Temperature Log.csv"); logger.Debug("Opening results file to: {0}", TemperatureFileName); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task.Run(() => { using (StreamWriter outStream = new StreamWriter(TemperatureFileName)) { outStream.AutoFlush = true; // Write the name of the protocol file. outStream.WriteLine(string.Format("Protocol file: {0}", Path.GetFullPath(scriptName))); outStream.WriteLine(string.Format("Run date.time: {0}", DateTime.Now.ToString())); outStream.WriteLine("Time, Elapsed Seconds, SPREP Thermal Setpoint," + " SPREP Thermal C, " + "PCR TEC1 Setpoint, PCR TEC1 C, PCR TEC1 PWR, PRC TE1C Amps," + "PCR TEC2 Setpoint, PCR TEC2 C, PCR TEC2 PWR, PRC TEC2 Amps" + "TEC3 Temp, TEC4 Temp, TEC5 temp, TEC6 temp"); float htrSetPoint = 0f; float htrTemp = 0f; float TECSetPoint = 0f; float TECTemperature = 0f; float TECPower = 0f; float TECCurrent = 0f; float TECSetPoint2 = 0f; float TECTemperature2 = 0f; float TECPower2 = 0f; float TECCurrent2 = 0f; DateTime startTime = DateTime.Now; double elapsedSeconds; bool bFirstTime = true; float TECTemperature3 = 0f; float TECTemperature4 = 0f; float TECTemperature5 = 0f; float TECTemperature6 = 0f; while (!bStopTempResults) { clsTec theBoard = tecBoard.theBoard; htrSetPoint = theBoard.GetRSHeaterSetPoint(0); htrTemp = theBoard.GetTemperature(6, 0); TECSetPoint = theBoard.GetSetPoint(0); TECTemperature = theBoard.GetTemperature(0, 0); TECPower = theBoard.GetPower(0); TECCurrent = theBoard.GetCurrent(0); TECSetPoint2 = theBoard.GetSetPoint(1); TECTemperature2 = theBoard.GetTemperature(1, 0); TECPower2 = theBoard.GetPower(1); TECCurrent2 = theBoard.GetCurrent(1); TECTemperature3 = theBoard.GetTemperature(2, 0); TECTemperature4 = theBoard.GetTemperature(3, 0); TECTemperature5 = theBoard.GetTemperature(4, 0); TECTemperature6 = theBoard.GetTemperature(5, 0); if (bFirstTime) { startTime = DateTime.Now; elapsedSeconds = 0; bFirstTime = false; } else { elapsedSeconds = DateTime.Now.Subtract(startTime).TotalSeconds; } outStream.WriteLine(string.Format("\"{0}\",{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), elapsedSeconds.ToString(), htrSetPoint.ToString(), htrTemp.ToString(), TECSetPoint.ToString(), TECTemperature.ToString(), TECPower.ToString(), TECCurrent.ToString(), TECSetPoint2.ToString(), TECTemperature2.ToString(), TECPower2.ToString(), TECCurrent2.ToString(), TECTemperature3.ToString(), TECTemperature4.ToString(), TECTemperature5.ToString(), TECTemperature6.ToString() ) ); Thread.Sleep(250); } //2018 } } ); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task <bool> bExecute = _protocol.Execute(); await bExecute; } catch (Exception ex) { logger.Error("RunScript caught an exception; {0}", ex.Message); } bStopTempResults = true; //await InitializeMoto(); if (ProtocolExecutionStepped != null) { ProtocolExecutionStepped("Execution Completed"); } StopScript(); // ControlComplete();//2018 CurrentScript = string.Empty; } } }