Skip to content

Commit

Permalink
- Opening the lid after sleep will continue the state machine
Browse files Browse the repository at this point in the history
  • Loading branch information
SoerenBusse committed Sep 9, 2020
1 parent cee8a05 commit f8c9117
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion AutoPowerManagementForShelfDevices/Enums/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum State
LoggedOut,
LoggedOutNetworkAttached,
Shutdown,
Sleep
Sleep,
SleepNetworkAttached
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,16 @@ public PowerManagementStateMachine(ILogger<PowerManagementStateMachine> logger,
.OnEntry(PowerControl.ForceShutdownLocalMachine);

_machine.Configure(State.Sleep)
.Permit(Trigger.LidOpen, State.LidOpen)
.Permit(Trigger.NetworkAttach, State.SleepNetworkAttached)
.OnEntry(() => LogState(State.Sleep))
.OnEntry(PowerControl.SleepLocalMachine);

_machine.Configure(State.SleepNetworkAttached)
.Permit(Trigger.LidOpen, State.LidOpenNetworkAttached)
.Permit(Trigger.NetworkUnplug, State.Sleep)
.OnEntry(() => LogState(State.SleepNetworkAttached));

// Ignore invalid triggers for state
// Our machine isn't a complete DFA
_machine.OnUnhandledTrigger((state, trigger) => { });
Expand Down

0 comments on commit f8c9117

Please sign in to comment.