예제 #1
0
        public RUSModuleSetDirectionVM(IRUSDevice device, BusyObject busy)
        {
            _device = device ?? throw new ArgumentNullException(nameof(device));
            IsBusy  = busy ?? throw new ArgumentNullException(nameof(busy));

            var descriptors = Requests.GetRequestDescription(_device.Id, Command.KEEP_MTF); // All other commands have the same body

            Entities = new EnhancedObservableCollection <CommandEntityVM>(
                descriptors.UserCommandDescriptors.Select(d => new CommandEntityVM(d)));

            SendCommand = new ActionCommand <Command>(sendAsync, IsBusy);

            async Task sendAsync(CommandParameter <Command> command)
            {
                using (IsBusy.BusyMode)
                {
                    assertViewValues();

                    if (command.IsSet)
                    {
                        await _device.BurnAsync(command.Value, Entities.Select(e => e.Entity), null, null);

                        Logger.LogOKEverywhere($"Команда отправлена");
                    }
                    else
                    {
                        Debugger.Break(); // Binding error
                    }
                }
            }
        }