Ejemplo n.º 1
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), "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);
                }
            }
        }
Ejemplo n.º 2
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), "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);
            }
        }
Ejemplo n.º 3
0
        public static List <Tuple <Job, int> > ReadExcelWithRowIndex(string file)
        {
            List <Tuple <Job, int> > jobs = new List <Tuple <Job, int> >();

            if (File.Exists(file))
            {
                var rows   = new XCelBook(file).GetRows("Autodrive");
                var header = rows[0];
                foreach (var row in rows.Skip(1).Where(r => r[0] != null && !((string)r[0]).StartsWith("//")).ToList())
                {
                    var state = new MachineState();
                    var index = rows.IndexOf(row);

                    state.Accessory     = XCelRowParser.GetAccessory(header, row);
                    state.CollimatorRot = XCelRowParser.GetCollimatorRot(header, row);
                    state.CouchLat      = XCelRowParser.GetCouchLat(header, row);
                    state.CouchVert     = XCelRowParser.GetCouchVert(header, row);
                    state.CouchLng      = XCelRowParser.GetCouchLng(header, row);
                    state.CouchRot      = XCelRowParser.GetCouchRot(header, row);
                    state.DoseRate      = XCelRowParser.GetDoseRate(header, row);
                    state.Energy        = XCelRowParser.GetEnergy(header, row);
                    state.GantryRot     = XCelRowParser.GetGantryRot(header, row);
                    state.MU            = XCelRowParser.GetMU(header, row);
                    state.Time          = XCelRowParser.GetTime(header, row);
                    state.X1            = XCelRowParser.GetX1(header, row);
                    state.X2            = XCelRowParser.GetX2(header, row);
                    state.Y1            = XCelRowParser.GetY1(header, row);
                    state.Y2            = XCelRowParser.GetY2(header, row);
                    var job = new Job(state);
                    foreach (var measurement in XCelRowParser.ReadMeasurements(header, row))
                    {
                        job.AddMeasurement(measurement);
                    }
                    job.DepthOfMeasurentMM          = XCelRowParser.GetMeasurementDepth(header, row);
                    job.NumberOfMeasurementsDesired = XCelRowParser.GetNMeasurements(header, row);
                    jobs.Add(new Tuple <Job, int>(job, index));
                }
            }
            return(jobs);
        }
Ejemplo n.º 4
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);
            }
        }