Added state publishing to TACOS state transition

This commit is contained in:
dario
2024-10-04 13:32:30 +02:00
parent c784e37eab
commit d1f7063912
4 changed files with 34 additions and 18 deletions

View File

@@ -46,7 +46,7 @@ namespace sta
*
* @ingroup tacos_api
*/
void setState(uint32_t from, uint32_t to, uint32_t lockout = 0, bool force = false);
void setState(uint32_t from, uint32_t to, uint32_t lockout = 0, bool force = false, bool publish = true);
/**
* @brief Request a state transition after a given time has passed. Invalid state transitions will be dismissed.
@@ -58,7 +58,7 @@ namespace sta
*
* @ingroup tacos_api
*/
void setStateTimed(uint32_t from, uint32_t to, uint32_t millis, uint32_t lockout = 0);
void setStateTimed(uint32_t from, uint32_t to, uint32_t millis, uint32_t lockout = 0, bool publish = true);
/**
* @brief Register a new thread to be run by TACOS.
@@ -97,13 +97,13 @@ namespace sta
*
* @param from The state we want to transition from.
* @param to The state we want to transition to.
* @param lockout An optional timer blocking state transition for a given time.
* @param timeout An optional timeout for the CAN communication
*
* @return bool True if the message was sent successfully.
*
* @ingroup tacos_api
*/
bool publishState(uint32_t from, uint32_t to, uint32_t lockout = 0);
bool publishState(uint32_t from, uint32_t to, uint32_t timeout = 0);
#endif // STA_TACOS_CAN_BUS_ENABLED
} // namespace tacos
}

View File

@@ -119,7 +119,9 @@ namespace sta
/// Event that triggered the transition
EventFlags event;
/// Lockout time after transition
uint32_t lockout;
uint32_t lockout;
/// Whether to publish the transition via CAN.
bool publish = false;
};
/**
@@ -164,7 +166,7 @@ namespace sta
* @param lockout The minimum number of milliseconds we expect to stay in this state. This is used to block premature transitions.
* @param force If true, the state transition will be executed regardless of the current state.
*/
void requestStateTransition(uint32_t from, uint32_t to, uint32_t lockout = 0, bool force = false);
void requestStateTransition(uint32_t from, uint32_t to, uint32_t lockout = 0, bool force = false, bool publish = true);
/**
* @brief Request a state transition after a given time has passed.
@@ -174,7 +176,7 @@ namespace sta
* @param millis the number of milliseconds to wait before triggering the transition.
* @param lockout The minimum number of milliseconds we expect to stay in this state. This is used to block premature transitions.
*/
void requestTimedStateTransition(uint32_t from, uint32_t to, uint32_t millis, uint32_t lockout = 0);
void requestTimedStateTransition(uint32_t from, uint32_t to, uint32_t millis, uint32_t lockout = 0, bool publish = true);
void init() override;
void func() override;