Exemplo n.º 1
0
        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();
                }
            }
        }
Exemplo n.º 2
0
 public MULinearity(CSeriesLinac linac, IElectrometer el, I1DScanner scan1D)
 {
     _linac  = linac;
     _el     = el;
     _scan1D = scan1D;
     Logger  = new Logger();
 }
Exemplo n.º 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}");
                    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();
                }
            }
        }
Exemplo n.º 4
0
 public OutputFactors(CSeriesLinac linac, IElectrometer el, I1DScanner scan1D)
 {
     _linac  = linac;
     _el     = el;
     _scan1D = scan1D;
     Logger  = new Logger();
 }
Exemplo n.º 5
0
        public static JawShots GetLightFieldCoincidence(CSeriesLinac linac)
        {
            var js = new JawShots(linac);

            js.AddShot(10, 10);
            js.AddShot(15, 15, Energy._15X);
            return(js);
        }
Exemplo n.º 6
0
        public static MULinearity GetDefault(CSeriesLinac linac, IElectrometer el, I1DScanner scan1D)
        {
            var muTest = new MULinearity(linac, el, scan1D);

            muTest.Logger.Logged  += (log => Console.WriteLine(log));
            muTest.ScanningDepthMM = 50;
            muTest.SetEnergiesToTest(Energy._6X, Energy._15X);
            muTest.SetMULevels(10, 20, 50, 100, 200, 500);
            return(muTest);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            ui = new ConsoleUI();
            ui.Write("---AUTODRIVE EXAMPLE : TBA RUNNER---");
            ui.Write("");

            ui.WritePrompt("Which port is the Autodrive linac controller on?");
            var com = ui.GetStringResponse(SerialPort.GetPortNames());

            linac = new CSeriesLinac();
            linac.Initialize(com);

            //Find the running TBA scan app
            while (tba == null)
            {
                tba = TbaScanApp.Find();
                if (tba == null)
                {
                    ui.WriteError("Cannot find TBA Scan software. Please make sure it is open. Then press Enter");
                    while (Console.ReadKey().Key != ConsoleKey.Enter)
                    {
                    }
                }
            }

            ui.Write("");

            //Ask user to start task list running before we start listening for popups
            ui.Write("TBA Software found!.");
            ui.WritePrompt("Go ahead and start a task list and start the first beam. Press Enter when once you are started.");
            while (Console.ReadKey().Key != ConsoleKey.Enter)
            {
            }

            ui.Write("");
            ui.Write("Listening for popup dialogs");
            ui.Write("");

            //Subscribe to changes that will be requested by the scanning software
            tba.FieldSizeChange   += Tba_FieldSizeChange;
            tba.ApplicatorChange  += Tba_ApplicatorChange;
            tba.EnergyChange      += Tba_EnergyChange;
            tba.PopupOpsCompleted += Tba_PopupOpsCompleted;
            tba.ListenForPopup();

            ui.WritePrompt("Press Esc to stop listener");
            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
            }
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            ui.Write("---AUTODRIVE EXAMPLE : OUTPUT FACTORS---");
            ui.WritePrompt("Which port is the Autodrive linac controller on?");
            var com = ui.GetStringResponse(SerialPort.GetPortNames());

            linac = new CSeriesLinac();
            linac.Initialize(com);
            ui.Write(""); //--Space

            //Set up electrometer
            var elecVerified = false;

            while (!elecVerified)
            {
                ui.WritePrompt("Which port is the Electrometer on?");
                com  = ui.GetStringResponse(SerialPort.GetPortNames());
                elec = new Max4000();
                elec.Initialize(com);
                elecVerified = elec.Verify();
                if (!elecVerified)
                {
                    ui.WriteError("Cannot find the Max 4000 electrometer. Try again.");
                }
            }

            if (ui.GetYesNoResponse("Do I need to zero the electrometer?"))
            {                                        //Get Electrometer ready
                ui.Write("");                        //--Space
                ui.Write("Zeroing Electrometer..."); //--Space
                elec.Zero().Wait();
            }

            elec.SetBias(Autodrive.Electrometers.Bias.NEG_100PERC);
            elec.SetMode(Autodrive.Electrometers.MeasureMode.CHARGE);
            elec.SetRange(Autodrive.Electrometers.Enums.Range.HIGH);
            Thread.Sleep(3000);


            ui.WritePrompt("I am going to store to an Excel file. I need some information");
            var savePath = ui.GetSaveFilePath("outputFactors.xlsx");

            PhotonFactors.RunFactors(ui, linac, elec, savePath);

            //Need to add depth changing for electrons
            //ElectronFactors.RunFactors(ui, linac, elec, savePath);

            ui.WritePrompt("COMPLETE!");
        }
Exemplo n.º 9
0
        public static JawShots GetXYCalibrationShots(CSeriesLinac linac)
        {
            var js    = new JawShots(linac);
            var sizes = new double[] { 2.5, 5, 7.5, 10, 15 };

            foreach (var size in sizes)
            {
                js.AddShot(size, size, 1.3, 1.3);
            }
            foreach (var size in sizes)
            {
                js.AddShot(1.3, 1.3, size, size);
            }
            return(js);
        }
Exemplo n.º 10
0
        public static OutputFactors GetDefault(CSeriesLinac linac, IElectrometer el, I1DScanner scan1D)
        {
            var of = new OutputFactors(linac, el, scan1D);

            of.Logger.Logged += (log => Console.WriteLine(log));
            of.AddEnergyDepth(Energy._6X, 15);
            of.AddEnergyDepth(Energy._15X, 27);
            of.AddEnergyDepth(Energy._6E, 13);
            of.AddEnergyDepth(Energy._9E, 21);
            of.AddEnergyDepth(Energy._12E, 29);
            of.AddEnergyDepth(Energy._15E, 33);
            of.AddEnergyDepth(Energy._18E, 22);

            of.SetPhotonFieldSizes(4, 10, 15, 20, 25, 30, 40);
            of.SetElectronCones("A6", "A10", "A15", "A20", "A25");
            return(of);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Takes measurements using the electrometer and linac input
        /// </summary>
        /// <param name="el"></param>
        /// <param name="linac"></param>
        /// <param name="repeatBeam">flags whether or not this is a repeat measurement</param>
        /// <returns></returns>
        public double TakeMeasurement(IElectrometer el, CSeriesLinac linac, bool repeatBeam)
        {
            if (el != null)
            {
                el.StartMeasurement();
            }
            if (linac != null)
            {
                var ms = MachineStateRun;
                if (repeatBeam)
                {
                    linac.RepeatBeam();
                }
                else
                {
                    linac.BeamOn();
                }
                Thread.Sleep(linac.WaitMsForMU(ms.MU, ms.Accessory != null && AccessoryHelper.IsEDW(ms.Accessory)));
                Thread.Sleep(1000); //Extra second to allow electrometer settling
            }

            if (el != null)
            {
                el.StopMeasurement();
            }

            double val = double.NaN;

            if (el != null)
            {
                val = el.GetValue().Measurement;
                el.Reset();
            }
            AddMeasurement(val);
            return(val);
        }
Exemplo n.º 12
0
 public CollimatorStarShot(CSeriesLinac linac)
 {
     _linac = linac;
 }
Exemplo n.º 13
0
        private void SetCommands()
        {
            RelaySpreadsheetControlCommand = new DelegateCommand <SfSpreadsheet>((sp) =>
            {
                this.spreadsheet = sp;
            });

            RefreshCommCommand = new DelegateCommand(() =>
            {
                SetDefaultComPorts();
            });

            StopCommand = new DelegateCommand(() =>
            {
                ServiceModeSession.Instance.Keyboard.IsEnabled = false; // Turn off keyboard immediately
                IsStopRequested = true;
                cTokenSource.Cancel();
                this.logger.Log($"Stopping measurement...");
            });

            ToggleDefaultInterlocksCommand = new DelegateCommand(() =>
            {
                if (linac != null)
                {
                    linac.OverrideDefaultInterlocks();
                }
                else
                {
                    MessageBox.Show("Connect to linac Autodrive first!");
                }
            });

            ConnectADCommand = new DelegateCommand(() =>
            {
                this.linac        = new CSeriesLinac();
                this.linac.Logger = logger;
                try
                {
                    linac.Initialize(ADComPort); ADConnected = "(Connected)";
                }
                catch (Exception e)
                {
                    ADConnected = "(Error)";
                }
            });

            ConnectELCommand = new DelegateCommand(() =>
            {
                this.el   = new Max4000();
                el.Logger = logger;
                try
                {
                    el.Initialize(ELComPort);
                    if (!el.Verify())
                    {
                        MessageBox.Show("Couldn't find Max 4000!");
                    }
                    else
                    {
                        ELConnected = "(Connected)";
                    }
                }
                catch (Exception e) { ELConnected = "(Error)"; }
            });

            Connect1DCommand = new DelegateCommand(() =>
            {
                this.scan1D   = new DoseView1D();
                scan1D.Logger = logger;
                try
                {
                    scan1D.Initialize(DVComPort);
                    var version = scan1D.GetVersion();
                    if (string.IsNullOrEmpty(version))
                    {
                        MessageBox.Show("Couldn't find DoseView 1D!");
                    }
                    else
                    {
                        DVConnected = "(Connected)";
                        logger.Log($"Found DoseView 1D version {version}");
                        ChamberDepth = scan1D.GetCurrentDepthMM();
                    }
                }
                catch (Exception e) { DVConnected = "(Error)"; }
            });

            MoveChamberCommand = new DelegateCommand(async() =>
            {
                if (!double.IsNaN(ChamberDepth))
                {
                    await MoveChamber(ChamberDepth);
                }
            });
        }
Exemplo n.º 14
0
 public MechanicalSuite(CSeriesLinac linac)
 {
     _linac = linac;
 }
Exemplo n.º 15
0
        public static void Run()
        {
            ui = new ConsoleUI();
            //Header
            ui.WriteSectionHeader("AUTODRIVE EXCEL RUNNER");
            ui.WriteSectionHeader("By Rex Cardan | UAB ");
            ui.SkipLines(2);

            //Connect to RS232
            var ports  = SerialPort.GetPortNames();
            var adPort = ui.GetStringResponse("Which port is the Autodrive on?", ports);

            ports = ports.Where(p => p != adPort).ToArray();

            var _1dport = ui.GetStringResponse("Which port is the 1D scanner on?", ports);

            ports = ports.Where(p => p != _1dport).ToArray();

            var elPort = ui.GetStringResponse("Which port is the electrometer on?", ports);

            ui.Write("Connecting to Autodrive...");
            _linac = new CSeriesLinac();
            _linac.Initialize(adPort);
            ui.Write("Connecting to DsoeView1D...");
            _1ds = new DoseView1D();
            _1ds.Initialize(_1dport);
            ui.Write($"Connected to DoseView {_1ds.GetVersion()}");

            ui.Write("Connecting to Max4000...");
            _el = new Max4000();
            _el.Initialize(elPort);
            if (_el.Verify())
            {
                ui.Write($"Connected to Max4000");
            }
            else
            {
                ui.WriteError($"Could not connect to Max4000! Check connections");
            }

            //Find Excel Sheet to key tasks from
            string excel = null;

            while (excel == null)
            {
                ui.WritePrompt("Please select the Excel file where the tasks are located.");
                var startingLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "toDoList.xlsx");
                excel = ui.GetOpenFilePath(startingLocation);
                if (excel == null)
                {
                    ui.WriteError("You must select a file!");
                }
            }

            //Read Excel
            var jobs = XCelJobList.Read(excel);
            var toDo = jobs.RowJobs.Where(j => !j.Item1.IsComplete());

            ui.Write($"Found {toDo}/{jobs.RowJobs.Count} jobs left to complete");

            var logger = new Logger();

            logger.Logged += Logger_Logged;
            jobs.Run(_linac, _el, _1ds, logger);
        }
Exemplo n.º 16
0
 public CouchStarShot(CSeriesLinac linac)
 {
     _linac = linac;
 }
Exemplo n.º 17
0
 public DeterminePion(CSeriesLinac linac, I1DScanner scanner, IElectrometer el)
 {
 }
Exemplo n.º 18
0
 public JawShots(CSeriesLinac linac)
 {
     _linac = linac;
 }
Exemplo n.º 19
0
        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>();
        }