private static void Tba_EnergyChange(string energyId, TbaPopup popup) { ui.Write($"Changing energy to {energyId}"); linac.StopBeam(); var current = linac.GetMachineStateCopy(); switch (energyId) { case "6 MV": current.Energy = Autodrive.Linacs.Energy._6X; break; case "15 MV": current.Energy = Autodrive.Linacs.Energy._15X; break; case "6 MeV": current.Energy = Autodrive.Linacs.Energy._6MeV; break; case "9 MeV": current.Energy = Autodrive.Linacs.Energy._9MeV; break; case "12 MeV": current.Energy = Autodrive.Linacs.Energy._12MeV; break; case "15 MeV": current.Energy = Autodrive.Linacs.Energy._15MeV; break; case "18 MeV": current.Energy = Autodrive.Linacs.Energy._18MeV; break; } linac.SetMachineState(current); popup.ResetEvent.Set(); //Allow to move on }
public void Run() { //Put couch and gantry and home position var ms = MachineState.InitNew(); ms.Energy = Linacs.Energy._6X; //ms.CouchLat = 101; //ms.CouchLng = 101; //ms.CouchVert = 101; //ms.CouchRot = 181; //_linac.SetMachineState(ms); //Thread.Sleep(8000); ms.Time = 99; //Set through different x y jaw combos and beam on to film/portal var jawShows = JawShots.GetXYCalibrationShots(_linac); //jawShows.Run(); //Shoot a couple square fields to test for coincidence //jawShows = JawShots.GetLightFieldCoincidence(_linac); //jawShows.Run(); //TESTING FOR COUCH RELATIVE MOTION ACCURACY //Step couch 20 cm long and lat to shoot a square ms = _linac.GetMachineStateCopy(); ms.CouchLat += 8; ms.CouchLng += 8; ms.X1 = ms.X2 = ms.Y1 = ms.Y2 = 1; //2 x 2 field ms.MU = 400; _linac.SetMachineState(ms); _linac.BeamOn(); Thread.Sleep(_linac.WaitMsForMU(400)); //Move couch to other side shoot a square ms.CouchLat -= 16; ms.CouchLng -= 16; _linac.SetMachineState(ms); _linac.BeamOn(); Thread.Sleep(_linac.WaitMsForMU(400)); //Collimator Star //var cs = new CollimatorStarShot(_linac); //cs.Run(); //Couch Star var cos = new CouchStarShot(_linac); cos.Run(); }
public void Run(CSeriesLinac linac, IElectrometer el, I1DScanner scan1D, Logger logger = null) { ServiceModeSession.Instance.Logger = logger; foreach (var job in RowJobs) { var measurementsLeft = job.Item1.NumberOfMeasurementsDesired - job.Item1.Measurements.Length; if (measurementsLeft > 0) { linac.SetMachineState(job.Item1.MachineStateRun); } if (scan1D != null) { scan1D.GoToDepth(job.Item1.DepthOfMeasurentMM).Wait(); } if (el != null && measurementsLeft > 0) { for (int i = 0; i < measurementsLeft; i++) { el.StartMeasurement(); linac.BeamOn(); el.StopMeasurement(); var val = el.GetValue(); job.Item1.AddMeasurement(val.Measurement); } SaveAction(); } } }
public static void RunFactors(ConsoleUI ui, CSeriesLinac linac, Max4000 elec, string savePath) { var xcel = new XCelBook(savePath); var xcelRows = new List <XCelData>(); //Write header xcelRows.Add(new XCelData("ENERGY", "FOV", "MEASURED")); //Start measuring //Create a list of things to do var measurementList = BuildMeasurementList(); int repeat = ui.GetIntInput("How many times to repeat each measurement?"); foreach (var m in measurementList) { for (int i = 0; i < repeat; i++) { ui.WritePrompt($"Starting measurement for {m.Energy} at {m.X1 * 2} x {m.Y1 * 2}"); linac.SetMachineState(m); elec.StartMeasurement(); Thread.Sleep(1000); linac.RepeatBeam(); Thread.Sleep((int)(250 / 600 * 60 * 1000 + 1000)); // 250MU/600MY/min * 60 sec/min *1000 ms/sec + 1 extra second elec.StopMeasurement(); var value = elec.GetValue().Measurement; ui.Write($"Measured = {value}"); xcelRows.Add(new XCelData(m.Energy, m.X1 * 2, value)); xcel.SetRows(xcelRows, "Photons"); xcel.Save(); elec.Reset(); } } }
public void Run() { if (string.IsNullOrEmpty(SavePath)) { Logger.Log("Save path is empty. Will save to desktop\n"); SavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "mulinearity.txt"); } ; //Move to Scanning Depth Logger.Log("Moving scanning chamber...\n"); _scan1D.GoToDepth(ScanningDepthMM).Wait(); var ms = MachineState.InitNew(); ms.X1 = ms.X2 = ms.Y1 = ms.Y2 = 5; foreach (var en in energiesToTest) { foreach (var mu in musToTest) { var movingMs = ms.Copy(); movingMs.Energy = en; movingMs.MU = mu; var jr = new Job(movingMs); jr.DepthOfMeasurentMM = ScanningDepthMM; for (int n = 0; n < RepeatMeasurements; n++) { Logger.Log($"Working on {en}, {mu} MU, Measurement {n + 1}\n"); _linac.SetMachineState(movingMs); //Start measuring _el.Reset(); _el.StartMeasurement(); if (n == 0) { _linac.BeamOn(); } else { _linac.RepeatBeam(); } Thread.Sleep(_linac.WaitMsForMU(mu)); //Stop and get measurement _el.StopMeasurement(); var measured = _el.GetValue().Measurement; Logger?.Log($"Measured : {measured}\n"); //Save results jr.AddMeasurement(_el.GetValue().Measurement); } JobWriter.AppendResult(SavePath, jr); } } }
public void Run() { if (string.IsNullOrEmpty(SavePath)) { Logger.Log("Save path is empty. Will save to desktop\n"); SavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "edwFactors.txt"); } ; var states = BuildMeasurementList(); foreach (var m in states) { var jr = new Job(m); jr.DepthOfMeasurentMM = DepthOfMeasurementMM; if (Math.Abs(_scan1D.LastKnowPositionMM - DepthOfMeasurementMM) > 0.1) { Logger.Log($"Changing depth to {DepthOfMeasurementMM} mm\n"); _scan1D.GoToDepth(jr.DepthOfMeasurentMM); } for (int n = 0; n < RepeatMeasurements; n++) { var fov = EnergyHelper.IsPhoton(m.Energy) ? $"{m.X1 * 2} x {m.Y1 * 2}" : m.Accessory; Logger.Log($"Working on {m.Energy}, Depth {jr.DepthOfMeasurentMM}, {m.Accessory} , Measurement {n + 1}\n\n"); _linac.SetMachineState(m); //Start measuring _el.Reset(); _el.StartMeasurement(); if (n == 0) { _linac.BeamOn(); } else { _linac.RepeatBeam(); } var waitTime = _linac.WaitMsForMU(m.MU, true); using (var t = new TimerLogger("Waiting on beam completion", waitTime, 1000, this.Logger)) { Thread.Sleep(waitTime); } //Stop and get measurement _el.StopMeasurement(); var measured = _el.GetValue().Measurement; Logger?.Log($"Measured : {measured}\n"); jr.AddMeasurement(_el.GetValue().Measurement); } //Save results JobWriter.AppendResult(SavePath, jr); } }
private Task SetLinacState(ExcelJob job) { return(Task.Run(() => { if (linac != null) { job.MachineStateRun.Time = 99; linac.SetMachineState(job.MachineStateRun); } })); }
public void Run() { foreach (var shot in toShoot) { shot.MU = MUPerShot; _linac.SetMachineState(shot); _linac.BeamOn(); Thread.Sleep(_linac.WaitMsForMU(shot.MU)); for (int i = 1; i < RepeatMeasurements; i++) { _linac.RepeatBeam(); } } }
public void Run() { Logger?.Log($"=====COUCH STAR SHOT =====\n"); var ms = _linac.GetMachineStateCopy(); ms.X1 = ms.X2 = 0.2; ms.Y1 = 5; ms.Y2 = -3; ms.MU = MUPerShot; ms.CollimatorRot = 180; ms.GantryRot = 180; foreach (var angle in new double[] { 270, 245, 220, 195, 170, 145, 120 }) { Logger?.Log($"Moding up couch angle {angle}...\n"); ms.CouchRot = angle; _linac.SetMachineState(ms); _linac.BeamOn(); Thread.Sleep(_linac.WaitMsForMU(MUPerShot)); } }
public void Run(bool photons = true, bool electrons = true) { if (string.IsNullOrEmpty(SavePath)) { Logger.Log("Save path is empty. Will save to desktop\n"); SavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "outputFactors.txt"); } ; var measurementList = BuildMeasurementList(photons, electrons); foreach (var m in measurementList) { var jr = new Job(m); jr.DepthOfMeasurentMM = energyDepths[m.Energy]; _scan1D.GoToDepth(jr.DepthOfMeasurentMM); for (int n = 0; n < RepeatMeasurements; n++) { var fov = EnergyHelper.IsPhoton(m.Energy) ? $"{m.X1 * 2} x {m.Y1 * 2}" : m.Accessory; Logger.Log($"Working on {m.Energy}, Depth {jr.DepthOfMeasurentMM}, {fov} , Measurement {n + 1}"); var state = _linac.GetMachineStateCopy(); //Check for cone change if (_linac.GetMachineStateCopy().Accessory != m.Accessory) { Console.Beep(4000, 1000); Logger.Log($"Please change the cone to {m.Accessory}\n"); Logger.Log($"Press ENTER when complete\n"); while (Console.ReadKey().Key != ConsoleKey.Enter) { } Logger.Log($"{m.Accessory} inserted! Continuing...\n"); } _linac.SetMachineState(m); //Start measuring _el.Reset(); _el.StartMeasurement(); if (n == 0) { _linac.BeamOn(); } else { _linac.RepeatBeam(); } Thread.Sleep(_linac.WaitMsForMU(m.MU)); //Stop and get measurement _el.StopMeasurement(); var measured = _el.GetValue().Measurement; Logger?.Log($"Measured : {measured}\n"); jr.AddMeasurement(_el.GetValue().Measurement); } //Save results JobWriter.AppendResult(SavePath, jr); } }
public void Run() { if (string.IsNullOrEmpty(SavePath)) { Logger.Log("Save path is empty. Will save to desktop\n"); SavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "outputs.txt"); } ; var measurementList = BuildMeasurementList(); BeamManager.SetFixed(); BeamManager.SetEnergy(Energy._6X); BeamManager.SetDoseRate(measurementList.First().MachineStateRun.DoseRate); foreach (var jr in measurementList) { Task depthTask = Task.Run(() => { }); if (_scan1D.GetCurrentDepthMM() != jr.DepthOfMeasurentMM) { depthTask = _scan1D.GoToDepth(jr.DepthOfMeasurentMM); } for (int n = 0; n < RepeatMeasurements; n++) { Logger.Log($"Working on {jr.MachineStateRun.Energy}, Depth {jr.DepthOfMeasurentMM}, Measurement {n + 1}\n"); var state = _linac.GetMachineStateCopy(); //Check for cone change if (_linac.GetMachineStateCopy().Accessory != jr.MachineStateRun.Accessory) { Console.Beep(4000, 1000); Logger.Log($"Please change the cone to {jr.MachineStateRun.Accessory}\n"); Logger.Log($"Press ENTER when complete\n"); while (Console.ReadKey().Key != ConsoleKey.Enter) { } Logger.Log($"{jr.MachineStateRun.Accessory} inserted! Continuing...\n"); } _linac.SetMachineState(jr.MachineStateRun); //Start measuring depthTask.Wait(); _el.Reset(); _el.StartMeasurement(); if (n == 0) { _linac.BeamOn(); } else { _linac.RepeatBeam(); } Thread.Sleep(_linac.WaitMsForMU(jr.MachineStateRun.MU)); //Stop and get measurement _el.StopMeasurement(); var measured = _el.GetValue().Measurement; Logger?.Log($"Measured : {measured}\n"); jr.AddMeasurement(_el.GetValue().Measurement); } //Save results JobWriter.AppendResult(SavePath, jr); } }
static void Main(string[] args) { var linac = new CSeriesLinac(); linac.Initialize("COM9"); var logger = new Logger(); logger.Logged += (log) => Console.WriteLine(log); linac.Logger = logger; var ms = MachineState.InitNew(); ms.Energy = Energy._6X; ms.X1 = 5; ms.X2 = 5; linac.SetMachineState(ms); var ss = ServiceModeSession.Instance; ss.Logger = logger; ss.AddWaitTime("test", 7000); ss.Wait(); var time = new TimerLogger("Test", 7000, 1000, logger); time.CompletionEvent.WaitOne(); Console.WriteLine("Timer complete"); Console.Read(); var max = new Max4000(); max.Initialize("COM1"); var verify = max.Verify(); var status = max.GetStatus(); var dv = new DoseView1D(); dv.Initialize("COM3"); dv.GoToDepth(64.2).Wait(); var test = dv.GetOrigin(); //var linac = new CSeriesLinac(); //linac.Initialize("COM5"); // linac.OverrideDefaultInterlocks(); //var of = @"C:\Users\variansupport\Desktop\photonOoutputFactors.txt"; //var edwOF = @"C:\Users\variansupport\Desktop\edwFactors.txt"; //var jobs = JobResultReader.Read(of); //var edwJobs = JobResultReader.Read(edwOF).ToList(); //var table = AccessoryOFProcessor.GetTableRows(edwJobs); //foreach(var t in table) //{ // t.PrintToConsole(); //} //Console.ReadLine(); //var dv = new DoseView1D(); //dv.Initalize("COM12"); //var max = new Max4000(); //max.Initialize("COM9"); //max.Verify(); //// max.Zero().Wait(); //var bias = max.SetBias(Autodrive.Electrometers.Bias.NEG_100PERC); //max.SetMode(Autodrive.Electrometers.MeasureMode.CHARGE); //var linac = new CSeriesLinac(); //linac.Initialize("COM10"); //var ofTest = new EDWFactors(linac, max, dv); //ofTest.Logger.Logged += Logger_Logged; //ofTest.Run(); // var session = ServiceModeSession.Instance; // session.Keyboard = new VetraKeyboard("COM3"); // session.KeySpeedMs = 100; //// session.EnterDefaultPassword(); // session.ResetConsoleState(); // //session.ToggleDefaultInterlocks(); // session.MachineState.GantryRot = 180; // session.MachineState.CollimatorRot = 180; // session.MachineState.X1 = 5.0; // session.MachineState.X2 = 5.0; // session.MachineState.Y1 = 5.0; // session.MachineState.Y2 = 5.0; // session.MachineState.CouchLat = 100.2; // session.MachineState.CouchVert = 127.9; // session.MachineState.CouchLng = 54.4; //MonthlyMechanicals.InitializePosition(); //MonthlyMechanicals.CouchStarShot(); Console.Read(); // var tasks = new List<ITask>(); }