StationID 32 bits, multiple targetted VCM
This commit is contained in:
parent
038d07968c
commit
f7b8c48882
|
|
@ -552,7 +552,7 @@ void lightship_reset_timer() {
|
|||
lightship->next_cam_max = now + lightship->vehicle_gen_max;
|
||||
lightship->next_cam_min = now + lightship->vehicle_gen_min;
|
||||
} else { // RSU
|
||||
if (now > lightship->last_vehicle + lightship->rsu_vehicle_permanence) {
|
||||
if (now > lightship->t_last_vehicle + lightship->rsu_vehicle_permanence) {
|
||||
lightship->is_vehicle_near = false;
|
||||
}
|
||||
lightship->next_cam_min = now + lightship->rsu_gen_min;
|
||||
|
|
@ -692,7 +692,7 @@ enum CAM_CHECK_R check_cam(BTPPacketIndication_t *bpi, CAM_t* cam, uint8_t* ssp,
|
|||
if (lightship->type == StationType_roadSideUnit) {
|
||||
// Send CAMs if vehicles nearby
|
||||
if (bpi->stationType != StationType_roadSideUnit && bpi->isNeighbour) {
|
||||
lightship->last_vehicle = now;
|
||||
lightship->t_last_vehicle = now;
|
||||
lightship->is_vehicle_near = true;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -879,7 +879,7 @@ void* ca_service() {
|
|||
// Logging
|
||||
if (facilities.logging.dbms) {
|
||||
pthread_mutex_lock(&facilities.id.lock);
|
||||
uint64_t station_id = facilities.id.station_id;
|
||||
uint32_t station_id = facilities.id.station_id;
|
||||
pthread_mutex_unlock(&facilities.id.lock);
|
||||
itss_db_add(facilities.logging.dbms, station_id, bpr->id, true, messageID_cam, NULL, bpr->data.buf, bpr->data.size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ typedef struct lightship {
|
|||
|
||||
|
||||
bool is_vehicle_near;
|
||||
uint64_t last_vehicle;
|
||||
uint64_t t_last_vehicle;
|
||||
|
||||
uint32_t vehicle_gen_min;
|
||||
uint32_t vehicle_gen_max;
|
||||
|
|
|
|||
|
|
@ -747,7 +747,7 @@ void *cp_service(){
|
|||
// Logging
|
||||
if (facilities.logging.dbms) {
|
||||
pthread_mutex_lock(&facilities.id.lock);
|
||||
uint64_t station_id = facilities.id.station_id;
|
||||
uint32_t station_id = facilities.id.station_id;
|
||||
pthread_mutex_unlock(&facilities.id.lock);
|
||||
itss_db_add(facilities.logging.dbms, station_id, bpr->id, true, 14, NULL, bpr->data.buf, bpr->data.size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ static int transport_indication(void* responder, void** security_socket, uint8_t
|
|||
// Logging
|
||||
if (facilities.logging.dbms) {
|
||||
pthread_mutex_lock(&facilities.id.lock);
|
||||
uint64_t station_id = facilities.id.station_id;
|
||||
uint32_t station_id = facilities.id.station_id;
|
||||
pthread_mutex_unlock(&facilities.id.lock);
|
||||
itss_db_add(facilities.logging.dbms, station_id, id, false, its_msg_type, NULL, packet, packet_len);
|
||||
}
|
||||
|
|
@ -659,7 +659,7 @@ static int networking_indication(void* responder, uint8_t* msg, uint32_t msg_len
|
|||
*ni->choice.data.mobileNeighbour) {
|
||||
|
||||
pthread_mutex_lock(&facilities.lightship.lock);
|
||||
facilities.lightship.last_vehicle = itss_time_get();
|
||||
facilities.lightship.t_last_vehicle = itss_time_get();
|
||||
facilities.lightship.is_vehicle_near = true;
|
||||
pthread_mutex_unlock(&facilities.lightship.lock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ typedef struct facilities {
|
|||
|
||||
struct {
|
||||
pthread_mutex_t lock;
|
||||
uint64_t station_id;
|
||||
uint32_t station_id;
|
||||
uint8_t ipv6_addr[16];
|
||||
struct {
|
||||
pthread_mutex_t lock;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ typedef struct service {
|
|||
uint64_t id;
|
||||
bool enabled;
|
||||
enum SERVICE_TYPE type;
|
||||
uint64_t station_id;
|
||||
uint32_t station_id;
|
||||
enum SERVICE_STATE state;
|
||||
|
||||
IVIM_t *ivim;
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ void *sa_service() {
|
|||
// Logging
|
||||
if (facilities.logging.dbms) {
|
||||
pthread_mutex_lock(&facilities.id.lock);
|
||||
uint64_t station_id = facilities.id.station_id;
|
||||
uint32_t station_id = facilities.id.station_id;
|
||||
pthread_mutex_unlock(&facilities.id.lock);
|
||||
itss_db_add(facilities.logging.dbms, station_id, bpr->id, true, messageID_saem, NULL, bpr->data.buf, bpr->data.size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ typedef struct announcement {
|
|||
void* internal_p;
|
||||
} info;
|
||||
|
||||
uint64_t station_id;
|
||||
uint32_t station_id;
|
||||
uint64_t timestamp;
|
||||
|
||||
uint32_t n_trigger; /* number of times service was triggered */
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ int tpm_pay(tolling_info_t* info, void** security_socket, uint8_t* neighbour, ui
|
|||
// Logging
|
||||
if (facilities.logging.dbms) {
|
||||
pthread_mutex_lock(&facilities.id.lock);
|
||||
uint64_t station_id = facilities.id.station_id;
|
||||
uint32_t station_id = facilities.id.station_id;
|
||||
pthread_mutex_unlock(&facilities.id.lock);
|
||||
itss_db_add(facilities.logging.dbms, station_id, id, true, 117, NULL, tpm_uper, tpm_uper_len);
|
||||
}
|
||||
|
|
@ -950,7 +950,7 @@ static void rsu_handle_recv(TPM_t* tpm_rx, void** security_socket, uint8_t* neig
|
|||
// Logging
|
||||
if (facilities.logging.dbms) {
|
||||
pthread_mutex_lock(&facilities.id.lock);
|
||||
uint64_t station_id = facilities.id.station_id;
|
||||
uint32_t station_id = facilities.id.station_id;
|
||||
pthread_mutex_unlock(&facilities.id.lock);
|
||||
itss_db_add(facilities.logging.dbms, station_id, id, true, 117, NULL, tpm_uper, tpm_uper_len);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ typedef struct tlsc {
|
|||
} tlsc_t;
|
||||
|
||||
typedef struct toll_client {
|
||||
uint64_t station_id;
|
||||
uint32_t station_id;
|
||||
uint64_t id;
|
||||
uint64_t ts;
|
||||
int8_t accepted;
|
||||
|
|
|
|||
55
src/vcm.c
55
src/vcm.c
|
|
@ -53,7 +53,7 @@ static int vcm_check_handle_request(VCM_t* vcm, mc_neighbour_s* neighbour) {
|
|||
coordination_t* coordination = &facilities.coordination;
|
||||
|
||||
pthread_mutex_lock(&facilities.id.lock);
|
||||
uint64_t my_station_id = facilities.id.station_id;
|
||||
uint32_t my_station_id = facilities.id.station_id;
|
||||
pthread_mutex_unlock(&facilities.id.lock);
|
||||
|
||||
// Is request for me?
|
||||
|
|
@ -61,7 +61,7 @@ static int vcm_check_handle_request(VCM_t* vcm, mc_neighbour_s* neighbour) {
|
|||
bool is_req4me = false;
|
||||
for (int i = 0; i < request->desiredTrajectories.list.count && !is_req4me; ++i) {
|
||||
for (int j = 0; j < request->desiredTrajectories.list.array[i]->affectingStations.list.count; ++j) {
|
||||
log_debug("[vc] VCM.request meant for %lld", *request->desiredTrajectories.list.array[i]->affectingStations.list.array[j]);
|
||||
log_debug("[vc] VCM.request meant for %d", *request->desiredTrajectories.list.array[i]->affectingStations.list.array[j]);
|
||||
if (my_station_id == *request->desiredTrajectories.list.array[i]->affectingStations.list.array[j]) {
|
||||
is_req4me = true;
|
||||
break;
|
||||
|
|
@ -397,6 +397,7 @@ static int intersection_detected(VCM_t* vcm, mc_neighbour_s* neighbour) {
|
|||
ProposedTrajectory_t* pt = mvc->negotiation->choice.request.desiredTrajectories.list.array[0];
|
||||
mvc->negotiation->choice.request.requesterId = vcm->header.stationID;
|
||||
mvc->negotiation->choice.request.nonce = rand() + 1;
|
||||
neighbour->nonce = mvc->negotiation->choice.request.nonce;
|
||||
|
||||
pt->trajectory.list.count = trajectoryA_len - 1;
|
||||
pt->trajectory.list.size = sizeof(void*) * (trajectoryA_len - 1);
|
||||
|
|
@ -411,12 +412,43 @@ static int intersection_detected(VCM_t* vcm, mc_neighbour_s* neighbour) {
|
|||
pt->offer = 5;
|
||||
pt->priority = 1;
|
||||
pt->id = 0;
|
||||
pt->affectingStations.list.count = 1;
|
||||
pt->affectingStations.list.size = 1*sizeof(void*);
|
||||
pt->affectingStations.list.array = malloc(sizeof(void*));
|
||||
pt->affectingStations.list.array[0] = malloc(sizeof(long long));
|
||||
*pt->affectingStations.list.array[0] = neighbour->station_id;
|
||||
log_debug("[vc] this VCM.request affects %ld", neighbour->station_id);
|
||||
|
||||
uint32_t intneigh[MC_MAX_NEIGHBOURS];
|
||||
intneigh[0] = neighbour->station_id;
|
||||
int n_intneigh = 1;
|
||||
for (int n = 0; n < coordination->neighbours_len; ++n) {
|
||||
if (coordination->neighbours[n].station_id == neighbour->station_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int index;
|
||||
if (are_vehicles_intersecting(
|
||||
trajectoryA, trajectoryA_len,
|
||||
facilities.vehicle.length, facilities.vehicle.length,
|
||||
coordination->neighbours[n].trajectory, coordination->neighbours[n].trajectory_len,
|
||||
coordination->neighbours[n].length, coordination->neighbours[n].width,
|
||||
&index
|
||||
)) {
|
||||
intneigh[n_intneigh] = coordination->neighbours[n].station_id;
|
||||
++n_intneigh;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
char buffer[512];
|
||||
int wr = 0;
|
||||
#endif
|
||||
pt->affectingStations.list.count = n_intneigh;
|
||||
pt->affectingStations.list.size = n_intneigh*sizeof(void*);
|
||||
pt->affectingStations.list.array = malloc(n_intneigh * sizeof(void*));
|
||||
for (int i = 0; i < n_intneigh; ++i) {
|
||||
pt->affectingStations.list.array[i] = malloc(sizeof(long long));
|
||||
*pt->affectingStations.list.array[i] = intneigh[i];
|
||||
#ifndef NDEBUG
|
||||
wr += sprintf(buffer + wr, " %d", intneigh[i]);
|
||||
#endif
|
||||
}
|
||||
log_debug("[vc] this VCM.request affects %d station(s):%s", n_intneigh, buffer);
|
||||
|
||||
asn_enc_rval_t enc = uper_encode_to_buffer(&asn_DEF_VCM, NULL, vcm_req, buf, buf_len);
|
||||
if (enc.encoded == -1) {
|
||||
|
|
@ -530,6 +562,7 @@ int vcm_check(VCM_t* vcm) {
|
|||
ni = coordination->neighbours_len;
|
||||
++coordination->neighbours_len;
|
||||
}
|
||||
|
||||
switch (vcm->vcm.maneuverContainer.present) {
|
||||
case ManeuverContainer_PR_vehicle:
|
||||
;
|
||||
|
|
@ -568,6 +601,12 @@ int vcm_check(VCM_t* vcm) {
|
|||
++trajectoryB_len;
|
||||
}
|
||||
|
||||
// Save neighbour trajectory
|
||||
memcpy(coordination->neighbours[ni].trajectory, trajectoryB, trajectoryB_len * sizeof(itss_st_t));
|
||||
coordination->neighbours[ni].trajectory_len = trajectoryB_len;
|
||||
coordination->neighbours[ni].length = mvc->vehicleLength.vehicleLengthValue;
|
||||
coordination->neighbours[ni].width = mvc->vehicleWidth;
|
||||
|
||||
bool intersecting = false;
|
||||
int index = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,17 +4,24 @@
|
|||
#include <vcm/VCM.h>
|
||||
|
||||
#include <it2s-tender/geodesy.h>
|
||||
#include <it2s-tender/epv.h>
|
||||
|
||||
#define MC_MAX_NEIGHBOURS 32
|
||||
#define MC_RESOLUTION_TIMEOUT 1000
|
||||
|
||||
typedef struct {
|
||||
uint64_t station_id;
|
||||
uint32_t station_id;
|
||||
uint16_t length;
|
||||
uint16_t width;
|
||||
|
||||
itss_st_t trajectory[TRAJECTORY_MAX_LEN + 1];
|
||||
uint8_t trajectory_len;
|
||||
|
||||
bool intersecting;
|
||||
uint64_t t_iid; /* initial intersection detection */
|
||||
|
||||
bool proposed;
|
||||
uint64_t nonce;
|
||||
uint64_t t_proposal;
|
||||
} mc_neighbour_s;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue