Ejemplo n.º 1
0
        public void Start(InteractClient.Sensors.SensorType sensorType, InteractClient.Sensors.SensorDelay interval = InteractClient.Sensors.SensorDelay.Default)
        {
            Android.Hardware.SensorDelay delay = Android.Hardware.SensorDelay.Normal;
            switch (interval)
            {
            case InteractClient.Sensors.SensorDelay.Fastest: delay = Android.Hardware.SensorDelay.Fastest; break;

            case InteractClient.Sensors.SensorDelay.Game: delay = Android.Hardware.SensorDelay.Game; break;

            case InteractClient.Sensors.SensorDelay.Ui: delay = Android.Hardware.SensorDelay.Ui; break;
            }

            switch (sensorType)
            {
            case InteractClient.Sensors.SensorType.AcceleroMeter:
                if (sensorAccelerometer != null)
                {
                    sensorManager.RegisterListener(this, sensorAccelerometer, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: AcceleroMeter not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Gyroscope:
                if (sensorGyroscope != null)
                {
                    sensorManager.RegisterListener(this, sensorGyroscope, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Gyroscope not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.MagnetoMeter:
                if (sensorMagnetometer != null)
                {
                    sensorManager.RegisterListener(this, sensorMagnetometer, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Magnetometer not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Compass:
                if (sensorCompass != null)
                {
                    sensorManager.RegisterListener(this, sensorCompass, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Compass not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Light:
                if (sensorLight != null)
                {
                    sensorManager.RegisterListener(this, sensorLight, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Light not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Pressure:
                if (sensorPressure != null)
                {
                    sensorManager.RegisterListener(this, sensorPressure, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Pressure not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Proximity:
                if (sensorProximity != null)
                {
                    sensorManager.RegisterListener(this, sensorProximity, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Proximity not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.LinearAcceleration:
                if (sensorLinearAcceleration != null)
                {
                    sensorManager.RegisterListener(this, sensorLinearAcceleration, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Linear Acceleration not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Rotation:
                if (sensorRotation != null)
                {
                    sensorManager.RegisterListener(this, sensorRotation, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Rotation not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.GameRotation:
                if (sensorGameRotation != null)
                {
                    sensorManager.RegisterListener(this, sensorGameRotation, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Game Rotation not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Humidity:
                if (sensorHumidity != null)
                {
                    sensorManager.RegisterListener(this, sensorHumidity, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Humidity not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.AmbientTemperature:
                if (sensorAmbientTemperature != null)
                {
                    sensorManager.RegisterListener(this, sensorAmbientTemperature, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Ambient Temperature not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.SignificantMotion:
                if (sensorSignificantMotion != null)
                {
                    sensorManager.RequestTriggerSensor(TriggerEventListener, sensorSignificantMotion);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Significant Motion not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.StepDetector:
                if (sensorStepDetector != null)
                {
                    sensorManager.RegisterListener(this, sensorStepDetector, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Step Detector not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.StepCounter:
                if (sensorStepCounter != null)
                {
                    sensorManager.RegisterListener(this, sensorStepCounter, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Step Counter not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.HeartRate:
                if (sensorHeartRate != null)
                {
                    sensorManager.RegisterListener(this, sensorHeartRate, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Heart Rate not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Pose:
                if (sensorPose != null)
                {
                    sensorManager.RegisterListener(this, sensorPose, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Pose not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Stationary:
                if (sensorStationary != null)
                {
                    sensorManager.RegisterListener(this, sensorStationary, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Stationary not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Motion:
                if (sensorMotion != null)
                {
                    sensorManager.RegisterListener(this, sensorMotion, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Motion not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.HeartBeat:
                if (sensorHeartBeat != null)
                {
                    sensorManager.RegisterListener(this, sensorHeartBeat, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Heart Beat not available.");
                }
                break;

            case InteractClient.Sensors.SensorType.Tilt:
                if (sensorMagnetometer != null && sensorAccelerometer != null)
                {
                    sensorManager.RegisterListener(this, sensorMagnetometer, delay);
                    sensorManager.RegisterListener(this, sensorAccelerometer, delay);
                }
                else
                {
                    Network.Sender.WriteLog("Sensor: Tilt not available.");
                }
                break;
            }
            sensorStatus[sensorType] = true;
        }
Ejemplo n.º 2
0
        public void Stop(InteractClient.Sensors.SensorType sensorType)
        {
            switch (sensorType)
            {
            case InteractClient.Sensors.SensorType.AcceleroMeter:
                if (sensorAccelerometer != null && sensorStatus[InteractClient.Sensors.SensorType.Tilt] == false)
                {
                    sensorManager.UnregisterListener(this, sensorAccelerometer);
                }
                break;

            case InteractClient.Sensors.SensorType.Gyroscope:
                if (sensorGyroscope != null)
                {
                    sensorManager.UnregisterListener(this, sensorGyroscope);
                }
                break;

            case InteractClient.Sensors.SensorType.MagnetoMeter:
                if (sensorMagnetometer != null && sensorStatus[InteractClient.Sensors.SensorType.Tilt] == false)
                {
                    sensorManager.UnregisterListener(this, sensorMagnetometer);
                }
                break;

            case InteractClient.Sensors.SensorType.Compass:
                if (sensorCompass != null)
                {
                    sensorManager.UnregisterListener(this, sensorCompass);
                }
                break;

            case InteractClient.Sensors.SensorType.Light:
                if (sensorLight != null)
                {
                    sensorManager.UnregisterListener(this, sensorLight);
                }
                break;

            case InteractClient.Sensors.SensorType.Pressure:
                if (sensorPressure != null)
                {
                    sensorManager.UnregisterListener(this, sensorPressure);
                }
                break;

            case InteractClient.Sensors.SensorType.Proximity:
                if (sensorProximity != null)
                {
                    sensorManager.UnregisterListener(this, sensorProximity);
                }
                break;

            case InteractClient.Sensors.SensorType.LinearAcceleration:
                if (sensorLinearAcceleration != null)
                {
                    sensorManager.UnregisterListener(this, sensorLinearAcceleration);
                }
                break;

            case InteractClient.Sensors.SensorType.Rotation:
                if (sensorRotation != null)
                {
                    sensorManager.UnregisterListener(this, sensorRotation);
                }
                break;

            case InteractClient.Sensors.SensorType.GameRotation:
                if (sensorGameRotation != null)
                {
                    sensorManager.UnregisterListener(this, sensorGameRotation);
                }
                break;

            case InteractClient.Sensors.SensorType.Humidity:
                if (sensorHumidity != null)
                {
                    sensorManager.UnregisterListener(this, sensorHumidity);
                }
                break;

            case InteractClient.Sensors.SensorType.AmbientTemperature:
                if (sensorAmbientTemperature != null)
                {
                    sensorManager.UnregisterListener(this, sensorAmbientTemperature);
                }
                break;

            case InteractClient.Sensors.SensorType.SignificantMotion:
                if (sensorSignificantMotion != null)
                {
                    sensorManager.CancelTriggerSensor(TriggerEventListener, sensorSignificantMotion);
                }
                break;

            case InteractClient.Sensors.SensorType.StepDetector:
                if (sensorStepDetector != null)
                {
                    sensorManager.CancelTriggerSensor(TriggerEventListener, sensorStepDetector);
                }
                break;

            case InteractClient.Sensors.SensorType.StepCounter:
                if (sensorStepCounter != null)
                {
                    sensorManager.UnregisterListener(this, sensorStepCounter);
                }
                break;

            case InteractClient.Sensors.SensorType.HeartRate:
                if (sensorHeartRate != null)
                {
                    sensorManager.UnregisterListener(this, sensorHeartRate);
                }
                break;

            case InteractClient.Sensors.SensorType.Pose:
                if (sensorPose != null)
                {
                    sensorManager.UnregisterListener(this, sensorPose);
                }
                break;

            case InteractClient.Sensors.SensorType.Stationary:
                if (sensorStationary != null)
                {
                    sensorManager.UnregisterListener(this, sensorStationary);
                }
                break;

            case InteractClient.Sensors.SensorType.Motion:
                if (sensorMotion != null)
                {
                    sensorManager.UnregisterListener(this, sensorMotion);
                }
                break;

            case InteractClient.Sensors.SensorType.HeartBeat:
                if (sensorHeartBeat != null)
                {
                    sensorManager.UnregisterListener(this, sensorHeartBeat);
                }
                break;

            case InteractClient.Sensors.SensorType.Tilt:
                if (sensorAccelerometer != null && sensorStatus[InteractClient.Sensors.SensorType.AcceleroMeter] == false)
                {
                    sensorManager.UnregisterListener(this, sensorAccelerometer);
                }
                if (sensorMagnetometer != null && sensorStatus[InteractClient.Sensors.SensorType.MagnetoMeter] == false)
                {
                    sensorManager.UnregisterListener(this, sensorMagnetometer);
                }
                break;
            }
            sensorStatus[sensorType] = false;
        }
Ejemplo n.º 3
0
 public bool IsActive(InteractClient.Sensors.SensorType sensorType)
 {
     return(sensorStatus[sensorType]);
 }