Rename TARGET_* -> INTENT_ALT_*
Rearrange the intent tracking a bit.
This commit is contained in:
parent
2142d2edf5
commit
27b0e9c40f
12
comm_b.c
12
comm_b.c
|
@ -391,23 +391,23 @@ static int decodeBDS40(struct modesMessage *mm, bool store)
|
||||||
if (source_valid) {
|
if (source_valid) {
|
||||||
switch (source_raw) {
|
switch (source_raw) {
|
||||||
case 0:
|
case 0:
|
||||||
mm->intent.altitude_source = TARGET_UNKNOWN;
|
mm->intent.altitude_source = INTENT_ALT_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mm->intent.altitude_source = TARGET_AIRCRAFT;
|
mm->intent.altitude_source = INTENT_ALT_AIRCRAFT;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mm->intent.altitude_source = TARGET_MCP;
|
mm->intent.altitude_source = INTENT_ALT_MCP;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mm->intent.altitude_source = TARGET_FMS;
|
mm->intent.altitude_source = INTENT_ALT_FMS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mm->intent.altitude_source = TARGET_INVALID;
|
mm->intent.altitude_source = INTENT_ALT_INVALID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mm->intent.altitude_source = TARGET_INVALID;
|
mm->intent.altitude_source = INTENT_ALT_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -529,7 +529,7 @@ struct modesMessage {
|
||||||
unsigned mcp_altitude; // MCP/FCU selected altitude
|
unsigned mcp_altitude; // MCP/FCU selected altitude
|
||||||
float alt_setting; // altimeter setting (QFE or QNH/QNE), millibars
|
float alt_setting; // altimeter setting (QFE or QNH/QNE), millibars
|
||||||
|
|
||||||
enum { TARGET_INVALID, TARGET_UNKNOWN, TARGET_AIRCRAFT, TARGET_MCP, TARGET_FMS } altitude_source;
|
enum { INTENT_ALT_INVALID, INTENT_ALT_UNKNOWN, INTENT_ALT_AIRCRAFT, INTENT_ALT_MCP, INTENT_ALT_FMS } altitude_source;
|
||||||
|
|
||||||
unsigned mode_autopilot : 1; // Autopilot engaged
|
unsigned mode_autopilot : 1; // Autopilot engaged
|
||||||
unsigned mode_vnav : 1; // Vertical Navigation Mode active
|
unsigned mode_vnav : 1; // Vertical Navigation Mode active
|
||||||
|
|
8
mode_s.c
8
mode_s.c
|
@ -1716,16 +1716,16 @@ void displayModesMessage(struct modesMessage *mm) {
|
||||||
if (mm->intent.alt_setting_valid)
|
if (mm->intent.alt_setting_valid)
|
||||||
printf(" Altimeter setting: %.1f millibars\n", mm->intent.alt_setting);
|
printf(" Altimeter setting: %.1f millibars\n", mm->intent.alt_setting);
|
||||||
|
|
||||||
if (mm->intent.altitude_source != TARGET_INVALID) {
|
if (mm->intent.altitude_source != INTENT_ALT_INVALID) {
|
||||||
printf(" Target altitude source: ");
|
printf(" Target altitude source: ");
|
||||||
switch (mm->intent.altitude_source) {
|
switch (mm->intent.altitude_source) {
|
||||||
case TARGET_AIRCRAFT:
|
case INTENT_ALT_AIRCRAFT:
|
||||||
printf("aircraft altitude\n");
|
printf("aircraft altitude\n");
|
||||||
break;
|
break;
|
||||||
case TARGET_MCP:
|
case INTENT_ALT_MCP:
|
||||||
printf("MCP selected altitude\n");
|
printf("MCP selected altitude\n");
|
||||||
break;
|
break;
|
||||||
case TARGET_FMS:
|
case INTENT_ALT_FMS:
|
||||||
printf("FMS selected altitude\n");
|
printf("FMS selected altitude\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
24
track.c
24
track.c
|
@ -622,20 +622,20 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
memcpy(a->callsign, mm->callsign, sizeof(a->callsign));
|
memcpy(a->callsign, mm->callsign, sizeof(a->callsign));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm->intent.valid) {
|
// prefer MCP over FMS
|
||||||
if (mm->intent.mcp_altitude_valid && accept_data(&a->intent_altitude_valid, mm->source, now)) {
|
// unless the source says otherwise
|
||||||
a->intent_altitude = mm->intent.mcp_altitude;
|
if (mm->intent.mcp_altitude_valid && mm->intent.altitude_source != INTENT_ALT_FMS && accept_data(&a->intent_altitude_valid, mm->source, now)) {
|
||||||
} else if (mm->intent.fms_altitude_valid && accept_data(&a->intent_altitude_valid, mm->source, now)) {
|
a->intent_altitude = mm->intent.mcp_altitude;
|
||||||
a->intent_altitude = mm->intent.fms_altitude;
|
} else if (mm->intent.fms_altitude_valid && accept_data(&a->intent_altitude_valid, mm->source, now)) {
|
||||||
}
|
a->intent_altitude = mm->intent.fms_altitude;
|
||||||
|
}
|
||||||
|
|
||||||
if (mm->intent.heading_valid && accept_data(&a->intent_heading_valid, mm->source, now)) {
|
if (mm->intent.heading_valid && accept_data(&a->intent_heading_valid, mm->source, now)) {
|
||||||
a->intent_heading = mm->intent.heading;
|
a->intent_heading = mm->intent.heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm->intent.alt_setting_valid && accept_data(&a->alt_setting_valid, mm->source, now)) {
|
if (mm->intent.alt_setting_valid && accept_data(&a->alt_setting_valid, mm->source, now)) {
|
||||||
a->alt_setting = mm->intent.alt_setting;
|
a->alt_setting = mm->intent.alt_setting;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPR, even
|
// CPR, even
|
||||||
|
|
Loading…
Reference in a new issue