From 39aeb7a48c69cfa525a444143e9b02bc23554e88 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 2 May 2019 18:19:27 +0800 Subject: [PATCH] Remove comm-b "consistency" bonuses, look at inconsistent data only. Rescale penalties so badly inconsistent messages will tend to get the same penalty in all formats, so the ambiguity check kicks in. With this final change the HEADING_SPEED and TRACK_TURN message rates are almost identical, which is what we'd expect to see if the interrogator is asking for both at about the same rate. Before: 567 AMBIGUOUS 7445 GICB_CAPS 19173 EMPTY_RESPONSE 75252 UNKNOWN 76469 AIRCRAFT_IDENT 127603 ACAS_RA 212654 HEADING_SPEED 223068 DATALINK_CAPS 229807 TRACK_TURN 269267 VERTICAL_INTENT 466 "suspicious" After: 7445 GICB_CAPS 17432 AMBIGUOUS 19173 EMPTY_RESPONSE 75252 UNKNOWN 76469 AIRCRAFT_IDENT 127603 ACAS_RA 212718 HEADING_SPEED 212878 TRACK_TURN 223068 DATALINK_CAPS 269267 VERTICAL_INTENT 328 "suspicious" --- comm_b.c | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/comm_b.c b/comm_b.c index 33bf361..196ec14 100644 --- a/comm_b.c +++ b/comm_b.c @@ -358,29 +358,24 @@ static int decodeBDS40(struct modesMessage *mm, bool store) return 0; } - // small bonuses for consistent data - if (mcp_valid && fms_valid && mcp_alt == fms_alt) { - score += 2; - } - - if (baro_valid && baro_raw == 2132) { - // 1013.2mb, standard pressure - score += 2; + // small penalty for inconsistent data + if (mcp_valid && fms_valid && mcp_alt != fms_alt) { + score -= 4; } if (mcp_valid) { unsigned remainder = mcp_alt % 500; - if (remainder < 16 || remainder > 484) { - // mcp altitude is a multiple of 500 - score += 2; + if (!(remainder < 16 || remainder > 484)) { + // mcp altitude is not a multiple of 500 + score -= 4; } } if (fms_valid) { unsigned remainder = fms_alt % 500; - if (remainder < 16 || remainder > 484) { - // fms altitude is a multiple of 500 - score += 2; + if (!(remainder < 16 || remainder > 484)) { + // fms altitude is not a multiple of 500 + score -= 4; } } @@ -544,13 +539,11 @@ static int decodeBDS50(struct modesMessage *mm, bool store) return 0; } - // small bonuses for consistent data + // small penalty for inconsistent data if (gs_valid && tas_valid) { int delta = abs((int)gs_valid - (int)tas_valid); - if (delta < 50) { - score += 5; - } else if (delta > 150) { - score -= 5; + if (delta > 150) { + score -= 6; } } @@ -558,10 +551,8 @@ static int decodeBDS50(struct modesMessage *mm, bool store) if (roll_valid && tas_valid && tas > 0 && track_rate_valid) { double turn_rate = 68625 * tan(roll * M_PI / 180.0) / (tas * 20 * M_PI); double delta = fabs(turn_rate - track_rate); - if (delta < 0.5) { - score += 5; - } else if (delta > 2.0) { - score -= 5; + if (delta > 2.0) { + score -= 6; } } @@ -704,16 +695,14 @@ static int decodeBDS60(struct modesMessage *mm, bool store) return 0; } - // small bonuses for consistent data + // small penalty for inconsistent data // Should check IAS vs Mach at given altitude, but the maths is a little involved if (baro_rate_valid && inertial_rate_valid) { int delta = abs(baro_rate - inertial_rate); - if (delta < 500) { - score += 5; - } else if (delta > 2000) { - score -= 5; + if (delta > 2000) { + score -= 12; } }