-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Conversation
…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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()) | ||
{ |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Баг есть с коллекцией. Если отключать устройства и затем их снова подключать, то они не будут отображаться. Нужна постоянная синхронизация коллекции
{ | ||
if (!_isDisposed) | ||
{ | ||
_list?.Dispose(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint на int везде заменить
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