RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Loading...
Searching...
No Matches
ab_gp_util_link_gate.c
Go to the documentation of this file.
1
6
8
10{
11 if (gate != NULL)
12 {
13 gate->ever_opened = false;
14 gate->next_attempt_ms = 0U;
15 }
16}
17
19{
20 bool open = false;
21
22 if (gate != NULL)
23 {
24 open = gate->ever_opened;
25 }
26 return open;
27}
28
29bool ab_gp_util_link_gate_may_attempt(const ab_gp_util_link_gate_t *gate, rte_timestamp_ms_t now_ms)
30{
31 bool allowed = false;
32
33 if (gate != NULL)
34 {
35 allowed = gate->ever_opened || (now_ms >= gate->next_attempt_ms);
36 }
37 return allowed;
38}
39
40void ab_gp_util_link_gate_on_attempt(ab_gp_util_link_gate_t *gate, rte_timestamp_ms_t now_ms)
41{
42 if ((gate != NULL) && !gate->ever_opened)
43 {
44 gate->next_attempt_ms = now_ms + (rte_timestamp_ms_t)RTE_EXAMPLE_UTIL_REOPEN_BACKOFF_MS;
45 }
46}
47
48void ab_gp_util_link_gate_on_result(ab_gp_util_link_gate_t *gate, rte_status_t status, rte_timestamp_ms_t now_ms)
49{
50 if ((gate != NULL) && !gate->ever_opened)
51 {
52 if (status == RTE_STATUS_OK)
53 {
54 gate->ever_opened = true;
55 }
56 else
57 {
58 gate->next_attempt_ms = now_ms + (rte_timestamp_ms_t)RTE_EXAMPLE_UTIL_REOPEN_BACKOFF_MS;
59 }
60 }
61}
#define RTE_EXAMPLE_UTIL_REOPEN_BACKOFF_MS