in sensors/Tools/SensorExplorer/Scenario0_Tests.xaml.cs [515:687]
private void TestBegin()
{
TestBeginInitialization();
rootPage.NotifyUser("", NotifyType.StatusMessage);
int count = 0;
int type = SensorType[pivotSensor.SelectedIndex];
int i = totalIndexToIndex[pivotSensor.SelectedIndex];
if (type == Sensor.ACCELEROMETER)
{
currentAccelerometer = Sensor.AccelerometerStandardList[i];
currentAccInfo = Sensor.AccelerometerStandardDeviceInfo[i];
// Set to minimum report interval (try 10 times)
while (currentAccelerometer.ReportInterval != currentAccelerometer.MinimumReportInterval && count < 10)
{
currentAccelerometer.ReportInterval = currentAccelerometer.MinimumReportInterval;
count++;
}
if (currentAccelerometer.ReportInterval != currentAccelerometer.MinimumReportInterval)
{
rootPage.NotifyUser("Failed to set to the minimum report interval.", NotifyType.ErrorMessage);
restartButton.Visibility = Visibility.Visible;
}
else
{
if (testType == "Jitter")
{
accelerometerInitialReading = currentAccelerometer.GetCurrentReading();
}
TestBeginHelper(type);
currentAccelerometer.ReadingChanged += AccelerometerReadingChanged;
}
}
else if (type == Sensor.COMPASS)
{
currentCompass = Sensor.CompassList[i];
// Set to minimum report interval (try 10 times)
while (currentCompass.ReportInterval != currentCompass.MinimumReportInterval && count < 10)
{
currentCompass.ReportInterval = currentCompass.MinimumReportInterval;
count++;
}
if (currentCompass.ReportInterval != currentCompass.MinimumReportInterval)
{
rootPage.NotifyUser("Failed to set to the minimum report interval.", NotifyType.ErrorMessage);
restartButton.Visibility = Visibility.Visible;
}
else
{
TestBeginHelper(type);
currentCompass.ReadingChanged += CompassReadingChanged;
}
}
else if (type == Sensor.GYROMETER)
{
currentGyrometer = Sensor.GyrometerList[i];
// Set to minimum report interval (try 10 times)
while (currentGyrometer.ReportInterval != currentGyrometer.MinimumReportInterval && count < 10)
{
currentGyrometer.ReportInterval = currentGyrometer.MinimumReportInterval;
count++;
}
if (currentGyrometer.ReportInterval != currentGyrometer.MinimumReportInterval)
{
rootPage.NotifyUser("Failed to set to the minimum report interval.", NotifyType.ErrorMessage);
restartButton.Visibility = Visibility.Visible;
}
else
{
if (testType == "Jitter")
{
gyrometerInitialReading = currentGyrometer.GetCurrentReading();
}
TestBeginHelper(type);
currentGyrometer.ReadingChanged += GyrometerReadingChanged;
}
}
else if (type == Sensor.LIGHTSENSOR)
{
currentLightSensor = Sensor.LightSensorList[i];
// Set to minimum report interval (try 10 times)
while (currentLightSensor.ReportInterval != currentLightSensor.MinimumReportInterval && count < 10)
{
currentLightSensor.ReportInterval = currentLightSensor.MinimumReportInterval;
count++;
}
if (currentLightSensor.ReportInterval != currentLightSensor.MinimumReportInterval)
{
rootPage.NotifyUser("Failed to set to the minimum report interval.", NotifyType.ErrorMessage);
restartButton.Visibility = Visibility.Visible;
}
else
{
if (testType == "Jitter")
{
lightSensorInitialReading = currentLightSensor.GetCurrentReading();
}
TestBeginHelper(type);
currentLightSensor.ReadingChanged += LightSensorReadingChanged;
}
}
else if (type == Sensor.MAGNETOMETER)
{
currentMagnetometer = Sensor.MagnetometerList[i];
// Set to minimum report interval (try 10 times)
while (currentMagnetometer.ReportInterval != currentMagnetometer.MinimumReportInterval && count < 10)
{
currentMagnetometer.ReportInterval = currentMagnetometer.MinimumReportInterval;
count++;
}
if (currentMagnetometer.ReportInterval != currentMagnetometer.MinimumReportInterval)
{
rootPage.NotifyUser("Failed to set to the minimum report interval.", NotifyType.ErrorMessage);
restartButton.Visibility = Visibility.Visible;
}
else
{
TestBeginHelper(type);
currentMagnetometer.ReadingChanged += MagnetometerReadingChanged;
}
}
else if (type == Sensor.ORIENTATIONSENSOR || type == Sensor.ORIENTATIONGEOMAGNETIC || type == Sensor.ORIENTATIONRELATIVE)
{
if (type == Sensor.ORIENTATIONSENSOR)
{
currentOrientationSensor = Sensor.OrientationAbsoluteList[i];
}
else if (type == Sensor.ORIENTATIONGEOMAGNETIC)
{
currentOrientationSensor = Sensor.OrientationGeomagneticList[i];
}
else
{
currentOrientationSensor = Sensor.OrientationRelativeList[i];
}
// Set to minimum report interval (try 10 times)
while (currentOrientationSensor.ReportInterval != currentOrientationSensor.MinimumReportInterval && count < 10)
{
currentOrientationSensor.ReportInterval = currentOrientationSensor.MinimumReportInterval;
count++;
}
if (currentOrientationSensor.ReportInterval != currentOrientationSensor.MinimumReportInterval)
{
rootPage.NotifyUser("Failed to set to the minimum report interval.", NotifyType.ErrorMessage);
restartButton.Visibility = Visibility.Visible;
}
else if (testType == "StaticAccuracy")
{
StaticAccuracyHandler();
}
else
{
if (testType == "Jitter")
{
orientationSensorInitialReading = currentOrientationSensor.GetCurrentReading();
}
TestBeginHelper(type);
currentOrientationSensor.ReadingChanged += OrientationSensorReadingChanged;
}
}
}