public static void ConnectToOnvifService(out OdmSession onvifHelper, BcDevices dev)
 {
     onvifHelper = (OdmSession)null;
     if (!(dev.Type == "Onvif Kipod Server"))
     {
         return;
     }
     try
     {
         NvtSessionFactory nvtSessionFactory = new NvtSessionFactory(new NetworkCredential(dev.Login, dev.Password));
         DetectorServer.Logger.Info((object)"onvifHelper Successfuly created");
         DetectorServer.Logger.Info((object)"subscribing to evets...");
         DetectorServer.Logger.Info((object)"Start Subscribe");
         try
         {
         }
         catch (Exception ex)
         {
             DetectorServer.Logger.Error((object)"Error subscribe ", ex);
         }
     }
     catch (Exception ex)
     {
         DetectorServer.Logger.Error((object)"Onvif Error", ex);
     }
 }
Example #2
0
        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);
        }
Example #3
0
 void SubscribeBase(OdmSession facade, MessageContentFilter[] contArray, TopicExpressionFilter[] topArray)
 {
     EventSubscriptions.Add(
         facade.GetBaseEvents(AppDefaults.visualSettings.Base_Subscription_Port, topArray, contArray).Subscribe(
             onvifEvent => {
         try {
             dispatch.BeginInvoke(() => {
                 var evdescr = new EventDescriptor(onvifEvent);
                 events.AddEvent(evdescr);
                 eventAggregator.GetEvent <DeviceEventReceived>().Publish(new DeviceEventArgs("", evdescr));
             });
         } catch (Exception err) {
             dbg.Error(err);
         }
     }, err => {
         dbg.Error(err);
         dispatch.BeginInvoke(() => {
             var evdescr          = new EventDescriptor(null);
             evdescr.ErrorMessage = err.Message;
             events.AddEvent(evdescr);
             eventAggregator.GetEvent <DeviceEventReceived>().Publish(new DeviceEventArgs("", evdescr));
         });
     }
             )
         );
 }
Example #4
0
        public static FSharpAsync <AnalyticsArgs> Load(INvtSession nvtSession, OdmSession odmSession, Capabilities capabilities)
        {
            AnalyticsArgs args = new AnalyticsArgs();

            args.odmSession   = odmSession;
            args.capabilities = capabilities;
            args.nvtSession   = nvtSession;

            return(Apm.Iterate(LoadImpl(args)).Select(f => { return args; }));
        }
		public static FSharpAsync<SourceViewArgs> Load(ChannelDescription channelDescr,
														Capabilities capabilities,
														INvtSession nvtSession,
														OdmSession odmsession,
														string prof = null) {
			SourceViewArgs args = new SourceViewArgs();
			args.nvtSession = nvtSession;
			args.odmSession = odmsession;
			args.capabilities = capabilities;
			args.channelDescr = channelDescr;
			args.selectedProfileToken = prof;

			return Apm.Iterate(LoadImpl(args)).Select(f => { return args; });
		}
		public static FSharpAsync<EngineViewArgs> Load(AnalyticsEngine engine,
														Capabilities capabilities,
														INvtSession nvtSession,
														OdmSession odmsession,
														string ctrl = null) {
			EngineViewArgs args = new EngineViewArgs();
			args.nvtSession = nvtSession;
			args.odmSession = odmsession;
			args.capabilities = capabilities;
			args.engine = engine;
			args.selectedEngineControlToken = ctrl;

			return Apm.Iterate(LoadImpl(args)).Select(f => { return args; });
		}
        public static FSharpAsync <EngineViewArgs> Load(AnalyticsEngine engine,
                                                        Capabilities capabilities,
                                                        INvtSession nvtSession,
                                                        OdmSession odmsession,
                                                        string ctrl = null)
        {
            EngineViewArgs args = new EngineViewArgs();

            args.nvtSession   = nvtSession;
            args.odmSession   = odmsession;
            args.capabilities = capabilities;
            args.engine       = engine;
            args.selectedEngineControlToken = ctrl;

            return(Apm.Iterate(LoadImpl(args)).Select(f => { return args; }));
        }
        public void Init(OdmSession facade, string path) {
            Binding();

            subscriptions = facade.UpgradeFirmware(path)
                .ObserveOnCurrentDispatcher()
                .Subscribe(message => {
                    IsProgressVisible = Visibility.Hidden;
                    Message = "Upgrade completed successfully.";
                    this.CreateBinding(ButtonNameProperty, Buttons, x => x.close);
                }, err => {
					dbg.Error(err);
					IsProgressVisible = Visibility.Hidden;
                    Message = err.Message;
                    this.CreateBinding(ButtonNameProperty, Buttons, x => x.close);
                });
        }
Example #9
0
        public static FSharpAsync <SourceViewArgs> Load(ChannelDescription channelDescr,
                                                        Capabilities capabilities,
                                                        INvtSession nvtSession,
                                                        OdmSession odmsession,
                                                        string prof = null)
        {
            SourceViewArgs args = new SourceViewArgs();

            args.nvtSession           = nvtSession;
            args.odmSession           = odmsession;
            args.capabilities         = capabilities;
            args.channelDescr         = channelDescr;
            args.selectedProfileToken = prof;

            return(Apm.Iterate(LoadImpl(args)).Select(f => { return args; }));
        }
Example #10
0
        public void Init(OdmSession facade, string path)
        {
            Binding();

            subscriptions = facade.UpgradeFirmware(path)
                            .ObserveOnCurrentDispatcher()
                            .Subscribe(message => {
                IsProgressVisible = Visibility.Hidden;
                Message           = "Upgrade completed successfully.";
                this.CreateBinding(ButtonNameProperty, Buttons, x => x.close);
            }, err => {
                dbg.Error(err);
                IsProgressVisible = Visibility.Hidden;
                Message           = err.Message;
                this.CreateBinding(ButtonNameProperty, Buttons, x => x.close);
            });
        }
        void ManualInitDeviceHolder(INvtSession session, DeviceDescriptionHolder devHolder)
        {
            devHolder.session = session;

            facade = new OdmSession(session);
            var model = new IdentificationModel();

            IdentitySubscriptions.Add(
                facade.GetIdentity(() => model)
                .ObserveOnCurrentDispatcher()
                .Subscribe(mod => {
                devHolder.Init(mod);
            }, err => {
                //dbg.Error(err);
                //MessageBox.Show(err.Message);
            })
                );
        }
Example #12
0
            private void Run()
            {
                OdmSession odmSess = new OdmSession(session);

                disposables.Add(odmSess.GetPullPointEvents()
                                .Subscribe(
                                    evnt => {
                    //Parse onvif event here
                    Console.WriteLine(EventParse.ParseTopic(evnt.topic));
                    var messages = EventParse.ParseMessage(evnt.message);
                    messages.ForEach(msg => Console.WriteLine(msg));
                    Console.WriteLine("----------------------------------------");
                    Console.WriteLine();
                    Console.WriteLine();
                }, err => {
                    Console.WriteLine(err.Message);
                }
                                    ));
            }
Example #13
0
    public void GenerateBaseEvent()
    {
        // for this device must be discoverable and and its account and uri must be known
        var        sessionFactory = new NvtSessionFactory(deviceparam.Account); // deviceparam is camera and account contaion its username and password
        var        sess           = sessionFactory.CreateSession(uri);
        OdmSession os             = new OdmSession(sess);

        os.GetBaseEvents(9865)    // some random port number
        .Subscribe(
            evnt =>
        {
            Console.WriteLine(EventParse.ParseTopic(evnt.topic));
            var messages = EventParse.ParseMessage(evnt.message);
            messages.ForEach(msg => Console.WriteLine(msg));
        }, err =>
        {
            Console.WriteLine(err.Message);
        }
            );
    }
        void InitDeviceHolder(INvtSession session, DeviceDescriptionHolder devHolder, bool publish)
        {
            devHolder.session = session;
            facade            = new OdmSession(session);
            var model = new IdentificationModel();

            IdentitySubscriptions.Add(
                facade.GetIdentity(() => model)
                .ObserveOnCurrentDispatcher()
                .Subscribe(mod => {
                devHolder.Init(mod);
                if (publish)
                {
                    DeviceSelectedPublish(devHolder, sessionFactory);
                }
            }, err => {
                //dbg.Error(err);
                //MessageBox.Show(err.Message);
            })
                );
        }
        System.Net.NetworkCredential LoadCurrentAccount()
        {
            var acc = AccountManager.Instance.CurrentAccount;

            System.Net.NetworkCredential account = null;
            if (!acc.IsAnonymous)
            {
                account = new System.Net.NetworkCredential()
                {
                    UserName = acc.Name, Password = acc.Password
                }
            }
            ;

            return(account);
        }

        void StartUpgrade(BatchItem bitem, string binPath)
        {
            NvtSessionFactory sessionFactory = new NvtSessionFactory(LoadCurrentAccount());

            IdentitySubscriptions.Add(sessionFactory.CreateSession(bitem.Device.Uris)
                                      .ObserveOnCurrentDispatcher()
                                      .Subscribe(isession => {
                OdmSession odmsession = new OdmSession(isession);
                var async             = odmsession.UpgradeFirmware(binPath);

                var taskFact       = BackgroundTask.CreateForAsync(async.ObserveOnCurrentDispatcher(), bitem.Device);
                var backgroundTask = taskFact(
                    result => CompleteWith(() => {
                }),
                    error => CompleteWith(() => {
                    context.Error(error);
                })
                    );
                BackgroundTaskManager.tasks.Add(backgroundTask);
            }, err => {
                dbg.Error(err);
            }));
        }
Example #16
0
        void StartRestore(BatchItem bitem, string binPath)
        {
            NvtSessionFactory sessionFactory = new NvtSessionFactory(LoadCurrentAccount());

            IdentitySubscriptions.Add(sessionFactory.CreateSession(bitem.Device.Uris)
                                      .ObserveOnCurrentDispatcher()
                                      .Subscribe(isession => {
                OdmSession odmsession = new OdmSession(isession);
                var async             = odmsession.RestoreSystem(binPath);

                var taskFact       = BackgroundTask.CreateForAsync(async.ObserveOnCurrentDispatcher(), bitem.Device);
                var backgroundTask = taskFact(
                    result => CompleteWith(() => {
                }),
                    error => CompleteWith(() => {
                    activityContext.Error(error);
                })
                    );
                BackgroundTaskManager.tasks.Add(backgroundTask);
            }, err => {
                dbg.Error(err);
            }));
        }
		void SubscribeBase(OdmSession facade, MessageContentFilter[] contArray, TopicExpressionFilter[] topArray) {
			EventSubscriptions.Add(
					 facade.GetBaseEvents(AppDefaults.visualSettings.Base_Subscription_Port, topArray, contArray).Subscribe(
						  onvifEvent => {
							  try {
								  dispatch.BeginInvoke(() => {
									  var evdescr = new EventDescriptor(onvifEvent);
									  events.AddEvent(evdescr);
									  eventAggregator.GetEvent<DeviceEventReceived>().Publish(new DeviceEventArgs("", evdescr));
								  });
							  } catch (Exception err) {
								  dbg.Error(err);
							  }
						  }, err => {
							  dbg.Error(err);
							  dispatch.BeginInvoke(() => {
								  var evdescr = new EventDescriptor(null);
								  evdescr.ErrorMessage = err.Message;
								  events.AddEvent(evdescr);
								  eventAggregator.GetEvent<DeviceEventReceived>().Publish(new DeviceEventArgs("", evdescr));
							  });
						  }
					 )
				);
		}
		public static FSharpAsync<SourcesArgs> Load(INvtSession nvtSession, OdmSession odmSession, Capabilities capabilities) {
			SourcesArgs args = new SourcesArgs();
			args.odmSession = odmSession;
			args.capabilities = capabilities;
			args.nvtSession = nvtSession;

			return Apm.Iterate(LoadImpl(args)).Select(f => { return 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);
		}