Ejemplo n.º 1
0
        private void AddPivotItem(int sensorType, int index, int totalIndex)
        {
            PivotItem    PivotItemSensor    = new PivotItem();
            ScrollViewer scrollViewerSensor = new ScrollViewer()
            {
                VerticalScrollBarVisibility = ScrollBarVisibility.Visible, HorizontalScrollBarVisibility = ScrollBarVisibility.Visible
            };

            SensorDisplay selected = Sensor.SensorDisplay[totalIndex];

            PivotItemSensor.Header = Constants.SensorName[selected.SensorType] + " " + (index + 1);

            // Special case proximity sensors and label the human presence sensors explicitly through the header. A human presence sensor is a proximity
            // sensor with the optional property DEVPKEY_Sensor_ProximityType set as 1.
            try
            {
                if (sensorType == Sensor.PROXIMITYSENSOR && (Sensor.ProximitySensorDeviceInfo[index].Properties[Constants.Properties["DEVPKEY_Sensor_ProximityType"]].ToString() == "1"))
                {
                    PivotItemSensor.Header = Constants.SensorName[selected.SensorType] + " (Human Presence) " + (index + 1);
                }
            }
            catch { }
            scrollViewerSensor.Content = selected.StackPanelSensor;
            PivotItemSensor.Content    = scrollViewerSensor;
            PivotSensor.Items.Add(PivotItemSensor);
        }
Ejemplo n.º 2
0
        protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            if (Sensor.SensorDisplay.Count > 0 && Sensor.CurrentId >= 0 && Sensor.CurrentId != PivotSensor.Items.Count - 1)
            {
                SensorDisplay selected = Sensor.SensorDisplay[Sensor.CurrentId];

                Sensor.DisableSensor(selected.SensorType, selected.Index);
            }

            rootPage.NotifyUser("", NotifyType.StatusMessage);
        }
Ejemplo n.º 3
0
 private void ShowPlotButton(object sender, RoutedEventArgs e)
 {
     try
     {
         SensorDisplay selected = Sensor.SensorDisplay[Sensor.CurrentId];
         selected.PlotCanvas.ShowCanvas();
         selected.StackPanelTop.Visibility = Visibility.Visible;
         hidePlotButton.IsEnabled          = true;
         showPlotButton.IsEnabled          = false;
     }
     catch { }
 }
Ejemplo n.º 4
0
        private async void EnumerateSensors()
        {
            try
            {
                await Sensor.GetDefault();

                int totalIndex = -1;

                for (int index = 0; index < Sensor.AccelerometerStandardList.Count; index++)
                {
                    totalIndex++;
                    SensorData    AccelerometerData    = new SensorData(Sensor.ACCELEROMETER, totalIndex, "Accelerometer (Standard)", Constants.AccelerometerPropertyTitles);
                    SensorDisplay AccelerometerDisplay = new SensorDisplay(Sensor.ACCELEROMETER, index, totalIndex, "Accelerometer (Standard)", -2, 2, 2, Constants.AccelerometerColors);
                    sensorDisplay.Add(AccelerometerDisplay);
                    sensorData.Add(AccelerometerData);
                    AddPivotItem(Sensor.ACCELEROMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.AccelerometerLinearList.Count; index++)
                {
                    totalIndex++;
                    SensorData    AccelerometerLinearData    = new SensorData(Sensor.ACCELEROMETERLINEAR, totalIndex, "Accelerometer (Linear)", Constants.AccelerometerPropertyTitles);
                    SensorDisplay AccelerometerLinearDisplay = new SensorDisplay(Sensor.ACCELEROMETERLINEAR, index, totalIndex, "Accelerometer (Linear)", -2, 2, 2, Constants.AccelerometerColors);
                    sensorDisplay.Add(AccelerometerLinearDisplay);
                    sensorData.Add(AccelerometerLinearData);
                    AddPivotItem(Sensor.ACCELEROMETERLINEAR, index, totalIndex);
                }
                for (int index = 0; index < Sensor.AccelerometerGravityList.Count; index++)
                {
                    totalIndex++;
                    SensorData    AccelerometerGravityData    = new SensorData(Sensor.ACCELEROMETERGRAVITY, totalIndex, "Accelerometer (Gravity)", Constants.AccelerometerPropertyTitles);
                    SensorDisplay AccelerometerGravityDisplay = new SensorDisplay(Sensor.ACCELEROMETERGRAVITY, index, totalIndex, "Accelerometer (Gravity)", -2, 2, 2, Constants.AccelerometerColors);
                    sensorDisplay.Add(AccelerometerGravityDisplay);
                    sensorData.Add(AccelerometerGravityData);
                    AddPivotItem(Sensor.ACCELEROMETERGRAVITY, index, totalIndex);
                }
                for (int index = 0; index < Sensor.ActivitySensorList.Count; index++)
                {
                    totalIndex++;
                    SensorData    ActivitySensorData    = new SensorData(Sensor.ACTIVITYSENSOR, totalIndex, "ActivitySensor", Constants.ActivitySensorPropertyTitles);
                    SensorDisplay ActivitySensorDisplay = new SensorDisplay(Sensor.ACTIVITYSENSOR, index, totalIndex, "ActivitySensor", 2, 0, 2, Constants.ActivitySensorColors);
                    sensorDisplay.Add(ActivitySensorDisplay);
                    sensorData.Add(ActivitySensorData);
                    AddPivotItem(Sensor.ACTIVITYSENSOR, index, totalIndex);
                }
                if (Sensor.Altimeter != null)
                {
                    totalIndex++;
                    SensorData    AltimeterData    = new SensorData(Sensor.ALTIMETER, totalIndex, "Altimeter", Constants.AltimeterPropertyTitles);
                    SensorDisplay AltimeterDisplay = new SensorDisplay(Sensor.ALTIMETER, 0, totalIndex, "Altimeter", -10, 10, 2, Constants.AltimeterColors);
                    sensorDisplay.Add(AltimeterDisplay);
                    sensorData.Add(AltimeterData);
                    AddPivotItem(Sensor.ALTIMETER, 0, totalIndex);
                }
                for (int index = 0; index < Sensor.BarometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    BarometerData    = new SensorData(Sensor.BAROMETER, totalIndex, "Barometer", Constants.BarometerPropertyTitles);
                    SensorDisplay BarometerDisplay = new SensorDisplay(Sensor.BAROMETER, index, totalIndex, "Barometer", 950, 1050, 2, Constants.BarometerColors);
                    sensorDisplay.Add(BarometerDisplay);
                    sensorData.Add(BarometerData);
                    AddPivotItem(Sensor.BAROMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.CompassList.Count; index++)
                {
                    totalIndex++;
                    SensorData    CompassData    = new SensorData(Sensor.COMPASS, totalIndex, "Compass", Constants.CompassPropertyTitles);
                    SensorDisplay CompassDisplay = new SensorDisplay(Sensor.COMPASS, index, totalIndex, "Compass", 0, 360, 2, Constants.CompassColors);
                    sensorDisplay.Add(CompassDisplay);
                    sensorData.Add(CompassData);
                    AddPivotItem(Sensor.COMPASS, index, totalIndex);
                }
                for (int index = 0; index < Sensor.GyrometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    GyrometerData    = new SensorData(Sensor.GYROMETER, totalIndex, "Gyrometer", Constants.GyrometerPropertyTitles);
                    SensorDisplay GyrometerDisplay = new SensorDisplay(Sensor.GYROMETER, index, totalIndex, "Gyrometer", -200, 200, 2, Constants.GyrometerColors);
                    sensorDisplay.Add(GyrometerDisplay);
                    sensorData.Add(GyrometerData);
                    AddPivotItem(Sensor.GYROMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.InclinometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    InclinometerData    = new SensorData(Sensor.INCLINOMETER, totalIndex, "Inclinometer", Constants.InclinometerPropertyTitles);
                    SensorDisplay InclinometerDisplay = new SensorDisplay(Sensor.INCLINOMETER, index, totalIndex, "Inclinometer", -180, 360, 3, Constants.InclinometerColors);
                    sensorDisplay.Add(InclinometerDisplay);
                    sensorData.Add(InclinometerData);
                    AddPivotItem(Sensor.INCLINOMETER, index, totalIndex);
                }
                if (Sensor.LightSensor != null)
                {
                    totalIndex++;
                    SensorData    LightSensorData    = new SensorData(Sensor.LIGHTSENSOR, totalIndex, "LightSensor", Constants.LightSensorPropertyTitles);
                    SensorDisplay LightSensorDisplay = new SensorDisplay(Sensor.LIGHTSENSOR, 0, totalIndex, "LightSensor", 0, 1000, 2, Constants.LightSensorColors);
                    sensorDisplay.Add(LightSensorDisplay);
                    sensorData.Add(LightSensorData);
                    AddPivotItem(Sensor.LIGHTSENSOR, 0, totalIndex);
                }
                for (int index = 0; index < Sensor.MagnetometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    MagnetometerData    = new SensorData(Sensor.MAGNETOMETER, totalIndex, "Magnetometer", Constants.MagnetometerPropertyTitles);
                    SensorDisplay MagnetometerDisplay = new SensorDisplay(Sensor.MAGNETOMETER, index, totalIndex, "Magnetometer", -500, 500, 2, Constants.MagnetometerColors);
                    sensorDisplay.Add(MagnetometerDisplay);
                    sensorData.Add(MagnetometerData);
                    AddPivotItem(Sensor.MAGNETOMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.OrientationAbsoluteList.Count; index++)
                {
                    totalIndex++;
                    SensorData    OrientationAbsoluteData    = new SensorData(Sensor.ORIENTATIONSENSOR, totalIndex, "Orientation (Absolute)", Constants.OrientationSensorPropertyTitles);
                    SensorDisplay OrientationAbsoluteDisplay = new SensorDisplay(Sensor.ORIENTATIONSENSOR, index, totalIndex, "Orientation (Absolute)", -1, 1, 2, Constants.OrientationSensorColors);
                    sensorDisplay.Add(OrientationAbsoluteDisplay);
                    sensorData.Add(OrientationAbsoluteData);
                    AddPivotItem(Sensor.ORIENTATIONSENSOR, index, totalIndex);
                }
                for (int index = 0; index < Sensor.OrientationRelativeList.Count; index++)
                {
                    totalIndex++;
                    SensorData    OrientationRelativeData    = new SensorData(Sensor.ORIENTATIONRELATIVE, totalIndex, "Orientation (Relative)", Constants.OrientationSensorPropertyTitles);
                    SensorDisplay OrientationRelativeDisplay = new SensorDisplay(Sensor.ORIENTATIONRELATIVE, index, totalIndex, "Orientation (Relative)", -1, 1, 2, Constants.OrientationSensorColors);
                    sensorDisplay.Add(OrientationRelativeDisplay);
                    sensorData.Add(OrientationRelativeData);
                    AddPivotItem(Sensor.ORIENTATIONRELATIVE, index, totalIndex);
                }
                for (int index = 0; index < Sensor.OrientationGeomagneticList.Count; index++)
                {
                    totalIndex++;
                    SensorData    OrientationGeomagneticData    = new SensorData(Sensor.ORIENTATIONGEOMAGNETIC, totalIndex, "Orientation (Geomagnetic)", Constants.OrientationSensorPropertyTitles);
                    SensorDisplay OrientationGeomagneticDisplay = new SensorDisplay(Sensor.ORIENTATIONGEOMAGNETIC, index, totalIndex, "Orientation (Geomagnetic)", -1, 1, 2, Constants.OrientationSensorColors);
                    sensorDisplay.Add(OrientationGeomagneticDisplay);
                    sensorData.Add(OrientationGeomagneticData);
                    AddPivotItem(Sensor.ORIENTATIONGEOMAGNETIC, index, totalIndex);
                }
                for (int index = 0; index < Sensor.PedometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    PedometerData    = new SensorData(Sensor.PEDOMETER, totalIndex, "Pedometer", Constants.PedometerPropertyTitles);
                    SensorDisplay PedometerDisplay = new SensorDisplay(Sensor.PEDOMETER, index, totalIndex, "Pedometer", 0, 50, 2, Constants.PedometerColors);
                    sensorDisplay.Add(PedometerDisplay);
                    sensorData.Add(PedometerData);
                    AddPivotItem(Sensor.PEDOMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.ProximitySensorList.Count; index++)
                {
                    totalIndex++;
                    SensorData    ProximitySensorData    = new SensorData(Sensor.PROXIMITYSENSOR, totalIndex, "ProximitySensor", Constants.ProximitySensorPropertyTitles);
                    SensorDisplay ProximitySensorDisplay = new SensorDisplay(Sensor.PROXIMITYSENSOR, index, totalIndex, "ProximitySensor", 0, 1, 1, Constants.ProximitySensorColors);
                    sensorDisplay.Add(ProximitySensorDisplay);
                    sensorData.Add(ProximitySensorData);
                    AddPivotItem(Sensor.PROXIMITYSENSOR, index, totalIndex);
                }
                if (Sensor.SimpleOrientationSensor != null)
                {
                    totalIndex++;
                    SensorData    simpleOrientationSensorData    = new SensorData(Sensor.SIMPLEORIENTATIONSENSOR, totalIndex, "SimpleOrientationSensor", Constants.SimpleOrientationSensorPropertyTitles);
                    SensorDisplay simpleOrientationSensorDisplay = new SensorDisplay(Sensor.SIMPLEORIENTATIONSENSOR, 0, totalIndex, "SimpleOrientationSensor", 0, 5, 5, Constants.SimpleOrientationSensorColors);
                    sensorDisplay.Add(simpleOrientationSensorDisplay);
                    sensorData.Add(simpleOrientationSensorData);
                    AddPivotItem(Sensor.PROXIMITYSENSOR, 0, totalIndex);
                }

                AddSummaryPage();

                var resourceLoader = ResourceLoader.GetForCurrentView();
                rootPage.NotifyUser(resourceLoader.GetString("NumberOfSensors") + ": " + (PivotSensor.Items.Count - 1), NotifyType.StatusMessage);
                ProgressRingSensor.IsActive = false;

                if (PivotSensor.Items.Count > 0)
                {
                    PivotSensor.SelectionChanged += PivotSensorSelectionChanged;
                    PivotSensor.SelectedIndex     = 0;
                    PivotSensorSelectionChanged(null, null);
                }
                else
                {
                    TextBlockNoSensor.Text = resourceLoader.GetString("CannotFindSensor");
                    return;
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
            }

            ProgressRingSensor.IsActive = false;
        }
Ejemplo n.º 5
0
 private void ReportIntervalButton(object sender, RoutedEventArgs e)
 {
     try
     {
         SensorDisplay selected = sensorDisplay[Sensor.currentId];
         if (selected.SensorType == Sensor.ACCELEROMETER)
         {
             Sensor.AccelerometerStandardList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.ACCELEROMETERLINEAR)
         {
             Sensor.AccelerometerLinearList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.ACCELEROMETERGRAVITY)
         {
             Sensor.AccelerometerGravityList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         // ActivitySensor doesn't have ReportInterval
         else if (selected.SensorType == Sensor.ALTIMETER)
         {
             Sensor.Altimeter.ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.BAROMETER)
         {
             Sensor.BarometerList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.COMPASS)
         {
             Sensor.CompassList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.GYROMETER)
         {
             Sensor.GyrometerList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.INCLINOMETER)
         {
             Sensor.InclinometerList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.LIGHTSENSOR)
         {
             Sensor.LightSensor.ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.MAGNETOMETER)
         {
             Sensor.MagnetometerList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.ORIENTATIONSENSOR)
         {
             Sensor.OrientationAbsoluteList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.ORIENTATIONGEOMAGNETIC)
         {
             Sensor.OrientationGeomagneticList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.ORIENTATIONRELATIVE)
         {
             Sensor.OrientationRelativeList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         else if (selected.SensorType == Sensor.PEDOMETER)
         {
             Sensor.PedometerList[selected.Index].ReportInterval = uint.Parse(textboxReportInterval.Text);
             sensorData[Sensor.currentId].UpdateReportInterval(uint.Parse(textboxReportInterval.Text));
         }
         //ProximitySensor doesn't have ReportInterval
         //SimpleOrientationSensor doesn't have ReportInterval
     }
     catch { }
 }
Ejemplo n.º 6
0
        private async static void PeriodicTimerCallbackSensorDisplay(ThreadPoolTimer timer)
        {
            await cd.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                for (int i = 0; i < Sensor.SensorDisplay.Count; i++)
                {
                    SensorDisplay selectedDisplay = Sensor.SensorDisplay[i];
                    SensorData selectedData       = Sensor.SensorData[i];
                    if (selectedDisplay.StackPanelSensor.Visibility == Visibility.Visible)
                    {
                        selectedDisplay.PlotCanvas.Plot(selectedData);
                        selectedDisplay.UpdateText(selectedData);
                    }

                    if (selectedData.ReportIntervalChanged)
                    {
                        try
                        {
                            if (selectedData.SensorType == Sensor.ACCELEROMETER)
                            {
                                Sensor.AccelerometerStandardList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.AccelerometerStandardList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.ACCELEROMETERGRAVITY)
                            {
                                Sensor.AccelerometerGravityList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.AccelerometerGravityList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.ACCELEROMETERLINEAR)
                            {
                                Sensor.AccelerometerLinearList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.AccelerometerLinearList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.COMPASS)
                            {
                                Sensor.CompassList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.CompassList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.GYROMETER)
                            {
                                Sensor.GyrometerList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.GyrometerList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.INCLINOMETER)
                            {
                                Sensor.InclinometerList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.InclinometerList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.LIGHTSENSOR)
                            {
                                Sensor.LightSensorList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.LightSensorList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.ORIENTATIONSENSOR)
                            {
                                Sensor.OrientationAbsoluteList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.OrientationAbsoluteList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.ORIENTATIONGEOMAGNETIC)
                            {
                                Sensor.OrientationGeomagneticList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.OrientationGeomagneticList[selectedDisplay.Index].ReportInterval;
                            }
                            else if (selectedData.SensorType == Sensor.ORIENTATIONRELATIVE)
                            {
                                Sensor.OrientationRelativeList[selectedDisplay.Index].ReportInterval = selectedData.ReportInterval;
                                selectedData.ReportInterval = Sensor.OrientationRelativeList[selectedDisplay.Index].ReportInterval;
                            }

                            selectedData.ReportIntervalChanged = false;
                        }
                        catch { }
                    }
                }
            });
        }
Ejemplo n.º 7
0
        private async void EnumerateSensors()
        {
            try
            {
                await Sensor.GetDefault();

                int totalIndex = -1;
                for (int index = 0; index < Sensor.AccelerometerStandardList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _accelerometerData    = new SensorData(Sensor.ACCELEROMETER, totalIndex, "Accelerometer (Standard)", new string[] { "AccelerationX (g)", "AccelerationY (g)", "AccelerationZ (g)" });
                    SensorDisplay _accelerometerDisplay = new SensorDisplay(Sensor.ACCELEROMETER, index, totalIndex, "Accelerometer (Standard)", -2, 2, 2, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan });
                    _sensorDisplay.Add(_accelerometerDisplay);
                    _sensorData.Add(_accelerometerData);
                    AddPivotItem(Sensor.ACCELEROMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.AccelerometerLinearList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _accelerometerLinearData    = new SensorData(Sensor.ACCELEROMETERLINEAR, totalIndex, "Accelerometer (Linear)", new string[] { "AccelerationX (g)", "AccelerationY (g)", "AccelerationZ (g)" });
                    SensorDisplay _accelerometerLinearDisplay = new SensorDisplay(Sensor.ACCELEROMETERLINEAR, index, totalIndex, "Accelerometer (Linear)", -2, 2, 2, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan });
                    _sensorDisplay.Add(_accelerometerLinearDisplay);
                    _sensorData.Add(_accelerometerLinearData);
                    AddPivotItem(Sensor.ACCELEROMETERLINEAR, index, totalIndex);
                }
                for (int index = 0; index < Sensor.AccelerometerGravityList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _accelerometerGravityData    = new SensorData(Sensor.ACCELEROMETERGRAVITY, totalIndex, "Accelerometer (Gravity)", new string[] { "AccelerationX (g)", "AccelerationY (g)", "AccelerationZ (g)" });
                    SensorDisplay _accelerometerGravityDisplay = new SensorDisplay(Sensor.ACCELEROMETERGRAVITY, index, totalIndex, "Accelerometer (Gravity)", -2, 2, 2, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan });
                    _sensorDisplay.Add(_accelerometerGravityDisplay);
                    _sensorData.Add(_accelerometerGravityData);
                    AddPivotItem(Sensor.ACCELEROMETERGRAVITY, index, totalIndex);
                }
                for (int index = 0; index < Sensor.ActivitySensorList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _activitySensorData    = new SensorData(Sensor.ACTIVITYSENSOR, totalIndex, "ActivitySensor", new string[] { "AccelerationX (g)", "AccelerationY (g)", "AccelerationZ (g)" });
                    SensorDisplay _activitySensorDisplay = new SensorDisplay(Sensor.ACTIVITYSENSOR, index, totalIndex, "ActivitySensor", 2, 0, 2, new Color[] { Colors.Gray, Colors.Brown, Colors.DarkRed, Colors.Orange, Colors.DarkOrange, Colors.Lime, Colors.DarkCyan, Colors.DarkViolet });
                    _sensorDisplay.Add(_activitySensorDisplay);
                    _sensorData.Add(_activitySensorData);
                    AddPivotItem(Sensor.ACTIVITYSENSOR, index, totalIndex);
                }
                if (Sensor.Altimeter != null)
                {
                    totalIndex++;
                    SensorData    _altimeterData    = new SensorData(Sensor.ALTIMETER, totalIndex, "Altimeter", new string[] { "AltitudeChange (m)" });
                    SensorDisplay _altimeterDisplay = new SensorDisplay(Sensor.ALTIMETER, 0, totalIndex, "Altimeter", -10, 10, 2, new Color[] { Colors.DarkRed });
                    _sensorDisplay.Add(_altimeterDisplay);
                    _sensorData.Add(_altimeterData);
                    AddPivotItem(Sensor.ALTIMETER, 0, totalIndex);
                }
                for (int index = 0; index < Sensor.BarometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _barometerData    = new SensorData(Sensor.BAROMETER, totalIndex, "Barometer", new string[] { "Pressure (hPa)" });
                    SensorDisplay _barometerDisplay = new SensorDisplay(Sensor.BAROMETER, index, totalIndex, "Barometer", 950, 1050, 2, new Color[] { Colors.Lime });
                    _sensorDisplay.Add(_barometerDisplay);
                    _sensorData.Add(_barometerData);
                    AddPivotItem(Sensor.BAROMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.CompassList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _compassData    = new SensorData(Sensor.COMPASS, totalIndex, "Compass", new string[] { "MagneticNorth (°)", "TrueNorth (°)", "HeadingAccuracy" });
                    SensorDisplay _compassDisplay = new SensorDisplay(Sensor.COMPASS, index, totalIndex, "Compass", 0, 360, 2, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan });
                    _sensorDisplay.Add(_compassDisplay);
                    _sensorData.Add(_compassData);
                    AddPivotItem(Sensor.COMPASS, index, totalIndex);
                }
                for (int index = 0; index < Sensor.GyrometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _gyrometerData    = new SensorData(Sensor.GYROMETER, totalIndex, "Gyrometer", new string[] { "AngularVelocityX (°/s)", "AngularVelocityY (°/s)", "AngularVelocityZ (°/s)" });
                    SensorDisplay _gyrometerDisplay = new SensorDisplay(Sensor.GYROMETER, index, totalIndex, "Gyrometer", -200, 200, 2, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan });
                    _sensorDisplay.Add(_gyrometerDisplay);
                    _sensorData.Add(_gyrometerData);
                    AddPivotItem(Sensor.GYROMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.InclinometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _inclinometerData    = new SensorData(Sensor.INCLINOMETER, totalIndex, "Inclinometer", new string[] { "Pitch (°)", "Roll (°)", "Yaw (°)", "YawAccuracy" });
                    SensorDisplay _inclinometerDisplay = new SensorDisplay(Sensor.INCLINOMETER, index, totalIndex, "Inclinometer", -180, 360, 3, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan, Colors.Black });
                    _sensorDisplay.Add(_inclinometerDisplay);
                    _sensorData.Add(_inclinometerData);
                    AddPivotItem(Sensor.INCLINOMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.LightSensorList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _lightSensorData    = new SensorData(Sensor.LIGHTSENSOR, totalIndex, "LightSensor", new string[] { "Illuminance (lux)", "Chromaticity X", "Chromaticity Y" });
                    SensorDisplay _lightSensorDisplay = new SensorDisplay(Sensor.LIGHTSENSOR, index, totalIndex, "LightSensor", 0, 1000, 2, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan });
                    _sensorDisplay.Add(_lightSensorDisplay);
                    _sensorData.Add(_lightSensorData);
                    AddPivotItem(Sensor.LIGHTSENSOR, index, totalIndex);
                }
                for (int index = 0; index < Sensor.MagnetometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _magnetometerData    = new SensorData(Sensor.MAGNETOMETER, totalIndex, "Magnetometer", new string[] { "MagneticFieldX (µT)", "MagneticFieldY (µT)", "MagneticFieldZ (µT)" });
                    SensorDisplay _magnetometerDisplay = new SensorDisplay(Sensor.MAGNETOMETER, index, totalIndex, "Magnetometer", -500, 500, 2, new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan });
                    _sensorDisplay.Add(_magnetometerDisplay);
                    _sensorData.Add(_magnetometerData);
                    AddPivotItem(Sensor.MAGNETOMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.OrientationAbsoluteList.Count; index++)
                {
                    totalIndex++;
                    SensorData _orientationAbsoluteData = new SensorData(Sensor.ORIENTATIONSENSOR, totalIndex, "Orientation (Absolute)",
                                                                         new string[] { "QuaternionX", "QuaternionY", "QuaternionZ", "QuaternionW",
                                                                                        "RotationMatrixM11", "RotationMatrixM12", "RotationMatrixM13",
                                                                                        "RotationMatrixM21", "RotationMatrixM22", "RotationMatrixM23",
                                                                                        "RotationMatrixM31", "RotationMatrixM32", "RotationMatrixM33" });
                    SensorDisplay _orientationAbsoluteDisplay = new SensorDisplay(Sensor.ORIENTATIONSENSOR, index, totalIndex, "Orientation (Absolute)", -1, 1, 2,
                                                                                  new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan, Colors.DarkViolet,
                                                                                                Colors.Black, Colors.Black, Colors.Black,
                                                                                                Colors.Black, Colors.Black, Colors.Black,
                                                                                                Colors.Black, Colors.Black, Colors.Black });
                    _sensorDisplay.Add(_orientationAbsoluteDisplay);
                    _sensorData.Add(_orientationAbsoluteData);
                    AddPivotItem(Sensor.ORIENTATIONSENSOR, index, totalIndex);
                }
                for (int index = 0; index < Sensor.OrientationRelativeList.Count; index++)
                {
                    totalIndex++;
                    SensorData _orientationRelativeData = new SensorData(Sensor.ORIENTATIONRELATIVE, totalIndex, "Orientation (Relative)",
                                                                         new string[] { "QuaternionX", "QuaternionY", "QuaternionZ", "QuaternionW",
                                                                                        "RotationMatrixM11", "RotationMatrixM12", "RotationMatrixM13",
                                                                                        "RotationMatrixM21", "RotationMatrixM22", "RotationMatrixM23",
                                                                                        "RotationMatrixM31", "RotationMatrixM32", "RotationMatrixM33" });
                    SensorDisplay _orientationRelativeDisplay = new SensorDisplay(Sensor.ORIENTATIONRELATIVE, index, totalIndex, "Orientation (Relative)", -1, 1, 2,
                                                                                  new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan, Colors.DarkViolet,
                                                                                                Colors.Black, Colors.Black, Colors.Black,
                                                                                                Colors.Black, Colors.Black, Colors.Black,
                                                                                                Colors.Black, Colors.Black, Colors.Black });
                    _sensorDisplay.Add(_orientationRelativeDisplay);
                    _sensorData.Add(_orientationRelativeData);
                    AddPivotItem(Sensor.ORIENTATIONRELATIVE, index, totalIndex);
                }
                for (int index = 0; index < Sensor.OrientationGeomagneticList.Count; index++)
                {
                    totalIndex++;
                    SensorData _orientationGeomagneticData = new SensorData(Sensor.ORIENTATIONGEOMAGNETIC, totalIndex, "Orientation (Geomagnetic)",
                                                                            new string[] { "QuaternionX", "QuaternionY", "QuaternionZ", "QuaternionW",
                                                                                           "RotationMatrixM11", "RotationMatrixM12", "RotationMatrixM13",
                                                                                           "RotationMatrixM21", "RotationMatrixM22", "RotationMatrixM23",
                                                                                           "RotationMatrixM31", "RotationMatrixM32", "RotationMatrixM33" });
                    SensorDisplay _orientationGeomagneticDisplay = new SensorDisplay(Sensor.ORIENTATIONGEOMAGNETIC, index, totalIndex, "Orientation (Geomagnetic)", -1, 1, 2,
                                                                                     new Color[] { Colors.DarkRed, Colors.DarkOrange, Colors.DarkCyan, Colors.DarkViolet,
                                                                                                   Colors.Black, Colors.Black, Colors.Black,
                                                                                                   Colors.Black, Colors.Black, Colors.Black,
                                                                                                   Colors.Black, Colors.Black, Colors.Black });
                    _sensorDisplay.Add(_orientationGeomagneticDisplay);
                    _sensorData.Add(_orientationGeomagneticData);
                    AddPivotItem(Sensor.ORIENTATIONGEOMAGNETIC, index, totalIndex);
                }
                for (int index = 0; index < Sensor.PedometerList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _pedometerData    = new SensorData(Sensor.PEDOMETER, totalIndex, "Pedometer", new string[] { "CumulativeSteps", "CumulativeStepsDuration (s)", "StepKind" });
                    SensorDisplay _pedometerDisplay = new SensorDisplay(Sensor.PEDOMETER, index, totalIndex, "Pedometer", 0, 50, 2, new Color[] { Colors.DarkCyan, Colors.Black, Colors.Black });
                    _sensorDisplay.Add(_pedometerDisplay);
                    _sensorData.Add(_pedometerData);
                    AddPivotItem(Sensor.PEDOMETER, index, totalIndex);
                }
                for (int index = 0; index < Sensor.ProximitySensorList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _proximitySensorData    = new SensorData(Sensor.PROXIMITYSENSOR, totalIndex, "ProximitySensor", new string[] { "IsDetected", "Distance (mm)" });
                    SensorDisplay _proximitySensorDisplay = new SensorDisplay(Sensor.PROXIMITYSENSOR, index, totalIndex, "ProximitySensor", 0, 1, 1, new Color[] { Colors.DarkOrange, Colors.Black });
                    _sensorDisplay.Add(_proximitySensorDisplay);
                    _sensorData.Add(_proximitySensorData);
                    AddPivotItem(Sensor.PROXIMITYSENSOR, index, totalIndex);
                }
                for (int index = 0; index < Sensor.SimpleOrientationSensorList.Count; index++)
                {
                    totalIndex++;
                    SensorData    _simpleOrientationSensorData    = new SensorData(Sensor.SIMPLEORIENTATIONSENSOR, totalIndex, "SimpleOrientationSensor", new string[] { "SimpleOrientation" });
                    SensorDisplay _simpleOrientationSensorDisplay = new SensorDisplay(Sensor.SIMPLEORIENTATIONSENSOR, index, totalIndex, "SimpleOrientationSensor", 0, 5, 5, new Color[] { Colors.Lime });
                    _sensorDisplay.Add(_simpleOrientationSensorDisplay);
                    _sensorData.Add(_simpleOrientationSensorData);
                    AddPivotItem(Sensor.PROXIMITYSENSOR, index, totalIndex);
                }

                AddSummaryPage();

                var resourceLoader = ResourceLoader.GetForCurrentView();
                rootPage.NotifyUser(resourceLoader.GetString("NumberOfSensors") + ": " + (PivotSensor.Items.Count - 1) + "\nNumber of sensors failed to enumerate: " + Sensor.NumFailedEnumerations, NotifyType.StatusMessage);
                ProgressRingSensor.IsActive = false;

                if (PivotSensor.Items.Count > 0)
                {
                    PivotSensor.SelectionChanged += PivotSensorSelectionChanged;
                    PivotSensor.SelectedIndex     = 0;
                    PivotSensorSelectionChanged(null, null);
                }
                else
                {
                    TextBlockNoSensor.Text = resourceLoader.GetString("CannotFindSensor");
                    return;
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
            }

            ProgressRingSensor.IsActive = false;
        }
Ejemplo n.º 8
0
        public void ReportIntervalButton(object sender, RoutedEventArgs e)
        {
            try
            {
                SensorDisplay selectedDisplay = Sensor.SensorDisplay[Sensor.CurrentId];
                SensorData    selectedData    = Sensor.SensorData[Sensor.CurrentId];

                uint newReportInterval = uint.Parse(selectedDisplay.TextboxReportInterval.Text);
                selectedData.UpdateReportInterval(newReportInterval);

                if (selectedDisplay.SensorType == Sensor.ACCELEROMETER)
                {
                    Sensor.AccelerometerStandardList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.ACCELEROMETERGRAVITY)
                {
                    Sensor.AccelerometerGravityList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.ACCELEROMETERLINEAR)
                {
                    Sensor.AccelerometerLinearList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.ALTIMETER)
                {
                    Sensor.Altimeter.ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.BAROMETER)
                {
                    Sensor.BarometerList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.COMPASS)
                {
                    Sensor.CompassList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.CUSTOMSENSOR)
                {
                    Sensor.CustomSensorList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.GYROMETER)
                {
                    Sensor.GyrometerList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.INCLINOMETER)
                {
                    Sensor.InclinometerList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.LIGHTSENSOR)
                {
                    Sensor.LightSensorList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.MAGNETOMETER)
                {
                    Sensor.MagnetometerList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.ORIENTATIONSENSOR)
                {
                    Sensor.OrientationAbsoluteList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.ORIENTATIONGEOMAGNETIC)
                {
                    Sensor.OrientationGeomagneticList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.ORIENTATIONRELATIVE)
                {
                    Sensor.OrientationRelativeList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
                else if (selectedDisplay.SensorType == Sensor.PEDOMETER)
                {
                    Sensor.PedometerList[selectedDisplay.Index].ReportInterval = newReportInterval;
                }
            }
            catch { }
        }