From f999cc62b2a55557dc8dc96c4c43602be71fe160 Mon Sep 17 00:00:00 2001
From: pvschakradhar <48746416+pvschakradhar@users.noreply.github.com>
Date: Mon, 16 Dec 2019 12:19:04 +0530
Subject: [PATCH] [Sensor] Addition of initial sensor values (#1153)
* addition of initial sensor values
* method name changed
* addition of ReadData() method in sensor class
* comment updated
* adding abstract method
* change in access modifier
* access modifier changed
---
src/Tizen.Sensor/Interop/Interop.Sensor.cs | 3 +++
.../Tizen.Sensor/Plugins/Accelerometer.cs | 19 ++++++++++++++++++
.../Plugins/FaceDownGestureDetector.cs | 17 ++++++++++++++++
.../Tizen.Sensor/Plugins/GravitySensor.cs | 19 ++++++++++++++++++
src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs | 19 ++++++++++++++++++
.../Plugins/GyroscopeRotationVectorSensor.cs | 21 ++++++++++++++++++++
.../Tizen.Sensor/Plugins/HeartRateMonitor.cs | 17 ++++++++++++++++
.../Tizen.Sensor/Plugins/HumiditySensor.cs | 17 ++++++++++++++++
.../Plugins/InVehicleActivityDetector.cs | 18 +++++++++++++++++
.../Tizen.Sensor/Plugins/LightSensor.cs | 17 ++++++++++++++++
.../Plugins/LinearAccelerationSensor.cs | 19 ++++++++++++++++++
.../Tizen.Sensor/Plugins/Magnetometer.cs | 19 ++++++++++++++++++
.../Plugins/MagnetometerRotationVectorSensor.cs | 21 ++++++++++++++++++++
.../Tizen.Sensor/Plugins/OrientationSensor.cs | 19 ++++++++++++++++++
src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs | 23 ++++++++++++++++++++++
.../Tizen.Sensor/Plugins/PickUpGestureDetector.cs | 17 ++++++++++++++++
.../Tizen.Sensor/Plugins/PressureSensor.cs | 17 ++++++++++++++++
.../Tizen.Sensor/Plugins/ProximitySensor.cs | 17 ++++++++++++++++
.../Tizen.Sensor/Plugins/RotationVectorSensor.cs | 21 ++++++++++++++++++++
.../Plugins/RunningActivityDetector.cs | 18 +++++++++++++++++
.../Tizen.Sensor/Plugins/SleepMonitor.cs | 17 ++++++++++++++++
.../Plugins/StationaryActivityDetector.cs | 18 +++++++++++++++++
.../Tizen.Sensor/Plugins/TemperatureSensor.cs | 17 ++++++++++++++++
.../Tizen.Sensor/Plugins/UltravioletSensor.cs | 17 ++++++++++++++++
.../Tizen.Sensor/Plugins/UncalibratedGyroscope.cs | 22 +++++++++++++++++++++
.../Plugins/UncalibratedMagnetometer.cs | 22 +++++++++++++++++++++
.../Plugins/WalkingActivityDetector.cs | 18 +++++++++++++++++
.../Tizen.Sensor/Plugins/WristUpGestureDetector.cs | 17 ++++++++++++++++
src/Tizen.Sensor/Tizen.Sensor/Sensor.cs | 5 +++++
29 files changed, 511 insertions(+)
diff --git a/src/Tizen.Sensor/Interop/Interop.Sensor.cs b/src/Tizen.Sensor/Interop/Interop.Sensor.cs
index 160c033..daa838d 100644
--- a/src/Tizen.Sensor/Interop/Interop.Sensor.cs
+++ b/src/Tizen.Sensor/Interop/Interop.Sensor.cs
@@ -90,6 +90,9 @@ internal static partial class Interop
[DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_attribute_int")]
internal static extern int SetAttribute(IntPtr listenerHandle, SensorAttribute sensorAttribute, int option);
+
+ [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_read_data")]
+ internal static extern int ReadData(IntPtr listenerHandle, out SensorEventStruct data);
}
internal static class SensorManager
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs
index b8f7e89..9f7efc9 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs
@@ -117,6 +117,25 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read accelerometer data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading accelerometer data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading accelerometer data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs
index 2d6a301..70346b8 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs
@@ -98,6 +98,23 @@ namespace Tizen.Sensor
}
///
+ /// Read face down gesture detector data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading face down gesture detector data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading face down gesture detector data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ FaceDown = (DetectorState)sensorData.values[0];
+ }
+
+ ///
/// An event handler for storing the callback functions for the event corresponding to the change in the face down gesture detector data.
///
/// 3
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs
index f8b1d40..e71a2a7 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs
@@ -143,6 +143,25 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read gravity sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading gravity sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading gravity sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs
index a1a859d..0015d26 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs
@@ -118,6 +118,25 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read gyroscope data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading gyroscope data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading gyroscope data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs
index ae0ad4e..699eaec 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs
@@ -132,6 +132,27 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read gyroscope rotation vector sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading gyroscope rotation vector sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading gyroscope rotation vector sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ W = sensorData.values[3];
+ Accuracy = sensorData.accuracy;
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs
index 010cd52..d2f7a08 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs
@@ -106,6 +106,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read heart rate monitor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading heart rate monitor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading heart rate monitor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ HeartRate = (int)sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs
index 387138b..dfb1d2c 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs
@@ -104,6 +104,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read humidity sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading humidity sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading humidity sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Humidity = sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs
index 233b079..3b2958a 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs
@@ -94,6 +94,24 @@ namespace Tizen.Sensor
}
///
+ /// Read in-vehicle activity detector data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading in-vehicle activity detector data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading in-vehicle activity detector data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ InVehicle = (DetectorState)sensorData.values[0];
+ ActivityAccuracy = (SensorDataAccuracy)sensorData.accuracy;
+ }
+
+ ///
/// An event handler for storing the callback functions for the event corresponding to the change in the in-vehicle activity detector data.
///
/// 3
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs
index deff1c6..af68a5b 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs
@@ -104,6 +104,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read light sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading light sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading light sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Level = sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs
index 46bd57a..4d80669 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs
@@ -143,6 +143,25 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read linear acceleration sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading linear acceleration sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading linear acceleration sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs
index 0b13b71..ac06bc2 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs
@@ -143,6 +143,25 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read magnetometer data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading magnetometer data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading magnetometer data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs
index 288af33..fa3480b 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs
@@ -169,6 +169,27 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read magnetometer rotation vector sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading magnetometer rotation vector sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading magnetometer rotation vector sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ W = sensorData.values[3];
+ Accuracy = sensorData.accuracy;
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs
index 866b29f..674be0c 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs
@@ -143,6 +143,25 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read orientation sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading orientation sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading orientation sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Azimuth = sensorData.values[0];
+ Pitch = sensorData.values[1];
+ Roll = sensorData.values[2];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs
index 7408d87..a175477 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs
@@ -156,6 +156,29 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read pedometer sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct pedoSensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out pedoSensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading pedometer sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading pedometer sensor data failed");
+ }
+
+ StepCount = (uint)pedoSensorData.values[0];
+ WalkStepCount = (uint)pedoSensorData.values[1];
+ RunStepCount = (uint)pedoSensorData.values[2];
+ MovingDistance = pedoSensorData.values[3];
+ CalorieBurned = pedoSensorData.values[4];
+ LastSpeed = pedoSensorData.values[5];
+ LastSteppingFrequency = pedoSensorData.values[6];
+ LastStepStatus = (PedometerState)pedoSensorData.values[7];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs
index 1f54973..fc9ccd6 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs
@@ -110,6 +110,23 @@ namespace Tizen.Sensor
}
///
+ /// Read pick up gesture detector data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading pick up gesture detector data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading pick up gesture detector data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ PickUp = (DetectorState)sensorData.values[0];
+ }
+
+ ///
/// An event handler for storing the callback functions for the event corresponding to the change in the pick up gesture detector data.
///
/// 3
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs
index 03a8eff..9d5aaa2 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs
@@ -105,6 +105,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read pressure sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading pressure sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading pressure sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Pressure = sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs
index ddcf132..dec5a49 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs
@@ -104,6 +104,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read proximity sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading proximity sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading proximity sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Proximity = (ProximitySensorState)sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs
index 724e4c2..8de60c7 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs
@@ -157,6 +157,27 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read rotation vector sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading rotation vector sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading rotation vector sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ W = sensorData.values[3];
+ Accuracy = sensorData.accuracy;
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs
index c8cb810..db8c7e7 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs
@@ -94,6 +94,24 @@ namespace Tizen.Sensor
}
///
+ /// Read running activity detector data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading running activity detector data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading running activity detector data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Running = (DetectorState)sensorData.values[0];
+ ActivityAccuracy = (SensorDataAccuracy)sensorData.accuracy;
+ }
+
+ ///
/// An event handler for storing the callback functions for the event corresponding to the change in running the activity detector data.
///
/// 3
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs
index 65d06d6..edb7ca7 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs
@@ -108,6 +108,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read sleep monitor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading sleep monitor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading sleep monitor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ SleepState = (SleepMonitorState)sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs
index 98cf01a..c8cfd3a 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs
@@ -94,6 +94,24 @@ namespace Tizen.Sensor
}
///
+ /// Read stationary activity detector data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading stationary activity detector data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading stationary activity detector data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Stationary = (DetectorState)sensorData.values[0];
+ ActivityAccuracy = (SensorDataAccuracy)sensorData.accuracy;
+ }
+
+ ///
/// An event handler for storing the callback functions for the event corresponding to the change in the stationary activity detector data.
///
/// 3
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs
index 2518e70..ba6df4e 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs
@@ -105,6 +105,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read temperature sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading temperature sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading temperature sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Temperature = sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs
index ec80d52..ec900da 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs
@@ -105,6 +105,23 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read ultraviolet sensor data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading ultraviolet sensor data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading ultraviolet sensor data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ UltravioletIndex = sensorData.values[0];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs
index ff1e28c..3c1e20e 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs
@@ -139,6 +139,28 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read uncalibrated gyroscope data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading uncalibrated gyroscope data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading uncalibrated gyroscope data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ BiasX = sensorData.values[3];
+ BiasY = sensorData.values[4];
+ BiasZ = sensorData.values[5];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs
index 948e863..f87b09e 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs
@@ -164,6 +164,28 @@ namespace Tizen.Sensor
return count;
}
+ ///
+ /// Read uncalibrated magnetometer data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading uncalibrated magnetometer data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading uncalibrated magnetometer data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ X = sensorData.values[0];
+ Y = sensorData.values[1];
+ Z = sensorData.values[2];
+ BiasX = sensorData.values[3];
+ BiasY = sensorData.values[4];
+ BiasZ = sensorData.values[5];
+ }
+
private static Interop.SensorListener.SensorEventCallback _callback;
internal override void EventListenStart()
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs
index 0a28317..8b9d104 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs
@@ -94,6 +94,24 @@ namespace Tizen.Sensor
}
///
+ /// Read walking activity detector data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading walking activity detector data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading walking activity detector data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ Walking = (DetectorState)sensorData.values[0];
+ ActivityAccuracy = (SensorDataAccuracy)sensorData.accuracy;
+ }
+
+ ///
/// An event handler for storing the callback functions for the event corresponding to the change in the walking activity gesture detector data.
///
/// 3
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs
index 93ab50d..27f488a 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs
@@ -98,6 +98,23 @@ namespace Tizen.Sensor
}
///
+ /// Read wrist up gesture detector data synchronously.
+ ///
+ internal override void ReadData()
+ {
+ Interop.SensorEventStruct sensorData;
+ int error = Interop.SensorListener.ReadData(ListenerHandle, out sensorData);
+ if (error != (int)SensorError.None)
+ {
+ Log.Error(Globals.LogTag, "Error reading wrist up gesture detector data");
+ throw SensorErrorFactory.CheckAndThrowException(error, "Reading wrist up gesture detector data failed");
+ }
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ WristUp = (DetectorState)sensorData.values[0];
+ }
+
+ ///
/// An event handler for storing the callback functions for the event corresponding to the change in the wrist up gesture detector data.
///
/// 3
diff --git a/src/Tizen.Sensor/Tizen.Sensor/Sensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Sensor.cs
index 0910188..3ebcfbb 100755
--- a/src/Tizen.Sensor/Tizen.Sensor/Sensor.cs
+++ b/src/Tizen.Sensor/Tizen.Sensor/Sensor.cs
@@ -47,6 +47,10 @@ namespace Tizen.Sensor
private IntPtr _sensorHandle = IntPtr.Zero;
private IntPtr _listenerHandle = IntPtr.Zero;
+ ///
+ /// Read a sensor data synchronously.
+ ///
+ internal abstract void ReadData();
internal abstract SensorType GetSensorType();
internal abstract void EventListenStart();
internal abstract void EventListenStop();
@@ -326,6 +330,7 @@ namespace Tizen.Sensor
Log.Error(Globals.LogTag, "Error starting sensor");
throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Start Sensor Listener");
}
+ ReadData();
EventListenStart();
_isSensing = true;
Log.Info(Globals.LogTag, "Sensor started");
--
2.7.4