diff --git a/ADIS_Csharp/RaspiControl/Application.cs b/ADIS_Csharp/RaspiControl/Application.cs index 38d395a..dd15244 100644 --- a/ADIS_Csharp/RaspiControl/Application.cs +++ b/ADIS_Csharp/RaspiControl/Application.cs @@ -32,6 +32,10 @@ namespace RaspiControl { public void Status_StatusChanged(object? sender, StatusEventArgs e) { try { + if(e.Status == RoboStatus.Manual) { + this.sm.MoveNext(Command.manualMode); + this.smHandler(); + } if (e.Status == RoboStatus.Auto) { this.sm.MoveNext(Command.autoMode); this.smHandler(); @@ -44,7 +48,7 @@ namespace RaspiControl { this.sm.MoveNext(Command.failure); this.smHandler(); } - }catch(Exception ex) { + } catch (Exception ex) { this.log.Error(ex.Message); } } diff --git a/ADIS_Csharp/RaspiControl/StateMachine.cs b/ADIS_Csharp/RaspiControl/StateMachine.cs index e2f3b29..b842125 100644 --- a/ADIS_Csharp/RaspiControl/StateMachine.cs +++ b/ADIS_Csharp/RaspiControl/StateMachine.cs @@ -33,7 +33,8 @@ namespace RaspiControl { autoMode, finished, failure, - none + none, + manualMode } internal class StateMachine { @@ -70,10 +71,13 @@ namespace RaspiControl { {new StateTransition(ProcessState.Ready,Command.JoystickDown), ProcessState.StartMoveManual }, {new StateTransition(ProcessState.Ready,Command.JoystickLeft), ProcessState.StartMoveManual }, {new StateTransition(ProcessState.Ready,Command.JoystickRight), ProcessState.StartMoveManual }, + {new StateTransition(ProcessState.Ready,Command.autoMode), ProcessState.Auto }, + {new StateTransition(ProcessState.Ready,Command.manualMode), ProcessState.Ready }, {new StateTransition(ProcessState.StartMoveManual,Command.none), ProcessState.MoveManual }, {new StateTransition(ProcessState.StartMoveManual, Command.autoMode), ProcessState.Auto }, + {new StateTransition(ProcessState.StartMoveManual, Command.manualMode), ProcessState.StartMoveManual }, {new StateTransition(ProcessState.MoveManualF, Command.none), ProcessState.MoveManual }, {new StateTransition(ProcessState.MoveManualF, Command.autoMode), ProcessState.Auto }, @@ -101,18 +105,22 @@ namespace RaspiControl { {new StateTransition(ProcessState.ResumeMoveManual, Command.autoMode), ProcessState.Auto }, {new StateTransition(ProcessState.Auto, Command.finished), ProcessState.Final }, - {new StateTransition(ProcessState.Auto, Command.JoystickUp), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Auto, Command.JoystickDown), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Auto, Command.JoystickLeft), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Auto, Command.JoystickRight), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Auto, Command.JoystickCenter), ProcessState.StartMoveManual }, + //{new StateTransition(ProcessState.Auto, Command.JoystickUp), ProcessState.StartMoveManual }, + //{new StateTransition(ProcessState.Auto, Command.JoystickDown), ProcessState.StartMoveManual }, + //{new StateTransition(ProcessState.Auto, Command.JoystickLeft), ProcessState.StartMoveManual }, + //{new StateTransition(ProcessState.Auto, Command.JoystickRight), ProcessState.StartMoveManual }, + //{new StateTransition(ProcessState.Auto, Command.JoystickCenter), ProcessState.StartMoveManual }, {new StateTransition(ProcessState.Auto, Command.failure), ProcessState.Error }, + {new StateTransition(ProcessState.Auto, Command.manualMode), ProcessState.ResumeMoveManual }, + + {new StateTransition(ProcessState.Error, Command.JoystickUp), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.Error, Command.JoystickDown), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.Error, Command.JoystickLeft), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.Error, Command.JoystickRight), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.Error, Command.JoystickCenter), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.Error, Command.finished), ProcessState.Final }, + {new StateTransition(ProcessState.Error, Command.manualMode), ProcessState.ResumeMoveManual }, - {new StateTransition(ProcessState.Error, Command.JoystickUp), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Error, Command.JoystickDown), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Error, Command.JoystickLeft), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Error, Command.JoystickRight), ProcessState.StartMoveManual }, - {new StateTransition(ProcessState.Error, Command.JoystickCenter), ProcessState.StartMoveManual }, }; }