mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-12-17 22:48:03 +00:00
feat(state-via-can): state transitions via can are forced to resync state across devices
This commit is contained in:
@@ -64,7 +64,7 @@ namespace sta
|
||||
return currentState_;
|
||||
}
|
||||
|
||||
void Statemachine::requestStateTransition(uint32_t from, uint32_t to, uint32_t lockout /* = 0 */)
|
||||
void Statemachine::requestStateTransition(uint32_t from, uint32_t to, uint32_t lockout /* = 0 */, bool force /* = 0 */)
|
||||
{
|
||||
StateTransition transition;
|
||||
transition.from = from;
|
||||
@@ -72,9 +72,28 @@ namespace sta
|
||||
transition.event = EventFlags::NORMAL;
|
||||
transition.lockout = lockout;
|
||||
|
||||
// Try to add a state transition request to the queue. Don't wait if another
|
||||
// thread is already requesting a state change.
|
||||
queue_.put(transition, 0);
|
||||
if (force){
|
||||
// Perform the transition and notify the threads. The event flags are set
|
||||
// here in order to allow threads to react immediately.
|
||||
currentState_ = transition.to;
|
||||
Statemachine::stateChangeEvent.set(transition.event);
|
||||
Statemachine::stateChangeEvent.clear(EventFlags::ALL);
|
||||
|
||||
if (failsafeTimer_.isRunning())
|
||||
{
|
||||
failsafeTimer_.stop();
|
||||
}
|
||||
|
||||
// Start the lockout timer if requested.
|
||||
if (transition.lockout != 0)
|
||||
{
|
||||
setLockoutTimer(transition.lockout);
|
||||
}
|
||||
}else{
|
||||
// Try to add a state transition request to the queue. Don't wait if another
|
||||
// thread is already requesting a state change.
|
||||
queue_.put(transition, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Statemachine::requestTimedStateTransition(uint32_t from, uint32_t to, uint32_t millis, uint32_t lockout /* = 0 */)
|
||||
|
||||
Reference in New Issue
Block a user