protected RUSConnectionInterfaceProxyBase(IRUSConnectionInterface @base) { _base = @base ?? throw new ArgumentNullException(nameof(@base)); _base.ConnectionClosed += _base_ConnectionClosed; _base.ConnectionEstablished += _base_ConnectionEstablished; }
public static IEnumerable <IRUSDevice> InstantiateSupported(IRUSConnectionInterface connectionInterface) { yield return(new RUSShockSensor(instantiateConnectionInterface()).wrap(connectionInterface)); yield return(new RUSIzmeritel(instantiateConnectionInterface()).wrap(connectionInterface)); yield return(new RUSRotationSensor(instantiateConnectionInterface()).wrap(connectionInterface)); yield return(new RUSInclinometr(instantiateConnectionInterface()).wrap(connectionInterface)); yield return(new RUSTelemetry(instantiateConnectionInterface()).wrap(connectionInterface)); yield return(new RUSTelesystem(instantiateConnectionInterface()).wrap(connectionInterface)); yield return(new RUSLWDLink(instantiateConnectionInterface()).wrap(connectionInterface)); yield return(new RUSDriveControll(instantiateConnectionInterface()).wrap(connectionInterface)); { var texModuleConnectionInterface = instantiateConnectionInterface() .Register(new RetranslatingMiddleware(RUSDeviceId.RUS_TECHNOLOGICAL_MODULE), InterfaceMiddlewareOrder.WRAPPER); yield return(new RUSTechnologicalModule(texModuleConnectionInterface, new IRUSDevice[] { new RUSInclinometr(texModuleConnectionInterface).wrap(connectionInterface), new RUSShockSensor(texModuleConnectionInterface).wrap(connectionInterface), new RUSIzmeritel(texModuleConnectionInterface).wrap(connectionInterface), }).wrap(connectionInterface)); } { var texModuleConnectionInterface = instantiateConnectionInterface() .Register(new RetranslatingMiddleware(RUSDeviceId.EMC_MODULE), InterfaceMiddlewareOrder.WRAPPER); yield return(new RUSEMCModule(texModuleConnectionInterface, new IRUSDevice[] { new RUSShockSensor(texModuleConnectionInterface).wrap(connectionInterface), }).wrap(connectionInterface)); } { var moduleConnectionInterface = instantiateConnectionInterface(); yield return(new RUSModule(moduleConnectionInterface, new IRUSDevice[] { new RUSInclinometr(moduleConnectionInterface).wrap(connectionInterface), new RUSShockSensor(moduleConnectionInterface).wrap(connectionInterface), new RUSRotationSensor(moduleConnectionInterface).wrap(connectionInterface), }).wrap(connectionInterface)); } MiddlewaredConnectionInterfaceDecorator instantiateConnectionInterface() { var middlewared = new MiddlewaredConnectionInterfaceDecorator(connectionInterface); middlewared.Register(new FTDIToSalachovProtocolUnificationMiddleware(middlewared), InterfaceMiddlewareOrder.ADAPTER); return(middlewared); } }
public MiddlewaredConnectionInterfaceDecorator(IRUSConnectionInterface @base) : base(@base) { _conveyor = new Enumerable <IInterfaceMiddleware>() { _middlewares[InterfaceMiddlewareOrder.WRAPPER], _middlewares[InterfaceMiddlewareOrder.ADAPTER], }; _supportedProtocols = base.SupportedProtocols; }
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; }
static IRUSDevice wrap(this IRUSDevice baseDevice, IRUSConnectionInterface connectionInterface) { IRUSDevice device = new BusyWaitProxy(baseDevice); device = new CommandSupportedCheckingProxy(device); device = new StatusFeatureProviderProxy(device); device = new ErrorsCatchingProxy(device); device = new SynchronizationProxy(device, connectionInterface); device = new AsyncProxy(device); device = new NullArgumentToDefaultProxy(device); return(device); }
public static async Task <FTDIBoxFeatures> CreateAsync(IRUSConnectionInterface pipe, DeviceOperationScope scope, CancellationToken cancellation) { var device = new FTDIBoxFeatures(pipe); var ok = await device.trySetModeAsync(Mode.HIGH_SPEED, scope, cancellation); ok |= await device.trySetModeAsync(Mode.COM_PORT, scope, cancellation); if (!ok) { Logger.LogErrorEverywhere("Ошибка инициализации устройства"); device = null; } return(device); }
public RUSDeviceBase(MiddlewaredConnectionInterfaceDecorator pipe, IReadOnlyList <IRUSDevice> children) { _pipe = pipe; Children = children ?? throw new ArgumentNullException(nameof(children)); Name = Id.GetEnumValueDescription(); SupportedCommands = Files.Descriptors.Keys .Where(t => t.TargetDeviceId == Id) .Select(k => k.FileType.GetRequestAddress()) .Concat(EnumUtils .GetValues <Command>() .Select(a => (Addr: a, Info: a.GetInfo())) .Where(i => i.Info != null && !i.Info.IsFileRequest && _pipe.SupportedProtocols.Contains(i.Info.Protocol) && i.Info.IsSupportedForDevice(Id)) .Select(i => i.Addr)) .ToArray(); }
public static IRUSDevice InstantiateSpecificDevice(RUSDeviceId rusDevice, IRUSConnectionInterface connectionInterface) { return(InstantiateSupported(connectionInterface).Single(d => d.Id == rusDevice)); }
FTDIBoxFeatures(IRUSConnectionInterface pipe) { _pipe = pipe ?? throw new ArgumentNullException(nameof(pipe)); }
public SynchronizationProxy(IRUSDevice @base, IRUSConnectionInterface connectionInterface) : base(@base) { _connectionInterface = connectionInterface; }
public FTDIToSalachovProtocolUnificationMiddleware(IRUSConnectionInterface connectionInterface) { _connectionInterface = connectionInterface ?? throw new ArgumentNullException(nameof(connectionInterface)); }