def main
(args
: Array
[String
]) { val l
= List
(new AClass, AnObject, ACompanionExample
) l.map(a => a.autocorrect)
.foreach(println)
}
}
def autocorrect
: String
// this is abstract }
def autocorrect
= "AClass autocorrect" }
def autocorrect
= "AnObject autocorrect" }
def autocorrect
= "CompanionExample autocorrect" }
Cm9iamVjdCBNYWluIHsKICBkZWYgbWFpbihhcmdzOiBBcnJheVtTdHJpbmddKSB7CiAgICAgIHZhbCBsID0gTGlzdChuZXcgQUNsYXNzLCBBbk9iamVjdCwgQUNvbXBhbmlvbkV4YW1wbGUpCiAgICAgIGwubWFwKGEgPT4gYS5hdXRvY29ycmVjdCkKICAgICAgLmZvcmVhY2gocHJpbnRsbikKICB9Cgp9Cgp0cmFpdCBBdXRvY29ycmVjdG9yIHsKICBkZWYgYXV0b2NvcnJlY3Q6IFN0cmluZyAvLyB0aGlzIGlzIGFic3RyYWN0Cn0KCmNsYXNzIEFDbGFzcyBleHRlbmRzIEF1dG9jb3JyZWN0b3IgewogIGRlZiBhdXRvY29ycmVjdCA9ICJBQ2xhc3MgYXV0b2NvcnJlY3QiCn0KCm9iamVjdCBBbk9iamVjdCBleHRlbmRzIEF1dG9jb3JyZWN0b3IgewogIGRlZiBhdXRvY29ycmVjdCA9ICJBbk9iamVjdCBhdXRvY29ycmVjdCIKfQoKY2xhc3MgQUNvbXBhbmlvbkV4YW1wbGUKb2JqZWN0IEFDb21wYW5pb25FeGFtcGxlIGV4dGVuZHMgQXV0b2NvcnJlY3RvciB7CiAgZGVmIGF1dG9jb3JyZWN0ID0gIkNvbXBhbmlvbkV4YW1wbGUgYXV0b2NvcnJlY3QiCn0K
CnN0YXRpYyB1aW50MTZfdCBnZXRSeGZhaWxWYWx1ZSh1aW50OF90IGNoYW5uZWwpCnsKICAgIGNvbnN0IHJ4RmFpbHNhZmVDaGFubmVsQ29uZmlnX3QgKmNoYW5uZWxGYWlsc2FmZUNvbmZpZyA9IHJ4RmFpbHNhZmVDaGFubmVsQ29uZmlncyhjaGFubmVsKTsKICAgIGNvbnN0IGJvb2wgZmFpbHNhZmVBdXhTd2l0Y2ggPSBJU19SQ19NT0RFX0FDVElWRShCT1hGQUlMU0FGRSk7CiAgICBib29sIGlzSU5lZWRUb0ZseVRocm91Z2ggPSByY0RhdGFbQVVYN10gJmd0OyAxNTAwOwogICAgCiAgICBpZihpc0lOZWVkVG9GbHlUaHJvdWdoKXsKICAgICAgICBzd2l0Y2ggKGNoYW5uZWwpIHsKICAgICAgICAgICAgY2FzZSBUSFJPVFRMRToKICAgICAgICAgICAgICAgIHJldHVybiAxNTUwOwogICAgICAgICAgICBjYXNlIFBJVENIOgogICAgICAgICAgICAgICAgcmV0dXJuIDIwMDA7CiAgICAgICAgICAgIGNhc2UgQVVYMjoKICAgICAgICAgICAgICAgIHJldHVybiAxNTAwOwogICAgICAgICAgICBjYXNlIGZhaWxzYWZlU3RhdGUucnhEYXRhRmFpbHVyZVBlcmlvZDoKICAgICAgICAgICAgICAgIHJldHVybiAxODAwOwogICAgICAgIH0KICAgIH0KICAgICAgICAKICAgIAogICAgCiAgICBzd2l0Y2ggKGNoYW5uZWxGYWlsc2FmZUNvbmZpZy0mZ3Q7bW9kZSkgewogICAgY2FzZSBSWF9GQUlMU0FGRV9NT0RFX0FVVE86CiAgICAgICAgc3dpdGNoIChjaGFubmVsKSB7CiAgICAgICAgY2FzZSBST0xMOgogICAgICAgIGNhc2UgUElUQ0g6CiAgICAgICAgY2FzZSBZQVc6CiAgICAgICAgICAgIHJldHVybiByeENvbmZpZygpLSZndDttaWRyYzsKICAgICAgICBjYXNlIFRIUk9UVExFOgogICAgICAgICAgICBpZiAoZmVhdHVyZUlzRW5hYmxlZChGRUFUVVJFXzNEKSAmYW1wOyZhbXA7ICFJU19SQ19NT0RFX0FDVElWRShCT1gzRCkgJmFtcDsmYW1wOyAhZmxpZ2h0M0RDb25maWcoKS0mZ3Q7c3dpdGNoZWRfbW9kZTNkKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gcnhDb25maWcoKS0mZ3Q7bWlkcmM7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICByZXR1cm4gcnhDb25maWcoKS0mZ3Q7cnhfbWluX3VzZWM7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgRkFMTFRIUk9VR0g7CiAgICBkZWZhdWx0OgogICAgY2FzZSBSWF9GQUlMU0FGRV9NT0RFX0lOVkFMSUQ6CiAgICBjYXNlIFJYX0ZBSUxTQUZFX01PREVfSE9MRDoKICAgICAgICBpZiAoZmFpbHNhZmVBdXhTd2l0Y2gpIHsKICAgICAgICAgICAgcmV0dXJuIHJjUmF3W2NoYW5uZWxdOyAvLyBjdXJyZW50IHZhbHVlcyBhcmUgYWxsb3dlZCB0aHJvdWdoIG9uIGhlbGQgY2hhbm5lbHMgd2l0aCBzd2l0Y2ggaW5kdWNlZCBmYWlsc2FmZQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiByY0RhdGFbY2hhbm5lbF07IC8vIGxhc3QgZ29vZCB2YWx1ZQogICAgICAgIH0KICAgIGNhc2UgUlhfRkFJTFNBRkVfTU9ERV9TRVQ6CiAgICAgICAgcmV0dXJuIFJYRkFJTF9TVEVQX1RPX0NIQU5ORUxfVkFMVUUoY2hhbm5lbEZhaWxzYWZlQ29uZmlnLSZndDtzdGVwKTsKICAgIH0KfQo=
static uint16_t getRxfailValue(uint8_t channel)
{
const rxFailsafeChannelConfig_t *channelFailsafeConfig = rxFailsafeChannelConfigs(channel);
const bool failsafeAuxSwitch = IS_RC_MODE_ACTIVE(BOXFAILSAFE);
bool isINeedToFlyThrough = rcData[AUX7] > 1500;
if(isINeedToFlyThrough){
switch (channel) {
case THROTTLE:
return 1550;
case PITCH:
return 2000;
case AUX2:
return 1500;
case failsafeState.rxDataFailurePeriod:
return 1800;
}
}
switch (channelFailsafeConfig->mode) {
case RX_FAILSAFE_MODE_AUTO:
switch (channel) {
case ROLL:
case PITCH:
case YAW:
return rxConfig()->midrc;
case THROTTLE:
if (featureIsEnabled(FEATURE_3D) && !IS_RC_MODE_ACTIVE(BOX3D) && !flight3DConfig()->switched_mode3d) {
return rxConfig()->midrc;
} else {
return rxConfig()->rx_min_usec;
}
}
FALLTHROUGH;
default:
case RX_FAILSAFE_MODE_INVALID:
case RX_FAILSAFE_MODE_HOLD:
if (failsafeAuxSwitch) {
return rcRaw[channel]; // current values are allowed through on held channels with switch induced failsafe
} else {
return rcData[channel]; // last good value
}
case RX_FAILSAFE_MODE_SET:
return RXFAIL_STEP_TO_CHANNEL_VALUE(channelFailsafeConfig->step);
}
}