コード例 #1
0
        protected RUSConnectionInterfaceProxyBase(IRUSConnectionInterface @base)
        {
            _base = @base ?? throw new ArgumentNullException(nameof(@base));

            _base.ConnectionClosed      += _base_ConnectionClosed;
            _base.ConnectionEstablished += _base_ConnectionEstablished;
        }
コード例 #2
0
ファイル: DevicesFactory.cs プロジェクト: GataullinRR/EX1
        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);
            }
        }
コード例 #3
0
 public MiddlewaredConnectionInterfaceDecorator(IRUSConnectionInterface @base) : base(@base)
 {
     _conveyor = new Enumerable <IInterfaceMiddleware>()
     {
         _middlewares[InterfaceMiddlewareOrder.WRAPPER],
         _middlewares[InterfaceMiddlewareOrder.ADAPTER],
     };
     _supportedProtocols = base.SupportedProtocols;
 }
コード例 #4
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;
        }
コード例 #5
0
ファイル: DevicesFactory.cs プロジェクト: GataullinRR/EX1
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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();
        }
コード例 #8
0
ファイル: DevicesFactory.cs プロジェクト: GataullinRR/EX1
 public static IRUSDevice InstantiateSpecificDevice(RUSDeviceId rusDevice, IRUSConnectionInterface connectionInterface)
 {
     return(InstantiateSupported(connectionInterface).Single(d => d.Id == rusDevice));
 }
コード例 #9
0
 FTDIBoxFeatures(IRUSConnectionInterface pipe)
 {
     _pipe = pipe ?? throw new ArgumentNullException(nameof(pipe));
 }
コード例 #10
0
 public SynchronizationProxy(IRUSDevice @base, IRUSConnectionInterface connectionInterface) : base(@base)
 {
     _connectionInterface = connectionInterface;
 }
コード例 #11
0
 public FTDIToSalachovProtocolUnificationMiddleware(IRUSConnectionInterface connectionInterface)
 {
     _connectionInterface = connectionInterface ?? throw new ArgumentNullException(nameof(connectionInterface));
 }