Tolling payment min period

This commit is contained in:
emanuel 2022-02-16 14:30:10 +00:00
parent eea1f89a55
commit ddd0f012b7
4 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,13 @@
typedef struct coordination {
bool active;
struct {
bool intersecting;
uint64_t t_negotiation;
} neighbours;
} coordination_s;
int dcm_check(void* fc, DCM_t* dcm);

View File

@ -340,6 +340,8 @@ void *sa_service(void *fc) {
lon = facilities->epv.space.longitude;
it2s_tender_unlock_space(&facilities->epv);
uint64_t now = it2s_tender_get_clock(&facilities->epv);
pthread_mutex_lock(&bulletin->lock);
for (int a = 0; a < bulletin->to_consume_len; ++a) {
/* do some checks, e.g.
@ -349,7 +351,7 @@ void *sa_service(void *fc) {
// Tolling
if (facilities->tolling.enabled &&
bulletin->to_consume[a]->its_aid == 0 &&
!bulletin->to_consume[a]->n_trigger &&
now > bulletin->to_consume[a]->t_trigger + TOLLING_PAYMENT_MIN_PERIOD_MS &&
facilities->station_type != 15) {
if (!tpm_is_inside_zone(facilities, (tolling_info_s*) bulletin->to_consume[a]->info.internal_p)) {
@ -360,6 +362,7 @@ void *sa_service(void *fc) {
case TOLLING_PROTOCOL_SIMPLE:
tpm_pay(facilities, bulletin->to_consume[a]->certificate_id);
++bulletin->to_consume[a]->n_trigger;
bulletin->to_consume[a]->t_trigger = now;
break;
case TOLLING_PROTOCOL_TLS:;

View File

@ -28,7 +28,8 @@ typedef struct announcement {
uint64_t station_id;
uint64_t timestamp;
uint32_t n_trigger;
uint32_t n_trigger; /* number of times service was triggered */
uint64_t t_trigger; /* last trigger timestamp */
} announcement_t;
typedef struct bulletin {

View File

@ -6,6 +6,7 @@
#include <stdbool.h>
#define TOLLING_INFOS_MAX_LENGTH 16
#define TOLLING_PAYMENT_MIN_PERIOD_MS 60000
typedef enum TOLLING_PROTOCOL {
TOLLING_PROTOCOL_SIMPLE,