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 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(); }