public SetVtoOffsetVoltage ( double value ) : void | ||
value | double | |
return | void |
public void InitializeUI() { ui.SetNumberOfPoints(default_ScanPoints); ui.SetVtoOffsetVoltage(0); foreach (KeyValuePair <string, SlaveLaser> laser in SlaveLasers) { ui.AddSlaveLaser(laser.Value); } ui.ShowAllTabPanels(); ui.UpdateUIState(TCLState); }
/// <summary> /// The main loop. Reads the analog inputs, fits to the data and (when locked) adjusts the slave laser voltage. /// </summary> private void mainLoop() { fits = new Dictionary <string, double[]>(); //Somewhere to store the fits for an iteration. readParametersFromUI(); //This isn't part of the loop. Do an initial setup of the parameters. ScanParameters sp = createInitialScanParameters(); double masterVoltage = 0; setupMasterVoltageOut(); writeMasterVoltageOut(0); disposeMasterVoltageOut(); initializeAIHardware(sp); CavityScanData scanData; int count = 0; while (TCLState != ControllerState.STOPPED) { scanData = acquireAI(sp); if (scanData != null) { plotCavity(scanData); if ((scanData.GetCavityData())[sp.Steps - 1] < (double)Environs.Hardware.GetInfo("TCL_MAX_INPUT_VOLTAGE")) // if the cavity ramp voltage exceeds the input voltage - do nothing { fits["masterFits"] = fitMaster(scanData); plotMaster(scanData, fits["masterFits"]); if (ui.masterLockEnableCheck.Checked == true && checkRampChannel() == true) { masterVoltage = calculateMasterVoltageShift(masterVoltage) + masterVoltage; setupMasterVoltageOut(); //write difference to analog output writeMasterVoltageOut(masterVoltage); ui.SetVtoOffsetVoltage(Math.Round(masterVoltage, 4)); ui.SetMasterFitTextBox(Math.Round((fits["masterFits"][1] - masterVoltage), 4)); disposeMasterVoltageOut(); } foreach (KeyValuePair <string, SlaveLaser> pair in SlaveLasers) { string slName = pair.Key; SlaveLaser sl = pair.Value; //Some rearrangements to fit only when log fit slave lasers parameters on and/or lock slave lasers on. plotSlaveNoFit(slName, scanData); if (ui.logCheckBox.Checked == true) { fits[slName + "Fits"] = fitSlave(slName, scanData); plotSlave(slName, scanData, fits[slName + "Fits"]); using (StreamWriter writer = new StreamWriter(Environs.FileSystem.Paths["transferCavityData"] + "log.txt", true)) { writer.WriteLine(slName + "," + DateTime.Now.ToString("h:mm:ss.ff t") + "," + Math.Round(fits["masterFits"][1], 5).ToString() + "," + Math.Round(fits[slName + "Fits"][1], 5).ToString() + "," + Math.Round(sl.VoltageToLaser, 5).ToString()); } } switch (sl.lState) { case SlaveLaser.LaserState.FREE: break; case SlaveLaser.LaserState.LOCKING: fits[slName + "Fits"] = fitSlave(slName, scanData); plotSlave(slName, scanData, fits[slName + "Fits"]); sl.CalculateLaserSetPoint(fits["masterFits"], fits[slName + "Fits"]); sl.Lock(); //RefreshErrorGraph(slName); count = 0; break; case SlaveLaser.LaserState.LOCKED: fits[slName + "Fits"] = fitSlave(slName, scanData); plotSlave(slName, scanData, fits[slName + "Fits"]); plotError(slName, new double[] { getErrorCount(slName) }, new double[] { fits[slName + "Fits"][1] - fits["masterFits"][1] - sl.LaserSetPoint }); sl.RefreshLock(fits["masterFits"], fits[slName + "Fits"]); RefreshLockParametersOnUI(sl.Name); incrementCounter(slName); count++; break; } } } else { Console.WriteLine("Cavity ramp voltage out of range"); Thread.Sleep(100); } } } endRamping(); }