예제 #1
0
 public DeviceSlimVM(SerialPortVM serialPortVM, IRUSDevice device, BusyObject busy, DeviceSlimVM[] children)
 {
     RUSDevice = device ?? throw new ArgumentNullException(nameof(device));
     _busy     = busy ?? throw new ArgumentNullException(nameof(busy));
     Widgets   = new WidgetsVM(WidgetsLocator.ResolveWidgetsForScope(RUSDevice, _busy).ToArray());
     Children  = this.ToSequence().Concat(children.NullToEmpty()).ToArray();
 }
예제 #2
0
        public DevicesVM(SerialPortVM serialPortVM, IRUSConnectionInterface connectionInterface, BusyObject isBusy)
        {
            IsBusy = isBusy;
            new DefaultFilesKeeper().CreateAllFiles(TEMPLATES_DIR_PATH, WidgetsLocator.Resolve <IFileExtensionFactory>());

            SupportedDevices = DevicesFactory
                               .InstantiateSupported(connectionInterface)
                               .OrderBy(d => d.Id)
                               .Select(d => new DeviceSlimVM(serialPortVM, d, IsBusy, d.Children.OrderBy(cd => cd.Id).Select(cd => new DeviceSlimVM(serialPortVM, cd, IsBusy)).ToArray()))
                               .ToObservable();
            PropertyChanged += _propertyHolder_PropertyChanged;
        }
예제 #3
0
 async Task execute(IRUSDevice scope, Func <IDeviceHandler, Task> executor)
 {
     using (_busy.BusyMode)
     {
         if (scope != null)
         {
             foreach (var deviceModel in WidgetsLocator.GetDeviceHandler(scope))
             {
                 try
                 {
                     await executor(deviceModel);
                 }
                 catch (Exception ex)
                 {
                     Logger.LogError("Ошибка отключения устройства", $"-MSG. Устройство: {scope}", ex);
                 }
             }
         }
     }
 }