update Statemachine

main
Simon Frei 4 years ago
parent a50811f3e2
commit 7ae79c639c
  1. 4
      ADIS_Csharp/RaspiControl/Application.cs
  2. 30
      ADIS_Csharp/RaspiControl/StateMachine.cs

@ -32,6 +32,10 @@ namespace RaspiControl {
public void Status_StatusChanged(object? sender, StatusEventArgs e) { public void Status_StatusChanged(object? sender, StatusEventArgs e) {
try { try {
if(e.Status == RoboStatus.Manual) {
this.sm.MoveNext(Command.manualMode);
this.smHandler();
}
if (e.Status == RoboStatus.Auto) { if (e.Status == RoboStatus.Auto) {
this.sm.MoveNext(Command.autoMode); this.sm.MoveNext(Command.autoMode);
this.smHandler(); this.smHandler();

@ -33,7 +33,8 @@ namespace RaspiControl {
autoMode, autoMode,
finished, finished,
failure, failure,
none none,
manualMode
} }
internal class StateMachine { internal class StateMachine {
@ -70,10 +71,13 @@ namespace RaspiControl {
{new StateTransition(ProcessState.Ready,Command.JoystickDown), ProcessState.StartMoveManual }, {new StateTransition(ProcessState.Ready,Command.JoystickDown), ProcessState.StartMoveManual },
{new StateTransition(ProcessState.Ready,Command.JoystickLeft), ProcessState.StartMoveManual }, {new StateTransition(ProcessState.Ready,Command.JoystickLeft), ProcessState.StartMoveManual },
{new StateTransition(ProcessState.Ready,Command.JoystickRight), 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.none), ProcessState.MoveManual },
{new StateTransition(ProcessState.StartMoveManual, Command.autoMode), ProcessState.Auto }, {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.none), ProcessState.MoveManual },
{new StateTransition(ProcessState.MoveManualF, Command.autoMode), ProcessState.Auto }, {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.ResumeMoveManual, Command.autoMode), ProcessState.Auto },
{new StateTransition(ProcessState.Auto, Command.finished), ProcessState.Final }, {new StateTransition(ProcessState.Auto, Command.finished), ProcessState.Final },
{new StateTransition(ProcessState.Auto, Command.JoystickUp), ProcessState.StartMoveManual }, //{new StateTransition(ProcessState.Auto, Command.JoystickUp), ProcessState.StartMoveManual },
{new StateTransition(ProcessState.Auto, Command.JoystickDown), ProcessState.StartMoveManual }, //{new StateTransition(ProcessState.Auto, Command.JoystickDown), ProcessState.StartMoveManual },
{new StateTransition(ProcessState.Auto, Command.JoystickLeft), ProcessState.StartMoveManual }, //{new StateTransition(ProcessState.Auto, Command.JoystickLeft), ProcessState.StartMoveManual },
{new StateTransition(ProcessState.Auto, Command.JoystickRight), ProcessState.StartMoveManual }, //{new StateTransition(ProcessState.Auto, Command.JoystickRight), ProcessState.StartMoveManual },
{new StateTransition(ProcessState.Auto, Command.JoystickCenter), ProcessState.StartMoveManual }, //{new StateTransition(ProcessState.Auto, Command.JoystickCenter), ProcessState.StartMoveManual },
{new StateTransition(ProcessState.Auto, Command.failure), ProcessState.Error }, {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 },
}; };
} }

Loading…
Cancel
Save