diff --git a/src/dcm.h b/src/dcm.h index ba613bc..8a81a77 100644 --- a/src/dcm.h +++ b/src/dcm.h @@ -5,6 +5,13 @@ typedef struct coordination { bool active; + + + struct { + bool intersecting; + uint64_t t_negotiation; + + } neighbours; } coordination_s; diff --git a/src/saem.c b/src/saem.c index 394a6f2..f6869bb 100644 --- a/src/saem.c +++ b/src/saem.c @@ -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:; diff --git a/src/saem.h b/src/saem.h index 0de7013..28fe300 100644 --- a/src/saem.h +++ b/src/saem.h @@ -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 { diff --git a/src/tpm.h b/src/tpm.h index 43acc6b..61b4021 100644 --- a/src/tpm.h +++ b/src/tpm.h @@ -6,6 +6,7 @@ #include #define TOLLING_INFOS_MAX_LENGTH 16 +#define TOLLING_PAYMENT_MIN_PERIOD_MS 60000 typedef enum TOLLING_PROTOCOL { TOLLING_PROTOCOL_SIMPLE,