コード例 #1
0
        protected override Task OnKeyUp(ActionEventArgs <KeyPayload> args)
        {
            timer.Stop();
            if (!timerHasTick)
            {
                var currentStatus = status;
                if (currentStatus != null)
                {
                    switch (settings?.Type)
                    {
                    case PresetFunction.Avionics:
                        logger.LogInformation("Toggle AV Master. Current state: {state}.", currentStatus.IsAvMasterOn);
                        uint off = 0;
                        uint on  = 1;
                        flightConnector.AvMasterToggle(currentStatus.IsAvMasterOn ? off : on);
                        break;

                    case PresetFunction.ApMaster:
                        logger.LogInformation("Toggle AP Master. Current state: {state}.", currentStatus.IsAutopilotOn);
                        flightConnector.ApToggle();
                        break;

                    case PresetFunction.Heading:
                        logger.LogInformation("Toggle AP HDG. Current state: {state}.", currentStatus.IsApHdgOn);
                        flightConnector.ApHdgToggle();
                        break;

                    case PresetFunction.Nav:
                        logger.LogInformation("Toggle AP NAV. Current state: {state}.", currentStatus.IsApNavOn);
                        flightConnector.ApNavToggle();
                        break;

                    case PresetFunction.Altitude:
                        logger.LogInformation("Toggle AP ALT. Current state: {state}.", currentStatus.IsApAltOn);
                        flightConnector.ApAltToggle();
                        break;

                    case PresetFunction.VerticalSpeed:
                        logger.LogInformation("Toggle AP VS. Current state: {state}.", currentStatus.IsApVsOn);
                        flightConnector.ApVsToggle();
                        break;

                    case PresetFunction.FLC:
                        logger.LogInformation("Toggle AP FLC. Current state: {state}.", currentStatus.IsApFlcOn);
                        if (currentStatus.IsApFlcOn)
                        {
                            flightConnector.ApFlcOff();
                        }
                        else
                        {
                            flightConnector.ApAirSpeedSet((uint)Math.Round(currentStatus.IndicatedAirSpeed));
                            flightConnector.ApFlcOn();
                        }
                        break;

                    case PresetFunction.Approach:
                        logger.LogInformation("Toggle AP APR. Current state: {state}.", currentStatus.IsApAprOn);
                        flightConnector.ApAprToggle();
                        break;
                    }
                }
            }
            timerHasTick = false;
            return(Task.CompletedTask);
        }