public void Init(DeviceViewArgs args) { eventAggregator = container.Resolve<IEventAggregator>(); filtersList = new ObservableCollection<FilterExpression>(); btnSwitch = new LinkButtonSwitch(eventAggregator); btnSwitch.ClearSelection = () => { buttonsList.UnselectAll(); }; disposables.Add(Observable.FromEventPattern(buttonsList, "SelectionChanged") .Subscribe(e => { btnSwitch.SelectedButton = (ButtonBase)buttonsList.SelectedItem; })); disposables.Add(btnSwitch); var subcrtok = eventAggregator.GetEvent<AddEventsFilterClick>().Subscribe(arg => { dispatch.BeginInvoke(() => { ReSubscribe(args); }); }); disposables.Add(Disposable.Create(() => { eventAggregator.GetEvent<AddEventsFilterClick>().Unsubscribe(subcrtok); })); odmSession = new OdmSession(args.nvtSession); InitDeviceImage(args); LoadButtons(args); EventsSubscription(args); }
public void Init(DeviceViewArgs args) { eventAggregator = container.Resolve <IEventAggregator>(); filtersList = new ObservableCollection <FilterExpression>(); btnSwitch = new LinkButtonSwitch(eventAggregator); btnSwitch.ClearSelection = () => { buttonsList.UnselectAll(); }; disposables.Add(Observable.FromEventPattern(buttonsList, "SelectionChanged") .Subscribe(e => { btnSwitch.SelectedButton = (ButtonBase)buttonsList.SelectedItem; })); disposables.Add(btnSwitch); var subcrtok = eventAggregator.GetEvent <AddEventsFilterClick>().Subscribe(arg => { dispatch.BeginInvoke(() => { ReSubscribe(args); }); }); disposables.Add(Disposable.Create(() => { eventAggregator.GetEvent <AddEventsFilterClick>().Unsubscribe(subcrtok); })); odmSession = new OdmSession(args.nvtSession); InitDeviceImage(args); LoadButtons(args); EventsSubscription(args); }
public void CreateView(DeviceViewArgs args, IUnityContainer container) { this.container = container; ProgressView progress = new ProgressView("Loading .."); if (this.content.Content is IDisposable) { var dis = this.content.Content as IDisposable; dis.Dispose(); } this.content.Content = progress; loadingDisp.Add(Load(args.nvtSession, args.odmSession, args.capabilities) .ObserveOnCurrentDispatcher() .Subscribe(analyticsArgs => { SectionAnalytics analyticsView = new SectionAnalytics(container); disposables.Add(analyticsView); analyticsView.Init(analyticsArgs); this.content.Content = analyticsView; }, err => { ErrorView errorView = new ErrorView(err); disposables.Add(errorView); this.content.Content = errorView; } )); }
public static FSharpAsync<DeviceViewArgs> Load(DeviceDescriptionHolder devHolder, NvtSessionFactory sessionFactory) { DeviceViewArgs args = new DeviceViewArgs(); args.deviceIconUri = devHolder.DeviceIconUri; args.deviceModel = devHolder.DeviceModel; args.manufacturer = devHolder.Manufacturer; return Apm.Iterate(LoadImpl(devHolder, sessionFactory, args)).Select(f => { return args; }); }
void EventsSubscription(DeviceViewArgs args) { if (AppDefaults.visualSettings.Events_IsEnabled && args.capabilities.events != null) { //if (AppDefaults.visualSettings.DefEventFilter != "") // filtersList.Add(new FilterExpression() { Value = AppDefaults.visualSettings.DefEventFilter }); ReSubscribe(args); } }
public static FSharpAsync <DeviceViewArgs> Load(DeviceDescriptionHolder devHolder, NvtSessionFactory sessionFactory) { DeviceViewArgs args = new DeviceViewArgs(); args.deviceIconUri = devHolder.DeviceIconUri; args.deviceModel = devHolder.DeviceModel; args.manufacturer = devHolder.Manufacturer; return(Apm.Iterate(LoadImpl(devHolder, sessionFactory, args)).Select(f => { return args; })); }
public SourceSectionPanel(DeviceViewArgs args, IUnityContainer container) { eventAggregator = container.Resolve <IEventAggregator>(); disposables.Add(Observable.FromEventPattern(btnRefresh, "Click").Subscribe(ev => { eventAggregator.GetEvent <ReleaseUI>().Publish(false); loadingDisp.Dispose(); loadingDisp = new CompositeDisposable(); CreateView(args, container); })); }
void ReSubscribe(DeviceViewArgs args) { if (EventSubscriptions != null && !EventSubscriptions.IsDisposed) { EventSubscriptions.Dispose(); EventSubscriptions = new CompositeDisposable(); } List <MessageContentFilter> contArray = new List <MessageContentFilter>(); List <TopicExpressionFilter> topArray = new List <TopicExpressionFilter>(); filtersList.ForEach(item => { if (item.FilterType == FilterExpression.ftype.CONTENT) { contArray.Add(new MessageContentFilter() { dialect = item.Dialect, expression = item.Value, namespaces = item.Namespaces }); } else { topArray.Add(new TopicExpressionFilter() { dialect = item.Dialect, expression = item.Value, namespaces = item.Namespaces }); } }); switch (AppDefaults.visualSettings.Event_Subscription_Type) { case VisualSettings.EventType.ONLY_BASE: SubscribeBase(args.odmSession, contArray.ToArray(), topArray.ToArray()); break; case VisualSettings.EventType.ONLY_PULL: SubscribePullPoint(args.odmSession, contArray.ToArray(), topArray.ToArray()); break; case VisualSettings.EventType.TRY_PULL: if (args.capabilities.events != null) { if (args.capabilities.events.wsPullPointSupport == true) { SubscribePullPoint(args.odmSession, contArray.ToArray(), topArray.ToArray()); } else { SubscribeBase(args.odmSession, contArray.ToArray(), topArray.ToArray()); } } break; } }
void LoadSections(DeviceViewArgs args) { //investigate capability to find what sections is available if (args.capabilities.media != null) { //nvt section on priority.Add(LoadNvtSection); } if (args.capabilities.extension != null && args.capabilities.extension.analyticsDevice != null) { priority.Add(LoadNvaSection); } for(int i=0; i<priority.Count; i++){ priority[i](args, i == 0); } }
void LoadSections(DeviceViewArgs args) { //investigate capability to find what sections is available if (args.capabilities.media != null) { //nvt section on priority.Add(LoadNvtSection); } if (args.capabilities.extension != null && args.capabilities.extension.analyticsDevice != null) { priority.Add(LoadNvaSection); } for (int i = 0; i < priority.Count; i++) { priority[i](args, i == 0); } }
void LoadNvtSection(DeviceViewArgs args, bool isActive) { SourceSectionPanel spanel = new SourceSectionPanel(args, container); spanel.Init(isActive, null, () => { sections.ForEach(sp => { if (sp != spanel) { sp.Hide(); } }); }); sections.Add(spanel); spanel.header.Content = "NVT"; onvifEntitiesPanel.Children.Add(spanel); spanel.CreateView(args, container); }
void InitDeviceImage(DeviceViewArgs args) { devImage.Source = odm.ui.Resources.loading_icon.ToBitmapSource(); ImageSource imgsrc = odm.ui.Resources.onvif.ToBitmapSource(); devImage.CreateBinding(Image.ToolTipProperty, LocalSnapshot.instance, s => s.loading); //"/odm;component/Resources/Images/onvif.png" //this.CreateBinding(ChannelViewModel.snapshotToolTipProperty, SnapshotTooltip, x => x.loading); if (args.deviceIconUri != null) { Uri uri = new Uri(args.nvtSession.deviceUri, args.deviceIconUri); disposables.Add(odmSession.DownloadStream(uri, null) .ObserveOnCurrentDispatcher() .Subscribe(imgStream => { try { BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.StreamSource = imgStream; bitmap.EndInit(); devImage.Source = bitmap; devImage.ToolTip = ""; } catch (Exception err) { dbg.Error(err); devImage.Source = imgsrc; devImage.CreateBinding(Image.ToolTipProperty, LocalSnapshot.instance, s => s.imagecorrupt); } }, err => { dbg.Error(err.Message); })); } else { devImage.Source = imgsrc; devImage.ToolTip = ""; } }
void ReSubscribe(DeviceViewArgs args) { if (EventSubscriptions != null && !EventSubscriptions.IsDisposed) { EventSubscriptions.Dispose(); EventSubscriptions = new CompositeDisposable(); } List<MessageContentFilter> contArray = new List<MessageContentFilter>(); List<TopicExpressionFilter> topArray = new List<TopicExpressionFilter>(); filtersList.ForEach(item => { if (item.FilterType == FilterExpression.ftype.CONTENT) { contArray.Add(new MessageContentFilter() { dialect = item.Dialect, expression = item.Value, namespaces = item.Namespaces }); } else { topArray.Add(new TopicExpressionFilter() { dialect = item.Dialect, expression = item.Value, namespaces = item.Namespaces }); } }); switch (AppDefaults.visualSettings.Event_Subscription_Type) { case VisualSettings.EventType.ONLY_BASE: SubscribeBase(args.odmSession, contArray.ToArray(), topArray.ToArray()); break; case VisualSettings.EventType.ONLY_PULL: SubscribePullPoint(args.odmSession, contArray.ToArray(), topArray.ToArray()); break; case VisualSettings.EventType.TRY_PULL: if (args.capabilities.events != null) { if (args.capabilities.events.wsPullPointSupport == true) { SubscribePullPoint(args.odmSession, contArray.ToArray(), topArray.ToArray()); } else { SubscribeBase(args.odmSession, contArray.ToArray(), topArray.ToArray()); } } break; } }
public AnalyticsSectionPanel(DeviceViewArgs args, IUnityContainer container) { eventAggregator = container.Resolve<IEventAggregator>(); disposables.Add(Observable.FromEventPattern(btnRefresh, "Click").Subscribe(ev => { eventAggregator.GetEvent<ReleaseUI>().Publish(false); loadingDisp.Dispose(); loadingDisp = new CompositeDisposable(); CreateView(args, container); })); }
void LoadButtons(DeviceViewArgs args) { try { var curAccount = AccountManager.Instance.CurrentAccount; Buttons.Add(new IdentificationButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new DateTimeButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new MaintenanceButton(eventAggregator, args.nvtSession, curAccount, args.capabilities, args.deviceModel, args.manufacturer)); var caps = args.capabilities; var devCaps = caps != null ? caps.device : null; if (devCaps != null) { Buttons.Add(new NetworkButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new UserManagerButton(eventAggregator, args.nvtSession, curAccount, args.deviceModel, args.manufacturer)); if (devCaps.security != null) { Buttons.Add(new SequrityButton(eventAggregator, args.nvtSession, curAccount)); } var sysCaps = devCaps.system; if (sysCaps != null) { if (sysCaps.systemLogging) { SysLogDescriptor slogdescr = new SysLogDescriptor(new SysLogType(SystemLogType.system), null, ""); Buttons.Add(new SystemLogButton(eventAggregator, args.nvtSession, curAccount, slogdescr)); } } var ioCaps = devCaps.io; if (ioCaps != null) { var hasRelays = ioCaps.relayOutputsSpecified && ioCaps.relayOutputs > 0; var hasInputs = ioCaps.inputConnectorsSpecified && ioCaps.inputConnectors > 0; if (hasRelays || hasInputs) { Buttons.Add(new DigitalIOButton(eventAggregator, args.nvtSession, curAccount)); } } } if (caps.actionEngine != null) { Buttons.Add(new ActionsButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new ActionTriggersButton(eventAggregator, args.nvtSession, curAccount)); } Buttons.Add(new WebPageButton(eventAggregator, args.nvtSession, curAccount)); if (AppDefaults.visualSettings.Events_IsEnabled) { Buttons.Add(new DeviceEventsButton(eventAggregator, filtersList, events, args.nvtSession, curAccount)); } if (caps.extension != null && caps.extension.receiver != null) { Buttons.Add(new ReceiversButton(eventAggregator, args.nvtSession, curAccount)); } //Buttons.Add(new XMLExplorerButton(eventAggregator, session, curAccount)); } catch (Exception err) { dbg.Error(err); } buttonsList.ItemsSource = Buttons; }
static IEnumerable<FSharpAsync<Unit>> LoadImpl(DeviceDescriptionHolder devHolder, NvtSessionFactory sessionFactory, DeviceViewArgs args) { yield return sessionFactory.CreateSession(devHolder.Uris).Select(f => { args.nvtSession = f; return (Unit)null; }); args.odmSession = new OdmSession(args.nvtSession); yield return args.nvtSession.GetAllCapabilities().Select(caps => { args.capabilities = caps; return (Unit)null; }); }
static IEnumerable <FSharpAsync <Unit> > LoadImpl(DeviceDescriptionHolder devHolder, NvtSessionFactory sessionFactory, DeviceViewArgs args) { yield return(sessionFactory.CreateSession(devHolder.Uris).Select(f => { args.nvtSession = f; return (Unit)null; })); args.odmSession = new OdmSession(args.nvtSession); yield return(args.nvtSession.GetAllCapabilities().Select(caps => { args.capabilities = caps; return (Unit)null; })); }
void LoadButtons(DeviceViewArgs args) { try { var curAccount = AccountManager.Instance.CurrentAccount; Buttons.Add(new IdentificationButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new DateTimeButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new MaintenanceButton(eventAggregator, args.nvtSession, curAccount, args.capabilities, args.deviceModel, args.manufacturer)); var caps = args.capabilities; var devCaps = caps != null ? caps.device : null; if (devCaps != null) { Buttons.Add(new NetworkButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new UserManagerButton(eventAggregator, args.nvtSession, curAccount, args.deviceModel, args.manufacturer)); if (devCaps.security != null) { Buttons.Add(new SequrityButton(eventAggregator, args.nvtSession, curAccount)); } var sysCaps = devCaps.system; if (sysCaps != null) { if (sysCaps.systemLogging) { SysLogDescriptor slogdescr = new SysLogDescriptor(new SysLogType(SystemLogType.system), null, ""); Buttons.Add(new SystemLogButton(eventAggregator, args.nvtSession, curAccount, slogdescr)); } } var ioCaps = devCaps.io; if (ioCaps != null){ var hasRelays = ioCaps.relayOutputsSpecified && ioCaps.relayOutputs > 0; var hasInputs = ioCaps.inputConnectorsSpecified && ioCaps.inputConnectors > 0; if (hasRelays || hasInputs) { Buttons.Add(new DigitalIOButton(eventAggregator, args.nvtSession, curAccount)); } } } if (caps.actionEngine != null) { Buttons.Add(new ActionsButton(eventAggregator, args.nvtSession, curAccount)); Buttons.Add(new ActionTriggersButton(eventAggregator, args.nvtSession, curAccount)); } Buttons.Add(new WebPageButton(eventAggregator, args.nvtSession, curAccount)); if (AppDefaults.visualSettings.Events_IsEnabled) { Buttons.Add(new DeviceEventsButton(eventAggregator, filtersList, events, args.nvtSession, curAccount)); } if (caps.extension != null && caps.extension.receiver != null) Buttons.Add(new ReceiversButton(eventAggregator, args.nvtSession, curAccount)); //Buttons.Add(new XMLExplorerButton(eventAggregator, session, curAccount)); } catch (Exception err) { dbg.Error(err); } buttonsList.ItemsSource = Buttons; }
void LoadNvrSection(DeviceViewArgs args, bool isActive) { }
void LoadDisplaySection(DeviceViewArgs args, bool isActive) { }
void LoadNvtSection(DeviceViewArgs args, bool isActive) { SourceSectionPanel spanel = new SourceSectionPanel(args, container); spanel.Init(isActive, null, () => { sections.ForEach(sp => { if (sp != spanel) sp.Hide(); }); }); sections.Add(spanel); spanel.header.Content = "NVT"; onvifEntitiesPanel.Children.Add(spanel); spanel.CreateView(args, container); }