PCM simple trigger check
This commit is contained in:
parent
607b0edc01
commit
d0c692d523
|
|
@ -314,8 +314,10 @@ int facilities_config(void* facilities_s) {
|
||||||
}
|
}
|
||||||
facilities->tolling.client_id = config->facilities.tpm.client_id;
|
facilities->tolling.client_id = config->facilities.tpm.client_id;
|
||||||
|
|
||||||
// DCM
|
// PCM
|
||||||
facilities->coordination.active = config->facilities.dcm.activate;
|
facilities->coordination.active = config->facilities.dcm.activate;
|
||||||
|
facilities->coordination.pcm_period_min = config->facilities.dcm.period_min;
|
||||||
|
facilities->coordination.pcm_period_max = config->facilities.dcm.period_max;
|
||||||
|
|
||||||
// Replay
|
// Replay
|
||||||
facilities->replay = config->networking.replay.activate;
|
facilities->replay = config->networking.replay.activate;
|
||||||
|
|
|
||||||
44
src/pcm.c
44
src/pcm.c
|
|
@ -8,8 +8,6 @@
|
||||||
#include <itss-transport/TransportRequest.h>
|
#include <itss-transport/TransportRequest.h>
|
||||||
#include <pcm/PCM.h>
|
#include <pcm/PCM.h>
|
||||||
|
|
||||||
#define SLEEP_TIME_MS 100
|
|
||||||
|
|
||||||
static int are_vehicles_intersecting(
|
static int are_vehicles_intersecting(
|
||||||
it2s_tender_st_s* tA, int tA_len, uint16_t vA_length, uint16_t vA_width,
|
it2s_tender_st_s* tA, int tA_len, uint16_t vA_length, uint16_t vA_width,
|
||||||
it2s_tender_st_s* tB, int tB_len, uint16_t vB_length, uint16_t vB_width,
|
it2s_tender_st_s* tB, int tB_len, uint16_t vB_length, uint16_t vB_width,
|
||||||
|
|
@ -512,6 +510,17 @@ cleanup:
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool pcm_timer_check(coordination_s* coordination, uint64_t now) {
|
||||||
|
|
||||||
|
bool send = false;
|
||||||
|
|
||||||
|
if (now > coordination->t_last_send_pcm + coordination->pcm_period_max) {
|
||||||
|
send = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return send;
|
||||||
|
}
|
||||||
|
|
||||||
void* pc_service(void* fc) {
|
void* pc_service(void* fc) {
|
||||||
|
|
||||||
facilities_t* facilities = (facilities_t*) fc;
|
facilities_t* facilities = (facilities_t*) fc;
|
||||||
|
|
@ -547,25 +556,28 @@ void* pc_service(void* fc) {
|
||||||
|
|
||||||
while (!facilities->exit) {
|
while (!facilities->exit) {
|
||||||
|
|
||||||
rv = mk_pcm(facilities, bpr->data.buf, (uint16_t *) &bpr->data.size);
|
uint64_t now = it2s_tender_get_clock(&facilities->epv);
|
||||||
if (rv) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, tr_oer+1, 1023);
|
|
||||||
if (enc.encoded == -1) {
|
|
||||||
syslog_err("[facilities] encoding TR for PCM failed");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
queue_send(facilities->tx_queue, tr_oer, enc.encoded+1, 3);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&coordination->lock);
|
pthread_mutex_lock(&coordination->lock);
|
||||||
|
if (pcm_timer_check(coordination, now)) {
|
||||||
|
rv = mk_pcm(facilities, bpr->data.buf, (uint16_t *) &bpr->data.size);
|
||||||
|
if (rv) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, tr_oer+1, 1023);
|
||||||
|
if (enc.encoded == -1) {
|
||||||
|
syslog_err("[facilities] encoding TR for PCM failed");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
queue_send(facilities->tx_queue, tr_oer, enc.encoded+1, 3);
|
||||||
|
|
||||||
|
coordination->t_last_send_pcm = now;
|
||||||
|
}
|
||||||
pthread_mutex_unlock(&coordination->lock);
|
pthread_mutex_unlock(&coordination->lock);
|
||||||
|
|
||||||
|
usleep(50 * 1000);
|
||||||
usleep(SLEEP_TIME_MS * 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,10 @@ typedef struct coordination {
|
||||||
|
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
|
|
||||||
|
uint64_t t_last_send_pcm;
|
||||||
|
uint64_t pcm_period_min;
|
||||||
|
uint64_t pcm_period_max;
|
||||||
|
|
||||||
mc_neighbour_s neighbours[MC_MAX_NEIGHBOURS];
|
mc_neighbour_s neighbours[MC_MAX_NEIGHBOURS];
|
||||||
uint8_t neighbours_len;
|
uint8_t neighbours_len;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue