1 // Copyright 2016 by Samsung Electronics, Inc.,
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
11 namespace Tizen.System.Sensor
13 public class WalkingActivityDetector : ActivityDetector
16 /// Gets the state of walking activity detector
18 public DetectorState Walking { get; private set; }
21 /// Returns true or false based on whether walking activity detector is supported by device.
23 public static bool IsSupported
27 Log.Info(Globals.LogTag, "Checking if the walking activity detector is supported");
28 return CheckIfSupported();
33 /// Returns the number of walking activity detector available on the device.
35 public static int Count
39 Log.Info(Globals.LogTag, "Getting the count of walking activity detectors");
45 /// Initializes a new instance of the <see cref="Tizen.System.Sensor.walkingActivityDetector"/> class.
47 /// <param name='index'>
48 /// Index. Default value for this is 0. Index refers to a particular walking activity detector in case of multiple sensors.
50 public WalkingActivityDetector(int index) : base(index)
52 SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.Walking);
53 Log.Info(Globals.LogTag, "Creating walking activity gesture detector object");
56 private static bool CheckIfSupported()
59 int error = Interop.SensorManager.SensorIsSupported(SensorType.WalkingActivityDetector, out isSupported);
60 if (error != (int)SensorError.None)
62 Log.Error(Globals.LogTag, "Error checking if walking activity detector is supported");
68 private static int GetCount()
72 int error = Interop.SensorManager.GetSensorList(SensorType.WalkingActivityDetector, out list, out count);
73 if (error != (int)SensorError.None)
75 Log.Error(Globals.LogTag, "Error getting sensor list for walking activity detector");
79 Interop.Libc.Free(list);
84 /// Event Handler for storing the callback functions for event corresponding to change in walking activity gesture detector data.
86 public event EventHandler<WalkingActivityDetectorDataUpdatedEventArgs> DataUpdated;
88 protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data)
90 Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr);
91 TimeSpan = new TimeSpan((Int64)sensorData.timestamp);
92 Walking = (DetectorState)sensorData.values[0];
93 ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy;
95 DataUpdated?.Invoke(this, new WalkingActivityDetectorDataUpdatedEventArgs(sensorData.values[0]));
98 internal override SensorType GetSensorType()
100 return SensorType.WalkingActivityDetector;