Tolling payment min period
This commit is contained in:
parent
eea1f89a55
commit
ddd0f012b7
|
|
@ -5,6 +5,13 @@
|
||||||
|
|
||||||
typedef struct coordination {
|
typedef struct coordination {
|
||||||
bool active;
|
bool active;
|
||||||
|
|
||||||
|
|
||||||
|
struct {
|
||||||
|
bool intersecting;
|
||||||
|
uint64_t t_negotiation;
|
||||||
|
|
||||||
|
} neighbours;
|
||||||
|
|
||||||
} coordination_s;
|
} coordination_s;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,8 @@ void *sa_service(void *fc) {
|
||||||
lon = facilities->epv.space.longitude;
|
lon = facilities->epv.space.longitude;
|
||||||
it2s_tender_unlock_space(&facilities->epv);
|
it2s_tender_unlock_space(&facilities->epv);
|
||||||
|
|
||||||
|
uint64_t now = it2s_tender_get_clock(&facilities->epv);
|
||||||
|
|
||||||
pthread_mutex_lock(&bulletin->lock);
|
pthread_mutex_lock(&bulletin->lock);
|
||||||
for (int a = 0; a < bulletin->to_consume_len; ++a) {
|
for (int a = 0; a < bulletin->to_consume_len; ++a) {
|
||||||
/* do some checks, e.g.
|
/* do some checks, e.g.
|
||||||
|
|
@ -349,7 +351,7 @@ void *sa_service(void *fc) {
|
||||||
// Tolling
|
// Tolling
|
||||||
if (facilities->tolling.enabled &&
|
if (facilities->tolling.enabled &&
|
||||||
bulletin->to_consume[a]->its_aid == 0 &&
|
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) {
|
facilities->station_type != 15) {
|
||||||
|
|
||||||
if (!tpm_is_inside_zone(facilities, (tolling_info_s*) bulletin->to_consume[a]->info.internal_p)) {
|
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:
|
case TOLLING_PROTOCOL_SIMPLE:
|
||||||
tpm_pay(facilities, bulletin->to_consume[a]->certificate_id);
|
tpm_pay(facilities, bulletin->to_consume[a]->certificate_id);
|
||||||
++bulletin->to_consume[a]->n_trigger;
|
++bulletin->to_consume[a]->n_trigger;
|
||||||
|
bulletin->to_consume[a]->t_trigger = now;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOLLING_PROTOCOL_TLS:;
|
case TOLLING_PROTOCOL_TLS:;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ typedef struct announcement {
|
||||||
uint64_t station_id;
|
uint64_t station_id;
|
||||||
uint64_t timestamp;
|
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;
|
} announcement_t;
|
||||||
|
|
||||||
typedef struct bulletin {
|
typedef struct bulletin {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define TOLLING_INFOS_MAX_LENGTH 16
|
#define TOLLING_INFOS_MAX_LENGTH 16
|
||||||
|
#define TOLLING_PAYMENT_MIN_PERIOD_MS 60000
|
||||||
|
|
||||||
typedef enum TOLLING_PROTOCOL {
|
typedef enum TOLLING_PROTOCOL {
|
||||||
TOLLING_PROTOCOL_SIMPLE,
|
TOLLING_PROTOCOL_SIMPLE,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue