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