Rename TARGET_* -> INTENT_ALT_*

Rearrange the intent tracking a bit.
This commit is contained in:
Oliver Jowett 2017-06-15 18:23:28 +01:00
parent 2142d2edf5
commit 27b0e9c40f
4 changed files with 23 additions and 23 deletions

View file

@ -391,23 +391,23 @@ static int decodeBDS40(struct modesMessage *mm, bool store)
if (source_valid) {
switch (source_raw) {
case 0:
mm->intent.altitude_source = TARGET_UNKNOWN;
mm->intent.altitude_source = INTENT_ALT_UNKNOWN;
break;
case 1:
mm->intent.altitude_source = TARGET_AIRCRAFT;
mm->intent.altitude_source = INTENT_ALT_AIRCRAFT;
break;
case 2:
mm->intent.altitude_source = TARGET_MCP;
mm->intent.altitude_source = INTENT_ALT_MCP;
break;
case 3:
mm->intent.altitude_source = TARGET_FMS;
mm->intent.altitude_source = INTENT_ALT_FMS;
break;
default:
mm->intent.altitude_source = TARGET_INVALID;
mm->intent.altitude_source = INTENT_ALT_INVALID;
break;
}
} else {
mm->intent.altitude_source = TARGET_INVALID;
mm->intent.altitude_source = INTENT_ALT_INVALID;
}
}

View file

@ -529,7 +529,7 @@ struct modesMessage {
unsigned mcp_altitude; // MCP/FCU selected altitude
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_vnav : 1; // Vertical Navigation Mode active

View file

@ -1716,16 +1716,16 @@ void displayModesMessage(struct modesMessage *mm) {
if (mm->intent.alt_setting_valid)
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: ");
switch (mm->intent.altitude_source) {
case TARGET_AIRCRAFT:
case INTENT_ALT_AIRCRAFT:
printf("aircraft altitude\n");
break;
case TARGET_MCP:
case INTENT_ALT_MCP:
printf("MCP selected altitude\n");
break;
case TARGET_FMS:
case INTENT_ALT_FMS:
printf("FMS selected altitude\n");
break;
default:

View file

@ -622,8 +622,9 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
memcpy(a->callsign, mm->callsign, sizeof(a->callsign));
}
if (mm->intent.valid) {
if (mm->intent.mcp_altitude_valid && accept_data(&a->intent_altitude_valid, mm->source, now)) {
// prefer MCP over FMS
// unless the source says otherwise
if (mm->intent.mcp_altitude_valid && mm->intent.altitude_source != INTENT_ALT_FMS && accept_data(&a->intent_altitude_valid, mm->source, now)) {
a->intent_altitude = mm->intent.mcp_altitude;
} else if (mm->intent.fms_altitude_valid && accept_data(&a->intent_altitude_valid, mm->source, now)) {
a->intent_altitude = mm->intent.fms_altitude;
@ -636,7 +637,6 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
if (mm->intent.alt_setting_valid && accept_data(&a->alt_setting_valid, mm->source, now)) {
a->alt_setting = mm->intent.alt_setting;
}
}
// CPR, even
if (mm->cpr_valid && !mm->cpr_odd && accept_data(&a->cpr_even_valid, mm->source, now)) {