SafeAPI RBC 2oo2 Generic Application
IL/CTC route and train logic for the safeAPIRBC2oo2 reference RBC
Loading...
Searching...
No Matches
ab_ga_route_fsm.h File Reference

Per-route state machine, driven by IL route commands (RBC_MSG_IL_ROUTE_CMD / ab_ga_il_route_cmd_t). More...

#include <stdbool.h>
#include <stdint.h>
#include "ab_ga_il_wire.h"
#include "ga_interface.h"
Include dependency graph for ab_ga_route_fsm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ab_ga_route_fsm_result_t
 Result of applying one IL route command to a route's FSM. More...

Enumerations

enum  ab_ga_route_state_t {
  AB_GA_ROUTE_STATE_NO_ROUTE = 0 , AB_GA_ROUTE_STATE_LOCKED = 1 , AB_GA_ROUTE_STATE_FS = 2 , AB_GA_ROUTE_STATE_OS = 3 ,
  AB_GA_ROUTE_STATE_SH = 4 , AB_GA_ROUTE_STATE_USED = 5 , AB_GA_ROUTE_STATE_DEGRADED = 6
}
 Per-route lifecycle state. Stored raw (uint32_t) on GP's route DB record - keep these values stable. More...

Functions

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, for tests and for ab_ga_route_fsm_step() itself.
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(), computes the target (ab_ga_route_fsm_eval), logs the transition at INFO (STUB targets logged as "not implemented yet"), and writes the target back via ab_gp_db_route_set_fsm_state().

Detailed Description

Per-route state machine, driven by IL route commands (RBC_MSG_IL_ROUTE_CMD / ab_ga_il_route_cmd_t).

One instance of this state exists per tracked route; it is persisted on GP's own route DB record (ab_gp_db_route_t.route_fsm_state, raw uint32_t) and read/written through ga_interface.h's ab_gp_db_route_get_fsm_state() / _set_fsm_state(). GA owns the transition logic here; GP just stores the value.

The state is essentially a function of the IL command's route_type + route_status + release_route_request. ab_ga_route_fsm_step() computes the target, logs the transition, and tells the caller whether the target is a REAL-handled state or a STUB one (OS / SH / DEGRADED - the state is tracked and logged, but no supervision-mode-specific behaviour is wired yet, same "stub, not silently ignored" posture as GP's own state_machines/ stubs).

Definition in file ab_ga_route_fsm.h.

Enumeration Type Documentation

◆ ab_ga_route_state_t

Per-route lifecycle state. Stored raw (uint32_t) on GP's route DB record - keep these values stable.

Enumerator
AB_GA_ROUTE_STATE_NO_ROUTE 

No route indicated by IL, or released.

AB_GA_ROUTE_STATE_LOCKED 

IL locked, no supervision mode yet.

AB_GA_ROUTE_STATE_FS 

Full Supervision (REAL).

AB_GA_ROUTE_STATE_OS 

On Sight (STUB).

AB_GA_ROUTE_STATE_SH 

Shunting (STUB).

AB_GA_ROUTE_STATE_USED 

Train has consumed / passed the route (REAL).

AB_GA_ROUTE_STATE_DEGRADED 

Route degraded (STUB - severity in the command).

Definition at line 38 of file ab_ga_route_fsm.h.

Function Documentation

◆ ab_ga_route_fsm_eval()

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, for tests and for ab_ga_route_fsm_step() itself.

Definition at line 30 of file ab_ga_route_fsm.c.

◆ ab_ga_route_fsm_step()

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(), computes the target (ab_ga_route_fsm_eval), logs the transition at INFO (STUB targets logged as "not implemented yet"), and writes the target back via ab_gp_db_route_set_fsm_state().

Parameters
[in]dbGP route DB handle (ga_interface.h).
[in]route_idRoute the command concerns (must already be tracked).
[in]cmdDecoded, already-validated IL route command.
[in]cycleCyclic-executive count, for the log line.
[in]role_tagRole string for the log line.
Returns
The transition result (also reflects what was written).

Definition at line 123 of file ab_ga_route_fsm.c.