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;
|
||||
|
||||
// DCM
|
||||
// PCM
|
||||
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
|
||||
facilities->replay = config->networking.replay.activate;
|
||||
|
|
|
|||
44
src/pcm.c
44
src/pcm.c
|
|
@ -8,8 +8,6 @@
|
|||
#include <itss-transport/TransportRequest.h>
|
||||
#include <pcm/PCM.h>
|
||||
|
||||
#define SLEEP_TIME_MS 100
|
||||
|
||||
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* tB, int tB_len, uint16_t vB_length, uint16_t vB_width,
|
||||
|
|
@ -512,6 +510,17 @@ cleanup:
|
|||
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) {
|
||||
|
||||
facilities_t* facilities = (facilities_t*) fc;
|
||||
|
|
@ -547,25 +556,28 @@ void* pc_service(void* fc) {
|
|||
|
||||
while (!facilities->exit) {
|
||||
|
||||
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);
|
||||
uint64_t now = it2s_tender_get_clock(&facilities->epv);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
usleep(SLEEP_TIME_MS * 1000);
|
||||
usleep(50 * 1000);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue