namespace Tizen.Sensor
{
/// <summary>
- /// UltravioletSensor Class. Used for registering callbacks for ultraviolet sensor and getting ultraviolet data
- /// /// </summary>
+ /// The UltravioletSensor class is used for registering callbacks for the ultraviolet sensor and getting the ultraviolet data.
+ /// </summary>
public sealed class UltravioletSensor : Sensor
{
private static string UltravioletSensorKey = "http://tizen.org/feature/sensor.ultraviolet";
/// <summary>
/// Gets the value of the ultraviolet sensor.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <value> The ultraviolet index. </value>
public float UltravioletIndex { get; private set; } = float.MinValue;
/// <summary>
- /// Returns true or false based on whether ultraviolet sensor is supported by device.
+ /// Returns true or false based on whether the ultraviolet sensor is supported by the device.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <value><c>true</c> if supported; otherwise <c>false</c>.</value>
public static bool IsSupported
{
get
/// <summary>
/// Returns the number of ultraviolet sensors available on the device.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <value> The count of ultraviolet sensors. </value>
public static int Count
{
get
/// <summary>
/// Initializes a new instance of the <see cref="Tizen.Sensor.UltravioletSensor"/> class.
/// </summary>
- /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
- /// <exception cref="NotSupportedException">Thrown when the sensor is not supported</exception>
- /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ /// <since_tizen> 3 </since_tizen>
+ /// <feature>http://tizen.org/feature/sensor.ultraviolet</feature>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the sensor is not supported.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
/// <param name='index'>
- /// Index. Default value for this is 0. Index refers to a particular ultraviolet sensor in case of multiple sensors
+ /// Index. Default value for this is 0. Index refers to a particular ultraviolet sensor in case of multiple sensors.
/// </param>
public UltravioletSensor(uint index = 0) : base(index)
{
}
/// <summary>
- /// Event Handler for storing the callback functions for event corresponding to change in ultraviolet sensor data.
+ /// An event handler for storing the callback functions for the event corresponding to the change in the ultraviolet sensor data.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public event EventHandler<UltravioletSensorDataUpdatedEventArgs> DataUpdated;
return count;
}
- protected internal override void EventListenStart()
+ private static Interop.SensorListener.SensorEventCallback _callback;
+
+ internal override void EventListenStart()
{
- int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero);
+ _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => {
+ Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr);
+
+ TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
+ UltravioletIndex = sensorData.values[0];
+
+ DataUpdated?.Invoke(this, new UltravioletSensorDataUpdatedEventArgs(sensorData.values[0]));
+ };
+
+ int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero);
if (error != (int)SensorError.None)
{
Log.Error(Globals.LogTag, "Error setting event callback for ultraviolet sensor");
}
}
- protected internal override void EventListenStop()
+ internal override void EventListenStop()
{
int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle);
if (error != (int)SensorError.None)
throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for ultraviolet");
}
}
-
- private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data)
- {
- Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr);
- TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
- UltravioletIndex = sensorData.values[0];
-
- DataUpdated?.Invoke(this, new UltravioletSensorDataUpdatedEventArgs(sensorData.values[0]));
- }
}
}