コード例 #1
0
        private static Response HandleNotificationStateUpdate(IHubController controller, string notification)
        {
            var portState = new PortNotificationState(notification);

            controller.Hub.GetPortByID(portState.Port).NotificationMode = portState.Mode;
            return(portState);
        }
コード例 #2
0
 public async Task HandleNotificationAsync(IHubController controller, Response message)
 {
     if (Application.Current == null)
     {
         return;
     }
     Application.Current.Dispatcher.Invoke(() =>
     {
         LogMessage($"{controller.Hub.HubType}: {message}");
         if (message is PortState portState)
         {
             RefreshConnectedHubsText();
             if (_hubSelect.SelectedItem is HubController selectedController &&
                 selectedController == controller)
             {
                 foreach (var portController in _portControllers)
                 {
                     if (portState.DeviceType == portController.HandledDeviceType)
                     {
                         if (portState.StateChangeEvent == DeviceState.Attached)
                         {
                             portController.Show();
                         }
                         if (portState.StateChangeEvent == DeviceState.Detached)
                         {
                             portController.Hide();
                         }
                     }
                 }
             }
         }
     });
     await Task.CompletedTask;
 }
コード例 #3
0
        public HubObjectBrowserViewModel(IDstController dstController, IDstHubService dstHubService,
                                         IHubController hubController, IObjectBrowserTreeSelectorService objectBrowserTreeSelectorService) : base(hubController, objectBrowserTreeSelectorService)
        {
            this.dstHubService = dstHubService;

            this.InitializesCommandsAndObservableSubscriptions();
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new <see cref="MappingViewModel"/>
        /// </summary>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        /// <param name="hubController">The <see cref="IHubController"/>"/></param>
        public MappingViewModel(IDstController dstController, IHubController hubController,
                                IDstObjectBrowserViewModel dstVariablesControlViewModel)
        {
            this.dstController = dstController;

            this.InitializeObservables();
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new <see cref="DstDataSourceViewModel"/>
 /// </summary>
 /// <param name="navigationService">The <see cref="INavigationService"/></param>
 /// <param name="dstController">The <see cref="IDstController"/></param>
 /// <param name="dstBrowserHeader">The <see cref="IHubBrowserHeaderViewModel"/></param>
 /// <param name="dstVariablesViewModel">The <see cref="IDstVariablesControlViewModel"/></param>
 /// <param name="hubController">The <see cref="IHubController"/></param>
 public DstDataSourceViewModel(INavigationService navigationService, IDstController dstController,
                               IDstBrowserHeaderViewModel dstBrowserHeader, IDstVariablesControlViewModel dstVariablesViewModel, IHubController hubController) : base(navigationService)
 {
     this.dstController         = dstController;
     this.hubController         = hubController;
     this.DstVariablesViewModel = dstVariablesViewModel;
     this.DstBrowserHeader      = dstBrowserHeader;
     this.InitializeCommands();
 }
コード例 #6
0
        protected override async void OnStart()
        {
            _appCancellationTokenSource = new CancellationTokenSource();

            new ViewModelAssemblyIncluder().LinkAssembly();
            new ViewAssemblyIncluder().LinkAssembly();

            _hubController = Container.Resolve <IHubController>();
            await _hubController.StartAsync();
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new <see cref="DstNetChangePreviewViewModel"/>
        /// </summary>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        /// <param name="navigationService">The <see cref="INavigationService"/></param>
        /// <param name="hubController">The <see cref="IHubController"/></param>
        /// <param name="statusBar">The <see cref="IStatusBarControlViewModel"/></param>
        public DstNetChangePreviewViewModel(IDstController dstController, INavigationService navigationService,
                                            IHubController hubController, IStatusBarControlViewModel statusBar) : base(dstController, navigationService, hubController, statusBar)
        {
            CDPMessageBus.Current.Listen <UpdateDstVariableTreeEvent>()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => this.UpdateTree(x.Reset));

            CDPMessageBus.Current.Listen <UpdateDstPreviewBasedOnSelectionEvent>()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => this.UpdateTreeBasedOnSelectionHandler(x.Selection.ToList()));
        }
コード例 #8
0
        private static Response HandleHubProperty(IHubController _, string notification)
        {
            var deviceInfo = new HubInfo(notification);

            return(deviceInfo.DeviceType switch
            {
                HubInfoType.HubName => new HubName(notification),
                HubInfoType.ButtonState => new ButtonStateMessage(notification),
                HubInfoType.FirmwareVersion => new FirmwareVersion(notification),
                HubInfoType.SystemType => new SystemType(notification),
                _ => deviceInfo,
            });
コード例 #9
0
        public async Task HandleConnectAsync(IHubController controller, string errorMessage)
        {
            if (controller != null)
            {
                _controllers.Add(controller);

                Console.WriteLine($"Connected device: {controller.Hub.HubType}");

                await Task.CompletedTask;
            }
            else
            {
                Console.WriteLine($"Failed to connect: {errorMessage}");
            }
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new <see cref="HubDataSourceViewModel"/>
        /// </summary>
        /// <param name="navigationService">The <see cref="INavigationService"/></param>
        /// <param name="hubController">The <see cref="IHubController"/></param>
        /// <param name="objectBrowser">The <see cref="IObjectBrowserViewModel"/></param>
        /// <param name="publicationBrowser">The <see cref="IPublicationBrowserViewModel"/></param>
        /// <param name="treeSelectorService">The <see cref="IObjectBrowserTreeSelectorService"/></param>
        /// <param name="hubBrowserHeader">The <see cref="IHubBrowserHeaderViewModel"/></param>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        /// <param name="statusBar">The <see cref="IStatusBarControlViewModel"/></param>
        /// <param name="sessionControl">The <see cref="IHubSessionControlViewModel"/></param>
        public HubDataSourceViewModel(INavigationService navigationService, IHubController hubController, IObjectBrowserViewModel objectBrowser,
                                      IPublicationBrowserViewModel publicationBrowser, IObjectBrowserTreeSelectorService treeSelectorService,
                                      IHubBrowserHeaderViewModel hubBrowserHeader, IDstController dstController,
                                      IHubSessionControlViewModel sessionControl) : base(navigationService)
        {
            this.hubController       = hubController;
            this.treeSelectorService = treeSelectorService;
            this.dstController       = dstController;
            this.SessionControl      = sessionControl;
            this.ObjectBrowser       = objectBrowser;
            this.PublicationBrowser  = publicationBrowser;
            this.HubBrowserHeader    = hubBrowserHeader;

            this.InitializeCommands();
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DEHPCommon.UserInterfaces.ViewModels.ObjectBrowserViewModel" /> class.
        /// </summary>
        /// <param name="hubController">The <see cref="T:DEHPCommon.HubController.Interfaces.IHubController" /></param>
        /// <param name="objectBrowserTreeSelectorService">The <see cref="T:DEHPCommon.Services.ObjectBrowserTreeSelectorService.IObjectBrowserTreeSelectorService" /></param>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        public HubNetChangePreviewViewModel(IHubController hubController, IObjectBrowserTreeSelectorService objectBrowserTreeSelectorService, IDstController dstController) : base(hubController, objectBrowserTreeSelectorService)
        {
            this.dstController = dstController;

            CDPMessageBus.Current.Listen <UpdateHubPreviewBasedOnSelectionEvent>()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => this.UpdateTreeBasedOnSelectionHandler(x.Selection.ToList()));

            CDPMessageBus.Current.Listen <SessionEvent>(this.HubController.Session)
            .Where(x => x.Status == SessionStatus.EndUpdate)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x =>
            {
                this.UpdateTreeBasedOnSelectionHandler(this.previousSelection);
            });
        }
コード例 #12
0
 public async Task HandleConnectAsync(IHubController controller, string errorMessage)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         if (controller != null)
         {
             _controllers.Add(controller);
             RefreshConnectedHubsText();
             LogMessage($"Connected device: {controller.Hub.HubType}");
         }
         else
         {
             LogMessage($"Failed to connect: {errorMessage}");
         }
     });
     await Task.CompletedTask;
 }
コード例 #13
0
 public async Task HandleDisconnectAsync(IHubController controller)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         if (_hubSelect.SelectedItem is HubController selectedController &&
             selectedController == controller)
         {
             foreach (var portController in _portControllers)
             {
                 portController.Hide();
             }
         }
         _controllers.Remove(controller);
         RefreshConnectedHubsText();
         LogMessage($"Disconnected device: {controller.Hub.HubType}");
     });
     await Task.CompletedTask;
 }
コード例 #14
0
        public static Response CreateResponse(string notification, IHubController controller)
        {
            var messageType = MessageTypes.GetByCode(notification.Substring(4, 2));

            if (messageType == MessageTypes.HubProperty)
            {
                return(HandleHubProperty(controller, notification));
            }
            if (messageType == MessageTypes.HubAction)
            {
                return(new HubActionResponse(notification));
            }
            if (messageType == MessageTypes.Error)
            {
                return(new Error(notification));
            }
            if (messageType == MessageTypes.HubAttachedDetachedIO)
            {
                return(HandleIOConnectionStateChange(controller, notification));
            }
            if (messageType == MessageTypes.PortInformation)
            {
                return(new PortInfo(notification));
            }
            if (messageType == MessageTypes.PortModeInformation)
            {
                return(new PortModeInfo(notification));
            }
            if (messageType == MessageTypes.PortValueSingle)
            {
                return(HandlePortValueUpdate(controller, notification));
            }
            if (messageType == MessageTypes.PortInputFormatSingle)
            {
                return(HandleNotificationStateUpdate(controller, notification));
            }
            if (messageType == MessageTypes.PortOutputFeedback)
            {
                return(new PortOutputFeedback(notification));
            }

            return(new Response(notification));
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new <see cref="MappingViewModel"/>
        /// </summary>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        /// <param name="hubController">The <see cref="IHubController"/>"/></param>
        /// <param name="dstVariablesControlViewModel">The <see cref="IDstVariablesControlViewModel"/></param>
        public MappingViewModel(IDstController dstController, IHubController hubController, IDstVariablesControlViewModel dstVariablesControlViewModel)
        {
            this.dstController = dstController;
            this.hubController = hubController;

            this.dstVariablesControlViewModel = dstVariablesControlViewModel;

            this.dstController.DstMapResult.ItemsAdded.Subscribe(this.UpdateMappedThings);

            this.dstController.DstMapResult.IsEmptyChanged.Where(x => x).Subscribe(_ =>
                                                                                   this.MappingRows.RemoveAll(this.MappingRows
                                                                                                              .Where(x => x.Direction == MappingDirection.FromDstToHub).ToList()));

            this.dstController.HubMapResult.ItemsAdded.Subscribe(this.UpdateMappedThings);

            this.dstController.HubMapResult.IsEmptyChanged.Where(x => x).Subscribe(_ =>
                                                                                   this.MappingRows.RemoveAll(this.MappingRows
                                                                                                              .Where(x => x.Direction == MappingDirection.FromHubToDst).ToList()));

            this.WhenAnyValue(x => x.dstController.MappingDirection)
            .Subscribe(this.UpdateMappingRowsDirection);
        }
コード例 #16
0
 public async Task HandleNotificationAsync(IHubController controller, Response message)
 {
     Console.WriteLine($"{controller.Hub.HubType}: {message}");
     await Task.CompletedTask;
 }
コード例 #17
0
 public EventHandlerBase(IHubController controller)
 {
     _controller = controller;
 }
 public RemoteButtonStateUpdateHubTypeEventHandler(IHubController controller) : base(controller)
 {
 }
コード例 #19
0
 public Task HandleNotificationAsync(IHubController hubController, Response notification)
 {
     return(Task.CompletedTask);
 }
コード例 #20
0
 public Task HandleConnectAsync(IHubController hubController, string errorMessage)
 {
     return(Task.CompletedTask);
 }
コード例 #21
0
 public DisconnectEventHandler(IHubController controller, Func <IHubController, Task> onDisconnectCallback)
     : base(controller)
 {
     _onDisconnectCallback = onDisconnectCallback;
 }
コード例 #22
0
        public RgbLightCommand(IHubController controller, RgbLightColor color)
        {
            var port = controller.Hub.GetPortsByDeviceType(IoDeviceTypes.RgbLight).First().PortID;

            HexCommand = AddHeader($"{port}115100{color.Code}");
        }
コード例 #23
0
 public RemoteButtonToRgbLightEventHandler(IHubController controller) : base(controller)
 {
 }
コード例 #24
0
 public Task HandleDisconnectAsync(IHubController hubController)
 {
     return(Task.CompletedTask);
 }
コード例 #25
0
 public MotorToRgbLightEventHandler(IHubController controller) : base(controller)
 {
 }
コード例 #26
0
 public InternalMotorStateUpdateHubTypeEventHandler(IHubController controller) : base(controller)
 {
 }
コード例 #27
0
 /// <summary>
 /// Constructor
 /// </summary>
 public DstHubService(IHubController hubController)
 {
     this.hubController = hubController;
 }
コード例 #28
0
 public async Task HandleDisconnectAsync(IHubController controller)
 {
     _controllers.Remove(controller);
     Console.WriteLine($"Disconnected device: {controller.Hub.HubType}");
     await Task.CompletedTask;
 }
コード例 #29
0
 public SystemTypeUpdateHubTypeEventHandler(IHubController controller) : base(controller)
 {
 }