RTE RBC 2oo2 Reference Application
0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Toggle main menu visibility
Loading...
Searching...
No Matches
ab_gp_util_link_gate.c
Go to the documentation of this file.
1
5
#include "
ab_gp_util_link_gate.h
"
6
7
#include "
../../common/common_config.h
"
8
9
void
ab_gp_util_link_gate_init
(
ab_gp_util_link_gate_t
*gate)
10
{
11
if
(gate != NULL)
12
{
13
gate->
ever_opened
=
false
;
14
gate->
next_attempt_ms
= 0U;
15
}
16
}
17
18
bool
ab_gp_util_link_gate_is_open
(
const
ab_gp_util_link_gate_t
*gate)
19
{
20
bool
open =
false
;
21
22
if
(gate != NULL)
23
{
24
open = gate->
ever_opened
;
25
}
26
return
open;
27
}
28
29
bool
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
40
void
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
48
void
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
}
ab_gp_util_link_gate_is_open
bool ab_gp_util_link_gate_is_open(const ab_gp_util_link_gate_t *gate)
Whether an open attempt has succeeded (the link is open for good).
Definition
ab_gp_util_link_gate.c:18
ab_gp_util_link_gate_on_attempt
void ab_gp_util_link_gate_on_attempt(ab_gp_util_link_gate_t *gate, rte_timestamp_ms_t now_ms)
Records that an open attempt starts now (call right before the send that triggers the open).
Definition
ab_gp_util_link_gate.c:40
ab_gp_util_link_gate_on_result
void ab_gp_util_link_gate_on_result(ab_gp_util_link_gate_t *gate, rte_status_t status, rte_timestamp_ms_t now_ms)
Feeds back the result of a send that ran under the gate.
Definition
ab_gp_util_link_gate.c:48
ab_gp_util_link_gate_init
void ab_gp_util_link_gate_init(ab_gp_util_link_gate_t *gate)
Resets the gate: never opened, first attempt allowed at any time.
Definition
ab_gp_util_link_gate.c:9
ab_gp_util_link_gate_may_attempt
bool ab_gp_util_link_gate_may_attempt(const ab_gp_util_link_gate_t *gate, rte_timestamp_ms_t now_ms)
Whether a send (and with it, before the first success, an open attempt) may run now.
Definition
ab_gp_util_link_gate.c:29
ab_gp_util_link_gate.h
Open gate of the UTIL relay link (ab-relay-util, ISS-020): bounds how often the A/B cycle thread may ...
common_config.h
RTE_EXAMPLE_UTIL_REOPEN_BACKOFF_MS
#define RTE_EXAMPLE_UTIL_REOPEN_BACKOFF_MS
Definition
common_config.h:255
ab_gp_util_link_gate_t
Gate state; all-zero (or ab_gp_util_link_gate_init()) allows the first attempt at once.
Definition
ab_gp_util_link_gate.h:26
ab_gp_util_link_gate_t::next_attempt_ms
rte_timestamp_ms_t next_attempt_ms
Definition
ab_gp_util_link_gate.h:28
ab_gp_util_link_gate_t::ever_opened
bool ever_opened
Definition
ab_gp_util_link_gate.h:27
src
application
AB
GP
com
ab_gp_util_link_gate.c
Generated by
1.18.0