Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (device-info): migrate DevicesInfoCommand to R3 #164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asv-soft-u06
Copy link
Contributor

Migrate the DevicesInfoCommand to R3 architecture. Update the MavlinkDeviceModel class to use device state subscription for improved handling of device states.
Asana: https://app.asana.com/0/1209147429100805/1209315664743522

…kDeviceModel

Migrate the DevicesInfoCommand to R3 architecture. Update the MavlinkDeviceModel class to use device state subscription for improved handling of device states.
Asana: https://app.asana.com/0/1209147429100805/1209315664743522
.Overflow(VerticalOverflow.Ellipsis)
.Cropping(VerticalOverflowCropping.Top)
.StartAsync(async ctx =>
ShellCommandsHelper.CreateDeviceExplorer(connectionString, out var deviceExplorer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Расширь DeviceExplorer другими настройками, чтобы его можно было подробнее конфигурировать. Сделай для этого класс DeviceExplorerPayload. Задокументируй в коде его и сделай по нему доку и в обычной документации. Проверь документацию команды и обнови ее, если потребуется.

}
catch (TaskCanceledException)
{
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше перехватывать ошибку выше и в общей конве вывода писать в консоль, что за ошибка случилась

});
uint localIterations = iterations ?? 0;

while (localIterations > 0 || runForever)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убирай переменную локальных итераторов. Она тут избыточна

var devices = deviceExplorer.Devices.ToImmutableDictionary();

while (!deviceExplorer.Devices.Any())
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут упрости. Не нужно лишний раз проверять на пустоту коллекции. Как только в коллекции что-то появится, тогда цикл сразу оборвется

if (iterations.HasValue) localIterations--;
AnsiConsole.Clear();
table.Rows.Clear();
RenderRows(table, _list);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Баг есть с коллекцией. Если отключать устройства и затем их снова подключать, то они не будут отображаться. Нужна постоянная синхронизация коллекции

{
if (!_isDisposed)
{
_list?.Dispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если райдер не обманывает, то тут у тебя лишняя проверка на нал

if (!_isDisposed)
{
_list?.Dispose();
await deviceExplorer.DisposeAsync();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Можешь диспоуз самому классу сделать. Он задиспоузит все после закрытия программы. Вообще диспоуз тут необзятелен, так как в случае завершения команды программа просто отключается. Она не работает в течении долгого времени

if (iterations.HasValue) localIterations--;
AnsiConsole.Clear();
table.Rows.Clear();
RenderRows(table, _list);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну и можно цветом выделить важные данные в таблице, например хартбит. Сделай все чутка интереснее с визуальной точки зрения

/// <param name="devicesTimeout">-dt, Lifetime of a MAVLink device if it does not send a Heartbeat.</param>
/// <param name="refreshRate">-r, Console refresh rate (in ms).</param>
[Command("devices-info")]
public int Run(string connectionString, uint? iterations = null, uint devicesTimeout = 10, uint refreshRate = 3000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint на int везде заменить

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants