Exemplo n.º 1
0
        private void Print(IVehicle vehicle)
        {
            Console.Clear();
            const int percentWidth = 30;
            var       dict         = new Dictionary <string, string>
            {
                { nameof(Vehicle.Link), vehicle.Link.Value.ToString() },
                { nameof(Vehicle.PacketRateHz), vehicle.PacketRateHz.Value.ToString("0 Hz") },
                { nameof(HeartbeatPayload.SystemStatus), vehicle.RawHeartbeat.Value?.SystemStatus.ToString() ?? string.Empty },
                { nameof(HeartbeatPayload.Type), vehicle.RawHeartbeat.Value?.Type.ToString() ?? string.Empty },
                { nameof(HeartbeatPayload.Autopilot), vehicle.RawHeartbeat.Value?.Autopilot.ToString() ?? string.Empty },
                { nameof(HeartbeatPayload.BaseMode), vehicle.RawHeartbeat.Value?.BaseMode.ToString("F") ?? string.Empty },
                { nameof(HeartbeatPayload.CustomMode), vehicle.RawHeartbeat.Value?.CustomMode.ToString() ?? string.Empty },
                { nameof(HeartbeatPayload.MavlinkVersion), vehicle.RawHeartbeat.Value?.MavlinkVersion.ToString() ?? string.Empty },
                { nameof(SysStatusPayload.BatteryRemaining), vehicle.RawSysStatus.Value?.BatteryRemaining.ToString() ?? string.Empty },
                { nameof(SysStatusPayload.CurrentBattery), vehicle.RawSysStatus.Value?.CurrentBattery.ToString() ?? string.Empty },
                { nameof(SysStatusPayload.DropRateComm), TextRender.Progress(((vehicle.RawSysStatus.Value?.DropRateComm) ?? 0) / 10000.0, percentWidth) },
                { nameof(SysStatusPayload.ErrorsComm), vehicle.RawSysStatus.Value?.ErrorsComm.ToString() ?? string.Empty },
                { nameof(SysStatusPayload.Load), TextRender.Progress((vehicle.RawSysStatus.Value?.Load ?? 0) / 1000.0, percentWidth) },
                { nameof(SysStatusPayload.VoltageBattery), vehicle.RawSysStatus.Value?.VoltageBattery.ToString() ?? string.Empty },
                { nameof(Vehicle.GlobGps), vehicle.GlobGps.Value.ToString() },
                { nameof(Vehicle.Home), vehicle.Home.Value.ToString() },
                { nameof(GpsRawIntPayload.Alt), ((vehicle.RawGpsRawInt.Value?.Alt ?? double.NaN) / 1000.0).ToString("F1") },
                { "LastCommand", _lastCommand }
            };

            GetAddidtionslParams(vehicle, dict);

            TextTable.PrintKeyValue(Console.WriteLine, new DoubleTextTableBorder(), dict.Max(_ => _.Key.Length), dict.Max(_ => _.Value.Length), "Vehicle", dict);

            var help = new Dictionary <string, string>
            {
                { "Arrows", "Move XY" },
                { "U and D", "Up/down altitude" },
                { "PageUp and PageDown", "Up / Down max speed (MPC_XY_VEL_MAX)" },
                { "A", "Arm" },
                { "T", "Take off" },
                { "Q", "Exit" },
            };

            TextTable.PrintKeyValue(Console.WriteLine, new DoubleTextTableBorder(), help.Max(_ => _.Key.Length), help.Max(_ => _.Value.Length), "Commands", help);
        }
Exemplo n.º 2
0
        protected override async Task <int> RunAsync(IVehicle vehicle)
        {
            await vehicle.Params.ReadAllParams(CancellationToken.None, new Progress <double>(_ => Console.WriteLine("Read params progress:" + TextRender.Progress(_, 20))));

            while (!_cancel.IsCancellationRequested)
            {
                Redraw();
                await Task.Delay(1000).ConfigureAwait(false);
            }
            return(0);
        }