Пример #1
0
        internal InputAnalyzer(ObservableDictionary <string, string> parameters, IDevice device, IAnalyzer analyzer)
        {
            _parameters = parameters;
            _analyzer   = analyzer;

            _analyzerWrapper = new AnalyzerWrapper(analyzer, parameters);
            _analyzerWrapper.Run();

            _device = device;
            _input  = device.GamingInput;

            if (_input is ISkeletonInput && analyzer is ISkeletonAnalyzer)
            {
                (_input as ISkeletonInput).SkeletonChanged +=
                    (_skeleton_handler = new EventHandler <SkeletonChangedEventArgs>(InputAnalyzer_SkeletonChanged));
            }
            else if (_input is IAccelerometerInput && analyzer is IAccelerometerAnalyzer)
            {
                (_input as IAccelerometerInput).AccelerometerChanged +=
                    (_accelerometer_handler = new EventHandler <AccelerometerChangedEventArgs>(InputAnalyzer_AccelerometerChanged));
            }
            else if (_input is IBalanceBoardInput && analyzer is IBalanceBoardAnalyzer)
            {
                (_input as IBalanceBoardInput).BalanceChanged +=
                    (_ballanceBoard_handler = new EventHandler <BalanceChangedEventArgs>(InputAnalyzer_BalanceChanged));
            }
            else if (_input is IEmgSensorInput && analyzer is IEmgSignalAnalyzer)
            {
                (_input as IEmgSensorInput).MuscleActivationChanged +=
                    (_emg_handler = new EventHandler <MuscleActivationChangedEventArgs>(InputAnalyzer_MuscleActivationChanged));
            }
        }
Пример #2
0
        private void ReleaseInput()
        {
            switch (_type)
            {
            case DeviceType.Skeleton:
                _input = new SkeletonInputProxy(this);
                _remoteObj.NewSkeleton -= (_input as SkeletonInputProxy).OnNewSkeleton;
                break;

            case DeviceType.BalanceBoard:
                _input = new BalanceBoardInputProxy(this);
                _remoteObj.NewBalanceBoard -= (_input as BalanceBoardInputProxy).OnNewBalanceBoard;
                break;

            default:
                Trace.WriteLine("Proxy not supported for this device - " + _type.ToString());
                break;
            }
        }
Пример #3
0
        private void ConfigureBindings(XPathNavigator navigator, Dictionary <string, IDevice> devices)
        {
            XPathNodeIterator bindingIt = navigator.Select(
                "/Configuration/bindings/binding[@device and @point and @sensitivity]");

            while (bindingIt.MoveNext())
            {
                string deviceName = bindingIt.Current.GetAttribute("device", "");

                if (!devices.ContainsKey(deviceName))
                {
                    UIThread.ShowMessage("", "Device " + deviceName + " was not found on this computer!");
                    continue;
                }

                IDevice device = devices[deviceName];
                if (!device.IsLoaded)
                {
                    try
                    {
                        device.LoadDriver(null);
                    }
                    catch (InitializationFailedException ex)
                    {
                        // MessageBox.Show(ex.Message, "ConfigureBindings: Unable to load driver", MessageBoxButton.OK, MessageBoxImage.Error);
                        continue;
                    }
                }

                IGamingInput gamingInput = device.GamingInput;
                InputBinding binding     = null;

                string point = bindingIt.Current.GetAttribute("point", "");
                if (Configuration.GetHandle(point) == null)
                {
                    continue;
                }

                if (device.GamingInput is ISkeletonInput)
                {
                    binding = ConfigureSkeleton(navigator, bindingIt, (ISkeletonInput)device.GamingInput);
                    ObservableDictionary <string, ObservableDictionary <string, string> > analyzersParams =
                        ParseAnalyzersParams(bindingIt.Current);
                    foreach (string analyzerFile in analyzersParams.Keys)
                    {
                        if (binding is SkeletonBinding)
                        {
                            (binding as SkeletonBinding).AddAnalyzer(
                                InputAnalyzerManager.GetSkeletonAnalyzer(analyzerFile), analyzersParams[analyzerFile]);
                        }
                        else if (binding is AbsoluteSkeletonBinding)
                        {
                            (binding as AbsoluteSkeletonBinding).AddAnalyzer(
                                InputAnalyzerManager.GetSkeletonAnalyzer(analyzerFile), analyzersParams[analyzerFile]);
                        }
                    }
                }
                else if (gamingInput is IAccelerometerInput)
                {
                    binding = ConfigureAccelerometer(navigator, bindingIt, (IAccelerometerInput)device.GamingInput);
                    ObservableDictionary <string, ObservableDictionary <string, string> > analyzersParams =
                        ParseAnalyzersParams(bindingIt.Current);
                    foreach (string analyzerFile in analyzersParams.Keys)
                    {
                        if (binding is AccelerometerBinding)
                        {
                            (binding as AccelerometerBinding).AddAnalyzer(
                                InputAnalyzerManager.GetAccelerometerAnalyzer(analyzerFile), analyzersParams[analyzerFile]);
                        }
                    }
                }
                else if (gamingInput is IBalanceBoardInput)
                {
                    binding = ConfigureBalanceBoard(navigator, bindingIt, (IBalanceBoardInput)device.GamingInput);
                    ObservableDictionary <string, ObservableDictionary <string, string> > analyzersParams =
                        ParseAnalyzersParams(bindingIt.Current);

                    //
                    //  TODO add balance board analyzers processing
                    //
                    //foreach (string analyzerFile in analyzersParams.Keys)
                    //{
                    //    if (binding is BalanceBoardBinding)
                    //        (binding as BalanceBoardBinding).AddAnalyzer(
                    //            AnalysisManager.GetBAccelerometerAnalyzer(analyzerFile), analyzersParams[analyzerFile]);
                    //}
                }
                else if (gamingInput is IEmgSensorInput)
                {
                    binding = ConfigureEmgSensor(navigator, bindingIt, (IEmgSensorInput)device.GamingInput);
                    //ObservableDictionary<string, ObservableDictionary<string, string>> analyzerParams =
                    //                                    ParseAnalyzersParams(bindingIt.Current);
                }


                if (binding != null)
                {
                    this.AddOrReplace(binding);
                }
            }
        }