Skip to content

Commit

Permalink
copy full DB details to aircraft struct
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 15, 2024
1 parent d6932bb commit 6035235
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
4 changes: 4 additions & 0 deletions aircraft.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,15 @@ void updateTypeReg(struct aircraft *a) {
memcpy(a->registration, d->registration, sizeof(a->registration));
memcpy(a->typeCode, d->typeCode, sizeof(a->typeCode));
memcpy(a->typeLong, d->typeLong, sizeof(a->typeLong));
memcpy(a->ownOp, d->ownOp, sizeof(a->ownOp));
memcpy(a->year, d->year, sizeof(a->year));
a->dbFlags = d->dbFlags;
} else {
memset(a->registration, 0, sizeof(a->registration));
memset(a->typeCode, 0, sizeof(a->typeCode));
memset(a->typeLong, 0, sizeof(a->typeLong));
memset(a->ownOp, 0, sizeof(a->ownOp));
memset(a->year, 0, sizeof(a->year));
a->dbFlags = 0;
}
uint32_t i = a->addr;
Expand Down
31 changes: 13 additions & 18 deletions json_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,15 +658,12 @@ char *sprintAircraftObject(char *p, char *end, struct aircraft *a, int64_t now,
}

if (Modes.jsonLongtype) {
dbEntry *e = dbGet(a->addr, Modes.dbIndex);
if (e) {
if (e->typeLong[0])
p = safe_snprintf(p, end, ",\"desc\":\"%.*s\"", (int) sizeof(e->typeLong), e->typeLong);
if (e->ownOp[0])
p = safe_snprintf(p, end, ",\n\"ownOp\":\"%.*s\"", (int) sizeof(e->ownOp), e->ownOp);
if (e->year[0])
p = safe_snprintf(p, end, ",\n\"year\":\"%.*s\"", (int) sizeof(e->year), e->year);
}
if (a->typeLong[0])
p = safe_snprintf(p, end, ",\"desc\":\"%.*s\"", (int) sizeof(a->typeLong), a->typeLong);
if (a->ownOp[0])
p = safe_snprintf(p, end, ",\n\"ownOp\":\"%.*s\"", (int) sizeof(a->ownOp), a->ownOp);
if (a->year[0])
p = safe_snprintf(p, end, ",\n\"year\":\"%.*s\"", (int) sizeof(a->year), a->year);
}
}

Expand Down Expand Up @@ -1770,15 +1767,13 @@ struct char_buffer generateTraceJson(struct aircraft *a, traceBuffer tb, int sta
dbFlags &= ~(1 << 7);
p = safe_snprintf(p, end, ",\n\"dbFlags\":%u", dbFlags);
}
dbEntry *e = dbGet(a->addr, Modes.dbIndex);
if (e) {
if (e->typeLong[0])
p = safe_snprintf(p, end, ",\n\"desc\":\"%.*s\"", (int) sizeof(e->typeLong), e->typeLong);
if (e->ownOp[0])
p = safe_snprintf(p, end, ",\n\"ownOp\":\"%.*s\"", (int) sizeof(e->ownOp), e->ownOp);
if (e->year[0])
p = safe_snprintf(p, end, ",\n\"year\":\"%.*s\"", (int) sizeof(e->year), e->year);
}

if (a->typeLong[0])
p = safe_snprintf(p, end, ",\"desc\":\"%.*s\"", (int) sizeof(a->typeLong), a->typeLong);
if (a->ownOp[0])
p = safe_snprintf(p, end, ",\n\"ownOp\":\"%.*s\"", (int) sizeof(a->ownOp), a->ownOp);
if (a->year[0])
p = safe_snprintf(p, end, ",\n\"year\":\"%.*s\"", (int) sizeof(a->year), a->year);
if (p == regInfo)
p = safe_snprintf(p, end, ",\n\"noRegData\":true");
}
Expand Down
3 changes: 3 additions & 0 deletions track.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ struct aircraft

char zeroStart;

char ownOp[64];
char year[4];

float messageRate;
uint16_t messageRateAcc[MESSAGE_RATE_CALC_POINTS];
int64_t nextMessageRateCalc;
Expand Down

0 comments on commit 6035235

Please sign in to comment.