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