public void SetCouchAutomatic(double couchVert, double couchLong, double couchLat, double couchRot) { var couchVertChange = !double.IsNaN(couchVert) && _session.MachineState.CouchVert != couchVert; var couchLongChange = !double.IsNaN(couchLong) && _session.MachineState.CouchLng != couchLong; var couchLatChange = !double.IsNaN(couchLat) && _session.MachineState.CouchLat != couchLat; var couchRotChange = !double.IsNaN(couchRot) && _session.MachineState.CouchRot != couchRot; if (!couchVertChange && !couchLongChange && !couchLatChange && !couchRotChange) { //No changes return; } if (MotionWatch.IsSystemInMotion) { MotionWatch.MotionCompleteEvent.WaitOne(); } _session.ResetConsoleState(); _session.Keyboard.Press("M"); _session.ServiceConsoleState.Main.Current = MainOptions.MOTOR; _session.Keyboard.Press("C"); _session.ServiceConsoleState.Motor.Current = MotorOptions.COUCH_AUTOMATIC; _session.ServiceConsoleState.CouchAutomatic.Current = CouchAutoOptions.VERT; if (couchVertChange) { _session.ServiceConsoleState.CouchAutomatic.MoveTo(CouchAutoOptions.VERT); _session.Keyboard.EnterNumber(couchVert); this.MotionWatch.AddMotion(_session.MachineState.CouchVert, couchVert, _session.MachineConstraints.CouchVertMoveCMPerSec); } if (couchLongChange) { _session.ServiceConsoleState.CouchAutomatic.MoveTo(CouchAutoOptions.LONG); _session.Keyboard.EnterNumber(couchLong); this.MotionWatch.AddMotion(_session.MachineState.CouchLng, couchLong, _session.MachineConstraints.CouchMoveCMPerSec); } if (couchLatChange) { _session.ServiceConsoleState.CouchAutomatic.MoveTo(CouchAutoOptions.LAT); _session.Keyboard.EnterNumber(couchLat); this.MotionWatch.AddMotion(_session.MachineState.CouchLat, couchLat, _session.MachineConstraints.CouchMoveCMPerSec); } if (couchRotChange) { _session.ServiceConsoleState.CouchAutomatic.MoveTo(CouchAutoOptions.ROT); _session.Keyboard.EnterNumber(couchRot); this.MotionWatch.AddMotion(_session.MachineState.CouchRot, couchRot, _session.MachineConstraints.CouchRotDegPerSec); } _session.Keyboard.PressF2(); this.MotionWatch.StartMotionClock(); //Update machine state _session.MachineState.CouchVert = couchVert; _session.MachineState.CouchLat = couchLat; _session.MachineState.CouchLng = couchLong; _session.MachineState.CouchRot = couchRot; }
public void Initialize(string comPort) { Logger?.Log($"Initalizing Autodrive on port {comPort}"); _session = ServiceModeSession.Instance; if (Logger != null) { _session.Logger = Logger; } _session.Keyboard = new VetraKeyboard(comPort); _session.KeySpeedMs = 100; _session.ResetConsoleState(); }