Example #1
0
        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
        }
Example #2
0
        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();
        }
Example #3
0
        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}");
                    //Check for cone change
                    if (linac.GetMachineStateCopy().Accessory != m.Accessory)
                    {
                        ui.WritePrompt($"Please change the cone to {m.Accessory}");
                        ui.WritePrompt($"Press ENTER when complete");
                        while (Console.ReadKey().Key != ConsoleKey.Enter)
                        {
                        }
                    }
                    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.Accessory, value));
                    xcel.SetRows(xcelRows, "Electrons");
                    xcel.Save();
                    elec.Reset();
                }
            }
        }
Example #4
0
        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));
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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);
            }
        }