8#include "safeapi/oal/log/sapi_log.h"
9#include "safeapi/utils/string/sapi_string.h"
46 if (cmd->release_route_request)
52 else if (cmd->route_type == RBC_IL_ROUTE_TYPE_NO_ROUTE)
58 r.
to = status_to_state(cmd->route_status);
77 default:
return "UNKNOWN";
81static void log_step(uint32_t cycle,
const char *role_tag, uint16_t route_id,
86 const char *out_cstr = NULL;
88 if (sapi_string_init(&line, storage,
sizeof(storage)) != SAPI_STATUS_OK)
92 (void)sapi_string_copy(&line,
"cycle=");
93 (void)sapi_string_append_u32(&line, cycle);
94 (void)sapi_string_concat(&line,
" role=");
95 (void)sapi_string_concat(&line, (role_tag != NULL) ? role_tag :
"?");
96 (void)sapi_string_concat(&line,
" route=");
97 (void)sapi_string_append_u32(&line, (uint32_t)route_id);
98 (void)sapi_string_concat(&line,
" ");
99 (void)sapi_string_concat(&line, state_name(r->
from));
100 (void)sapi_string_concat(&line,
" -> ");
101 (void)sapi_string_concat(&line, state_name(r->
to));
104 (void)sapi_string_concat(&line,
" (release)");
108 (void)sapi_string_concat(&line,
" STUB: ");
109 (void)sapi_string_concat(&line, state_name(r->
to));
110 (void)sapi_string_concat(&line,
" route supervision not implemented yet");
112 if (sapi_string_c_str(&line, &out_cstr) == SAPI_STATUS_OK)
114 sapi_log_write(SAPI_LOG_LEVEL_INFO,
"GA_ROUTE_FSM", out_cstr);
119 SAFEAPI_EXAMPLE_LOG(
"[%s] GA_ROUTE_FSM %s\n", (role_tag != NULL) ? role_tag :
"?", out_cstr);
125 uint32_t cycle,
const char *role_tag)
133 log_step(cycle, role_tag, route_id, &r);
137 (void)ab_gp_db_route_set_fsm_state(db, route_id, (uint32_t)r.
to);
ab_ga_route_fsm_result_t ab_ga_route_fsm_step(ab_gp_db_t *db, uint16_t route_id, const ab_ga_il_route_cmd_t *cmd, uint32_t cycle, const char *role_tag)
Applies cmd to the route's FSM: reads the current state via ab_gp_db_route_get_fsm_state(),...
ab_ga_route_fsm_result_t ab_ga_route_fsm_eval(ab_ga_route_state_t from, const ab_ga_il_route_cmd_t *cmd)
Computes the target state for (from, cmd), WITHOUT logging or touching any storage - pure,...
Per-route state machine, driven by IL route commands (RBC_MSG_IL_ROUTE_CMD / ab_ga_il_route_cmd_t).
ab_ga_route_state_t
Per-route lifecycle state. Stored raw (uint32_t) on GP's route DB record - keep these values stable.
@ AB_GA_ROUTE_STATE_LOCKED
@ AB_GA_ROUTE_STATE_DEGRADED
@ AB_GA_ROUTE_STATE_NO_ROUTE
Decoded RBC_MSG_IL_ROUTE_CMD payload.
Result of applying one IL route command to a route's FSM.