Beispiel #1
0
        public ConfigurationViewModel(IItemInteractionService manipulationService)
        {
            Messenger.Default.Register <string>(this, (message) =>
            {
                //Debug.WriteLine("CVM msg recieved: " + message);
                switch (message.ToUpper())
                {
                case "STARTCALIBRATION":
                    this.Start();
                    break;

                case "STOPCALIBRATION":
                    this.Stop();
                    break;
                }
            });
            _manipulationService = manipulationService as ObjectDetectionService;

            _manipulationService.IsWindowVisible = true;

            this.SaveCalibration = new RelayCommand(() =>
            {
                if (_manipulationService.IsCalibrating || _manipulationService.ObjectCount == 0)
                {
                    MessageBox.Show("Please complete calibration and ensure that the 'Calibrate' setting is unchecked and at least one Object is Detected before Saving Calibration.");
                }
                else
                {
                    MessageBox.Show(_manipulationService.SaveCalibration());
                }
            });

            this.LoadCalibration = new RelayCommand(() =>
            {
                _manipulationService.LoadCalibration();
            });

            this.CloseCommand = new RelayCommand <Window>(
                (window) =>
            {
                _manipulationService.IsWindowVisible = false;
                _manipulationService.IsCalibrating   = false;
                window.Close();
                var mainWindow = Application.Current.Windows.Cast <Window>().SingleOrDefault(w => w.Name == "MainWindow");
                if (mainWindow != null)
                {
                    mainWindow.Show();
                }
            },
                (window) => window != null
                );

            this.StartService = new RelayCommand(() => { _manipulationService.Start(); });
            this.StopService  = new RelayCommand(() => { _manipulationService.Stop(); });

            this._manipulationService.PropertyChanged += _manipulationService_PropertyChanged;
        }
        public KioskInteractionService(ISensorService <KinectSensor> sensorService,
                                       IDemographicsService demographicsService,
                                       IItemInteractionService itemInteractionService,
                                       IBodyTrackingService bodyTrackingService,
                                       IConfigurationProvider configurationProvider)
        {
            _currentZone        = "NoTrack";
            _demographicService = demographicsService;

            _InteractionEventHub = new EventHubMessageSender(ConfigurationManager.AppSettings["Azure.Hub.Kiosk"]);

            _sensorService = sensorService;

            SendKioskReportConfigurationToAzure();

            _itemInteractionService = itemInteractionService;
            _itemInteractionService.ItemInteraction += _itemInteractionService_ItemInteraction;
            _coordinateMapper = _sensorService.Sensor.CoordinateMapper;

            _configurationProvider = configurationProvider;
            _configurationProvider.ConfigurationSettingsChanged += _configurationProvider_ConfigurationSettingsChanged;
            GetConfig();

            _sensorService.StatusChanged += _sensorService_StatusChanged;

            _bodyFrameReader = _sensorService.Sensor.BodyFrameSource.OpenReader();
            if (_bodyFrameReader != null)
            {
                _bodyFrameReader.FrameArrived += _bodyFrameReader_FrameArrived;
            }

            _sensorService.Open();

            // Telemetry processing routine done on a seperate background thread via queues
            _interactionProcessingQueue = new BlockingCollection <KioskStateEventArgs>();
            {
                IObservable <KioskStateEventArgs> ob = _interactionProcessingQueue.
                                                       GetConsumingEnumerable().
                                                       ToObservable(TaskPoolScheduler.Default);

                ob.Subscribe(p =>
                {
                    // This handler will get called whenever
                    // anything appears on myQueue in the future.
                    this.SendIteraction(p);
                });
            }

            _bodyTrackingService = bodyTrackingService;

            CurrentState = KioskStates.NoTrack;
        }
        public KioskInteractionService(ISensorService<KinectSensor> sensorService,
            IDemographicsService demographicsService,
            IItemInteractionService itemInteractionService,
            IBodyTrackingService bodyTrackingService,
            IConfigurationProvider configurationProvider)
        {
            _currentZone = "NoTrack";
            _demographicService = demographicsService;

            _eventHub = new EventHubMessageSender(ConfigurationManager.AppSettings["Azure.Hub.Kiosk"]);

            _sensorService = sensorService;
              //  _telemetryService = telemetryService;

            _itemInteractionService = itemInteractionService;
            _itemInteractionService.ItemInteraction += _itemInteractionService_ItemInteraction;
            _coordinateMapper = _sensorService.Sensor.CoordinateMapper;

            _configurationProvider = configurationProvider;
            _configurationProvider.ConfigurationSettingsChanged += _configurationProvider_ConfigurationSettingsChanged;
            GetConfig();

            _sensorService.StatusChanged += _sensorService_StatusChanged;
            _bodyFrameReader = _sensorService.Sensor.BodyFrameSource.OpenReader();
            if (_bodyFrameReader != null)
                _bodyFrameReader.FrameArrived += _bodyFrameReader_FrameArrived;

            _sensorService.Open();

            _interactionProcessingQueue = new BlockingCollection<KioskStateEventArgs>();
            {
                IObservable<KioskStateEventArgs> ob = _interactionProcessingQueue.
                  GetConsumingEnumerable().
                  ToObservable(TaskPoolScheduler.Default);

                ob.Subscribe(p =>
                {
                    //var temp = Thread.CurrentThread.ManagedThreadId;
                    // This handler will get called whenever
                    // anything appears on myQueue in the future.
                    this.SendIteraction(p);
                    //Debug.Write("Consuming: {0}\n", p);
                });
            }

            _bodyTrackingService = bodyTrackingService;

            CurrentState = KioskStates.NoTrack;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IKioskInteractionService interactionService,
                             ISpeechService speechService,
                             IItemInteractionService manipulationService,
                             IConfigurationProvider configurationProvider)
        {
            this.RowWidth = DEPTH_WIDTH;

            _kioskInteractionService = interactionService;
            _kioskInteractionService.KioskStateChanged += _kioskInteractionService_KioskStateChanged;
            _kioskInteractionService.BodyTrackUpdate   += _kioskInteractionService_BodyTrackUpdate;

            BodyTrack = new ObservableCollection <double>()
            {
                -75, -75, -75, -75, -75, -75
            };

            _itemInteractionService = manipulationService;
            _itemInteractionService.ServiceStateChanged += _itemInteractionService_ServiceStateChanged;
            _itemInteractionService.ItemInteraction     += _itemInteractionService_ItemInteraction;
            _itemInteractionService.PropertyChanged     += _itemInteractionService_PropertyChanged;

            _speechService = speechService;
            _speechService.SpeechRecognized += _speechService_SpeechRecognized;
            _speechService.SpeechRejected   += _speechService_SpeechRejected;
            _speechService.StartListening();
            _speechService.Speak("Kiosk Ready");

            Messenger.Default.Register <string>(this, (msg) => {
                if (msg == "SPECIALSTOP")
                {
                    Debug.WriteLine("MVM SPECIALSTOP " + _lastKioskState);
                    this.KioskState = "CloseSpecial";
                }
            });

            this.OpenObjectDetection = new RelayCommand(() =>
            {
                ShowObjectDetectionWindow(true);
            });

            _configurationProvider = configurationProvider;
            _configurationProvider.ConfigurationSettingsChanged += _configurationProvider_ConfigurationSettingsChanged;
            GetConfig();

            // Show Object Detection Window on start up
            ShowObjectDetectionWindow();
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IKioskInteractionService interactionService,
                             ISpeechService speechService,
                             IItemInteractionService manipulationService,
                             IConfigurationProvider configurationProvider)
        {
            this.RowWidth = DEPTH_WIDTH;

            _kioskInteractionService = interactionService;
            _kioskInteractionService.KioskStateChanged += _kioskInteractionService_KioskStateChanged;
            _kioskInteractionService.BodyTrackUpdate += _kioskInteractionService_BodyTrackUpdate;

            BodyTrack = new ObservableCollection<double>() { -75, -75, -75, -75, -75, -75 };

            _itemInteractionService = manipulationService;
            _itemInteractionService.ServiceStateChanged += _itemInteractionService_ServiceStateChanged;
            _itemInteractionService.ItemInteraction += _itemInteractionService_ItemInteraction;
            _itemInteractionService.PropertyChanged += _itemInteractionService_PropertyChanged;

            _speechService = speechService;
            _speechService.SpeechRecognized += _speechService_SpeechRecognized;
            _speechService.SpeechRejected += _speechService_SpeechRejected;
            _speechService.StartListening();
            _speechService.Speak("Kiosk Ready");

            Messenger.Default.Register<string>(this, (msg) => {

                if (msg == "SPECIALSTOP")
                {
                    Debug.WriteLine("MVM SPECIALSTOP " + _lastKioskState);
                    this.KioskState = "CloseSpecial";
                }
            });

            this.OpenObjectDetection = new RelayCommand(() =>
            {
                ShowObjectDetectionWindow(true);
            });

            _configurationProvider = configurationProvider;
            _configurationProvider.ConfigurationSettingsChanged += _configurationProvider_ConfigurationSettingsChanged;
            GetConfig();

            // Show Object Detection Window on start up
            ShowObjectDetectionWindow();
        }
Beispiel #6
0
        public MediaContentViewModel(IKioskInteractionService interactionService, 
                                     IDemographicsService demographicSrv, 
                                     IContentManagement<ZoneFileMetaData> contentManagement, 
                                     IItemInteractionService itemInteractionService)
        {
            ItemState = ManipulationStates.NoTrack;
            _interactionService = interactionService;
            _interactionService.KioskStateChanged += _interactionService_KioskStateChanged;

            _demographicsService = demographicSrv;
            _demographicsService.DemographicsReceived += _demographicsService_DemographicsReceived;
            _demographicsService.DemographicsProcessingFailure += _demographicsService_DemographicsProcessingFailure;

            _contentManagement = contentManagement;

            _itemInteractionService = itemInteractionService;
            _itemInteractionService.ItemInteraction += _itemInteractionService_ItemStateChanged;

            ConfigurationProvider cp = new ConfigurationProvider();
            IConfigSettings cs = cp.Load();
            EnableDiagnostics = cs.EnableDiagnostics;
        }
Beispiel #7
0
        public MediaContentViewModel(IKioskInteractionService interactionService, 
                                     IDemographicsService demographicSrv, 
                                     IContentManagement<ZoneFileMetaData> contentManagement, 
                                     IItemInteractionService itemInteractionService)
        {
            ItemState = ManipulationStates.NoTrack;
            _interactionService = interactionService;
            _interactionService.KioskStateChanged += _interactionService_KioskStateChanged;

            _demographicsService = demographicSrv;
            _demographicsService.DemographicsReceived += _demographicsService_DemographicsReceived;
            _demographicsService.DemographicsProcessingFailure += _demographicsService_DemographicsProcessingFailure;

            _contentManagement = contentManagement;

            _itemInteractionService = itemInteractionService;
            _itemInteractionService.ItemInteraction += _itemInteractionService_ItemStateChanged;

            ConfigurationProvider cp = new ConfigurationProvider();
            IConfigSettings cs = cp.Load();
            EnableDiagnostics = cs.EnableDiagnostics;
            //ClosestZone = cs.ZoneDefinitions.Where(x => x.MaximumRange == cs.ZoneDefinitions.Min(o => o.MaximumRange)).First().Name;
        }
        public MediaContentViewModel(IKioskInteractionService interactionService,
                                     IDemographicsService demographicSrv,
                                     IContentManagement <ZoneFileMetaData> contentManagement,
                                     IItemInteractionService itemInteractionService)
        {
            ItemState           = ManipulationStates.NoTrack;
            _interactionService = interactionService;
            _interactionService.KioskStateChanged += _interactionService_KioskStateChanged;

            _demographicsService = demographicSrv;
            _demographicsService.DemographicsReceived          += _demographicsService_DemographicsReceived;
            _demographicsService.DemographicsProcessingFailure += _demographicsService_DemographicsProcessingFailure;

            _contentManagement = contentManagement;

            _itemInteractionService = itemInteractionService;
            _itemInteractionService.ItemInteraction += _itemInteractionService_ItemStateChanged;

            ConfigurationProvider cp = new ConfigurationProvider();
            IConfigSettings       cs = cp.Load();

            EnableDiagnostics = cs.EnableDiagnostics;
        }
Beispiel #9
0
        public ConfigurationViewModel(IItemInteractionService manipulationService)
        {
            Messenger.Default.Register<string>(this, (message) =>
            {
                //Debug.WriteLine("CVM msg recieved: " + message);
                switch (message.ToUpper())
                {
                    case "STARTCALIBRATION":
                        this.Start();
                        break;
                    case "STOPCALIBRATION":
                        this.Stop();
                        break;
                }
            });
            _manipulationService = manipulationService as ObjectDetectionService;

            _manipulationService.IsWindowVisible = true; 

            this.SaveCalibration = new RelayCommand(() =>
            {
                if (_manipulationService.IsCalibrating || _manipulationService.ObjectCount == 0)
                    MessageBox.Show("Please complete calibration and ensure that the 'Calibrate' setting is unchecked and at least one Object is Detected before Saving Calibration.");
                else
                    MessageBox.Show(_manipulationService.SaveCalibration());
            });

            this.LoadCalibration = new RelayCommand(() =>
            {
                _manipulationService.LoadCalibration();
            });

            this.CloseCommand = new RelayCommand<Window>(
                (window) => 
                    {
                        _manipulationService.IsWindowVisible = false;
                        _manipulationService.IsCalibrating = false;
                        window.Close();
                        var mainWindow = Application.Current.Windows.Cast<Window>().SingleOrDefault(w => w.Name == "MainWindow");
                        if (mainWindow != null)
                        {
                            mainWindow.Show();
                        }
                    },
                (window) =>  window != null
                );

            this.StartService = new RelayCommand(() => { _manipulationService.Start(); });
            this.StopService = new RelayCommand(() => { _manipulationService.Stop(); });

            this._manipulationService.PropertyChanged += _manipulationService_PropertyChanged;

        }