Fix vcm neighbour lookup
This commit is contained in:
parent
c665d23381
commit
003b7e5a46
|
|
@ -769,8 +769,7 @@ int main() {
|
|||
|
||||
syslog_info("[facilities] starting");
|
||||
|
||||
facilities_t facilities;
|
||||
memset(&facilities, 0x00, sizeof(facilities_t));
|
||||
facilities_t facilities = {0};
|
||||
|
||||
facilities.zmq.ctx = zmq_ctx_new();
|
||||
facilities.tx_queue = it2s_tender_queue_new();
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ static int vcm_check_handle_request(facilities_t* facilities, VCM_t* vcm, mc_nei
|
|||
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) {
|
||||
syslog_debug("[facilities] [vc] VCM.request meant for %lld", *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;
|
||||
|
|
@ -301,7 +302,6 @@ static int vcm_check_intersection_detected(facilities_t* facilities, VCM_t* vcm,
|
|||
|
||||
vcm_req->header.messageID = 43;
|
||||
vcm_req->header.protocolVersion = 1;
|
||||
vcm_req->header.stationID = 1;
|
||||
pthread_mutex_lock(&facilities->id.lock);
|
||||
vcm_req->header.stationID = facilities->id.station_id;
|
||||
pthread_mutex_unlock(&facilities->id.lock);
|
||||
|
|
@ -366,6 +366,7 @@ static int vcm_check_intersection_detected(facilities_t* facilities, VCM_t* vcm,
|
|||
pt->affectingStations.list.array = malloc(sizeof(void*));
|
||||
pt->affectingStations.list.array[0] = malloc(sizeof(long long));
|
||||
*pt->affectingStations.list.array[0] = neighbour->station_id;
|
||||
syslog_debug("[facilities] [vc] this VCM.request affects %ld", neighbour->station_id);
|
||||
|
||||
asn_enc_rval_t enc = uper_encode_to_buffer(&asn_DEF_VCM, NULL, vcm_req, buf, buf_len);
|
||||
if (enc.encoded == -1) {
|
||||
|
|
@ -468,14 +469,14 @@ int vcm_check(void* fc, VCM_t* vcm) {
|
|||
// Find neighbours
|
||||
int ni = -1;
|
||||
for (int i = 0; i < coordination->neighbours_len; ++i) {
|
||||
if (coordination->neighbours->station_id == vcm->header.stationID) {
|
||||
if (coordination->neighbours[i].station_id == vcm->header.stationID) {
|
||||
ni = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add it if not found
|
||||
if (ni == -1 && coordination->neighbours_len + 1 < MC_MAX_NEIGHBOURS) {
|
||||
if (ni == -1 && coordination->neighbours_len < MC_MAX_NEIGHBOURS) {
|
||||
coordination->neighbours[coordination->neighbours_len].station_id = vcm->header.stationID;
|
||||
ni = coordination->neighbours_len;
|
||||
++coordination->neighbours_len;
|
||||
|
|
|
|||
Loading…
Reference in New Issue