示例#1
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}");
                    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();
                }
            }
        }
示例#2
0
        public static XCelJobList Read(string path)
        {
            var tl = new XCelJobList();

            tl.RowJobs = new List <Tuple <Job, int> >();

            var xcel = new XCelBook(path);

            tl._bookPath = path;

            tl.RowJobs    = JobReader.ReadExcelWithRowIndex(path);
            tl.SaveAction = () => tl.Save();
            return(tl);
        }
示例#3
0
        public static List <Job> ReadExcel(string file)
        {
            List <Job> jobs = new List <Job>();

            if (File.Exists(file))
            {
                var rows   = new XCelBook(file).GetRows("Autodrive");
                var header = rows[0];
                var state  = new MachineState();
                foreach (var row in rows.Skip(1).Where(r => r[0] != null && !((string)r[0]).StartsWith("//")).ToList())
                {
                    state.Energy = XCelRowParser.GetEnergy(header, row);
                }
            }
            return(jobs);
        }
示例#4
0
        public void Save()
        {
            var xcel   = new XCelBook(_bookPath);
            var rows   = xcel.GetRows("Autodrive");
            var header = rows[0];

            foreach (var t in RowJobs)
            {
                var row = rows[t.Item2]; //Item2 is row index
                for (int i = 0; i < t.Item1.Measurements.Length; i++)
                {
                    var h = $"M{i + 1}"; //Measurement header (M1,M2,M3...)
                    row = TrySetDouble(header, row, h, t.Item1.Measurements[i]);
                }
                rows[t.Item2] = row;
            }
            xcel.SetRows(rows, "Autodrive");
            xcel.Save();
        }
示例#5
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);
        }