From: kibak.yoon Date: Wed, 19 Oct 2016 02:00:58 +0000 (+0900) Subject: csapi-sensor: change namespace from Tizen.System.Sensor to Tizen.Sensor X-Git-Tag: submit/tizen/20161214.063015~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5fd824d8f707ca896978f0ef8f12d8188167553;p=platform%2Fcore%2Fcsapi%2Fsensor.git csapi-sensor: change namespace from Tizen.System.Sensor to Tizen.Sensor Change-Id: I518268701bd3f16629bfbdb6a93a7d8f204f5985 Signed-off-by: kibak.yoon --- diff --git a/Tizen.Sensor/Interop/Interop.Libraries.cs b/Tizen.Sensor/Interop/Interop.Libraries.cs new file mode 100644 index 0000000..2b42537 --- /dev/null +++ b/Tizen.Sensor/Interop/Interop.Libraries.cs @@ -0,0 +1,16 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +internal static partial class Interop +{ + internal static partial class Libraries + { + public const string Sensor = "libcapi-system-sensor.so.0"; + public const string Libc = "libc.so.6"; + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Interop/Interop.Sensor.cs b/Tizen.Sensor/Interop/Interop.Sensor.cs new file mode 100644 index 0000000..819d2f7 --- /dev/null +++ b/Tizen.Sensor/Interop/Interop.Sensor.cs @@ -0,0 +1,128 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; +using System.Runtime.InteropServices; +using Tizen.Sensor; + +internal static partial class Interop +{ + internal static class Sensor + { + //Sensor Hardware CAPI + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_name")] + internal static extern int GetName(IntPtr sensorhandle, out String name); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_vendor")] + internal static extern int GetVendor(IntPtr sensorHandle, out String vendor); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_type")] + internal static extern int GetType(IntPtr sensorHandle, out SensorType type); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_min_range")] + internal static extern int GetMinRange(IntPtr sensorHandle, out float minRange); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_max_range")] + internal static extern int GetMaxRange(IntPtr sensorHandle, out float maxRange); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_resolution")] + internal static extern int GetResolution(IntPtr sensorHandle, out float resolution); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_min_interval")] + internal static extern int GetMinInterval(IntPtr sensorHandle, out int minInterval); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_fifo_count")] + internal static extern int GetFifoCount(IntPtr sensorHandle, out int fifoCount); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_max_batch_count")] + internal static extern int GetMaxBatchCount(IntPtr sensorHandle, out int maxBatchCount); + } + internal static class SensorListener + { + //Sensor Listener CAPI + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void SensorEventCallback(IntPtr sensorHandle, IntPtr eventData, IntPtr data); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void SensorAccuracyCallback(IntPtr sensorHandle, ulong timestamp, SensorDataAccuracy accuracy, IntPtr data); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_create_listener")] + internal static extern int CreateListener(IntPtr sensorHandle, out IntPtr listenerHandle); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_destroy_listener")] + internal static extern int DestroyListener(IntPtr listenerHandle); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_start")] + internal static extern int StartListener(IntPtr listenerHandle); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_stop")] + internal static extern int StopListener(IntPtr listenerHandle); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_event_cb")] + internal static extern int SetEventCallback(IntPtr listenerHandle, uint intervalMs, SensorEventCallback callback, IntPtr data); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_unset_event_cb")] + internal static extern int UnsetEventCallback(IntPtr listernerHandle); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_accuracy_cb")] + internal static extern int SetAccuracyCallback(IntPtr listenerHandle, uint intervalMs, SensorAccuracyCallback callback, IntPtr data); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_unset_accuracy_cb")] + internal static extern int UnsetAccuracyCallback(IntPtr listernerHandle); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_interval")] + internal static extern int SetInterval(IntPtr listenerHandle, uint intervalMs); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_max_batch_latency")] + internal static extern int SetMaxBatchLatency(IntPtr listenerHandle, uint maxBatchLatency); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_attribute_int")] + internal static extern int SetAttribute(IntPtr listenerHandle, SensorAttribute sensorAttribute, int option); + } + + internal static class SensorManager + { + //Sensor Manager CAPI + [DllImport(Libraries.Sensor, EntryPoint = "sensor_is_supported")] + internal static extern int SensorIsSupported(SensorType type, out bool supported); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_default_sensor")] + internal static extern int GetDefaultSensor(SensorType type, out IntPtr sensor); + + [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_sensor_list")] + internal static extern int GetSensorList(SensorType type, out IntPtr list, out int sensor_count); + } + + internal static partial class Libc + { + [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Free(IntPtr ptr); + } + + [StructLayout(LayoutKind.Sequential, Pack = 0)] + internal struct SensorEventStruct + { + internal SensorDataAccuracy accuracy; + internal UInt64 timestamp; + internal int value_count; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + internal float[] values; + } + + internal static IntPtr[] IntPtrToIntPtrArray(IntPtr unmanagedArray, int size) + { + IntPtr[] managedArray = new IntPtr[size]; + Marshal.Copy(unmanagedArray, managedArray, 0, size); + return managedArray; + } + + internal static SensorEventStruct IntPtrToEventStruct(IntPtr unmanagedVariable) + { + SensorEventStruct outStruct = (SensorEventStruct)Marshal.PtrToStructure(unmanagedVariable, typeof(SensorEventStruct)); + return outStruct; + } +} diff --git a/Tizen.Sensor/Properties/AssemblyInfo.cs b/Tizen.Sensor/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ff43f17 --- /dev/null +++ b/Tizen.Sensor/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("Tizen.Sensor")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Samsung Electronics")] +[assembly: AssemblyProduct("Tizen.Sensor")] +[assembly: AssemblyCopyright("Copyright (c) 2015 Samsung Electronics Co., Ltd")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.0.0")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Tizen.Sensor/Tizen.Sensor.Net45.csproj b/Tizen.Sensor/Tizen.Sensor.Net45.csproj new file mode 100644 index 0000000..5a8843d --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor.Net45.csproj @@ -0,0 +1,128 @@ + + + + Debug + AnyCPU + {15FBE509-20D4-4D66-A8FC-5B0AC807BB88} + Library + Properties + Tizen.Sensor + Tizen.Sensor + 512 + v4.5 + + + true + full + false + bin\Debug\Net45\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\Net45\ + TRACE + prompt + 4 + false + false + + + true + + + Tizen.Sensor.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tizen.Sensor/Tizen.Sensor.Net45.project.json b/Tizen.Sensor/Tizen.Sensor.Net45.project.json new file mode 100755 index 0000000..503a8ff --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor.Net45.project.json @@ -0,0 +1,12 @@ +{ + "dependencies": { + "Tizen": "1.0.1", + "Tizen.System": "1.0.2" + }, + "frameworks": { + "net45": {} + }, + "runtimes": { + "win": {} + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor.csproj b/Tizen.Sensor/Tizen.Sensor.csproj new file mode 100644 index 0000000..a08d010 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor.csproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + {CB655C6A-F73B-448E-913C-CA4DCBC5E401} + Library + Properties + Tizen.Sensor + Tizen.Sensor + 512 + + + .NETStandard + v1.3 + .NETStandard,Version=v1.3 + false + true + $(NoWarn);1701;1702 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + false + + + true + + + Tizen.Sensor.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) + true + + diff --git a/Tizen.Sensor/Tizen.Sensor.nuspec b/Tizen.Sensor/Tizen.Sensor.nuspec new file mode 100644 index 0000000..1ec417d --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor.nuspec @@ -0,0 +1,16 @@ + + + + Tizen.Sensor + $version$ + Tizen Developers + Sensor API for Tizen.Net + + + + + + + + + diff --git a/Tizen.Sensor/Tizen.Sensor.project.json b/Tizen.Sensor/Tizen.Sensor.project.json new file mode 100644 index 0000000..5abf875 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor.project.json @@ -0,0 +1,10 @@ +{ + "dependencies": { + "NETStandard.Library": "1.6.0", + "Tizen": "1.0.1", + "Tizen.System": "1.0.2" + }, + "frameworks": { + "netstandard1.3": {} + } +} diff --git a/Tizen.Sensor/Tizen.Sensor.snk b/Tizen.Sensor/Tizen.Sensor.snk new file mode 100644 index 0000000..e480db4 Binary files /dev/null and b/Tizen.Sensor/Tizen.Sensor.snk differ diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs new file mode 100644 index 0000000..4be7082 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs @@ -0,0 +1,40 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Accelerometer changed event arguments. Class for storing the data returned by accelerometer + /// + public class AccelerometerDataUpdatedEventArgs : EventArgs + { + internal AccelerometerDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// + /// Gets the X component of the acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the acceleration. + /// + public float Z { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/FaceDownGestureDetectorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/FaceDownGestureDetectorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..7345195 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/FaceDownGestureDetectorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// FaceDownGestureDetector changed event arguments. Class for storing the data returned by face down gesture detector. + /// + public class FaceDownGestureDetectorDataUpdatedEventArgs : EventArgs + { + internal FaceDownGestureDetectorDataUpdatedEventArgs(float state) + { + FaceDown = (DetectorState) state; + } + + /// + /// Gets the face down state. + /// + public DetectorState FaceDown { get; private set; } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..74ad299 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs @@ -0,0 +1,40 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// GravitySensor changed event arguments. Class for storing the data returned by gravity sensor + /// + public class GravitySensorDataUpdatedEventArgs : EventArgs + { + internal GravitySensorDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// + /// Gets the X component of the gravity. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the gravity. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the gravity. + /// + public float Z { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/GyroscopeDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/GyroscopeDataUpdatedEventArgs.cs new file mode 100644 index 0000000..72a9c26 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/GyroscopeDataUpdatedEventArgs.cs @@ -0,0 +1,40 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Gyroscope changed event arguments. Class for storing the data returned by gyroscope + /// + public class GyroscopeDataUpdatedEventArgs : EventArgs + { + internal GyroscopeDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// + /// Gets the X component of the gyroscope data. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the gyroscope data. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the gyroscope data. + /// + public float Z { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/GyroscopeRotationVectorSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/GyroscopeRotationVectorSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..2b599cb --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/GyroscopeRotationVectorSensorDataUpdatedEventArgs.cs @@ -0,0 +1,52 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// GyroscopeRotationVectorSensor changed event arguments. Class for storing the data returned by gyroscope rotation vector sensor + /// + public class GyroscopeRotationVectorSensorDataUpdatedEventArgs : EventArgs + { + internal GyroscopeRotationVectorSensorDataUpdatedEventArgs(float[] values, SensorDataAccuracy accuracy) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + W = values[3]; + Accuracy = accuracy; + } + + /// + /// Gets the X component of the gyroscope rotation vector. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the gyroscope rotation vector. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the gyroscope rotation vector. + /// + public float Z { get; private set; } + + /// + /// Gets the W component of the gyroscope rotation vector. + /// + public float W { get; private set; } + + /// + /// Gets the accuracy of the gyroscope rotation vector data. + /// + public SensorDataAccuracy Accuracy { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/HeartRateMonitorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/HeartRateMonitorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..f7740a4 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/HeartRateMonitorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// HeartRateMonitor changed event arguments. Class for storing the data returned by heart rate monitor + /// + public class HeartRateMonitorDataUpdatedEventArgs : EventArgs + { + internal HeartRateMonitorDataUpdatedEventArgs(int heartRate) + { + HeartRate = heartRate; + } + + /// + /// Gets the value of the heartRate. + /// + public int HeartRate { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/HumiditySensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/HumiditySensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..19ec84e --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/HumiditySensorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// HumiditySensor changed event arguments. Class for storing the data returned by humidity sensor + /// + public class HumiditySensorDataUpdatedEventArgs : EventArgs + { + internal HumiditySensorDataUpdatedEventArgs(float humidity) + { + Humidity = humidity; + } + + /// + /// Gets the value of the humidity. + /// + public float Humidity { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/InVehicleActivityDetectorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/InVehicleActivityDetectorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..70914a7 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/InVehicleActivityDetectorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// InVehicleActivityDetector changed event arguments. Class for storing the data returned by in-vehicle activity detector + /// + public class InVehicleActivityDetectorDataUpdatedEventArgs : EventArgs + { + internal InVehicleActivityDetectorDataUpdatedEventArgs(float state) + { + InVehicle = (DetectorState) state; + } + + /// + /// Gets the in-vehicle state. + /// + public DetectorState InVehicle { get; private set; } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..b91a33a --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// LightSensor changed event arguments. Class for storing the data returned by light sensor + /// + public class LightSensorDataUpdatedEventArgs : EventArgs + { + internal LightSensorDataUpdatedEventArgs(float level) + { + Level = level; + } + + /// + /// Gets the level of the light. + /// + public float Level { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/LinearAccelerationSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/LinearAccelerationSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..37b1421 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/LinearAccelerationSensorDataUpdatedEventArgs.cs @@ -0,0 +1,40 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// LinearAccelerationSensor changed event arguments. Class for storing the data returned by linear acceleration sensor + /// + public class LinearAccelerationSensorDataUpdatedEventArgs : EventArgs + { + internal LinearAccelerationSensorDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// + /// Gets the X component of the linear acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the linear acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the linear acceleration. + /// + public float Z { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/MagnetometerDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/MagnetometerDataUpdatedEventArgs.cs new file mode 100644 index 0000000..b756784 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/MagnetometerDataUpdatedEventArgs.cs @@ -0,0 +1,40 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Magnetometer changed event arguments. Class for storing the data returned by magnetometer sensor + /// + public class MagnetometerDataUpdatedEventArgs : EventArgs + { + internal MagnetometerDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// + /// Gets the X component of the magnetometer. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the magnetometer. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the magnetometer. + /// + public float Z { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/MagnetometerRotationVectorSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/MagnetometerRotationVectorSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..8087140 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/MagnetometerRotationVectorSensorDataUpdatedEventArgs.cs @@ -0,0 +1,52 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// MagnetometerRotationVectorSensor changed event arguments. Class for storing the data returned by magnetometer rotation vector sensor + /// + public class MagnetometerRotationVectorSensorDataUpdatedEventArgs : EventArgs + { + internal MagnetometerRotationVectorSensorDataUpdatedEventArgs(float[] values, SensorDataAccuracy accuracy) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + W = values[3]; + Accuracy = accuracy; + } + + /// + /// Gets the X component of the magnetometer rotation vector. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the magnetometer rotation vector. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the magnetometer rotation vector. + /// + public float Z { get; private set; } + + /// + /// Gets the W component of the magnetometer rotation vector. + /// + public float W { get; private set; } + + /// + /// Gets the accuracy of the magnetometer rotation vector data. + /// + public SensorDataAccuracy Accuracy { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/OrientationSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/OrientationSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..507c111 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/OrientationSensorDataUpdatedEventArgs.cs @@ -0,0 +1,40 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// OrientationSensor changed event arguments. Class for storing the data returned by orientation sensor + /// + public class OrientationSensorDataUpdatedEventArgs : EventArgs + { + internal OrientationSensorDataUpdatedEventArgs(float[] values) + { + Azimuth = values[0]; + Pitch = values[1]; + Roll = values[2]; + } + + /// + /// Gets the azimuth component of the orientation. + /// + public float Azimuth { get; private set; } + + /// + /// Gets the pitch component of the orientation. + /// + public float Pitch { get; private set; } + + /// + /// Gets the roll component of the orientation. + /// + public float Roll { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/PedometerDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/PedometerDataUpdatedEventArgs.cs new file mode 100644 index 0000000..c767740 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/PedometerDataUpdatedEventArgs.cs @@ -0,0 +1,70 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Pedometer changed event arguments. Class for storing the data returned by pedometer + /// + public class PedometerDataUpdatedEventArgs : EventArgs + { + internal PedometerDataUpdatedEventArgs(float[] values) + { + StepCount = (int) values[0]; + WalkStepCount = (int) values[1]; + RunStepCount = (int) values[2]; + MovingDistance = values[3]; + CalorieBurned = values[4]; + LastSpeed = values[5]; + LastSteppingFrequency = values[6]; + LastStepStatus = (PedometerState) values[7]; + } + + /// + /// Gets the step count + /// + public int StepCount { get; private set; } + + /// + /// Gets the walking step count + /// + public int WalkStepCount { get; private set; } + + /// + /// Gets the running step count + /// + public int RunStepCount { get; private set; } + + /// + /// Gets the moving distance + /// + public float MovingDistance { get; private set; } + + /// + /// Gets the calorie burned + /// + public float CalorieBurned { get; private set; } + + /// + /// Gets the last speed + /// + public float LastSpeed { get; private set; } + + /// + /// Gets the last stepping frequency + /// + public float LastSteppingFrequency { get; private set; } + + /// + /// Gets the last step status + /// + public PedometerState LastStepStatus { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/PickUpGestureDetectorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/PickUpGestureDetectorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..a519edc --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/PickUpGestureDetectorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// PickUpGestureDetector changed event arguments. Class for storing the data returned by pick up gesture detector + /// + public class PickUpGestureDetectorDataUpdatedEventArgs : EventArgs + { + internal PickUpGestureDetectorDataUpdatedEventArgs(float state) + { + PickUp = (DetectorState) state; + } + + /// + /// Gets the pick up state. + /// + public DetectorState PickUp { get; private set; } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..283ca48 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// PressureSensor changed event arguments. Class for storing the data returned by pressure sensor + /// + public class PressureSensorDataUpdatedEventArgs : EventArgs + { + internal PressureSensorDataUpdatedEventArgs(float pressure) + { + Pressure = pressure; + } + + /// + /// Gets the value of the pressure. + /// + public float Pressure { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/ProximitySensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/ProximitySensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..57fb65f --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/ProximitySensorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// ProximitySensor changed event arguments. Class for storing the data returned by proximity sensor + /// + public class ProximitySensorDataUpdatedEventArgs : EventArgs + { + internal ProximitySensorDataUpdatedEventArgs(float proximity) + { + Proximity = (ProximitySensorState) proximity; + } + + /// + /// Gets the proximity state. + /// + public ProximitySensorState Proximity { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/RotationVectorSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/RotationVectorSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..5ab2113 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/RotationVectorSensorDataUpdatedEventArgs.cs @@ -0,0 +1,52 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// RotationVectorSensor changed event arguments. Class for storing the data returned by rotation vector sensor + /// + public class RotationVectorSensorDataUpdatedEventArgs : EventArgs + { + internal RotationVectorSensorDataUpdatedEventArgs(float[] values, SensorDataAccuracy accuracy) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + W = values[3]; + Accuracy = accuracy; + } + + /// + /// Gets the X component of the rotation vector. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the rotation vector. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the rotation vector. + /// + public float Z { get; private set; } + + /// + /// Gets the W component of the rotation vector. + /// + public float W { get; private set;} + + /// + /// Gets the accuracy of the rotation vector data. + /// + public SensorDataAccuracy Accuracy { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/RunningActivityDetectorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/RunningActivityDetectorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..8fe3ea7 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/RunningActivityDetectorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// RunningActivityDetector changed event arguments. Class for storing the data returned by running activity detector + /// + public class RunningActivityDetectorDataUpdatedEventArgs : EventArgs + { + internal RunningActivityDetectorDataUpdatedEventArgs(float state) + { + Running = (DetectorState) state; + } + + /// + /// Gets the running state. + /// + public DetectorState Running { get; private set; } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs new file mode 100644 index 0000000..b89277d --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs @@ -0,0 +1,34 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Sensor accuracy changed event arguments Class. Contains the parameters to be returned through accuracy callback + /// + public class SensorAccuracyChangedEventArgs : EventArgs + { + internal SensorAccuracyChangedEventArgs(TimeSpan timespan, SensorDataAccuracy accuracy) + { + TimeSpan = timespan; + Accuracy = accuracy; + } + + /// + /// Gets the time stamp. + /// + public TimeSpan TimeSpan { get; private set; } + + /// + /// Gets the accuracy. + /// + public SensorDataAccuracy Accuracy { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..80914f9 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// SleepMonitor changed event arguments. Class for storing the data returned by sleep monitor + /// + public class SleepMonitorDataUpdatedEventArgs : EventArgs + { + internal SleepMonitorDataUpdatedEventArgs(int sleepState) + { + SleepState = (SleepMonitorState) sleepState; + } + + /// + /// Gets the value of the sleep state. + /// + public SleepMonitorState SleepState { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/StationaryActivityDetectorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/StationaryActivityDetectorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..4e064d3 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/StationaryActivityDetectorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// StationaryActivityDetector changed event arguments. Class for storing the data returned by stationary activity detector + /// + public class StationaryActivityDetectorDataUpdatedEventArgs : EventArgs + { + internal StationaryActivityDetectorDataUpdatedEventArgs(float state) + { + Stationary = (DetectorState) state; + } + + /// + /// Gets the stationary state. + /// + public DetectorState Stationary { get; private set; } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..0e9a14c --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// TemperatureSensor changed event arguments. Class for storing the data returned by temperature sensor + /// + public class TemperatureSensorDataUpdatedEventArgs : EventArgs + { + internal TemperatureSensorDataUpdatedEventArgs(float temperature) + { + Temperature = temperature; + } + + /// + /// Gets the value of the temperature. + /// + public float Temperature { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/UltravioletSensorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/UltravioletSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..de899bd --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/UltravioletSensorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// UltravioletSensor changed event arguments. Class for storing the data returned by ultraviolet sensor + /// + public class UltravioletSensorDataUpdatedEventArgs : EventArgs + { + internal UltravioletSensorDataUpdatedEventArgs(float ultravioletIndex) + { + UltravioletIndex = ultravioletIndex; + } + + /// + /// Gets the value of the ultraviolet index. + /// + public float UltravioletIndex { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/UncalibratedGyroscopeDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/UncalibratedGyroscopeDataUpdatedEventArgs.cs new file mode 100644 index 0000000..54b8d80 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/UncalibratedGyroscopeDataUpdatedEventArgs.cs @@ -0,0 +1,58 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// UncalibratedGyroscope changed event arguments. Class for storing the data returned by uncalibrated gyroscope + /// + public class UncalibratedGyroscopeDataUpdatedEventArgs : EventArgs + { + internal UncalibratedGyroscopeDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + BiasX = values[3]; + BiasY = values[4]; + BiasZ = values[5]; + } + + /// + /// Gets the X component of the uncalibrated gyroscope data. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the uncalibrated gyroscope data. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the uncalibrated gyroscope data. + /// + public float Z { get; private set; } + + /// + /// Gets the BiasX component of the uncalibrated gyroscope data. + /// + public float BiasX { get; private set; } + + /// + /// Gets the BiasY component of the uncalibrated gyroscope data. + /// + public float BiasY { get; private set; } + + /// + /// Gets the BiasZ component of the uncalibrated gyroscope data. + /// + public float BiasZ { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/UncalibratedMagnetometerDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/UncalibratedMagnetometerDataUpdatedEventArgs.cs new file mode 100644 index 0000000..e015319 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/UncalibratedMagnetometerDataUpdatedEventArgs.cs @@ -0,0 +1,58 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// UncalibratedMagnetometer changed event arguments. Class for storing the data returned by uncalibrated magnetometer + /// + public class UncalibratedMagnetometerDataUpdatedEventArgs : EventArgs + { + internal UncalibratedMagnetometerDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + BiasX = values[3]; + BiasY = values[4]; + BiasZ = values[5]; + } + + /// + /// Gets the X component of the uncalibrated magnetometer data. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the uncalibrated magnetometer data. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the uncalibrated magnetometer data. + /// + public float Z { get; private set; } + + /// + /// Gets the BiasX component of the uncalibrated magnetometer data. + /// + public float BiasX { get; private set; } + + /// + /// Gets the BiasY component of the uncalibrated magnetometer data. + /// + public float BiasY { get; private set; } + + /// + /// Gets the BiasZ component of the uncalibrated magnetometer data. + /// + public float BiasZ { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/WalkingActivityDetectorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/WalkingActivityDetectorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..59782a9 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/WalkingActivityDetectorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// WalkingActivityDetector changed event arguments. Class for storing the data returned by walking activity detector + /// + public class WalkingActivityDetectorDataUpdatedEventArgs : EventArgs + { + internal WalkingActivityDetectorDataUpdatedEventArgs(float state) + { + Walking = (DetectorState) state; + } + + /// + /// Gets the walking state. + /// + public DetectorState Walking { get; private set; } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/EventArgs/WristUpGestureDetectorDataUpdatedEventArgs.cs b/Tizen.Sensor/Tizen.Sensor/EventArgs/WristUpGestureDetectorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..205cc75 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/EventArgs/WristUpGestureDetectorDataUpdatedEventArgs.cs @@ -0,0 +1,28 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// WristUpGestureDetector changed event arguments. Class for storing the data returned by wrist up gesture detector + /// + public class WristUpGestureDetectorDataUpdatedEventArgs : EventArgs + { + internal WristUpGestureDetectorDataUpdatedEventArgs(float state) + { + WristUp = (DetectorState) state; + } + + /// + /// Gets the wrist up state. + /// + public DetectorState WristUp { get; private set; } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs new file mode 100644 index 0000000..17025e6 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs @@ -0,0 +1,126 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Accelerometer Sensor Class. Used for registering callbacks for accelerometer and getting accelerometer data + /// /// + public class Accelerometer : Sensor + { + private static string AccelerometerKey = "http://tizen.org/feature/sensor.accelerometer"; + /// + /// Gets the X component of the acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the acceleration. + /// + public float Z { get; private set; } + + /// + /// Returns true or false based on whether accelerometer sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the Accelerometer sensor is supported"); + return CheckIfSupported(SensorType.Accelerometer, AccelerometerKey); + } + } + + /// + /// Returns the number of accelerometer sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of accelerometer sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular accelerometer sensor in case of multiple sensors + /// + public Accelerometer(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating Accelerometer object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.Accelerometer; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in accelerometer sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.Accelerometer, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for accelerometer"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for accelerometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for accelerometer"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for accelerometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for accelerometer"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new AccelerometerDataUpdatedEventArgs(sensorData.values)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/ActivityDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/ActivityDetector.cs new file mode 100644 index 0000000..917c88c --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/ActivityDetector.cs @@ -0,0 +1,58 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + public abstract class ActivityDetector : Sensor + { + protected const int ActivityAttribute = (((int)SensorType.InVehicleActivityDetector << 8) | 0x80 | 0x1); + + protected enum ActivityType + { + Unknown = 1, + Stationary = 2, + Walking = 4, + Running = 8, + InVehicle = 16, + OnBicycle = 32, + }; + + /// + /// Gets the activity accuracy of activity detector + /// + public SensorDataAccuracy ActivityAccuracy { get; protected set; } + + protected abstract void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data); + + internal ActivityDetector(int index) : base(index) + { + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for activity detector"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for activity detector"); + } + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs new file mode 100644 index 0000000..18df9b6 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs @@ -0,0 +1,114 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// FaceDownGestureDetector Class. Used for registering callbacks for face down gesture detector and getting the face down state + /// + public class FaceDownGestureDetector : Sensor + { + private static string GestureDetectorKey = "http://tizen.org/feature/sensor.gesture_recognition"; + + /// + /// Gets the state of the face down gesture. + /// + public DetectorState FaceDown { get; private set; } + + /// + /// Returns true or false based on whether face down gesture detector is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the face down gesture detector is supported"); + return CheckIfSupported(SensorType.FaceDownGestureDetector, GestureDetectorKey); + } + } + + /// + /// Returns the number of face down gesture detector available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of face down gesture detectors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular face down gesture detector in case of multiple sensors. + /// + public FaceDownGestureDetector(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating face down gesture detector object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.FaceDownGestureDetector; + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.FaceDownGestureDetector, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for face down gesture detector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in face down gesture detector data. + /// + public event EventHandler DataUpdated; + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for face down gesture detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for face down gesture detector"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for face down gesture detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for face down gesture detector"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + FaceDown = (DetectorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new FaceDownGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs new file mode 100644 index 0000000..e1d8eb5 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs @@ -0,0 +1,177 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// GravitySensor Class. Used for registering callbacks for gravity sensor and getting gravity data + /// /// + public class GravitySensor : Sensor + { + private const string GravitySensorKey = "http://tizen.org/feature/sensor.gravity"; + + private event EventHandler _accuracyChanged; + /// + /// Gets the X component of the gravity. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the gravity. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the gravity. + /// + public float Z { get; private set; } + + /// + /// Returns true or false based on whether gravity sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the GravitySensor is supported"); + return CheckIfSupported(SensorType.GravitySensor, GravitySensorKey); + } + } + + /// + /// Returns the number of gravity sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of gravity sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular gravity sensor in case of multiple sensors + /// + public GravitySensor (int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating GravitySensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.GravitySensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in gravity sensor data. + /// + + public event EventHandler DataUpdated; + + /// + /// Event handler for accuracy changed events. + /// + public event EventHandler AccuracyChanged + { + add + { + if (_accuracyChanged == null) + { + AccuracyListenStart(); + } + _accuracyChanged += value; + } + remove + { + _accuracyChanged -= value; + if (_accuracyChanged == null) + { + AccuracyListenStop(); + } + } + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.GravitySensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for gravity"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for gravity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for gravity"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for gravity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gravity"); + } + } + + private void AccuracyListenStart() + { + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting accuracy event callback for gravity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for gravity"); + } + } + + private void AccuracyListenStop() + { + int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for gravity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for gravity"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new GravitySensorDataUpdatedEventArgs(sensorData.values)); + } + + private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) + { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs new file mode 100644 index 0000000..01ec84a --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs @@ -0,0 +1,127 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Gyroscope Sensor Class. Used for registering callbacks for gyroscope and getting gyroscope data + /// /// + public class Gyroscope : Sensor + { + private const string GyroscopeKey = "http://tizen.org/feature/sensor.gyroscope"; + + /// + /// Gets the X component of the acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the acceleration. + /// + public float Z { get; private set; } + + /// + /// Returns true or false based on whether gyroscope sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the Gyroscope sensor is supported"); + return CheckIfSupported(SensorType.Gyroscope, GyroscopeKey); + } + } + + /// + /// Returns the number of gyroscope sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of gyroscope sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular gyroscope sensor in case of multiple sensors + /// + public Gyroscope(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating Gyroscope object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.Gyroscope; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in gyroscope sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.Gyroscope, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for gyroscope"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for gyroscope sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for gyroscope"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for gyroscope sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gyroscope"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new GyroscopeDataUpdatedEventArgs(sensorData.values)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs new file mode 100644 index 0000000..4651983 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs @@ -0,0 +1,139 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// GyroscopeRotationVectorSensor Class. Used for registering callbacks for gyroscope rotation vector sensor and getting gyroscope rotation vector data + /// /// + public class GyroscopeRotationVectorSensor : Sensor + { + private const string GyroscopeRVKey = "http://tizen.org/feature/sensor.gyroscope_rotation_vector"; + + /// + /// Gets the X component of the gyroscope rotation vector. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the gyroscope rotation vector. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the gyroscope rotation vector. + /// + public float Z { get; private set; } + + /// + /// Gets the W component of the gyroscope rotation vector. + /// + public float W { get; private set; } + + /// + /// Gets the Accuracy of the gyroscope rotation vector data. + /// + public SensorDataAccuracy Accuracy { get; private set; } + + /// + /// Returns true or false based on whether gyroscope rotation vector sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the GyroscopeRotationVectorSensor is supported"); + return CheckIfSupported(SensorType.GyroscopeRotationVectorSensor, GyroscopeRVKey); + } + } + + /// + /// Returns the number of gyroscope rotation vector sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of gyroscope rotation vector sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular gyroscope rotation vector sensor in case of multiple sensors + /// + public GyroscopeRotationVectorSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating GyroscopeRotationVectorSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.GyroscopeRotationVectorSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in gyroscope rotation vector sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.GyroscopeRotationVectorSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for gyroscope rotation vector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for gyroscope rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for gyroscope rotation vector"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for gyroscope rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gyroscope rotation vector"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + Accuracy = sensorData.accuracy; + + DataUpdated?.Invoke(this, new GyroscopeRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); + } + + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs new file mode 100644 index 0000000..f5ea54a --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs @@ -0,0 +1,115 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// HeartRateMonitor Class. Used for registering callbacks for heart rate monitor and getting heart rate data + /// /// + public class HeartRateMonitor : Sensor + { + private const string HRMKey = "http://tizen.org/feature/sensor.heart_rate_monitor"; + + /// + /// Gets the value of the heart rate monitor. + /// + public int HeartRate { get; private set; } + + /// + /// Returns true or false based on whether heart rate monitor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the HeartRateMonitor is supported"); + return CheckIfSupported(SensorType.HeartRateMonitor, HRMKey); + } + } + + /// + /// Returns the number of heart rate monitors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of heart rate monitors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular heart rate monitor in case of multiple sensors + /// + public HeartRateMonitor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating HeartRateMonitor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.HeartRateMonitor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in heart rate monitor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.HeartRateMonitor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for heart rate"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for heart rate monitor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for heart rate"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for heart rate monitor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for heart rate"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + HeartRate = (int)sensorData.values[0]; + + DataUpdated?.Invoke(this, new HeartRateMonitorDataUpdatedEventArgs((int)sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs new file mode 100644 index 0000000..d611b0c --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs @@ -0,0 +1,115 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// HumiditySensor Class. Used for registering callbacks for humidity sensor and getting humidity data + /// /// + public class HumiditySensor : Sensor + { + private const string HumiditySensorKey = "http://tizen.org/feature/sensor.humidity"; + + /// + /// Gets the value of the humidity sensor. + /// + public float Humidity { get; private set; } + + /// + /// Returns true or false based on whether humidity sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the HumiditySensor is supported"); + return CheckIfSupported(SensorType.HumiditySensor, HumiditySensorKey); + } + } + + /// + /// Returns the number of humidity sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of humidity sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular humidity sensor in case of multiple sensors + /// + public HumiditySensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating HumiditySensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.HumiditySensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in humidity sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.HumiditySensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for humidity"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for humidity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for humidity"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for humidity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for humidity"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Humidity = sensorData.values[0]; + + DataUpdated?.Invoke(this, new HumiditySensorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs new file mode 100644 index 0000000..47e9931 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs @@ -0,0 +1,96 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// InVehicleActivityDetector Class. Used for registering callbacks for in vehicle activity detector and getting the in vehicle state + /// + public class InVehicleActivityDetector : ActivityDetector + { + private const string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + + /// + /// Gets the state of in-vehicle activity detector + /// + public DetectorState InVehicle { get; private set; } + + /// + /// Returns true or false based on whether in-vehicle activity detector is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the in-vehicle activity detector is supported"); + return CheckIfSupported(SensorType.InVehicleActivityDetector, ActivityDetectorKey); + } + } + + /// + /// Returns the number of in-vehicle activity detector available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of in-vehicle activity detectors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular in-vehicle activity detector in case of multiple sensors. + /// + public InVehicleActivityDetector(int index = 0) : base(index) + { + SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.InVehicle); + Log.Info(Globals.LogTag, "Creating in-vehicle activity detector object"); + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.InVehicleActivityDetector, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for in-vehicle activity detector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in in-vehicle activity detector data. + /// + public event EventHandler DataUpdated; + + protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + InVehicle = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new InVehicleActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + } + + internal override SensorType GetSensorType() + { + return SensorType.InVehicleActivityDetector; + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs new file mode 100644 index 0000000..869580e --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs @@ -0,0 +1,115 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// LightSensor Class. Used for registering callbacks for light sensor and getting light data + /// /// + public class LightSensor : Sensor + { + private const string LightSensorKey = "http://tizen.org/feature/sensor.photometer"; + + /// + /// Gets the Level of the light. + /// + public float Level { get; private set; } + + /// + /// Returns true or false based on whether light sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the LightSensor is supported"); + return CheckIfSupported(SensorType.LightSensor, LightSensorKey); + } + } + + /// + /// Returns the number of light sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of light sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular light sensor in case of multiple sensors + /// + public LightSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating LightSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.LightSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in light sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.LightSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for light"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for light sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for light"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for light sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for light"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Level = sensorData.values[0]; + + DataUpdated?.Invoke(this, new LightSensorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs new file mode 100644 index 0000000..69232a0 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs @@ -0,0 +1,177 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// LinearAccelerationSensor Class. Used for registering callbacks for linear acceleration sensor and getting linear acceleration data + /// /// + public class LinearAccelerationSensor : Sensor + { + private const string LinearAccelerationSensorKey = "http://tizen.org/feature/sensor.linear_acceleration"; + + private event EventHandler _accuracyChanged; + /// + /// Gets the X component of the linear acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the linear acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the linear acceleration. + /// + public float Z { get; private set; } + + /// + /// Returns true or false based on whether linear acceleration sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the LinearAccelerationSensor is supported"); + return CheckIfSupported(SensorType.LinearAccelerationSensor, LinearAccelerationSensorKey); + } + } + + /// + /// Returns the number of linear acceleration sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of linear acceleration sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular linear acceleration sensor in case of multiple sensors + /// + public LinearAccelerationSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating LinearAccelerationSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.LinearAccelerationSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in linear acceleration sensor data. + /// + + public event EventHandler DataUpdated; + + /// + /// Event handler for accuracy changed events. + /// + public event EventHandler AccuracyChanged + { + add + { + if (_accuracyChanged == null) + { + AccuracyListenStart(); + } + _accuracyChanged += value; + } + remove + { + _accuracyChanged -= value; + if (_accuracyChanged == null) + { + AccuracyListenStop(); + } + } + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.LinearAccelerationSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for linear acceleration sensor"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for linear acceleration sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for linear acceleration sensor"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for linear acceleration sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for linear acceleration"); + } + } + + private void AccuracyListenStart() + { + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting accuracy event callback for linear acceleration sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for linear acceleration sensor"); + } + } + + private void AccuracyListenStop() + { + int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for linear acceleration sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for linear acceleration sensor"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new LinearAccelerationSensorDataUpdatedEventArgs(sensorData.values)); + } + + private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) + { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs new file mode 100644 index 0000000..db407df --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs @@ -0,0 +1,177 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Magnetometer Class. Used for registering callbacks for magnetometer and getting magnetometer data + /// /// + public class Magnetometer : Sensor + { + private static string MagnetometerKey = "http://tizen.org/feature/sensor.magnetometer"; + + private event EventHandler _accuracyChanged; + /// + /// Gets the X component of the magnetometer. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the magnetometer. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the magnetometer. + /// + public float Z { get; private set; } + + /// + /// Returns true or false based on whether magnetometer is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the Magnetometer is supported"); + return CheckIfSupported(SensorType.Magnetometer, MagnetometerKey); + } + } + + /// + /// Returns the number of magnetometers available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of magnetometers"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular magnetometer in case of multiple sensors + /// + public Magnetometer(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating Magnetometer object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.Magnetometer; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in magnetometer data. + /// + + public event EventHandler DataUpdated; + + /// + /// Event handler for accuracy changed events. + /// + public event EventHandler AccuracyChanged + { + add + { + if (_accuracyChanged == null) + { + AccuracyListenStart(); + } + _accuracyChanged += value; + } + remove + { + _accuracyChanged -= value; + if (_accuracyChanged == null) + { + AccuracyListenStop(); + } + } + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.Magnetometer, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for magnetometer"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for magnetometer"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for magnetometer"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for magnetometer"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for magnetometer"); + } + } + + private void AccuracyListenStart() + { + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting accuracy event callback for magnetometer"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for magnetometer"); + } + } + + private void AccuracyListenStop() + { + int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for magnetometer"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for magnetometer"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new MagnetometerDataUpdatedEventArgs(sensorData.values)); + } + + private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) + { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs new file mode 100644 index 0000000..f90ed36 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs @@ -0,0 +1,201 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// MagnetometerRotationVectorSensor Class. Used for registering callbacks for magnetometer rotation vector sensor and getting magnetometer rotation vector data + /// /// + public class MagnetometerRotationVectorSensor : Sensor + { + private static string MagnetometerRVKey = "http://tizen.org/feature/sensor.geomagnetic_rotation_vector"; + + private event EventHandler _accuracyChanged; + /// + /// Gets the X component of the magnetometer rotation vector. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the magnetometer rotation vector. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the magnetometer rotation vector. + /// + public float Z { get; private set; } + + /// + /// Gets the W component of the magnetometer rotation vector. + /// + public float W { get; private set; } + + /// + /// Gets the Accuracy of the magnetometer rotation vector data. + /// + public SensorDataAccuracy Accuracy { get; private set; } + + /// + /// Returns true or false based on whether magnetometer rotation vector sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the MagnetometerRotationVectorSensor is supported"); + return CheckIfSupported(SensorType.MagnetometerRotationVectorSensor, MagnetometerRVKey); + } + } + + /// + /// Returns the number of magnetometer rotation vector sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of magnetometer rotation vector sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular magnetometer rotation vector sensor in case of multiple sensors + /// + public MagnetometerRotationVectorSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating MagnetometerRotationVectorSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.MagnetometerRotationVectorSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in magnetometer rotation vector sensor data. + /// + + public event EventHandler DataUpdated; + + /// + /// Event handler for accuracy changed events. + /// + public event EventHandler AccuracyChanged + { + add + { + if (_accuracyChanged == null) + { + AccuracyListenStart(); + } + _accuracyChanged += value; + } + remove + { + _accuracyChanged -= value; + if (_accuracyChanged == null) + { + AccuracyListenStop(); + } + } + } + + private static bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.MagnetometerRotationVectorSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if magnetometer rotation vector sensor is supported"); + isSupported = false; + } + return isSupported; + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.MagnetometerRotationVectorSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for magnetometer rotation vector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for magnetometer rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for magnetometer rotation vector"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for magnetometer rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for magnetometer rotation vector"); + } + } + + private void AccuracyListenStart() + { + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting accuracy event callback for magnetometer rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for magnetometer rotation vector"); + } + } + + private void AccuracyListenStop() + { + int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for magnetometer rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for magnetometer rotation vector"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + Accuracy = sensorData.accuracy; + + DataUpdated?.Invoke(this, new MagnetometerRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); + } + + private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) + { + TimeSpan = new TimeSpan((Int64)timestamp); + Accuracy = accuracy; + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs new file mode 100644 index 0000000..6a2d68e --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs @@ -0,0 +1,177 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// OrientationSensor Class. Used for registering callbacks for orientation sensor and getting orientation data + /// /// + public class OrientationSensor : Sensor + { + private static string OrientationSensorKey = "http://tizen.org/feature/sensor.tiltmeter"; + + private event EventHandler _accuracyChanged; + /// + /// Gets the Azimuth component of the orientation. + /// + public float Azimuth { get; private set; } + + /// + /// Gets the Pitch component of the orientation. + /// + public float Pitch { get; private set; } + + /// + /// Gets the Roll component of the orientation. + /// + public float Roll { get; private set; } + + /// + /// Returns true or false based on whether orientation sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the OrientationSensor is supported"); + return CheckIfSupported(SensorType.OrientationSensor, OrientationSensorKey); + } + } + + /// + /// Returns the number of orientation sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of orientation sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular orientation sensor in case of multiple sensors + /// + public OrientationSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating OrientationSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.OrientationSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in orientation sensor data. + /// + + public event EventHandler DataUpdated; + + /// + /// Event handler for accuracy changed events. + /// + public event EventHandler AccuracyChanged + { + add + { + if (_accuracyChanged == null) + { + AccuracyListenStart(); + } + _accuracyChanged += value; + } + remove + { + _accuracyChanged -= value; + if (_accuracyChanged == null) + { + AccuracyListenStop(); + } + } + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.OrientationSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for orientation"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for orientation sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for orientation"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for orientation sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for orientation"); + } + } + + private void AccuracyListenStart() + { + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting accuracy event callback for orientation sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy accuracy event callback for orientation"); + } + } + + private void AccuracyListenStop() + { + int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for orientation sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for orientation"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Azimuth = sensorData.values[0]; + Pitch = sensorData.values[1]; + Roll = sensorData.values[2]; + + DataUpdated?.Invoke(this, new OrientationSensorDataUpdatedEventArgs(sensorData.values)); + } + + private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) + { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs new file mode 100644 index 0000000..67f2920 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs @@ -0,0 +1,157 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// Pedometer Sensor Class. Used for registering callbacks for pedometer and getting pedometer data + /// /// + public class Pedometer : Sensor + { + private static string PedometerKey = "http://tizen.org/feature/sensor.pedometer"; + + /// + /// Gets the step count + /// + public int StepCount { get; private set; } + + /// + /// Gets the walking step count + /// + public int WalkStepCount { get; private set; } + + /// + /// Gets the running step count + /// + public int RunStepCount { get; private set; } + + /// + /// Gets the moving distance + /// + public float MovingDistance { get; private set; } + + /// + /// Gets the calorie burned + /// + public float CalorieBurned { get; private set; } + + /// + /// Gets the last speed + /// + public float LastSpeed { get; private set; } + + /// + /// Gets the last stepping frequency + /// + public float LastSteppingFrequency { get; private set; } + + /// + /// Gets the last step status + /// + public PedometerState LastStepStatus { get; private set; } + + /// + /// Returns true or false based on whether pedometer sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the Pedometer sensor is supported"); + return CheckIfSupported(SensorType.Pedometer, PedometerKey); + } + } + + /// + /// Returns the number of pedometer sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of pedometer sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular pedometer sensor in case of multiple sensors + /// + public Pedometer(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating Pedometer object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.Pedometer; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in pedometer sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.Pedometer, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for pedometer"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for pedometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pedometer"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for pedometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pedometer"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + StepCount = (int)sensorData.values[0]; + WalkStepCount = (int)sensorData.values[1]; + RunStepCount = (int)sensorData.values[2]; + MovingDistance = sensorData.values[3]; + CalorieBurned = sensorData.values[4]; + LastSpeed = sensorData.values[5]; + LastSteppingFrequency = sensorData.values[6]; + LastStepStatus = (PedometerState)sensorData.values[7]; + + DataUpdated?.Invoke(this, new PedometerDataUpdatedEventArgs(sensorData.values)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs new file mode 100644 index 0000000..09c18f0 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs @@ -0,0 +1,126 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// PickUpGestureDetector Class. Used for registering callbacks for pick up activity detector and getting the pick up state + /// + public class PickUpGestureDetector : Sensor + { + private static string GestureDetectorKey = "http://tizen.org/feature/sensor.gesture_recognition"; + + /// + /// Gets the state of the pick up gesture. + /// + public DetectorState PickUp { get; private set; } + + /// + /// Returns true or false based on whether pick up gesture detector is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the pick up gesture detector is supported"); + return CheckIfSupported(SensorType.PickUpGestureDetector, GestureDetectorKey); + } + } + + /// + /// Returns the number of pick up gesture detector available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of pick up gesture detectors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular pick up gesture detector in case of multiple sensors. + /// + public PickUpGestureDetector(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating pick up gesture detector object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.PickUpGestureDetector; + } + + private static bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.PickUpGestureDetector, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if pick up gesture detector is supported"); + isSupported = false; + } + return isSupported; + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.PickUpGestureDetector, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for pick up gesture detector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in pick up gesture detector data. + /// + public event EventHandler DataUpdated; + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for pick up gesture detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pick up gesture detector"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for pick up gesture detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pick up gesture detector"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + PickUp = (DetectorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new PickUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs new file mode 100644 index 0000000..1a622d7 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs @@ -0,0 +1,116 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// PressureSensor Class. Used for registering callbacks for pressure sensor and getting pressure data + /// /// + public class PressureSensor : Sensor + { + private static string PressureSensorKey = "http://tizen.org/feature/sensor.barometer"; + + /// + /// Gets the value of the pressure sensor. + /// + public float Pressure { get; private set; } + + /// + /// Returns true or false based on whether pressure sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the PressureSensor is supported"); + return CheckIfSupported(SensorType.PressureSensor, PressureSensorKey); + } + } + + /// + /// Returns the number of pressure sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of pressure sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular pressure sensor in case of multiple sensors + /// + public PressureSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating PressureSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.PressureSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in pressure sensor data. + /// + + public event EventHandler DataUpdated; + + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.PressureSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for pressure"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for pressure sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pressure"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for pressure sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pressure"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Pressure = sensorData.values[0]; + + DataUpdated?.Invoke(this, new PressureSensorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs new file mode 100644 index 0000000..e61b774 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs @@ -0,0 +1,115 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// ProximitySensor Class. Used for registering callbacks for proximity sensor and getting proximity data + /// /// + public class ProximitySensor : Sensor + { + private static string ProximitySensorKey = "http://tizen.org/feature/sensor.proximity"; + + /// + /// Gets the proximity state. + /// + public ProximitySensorState Proximity { get; private set; } + + /// + /// Returns true or false based on whether proximity sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the ProximitySensor is supported"); + return CheckIfSupported(SensorType.ProximitySensor, ProximitySensorKey); + } + } + + /// + /// Returns the number of proximity sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of proximity sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular proximity sensor in case of multiple sensors + /// + public ProximitySensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating ProximitySensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.ProximitySensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in proximity sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.ProximitySensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for proximity"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for proximity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for proximity"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for proximity sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for proximity"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Proximity = (ProximitySensorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new ProximitySensorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs new file mode 100644 index 0000000..52cb6e2 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs @@ -0,0 +1,189 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// RotationVectorSensor Class. Used for registering callbacks for rotation vector sensor and getting rotation vector data + /// /// + public class RotationVectorSensor : Sensor + { + private static string RotationVectorKey = "http://tizen.org/feature/sensor.rotation_vector"; + + private event EventHandler _accuracyChanged; + /// + /// Gets the X component of the rotation vector. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the rotation vector. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the rotation vector. + /// + public float Z { get; private set; } + + /// + /// Gets the W component of the rotation vector. + /// + public float W { get; private set; } + + /// + /// Gets the Accuracy of the rotation vector data. + /// + public SensorDataAccuracy Accuracy { get; private set; } + + /// + /// Returns true or false based on whether rotation vector sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the RotationVectorSensor is supported"); + return CheckIfSupported(SensorType.RotationVectorSensor, RotationVectorKey); + } + } + + /// + /// Returns the number of rotation vector sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of rotation vector sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular rotation vector sensor in case of multiple sensors + /// + public RotationVectorSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating RotationVectorSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.RotationVectorSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in rotation vector sensor data. + /// + + public event EventHandler DataUpdated; + + /// + /// Event handler for accuracy changed events. + /// + public event EventHandler AccuracyChanged + { + add + { + if (_accuracyChanged == null) + { + AccuracyListenStart(); + } + _accuracyChanged += value; + } + remove + { + _accuracyChanged -= value; + if (_accuracyChanged == null) + { + AccuracyListenStop(); + } + } + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.RotationVectorSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for rotation vector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for rotation vector"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for rotation vector"); + } + } + + private void AccuracyListenStart() + { + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting accuracy event callback for rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for rotation vector"); + } + } + + private void AccuracyListenStop() + { + int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for rotation vector sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for rotation vector"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + Accuracy = sensorData.accuracy; + + DataUpdated?.Invoke(this, new RotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); + } + + private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) + { + TimeSpan = new TimeSpan((Int64)timestamp); + Accuracy = accuracy; + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs new file mode 100644 index 0000000..febf956 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs @@ -0,0 +1,96 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// RunningActivityDetector Class. Used for registering callbacks for running activity detector and getting the running state + /// + public class RunningActivityDetector : ActivityDetector + { + private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + + /// + /// Gets the state of running activity detector + /// + public DetectorState Running { get; private set; } + + /// + /// Returns true or false based on whether running activity detector is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the running activity detector is supported"); + return CheckIfSupported(SensorType.RunningActivityDetector, ActivityDetectorKey); + } + } + + /// + /// Returns the number of running activity detector available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of running activity detectors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular running activity detector in case of multiple sensors. + /// + public RunningActivityDetector(int index = 0) : base(index) + { + SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.Running); + Log.Info(Globals.LogTag, "Creating running activity detector object"); + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.RunningActivityDetector, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for running activity detector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in running activity detector data. + /// + public event EventHandler DataUpdated; + + protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Running = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new RunningActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + } + + internal override SensorType GetSensorType() + { + return SensorType.RunningActivityDetector; + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs new file mode 100644 index 0000000..4aaff52 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs @@ -0,0 +1,116 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// SleepMonitor Class. Used for registering callbacks for sleep monitor and getting sleep data + /// /// + public class SleepMonitor : Sensor + { + private static string SleepMonitorKey = "http://tizen.org/feature/sensor.sleep_monitor"; + + /// + /// Gets the value of the sleep state. + /// + public SleepMonitorState SleepState { get; private set; } + + /// + /// Returns true or false based on whether sleep monitor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the SleepMonitor is supported"); + return CheckIfSupported(SensorType.SleepMonitor, SleepMonitorKey); + } + } + + /// + /// Returns the number of sleep monitors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of sleep monitors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular sleep monitor in case of multiple sensors + /// + public SleepMonitor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating SleepMonitor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.SleepMonitor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in sleep monitor data. + /// + + public event EventHandler DataUpdated; + + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.SleepMonitor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for sleep"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for sleep monitor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for sleep"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for sleep monitor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for sleep"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + SleepState = (SleepMonitorState)sensorData.values[0]; + + DataUpdated?.Invoke(this, new SleepMonitorDataUpdatedEventArgs((int)sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs new file mode 100644 index 0000000..04c9788 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs @@ -0,0 +1,96 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// StationaryActivityDetector Class. Used for registering callbacks for stationary activity detector and getting the stationary state + /// + public class StationaryActivityDetector : ActivityDetector + { + private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + + /// + /// Gets the state of stationary activity detector + /// + public DetectorState Stationary { get; private set; } + + /// + /// Returns true or false based on whether stationary activity detector is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the stationary activity detector is supported"); + return CheckIfSupported(SensorType.StationaryActivityDetector, ActivityDetectorKey); + } + } + + /// + /// Returns the number of stationary activity detector available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of stationary activity detectors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular stationary activity detector in case of multiple sensors. + /// + public StationaryActivityDetector(int index = 0) : base(index) + { + SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.Stationary); + Log.Info(Globals.LogTag, "Creating stationary activity detector object"); + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.StationaryActivityDetector, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for stationary activity detector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in stationary activity detector data. + /// + public event EventHandler DataUpdated; + + protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Stationary = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new StationaryActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + } + + internal override SensorType GetSensorType() + { + return SensorType.StationaryActivityDetector; + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs new file mode 100644 index 0000000..cd495cf --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs @@ -0,0 +1,116 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// TemperatureSensor Class. Used for registering callbacks for temperature sensor and getting temperature data + /// /// + public class TemperatureSensor : Sensor + { + private static string TemperatureSensorKey = "http://tizen.org/feature/sensor.temperature"; + + /// + /// Gets the value of the temperature sensor. + /// + public float Temperature { get; private set; } + + /// + /// Returns true or false based on whether temperature sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the TemperatureSensor is supported"); + return CheckIfSupported(SensorType.TemperatureSensor, TemperatureSensorKey); + } + } + + /// + /// Returns the number of temperature sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of temperature sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular temperature sensor in case of multiple sensors + /// + public TemperatureSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating TemperatureSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.TemperatureSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in temperature sensor data. + /// + + public event EventHandler DataUpdated; + + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.TemperatureSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for temperature"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for temperature sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for temperature"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for temperature sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for temperature"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Temperature = sensorData.values[0]; + + DataUpdated?.Invoke(this, new TemperatureSensorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs new file mode 100644 index 0000000..3df18ec --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs @@ -0,0 +1,116 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// UltravioletSensor Class. Used for registering callbacks for ultraviolet sensor and getting ultraviolet data + /// /// + public class UltravioletSensor : Sensor + { + private static string UltravioletSensorKey = "http://tizen.org/feature/sensor.ultraviolet"; + + /// + /// Gets the value of the ultraviolet sensor. + /// + public float UltravioletIndex { get; private set; } + + /// + /// Returns true or false based on whether ultraviolet sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the UltravioletSensor is supported"); + return CheckIfSupported(SensorType.UltravioletSensor, UltravioletSensorKey); + } + } + + /// + /// Returns the number of ultraviolet sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of ultraviolet sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular ultraviolet sensor in case of multiple sensors + /// + public UltravioletSensor(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating UltravioletSensor object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.UltravioletSensor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in ultraviolet sensor data. + /// + + public event EventHandler DataUpdated; + + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.UltravioletSensor, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for ultraviolet"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for ultraviolet sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for ultraviolet"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for ultraviolet sensor"); + 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])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs new file mode 100644 index 0000000..a66e054 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs @@ -0,0 +1,145 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// UncalibratedGyroscope Sensor Class. Used for registering callbacks for uncalibrated gyroscope and getting uncalibrated gyroscope data + /// /// + public class UncalibratedGyroscope : Sensor + { + private static string UncalibratedGyroscopeKey = "http://tizen.org/feature/sensor.gyroscope.uncalibrated"; + + /// + /// Gets the X component of the acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the acceleration. + /// + public float Z { get; private set; } + + /// + /// Gets the BiasX component of the uncalibrated gyroscope data. + /// + public float BiasX { get; private set; } + + /// + /// Gets the BiasY component of the uncalibrated gyroscope data. + /// + public float BiasY { get; private set; } + + /// + /// Gets the BiasZ component of the uncalibrated gyroscope data. + /// + public float BiasZ { get; private set; } + + /// + /// Returns true or false based on whether uncalibrated gyroscope sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the UncalibratedGyroscope sensor is supported"); + return CheckIfSupported(SensorType.UncalibratedGyroscope, UncalibratedGyroscopeKey); + } + } + + /// + /// Returns the number of uncalibrated gyroscope sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of uncalibrated gyroscope sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular uncalibrated gyroscope sensor in case of multiple sensors + /// + public UncalibratedGyroscope(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating UncalibratedGyroscope object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.UncalibratedGyroscope; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in uncalibrated gyroscope sensor data. + /// + + public event EventHandler DataUpdated; + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.UncalibratedGyroscope, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for uncalibrated gyroscope"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated gyroscope sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for uncalibrated gyroscope"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for uncalibrated gyroscope sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for uncalibrated gyroscope"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + 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]; + + DataUpdated?.Invoke(this, new UncalibratedGyroscopeDataUpdatedEventArgs(sensorData.values)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs new file mode 100644 index 0000000..222dd14 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs @@ -0,0 +1,195 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// UncalibratedMagnetometer Sensor Class. Used for registering callbacks for uncalibrated magnetometer and getting uncalibrated magnetometer data + /// /// + public class UncalibratedMagnetometer : Sensor + { + private static string UncalibratedMagnetometerKey = "http://tizen.org/feature/sensor.magnetometer.uncalibrated"; + + private event EventHandler _accuracyChanged; + /// + /// Gets the X component of the acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the acceleration. + /// + public float Z { get; private set; } + + /// + /// Gets the BiasX component of the uncalibrated magnetometer data. + /// + public float BiasX { get; private set; } + + /// + /// Gets the BiasY component of the uncalibrated magnetometer data. + /// + public float BiasY { get; private set; } + + /// + /// Gets the BiasZ component of the uncalibrated magnetometer data. + /// + public float BiasZ { get; private set; } + + /// + /// Returns true or false based on whether uncalibrated magnetometer sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the UncalibratedMagnetometer sensor is supported"); + return CheckIfSupported(SensorType.UncalibratedMagnetometer, UncalibratedMagnetometerKey); + } + } + + /// + /// Returns the number of uncalibrated magnetometer sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of uncalibrated magnetometer sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular uncalibrated magnetometer sensor in case of multiple sensors + /// + public UncalibratedMagnetometer(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating UncalibratedMagnetometer object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.UncalibratedMagnetometer; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in uncalibrated magnetometer sensor data. + /// + + public event EventHandler DataUpdated; + + /// + /// Event handler for accuracy changed events. + /// + public event EventHandler AccuracyChanged + { + add + { + if (_accuracyChanged == null) + { + AccuracyListenStart(); + } + _accuracyChanged += value; + } + remove + { + _accuracyChanged -= value; + if (_accuracyChanged == null) + { + AccuracyListenStop(); + } + } + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.UncalibratedMagnetometer, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for uncalibrated magnetometer"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated magnetometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for uncalibrated magnetometer"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for uncalibrated magnetometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for uncalibrated magnetometer"); + } + } + + private void AccuracyListenStart() + { + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting accuracy event callback for uncalibrated magnetometer"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for uncalibrated magnetometer"); + } + } + + private void AccuracyListenStop() + { + int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for uncalibrated magnetometer"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for uncalibrated magnetometer"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + 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]; + + DataUpdated?.Invoke(this, new UncalibratedMagnetometerDataUpdatedEventArgs(sensorData.values)); + } + + private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) + { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs new file mode 100644 index 0000000..cb28c7d --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs @@ -0,0 +1,96 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// WalkingActivityDetector Class. Used for registering callbacks for walking activity detector and getting the walking state + /// + public class WalkingActivityDetector : ActivityDetector + { + private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + + /// + /// Gets the state of walking activity detector + /// + public DetectorState Walking { get; private set; } + + /// + /// Returns true or false based on whether walking activity detector is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the walking activity detector is supported"); + return CheckIfSupported(SensorType.WalkingActivityDetector, ActivityDetectorKey); + } + } + + /// + /// Returns the number of walking activity detector available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of walking activity detectors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular walking activity detector in case of multiple sensors. + /// + public WalkingActivityDetector(int index = 0) : base(index) + { + SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.Walking); + Log.Info(Globals.LogTag, "Creating walking activity gesture detector object"); + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.WalkingActivityDetector, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for walking activity detector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in walking activity gesture detector data. + /// + public event EventHandler DataUpdated; + + protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Walking = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new WalkingActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + } + + internal override SensorType GetSensorType() + { + return SensorType.WalkingActivityDetector; + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs b/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs new file mode 100644 index 0000000..a5624eb --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs @@ -0,0 +1,114 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// WristUpGestureDetector Class. Used for registering callbacks for wrist up gesture detector and getting the wrist up state + /// + public class WristUpGestureDetector : Sensor + { + private static string WristUpKey = "http://tizen.org/feature/sensor.wrist_up"; + + /// + /// Gets the state of the wrist up gesture. + /// + public DetectorState WristUp { get; private set; } + + /// + /// Returns true or false based on whether wrist up gesture detector is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the wrist up gesture detector is supported"); + return CheckIfSupported(SensorType.WristUpGestureDetector, WristUpKey); + } + } + + /// + /// Returns the number of wrist up gesture detector available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of wrist up gesture detectors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular wrist up gesture detector in case of multiple sensors. + /// + public WristUpGestureDetector(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating wrist up gesture detector object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.WristUpGestureDetector; + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.WristUpGestureDetector, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for wrist up gesture detector"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in wrist up gesture detector data. + /// + public event EventHandler DataUpdated; + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for wrist up gesture detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for wrist up gesture detector"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for wrist up gesture detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for wrist up gesture detector"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + WristUp = (DetectorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new WristUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/Sensor.cs b/Tizen.Sensor/Tizen.Sensor/Sensor.cs new file mode 100644 index 0000000..f255070 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/Sensor.cs @@ -0,0 +1,499 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; +using Tizen.System; + +namespace Tizen.Sensor +{ + internal static class Globals + { + internal const string LogTag = "Tizen.Sensor"; + } + + /// + /// Sensor class for storing hardware information about a particular sensor + /// + public abstract class Sensor : IDisposable + { + private string _name; + private string _vendor; + private float _minValue; + private float _maxValue; + private float _resolution; + private int _minInterval; + private int _fifoCount; + private int _maxBatchCount; + private bool _isSensing = false; + private bool _disposed = false; + private TimeSpan _timeSpan; + private uint _interval = 0; + private uint _maxBatchLatency = 0; + private SensorPausePolicy _pausePolicy = SensorPausePolicy.None; + private IntPtr _sensorHandle = IntPtr.Zero; + private IntPtr _listenerHandle = IntPtr.Zero; + + internal abstract SensorType GetSensorType(); + protected abstract void EventListenStart(); + protected abstract void EventListenStop(); + + internal Sensor(int index) + { + SensorType type = GetSensorType(); + GetHandleList(type, index); + if (CheckSensorHandle()) + { + CreateListener(); + GetProperty(); + } + } + + ~Sensor() + { + Dispose(false); + } + + /// + /// Property: For getting the name of the sensor + /// + public string Name + { + get + { + Log.Info(Globals.LogTag, "Getting the sensor name"); + return _name; + } + } + + /// + /// Property: Gets the vendor. + /// + public string Vendor + { + get + { + Log.Info(Globals.LogTag, "Getting the sensor vendor name"); + return _vendor; + } + } + + /// + /// Property: Gets the minimum value of range of sensor data. + /// + public float MinValue + { + get + { + Log.Info(Globals.LogTag, "Getting the min value of the sensor"); + return _minValue; + } + } + + /// + /// Property: Gets the maximum value of range of sensor data. + /// + public float MaxValue + { + get + { + Log.Info(Globals.LogTag, "Getting the max value of the sensor"); + return _maxValue; + } + } + + /// + /// Property: Gets the resolution. + /// + public float Resolution + { + get + { + Log.Info(Globals.LogTag, "Getting the resolution of the sensor"); + return _resolution; + } + } + + /// + /// Property: Gets the minimum interval. + /// + public int MinInterval + { + get + { + Log.Info(Globals.LogTag, "Getting the min interval for the sensor"); + return _minInterval; + } + } + + /// + /// Property: Gets the fifo count. + /// + public int FifoCount + { + get + { + Log.Info(Globals.LogTag, "Getting the fifo count of the sensor"); + return _fifoCount; + } + } + + /// + /// Property: Gets the maximum batch count. + /// + public int MaxBatchCount + { + get + { + Log.Info(Globals.LogTag, "Getting the max batch count of the sensor"); + return _maxBatchCount; + } + } + + /// + /// Sets the interval of the sensor for sensor data event + /// Callbacks will be called at frequency of this interval + /// + public uint Interval + { + set + { + Log.Info(Globals.LogTag, "Setting the interval of the sensor"); + _interval = value; + SetInterval(); + } + get + { + Log.Info(Globals.LogTag, "Getting the interval of the sensor"); + return _interval; + } + } + + /// + /// Sets the max batch latency for the sensor corresponding to the sensor data event. + /// + public uint MaxBatchLatency + { + set + { + Log.Info(Globals.LogTag, "Setting the max batch latency of the sensor"); + _maxBatchLatency = value; + SetMaxBatchLatency(); + } + get + { + Log.Info(Globals.LogTag, "Getting the max batch latency of the sensor"); + return _maxBatchLatency; + } + } + + /// + /// Sets the pause policy of the sensor. + /// + /// + public SensorPausePolicy PausePolicy + { + set + { + Log.Info(Globals.LogTag, "Setting the pause policy of the sensor"); + _pausePolicy = value; + SetAttribute(SensorAttribute.PausePolicy, (int)_pausePolicy); + } + get + { + Log.Info(Globals.LogTag, "Getting the pause policy of the sensor"); + return _pausePolicy; + } + } + + /// + /// Gets or sets the time span. + /// + /// The time span. + public TimeSpan TimeSpan + { + set + { + Log.Info(Globals.LogTag, "Setting the timespan of the sensor values"); + _timeSpan = value; + } + get + { + Log.Info(Globals.LogTag, "Getting the timespan of the sensor values"); + return _timeSpan; + } + } + + /// + /// Indicates whether this sensor is sensing. + /// + /// true if this sensor is sensing; otherwise, false. + public bool IsSensing + { + get + { + Log.Info(Globals.LogTag, "Checking if the sensor is started"); + return _isSensing; + } + } + + internal IntPtr ListenerHandle + { + get + { + return _listenerHandle; + } + } + + internal static bool CheckIfSupported(SensorType type, String key) + { + bool isSupported = false; + bool error = SystemInfo.TryGetValue(key, out isSupported); + + if (!error || !isSupported) + { + Log.Error(Globals.LogTag, "Error checking if sensor is supported(systeminfo)"); + return false; + } + + int ret = Interop.SensorManager.SensorIsSupported(type, out isSupported); + if (ret != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if sensor is supported"); + isSupported = false; + } + + return isSupported; + } + + /// + /// Starts the sensor. + /// After this the event handlers will start receiving events. + /// + public void Start() + { + Log.Info(Globals.LogTag, "Starting the sensor"); + if (CheckListenerHandle()) + { + int error = Interop.SensorListener.StartListener(_listenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error starting sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Start Sensor Listener"); + } + EventListenStart(); + _isSensing = true; + Log.Info(Globals.LogTag, "Sensor started"); + } + } + + /// + /// Stop the sensor. + /// After this the event handlers will stop receiving the events + /// + public void Stop() + { + Log.Info(Globals.LogTag, "Stopping the sensor"); + if (_isSensing) + { + int error = Interop.SensorListener.StopListener(_listenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error stopping the sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Stop Sensor Listener"); + } + EventListenStop(); + _isSensing = false; + Log.Info(Globals.LogTag, "Sensor stopped"); + } + else + { + Log.Error(Globals.LogTag, "Can't stop sensor as it is already stopped"); + throw new InvalidOperationException("Operation Failed: Sensor is already stopped"); + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (_disposed) + return; + + DestroyHandles(); + _disposed = true; + } + + protected void SetAttribute(SensorAttribute attribute, int option) + { + if (CheckListenerHandle()) + { + int error = Interop.SensorListener.SetAttribute(_listenerHandle, attribute, option); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting sensor pause policy"); + throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed"); + } + } + } + + private void GetHandleList(SensorType type, int index) + { + IntPtr list; + IntPtr[] sensorList; + int count; + int error = Interop.SensorManager.GetSensorList(type, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.GetSensorList Failed"); + } + sensorList = Interop.IntPtrToIntPtrArray(list, count); + _sensorHandle = sensorList[index]; + Interop.Libc.Free(list); + } + + private void GetProperty() + { + int error = (int)SensorError.None; + + error = Interop.Sensor.GetName(_sensorHandle, out _name); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor name"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Name Failed"); + } + + error = Interop.Sensor.GetVendor(_sensorHandle, out _vendor); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor vendor name"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Vendor Failed"); + } + + error = Interop.Sensor.GetMinRange(_sensorHandle, out _minValue); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor min value"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinValue Failed"); + } + + error = Interop.Sensor.GetMaxRange(_sensorHandle, out _maxValue); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor max value"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxValue Failed"); + } + + error = Interop.Sensor.GetResolution(_sensorHandle, out _resolution); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor resolution"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Resolution Failed"); + } + + error = Interop.Sensor.GetMinInterval(_sensorHandle, out _minInterval); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor min interval"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinInterval Failed"); + } + + error = Interop.Sensor.GetFifoCount(_sensorHandle, out _fifoCount); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor fifo count"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.FifoCount Failed"); + } + + error = Interop.Sensor.GetMaxBatchCount(_sensorHandle, out _maxBatchCount); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor max batch count"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxBatchCount Failed"); + } + } + + private void CreateListener() + { + int error = Interop.SensorListener.CreateListener(_sensorHandle, out _listenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error cerating sensor listener handle"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.CreateListener Failed"); + } + } + + private void SetInterval() + { + if (CheckListenerHandle()) + { + if (_isSensing) + { + int error = Interop.SensorListener.SetInterval(_listenerHandle, _interval); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting sensor interval"); + throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.SetInterval Failed"); + } + } + } + } + + private void SetMaxBatchLatency() + { + if (CheckListenerHandle()) + { + int error = Interop.SensorListener.SetMaxBatchLatency(_listenerHandle, _maxBatchLatency); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting max batch latency"); + throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.MaxBatchLatency Failed"); + } + } + } + + private bool CheckListenerHandle() + { + bool result = false; + if (_listenerHandle != IntPtr.Zero) + { + result = true; + } + else + { + Log.Error(Globals.LogTag, "Sensor listener handle is null"); + throw new ArgumentException("Invalid Parameter: Sensor is null"); + } + return result; + } + + private bool CheckSensorHandle() + { + bool result = false; + if (_sensorHandle != IntPtr.Zero) + { + result = true; + } + else + { + Log.Error(Globals.LogTag, "Sensor handle is null"); + throw new ArgumentException("Invalid Parameter: Sensor is null"); + } + return result; + } + + private void DestroyHandles() + { + Interop.SensorListener.DestroyListener(_listenerHandle); + } + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/SensorEnumerations.cs b/Tizen.Sensor/Tizen.Sensor/SensorEnumerations.cs new file mode 100644 index 0000000..0999a77 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/SensorEnumerations.cs @@ -0,0 +1,276 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Sensor +{ + /// + /// The SensorType Enum defintion for all sensor types. + /// + internal enum SensorType + { + /// + /// All sensors. This can be used to retrieve Sensor class object for all available sensors. + /// + All = -1, + /// + /// Accelerometer sensor. + /// + Accelerometer = 0, + /// + /// Gravity sensor. + /// + GravitySensor = 1, + /// + /// Linear Acceleration sensor. + /// + LinearAccelerationSensor = 2, + /// + /// Magnetometer sensor. + /// + Magnetometer = 3, + /// + /// Rotation Vector sensor. + /// + RotationVectorSensor = 4, + /// + /// Orientation sensor. + /// + OrientationSensor = 5, + /// + /// Gyroscope sensor. + /// + Gyroscope = 6, + /// + /// Light sensor. + /// + LightSensor = 7, + /// + /// Proximity sensor. + /// + ProximitySensor = 8, + /// + /// Pressure sensor. + /// + PressureSensor = 9, + /// + /// Ultraviolet sensor. + /// + UltravioletSensor = 10, + /// + /// Temperature sensor. + /// + TemperatureSensor = 11, + /// + /// Humidity sensor. + /// + HumiditySensor = 12, + /// + /// Hear rate monitor sensor. + /// + HeartRateMonitor = 13, + /// + /// Uncalibrated Gyroscope sensor. + /// + UncalibratedGyroscope = 17, + /// + /// Uncalibrated Geomagnetic sensor. + /// + UncalibratedMagnetometer = 18, + /// + /// Gyroscope-based rotation vector sensor. + /// + GyroscopeRotationVectorSensor = 19, + /// + /// Geomagnetic-based rotation vector sensor. + /// + MagnetometerRotationVectorSensor = 20, + /// + /// Pedometer sensor. + /// + Pedometer = 0x300, + /// + /// Sleep monitor sensor. + /// + SleepMonitor = 0x301, + /// + /// Walking activity detector. + /// + WalkingActivityDetector = 0x1A00, + /// + /// Running activity detector. + /// + RunningActivityDetector = 0x1A00, + /// + /// Stationary activity detector. + /// + StationaryActivityDetector = 0x1A00, + /// + /// InVehicle activity detector. + /// + InVehicleActivityDetector = 0x1A00, + /// + /// Wrist up gesture detector. + /// + WristUpGestureDetector = 0x1201, + /// + /// Pick up gesture detector. + /// + PickUpGestureDetector = 0x1204, + /// + /// Face down gesture detector. + /// + FaceDownGestureDetector = 0x1205 + } + + /// + /// SensorDataAccuracy Enum definition for all possible sensor data accuracy Values. + /// + public enum SensorDataAccuracy + { + /// + /// Undefined sensor data accuracy. + /// + Undefined = -1, + /// + /// Sensor data not accurate. + /// + Bad = 0, + /// + /// Moderately accurate sensor data. + /// + Normal = 1, + /// + /// Highly accurate sensor data. + /// + Good = 2, + /// + /// Very highly accurate sensor data. + /// + VeryGood = 3 + } + + /// + /// Sensor Option Enum definition for sensor option Values + /// + public enum SensorPausePolicy + { + /// + /// Does not receive data when the LCD is off and in the power save mode. + /// + None, + /// + /// Receives data when the LCD is off. + /// + DisplayOff, + /// + /// Receives data in the power save mode. + /// + PowerSaveMode, + /// + /// Receives data when the LCD is off and in the power save mode. + /// + All + } + + /// + /// Sensor attribute. + /// + public enum SensorAttribute + { + /// + /// The axis orientation. + /// + AxisOrientation, + + /// + /// The pause policy. + /// + PausePolicy + } + + /// + /// Pedometer state. + /// + public enum PedometerState + { + /// + /// Unknown. + /// + Unknown, + + /// + /// Stop state. + /// + Stop, + + /// + /// Walking state. + /// + Walk, + + /// + /// Running state. + /// + Run + } + + /// + /// Sleep monitor state. + /// + public enum SleepMonitorState + { + /// + /// Unknown. + /// + Unknown, + + /// + /// The wake state. + /// + Wake, + + /// + /// The sleeping state. + /// + Sleep + } + + /// + /// Proximity sensor state. + /// + public enum ProximitySensorState + { + /// + /// Near sate. + /// + Near = 0, + + /// + /// Far state. + /// + Far = 5 + } + + /// + /// Detector sensor state. + /// + public enum DetectorState + { + /// + /// None sate. + /// + NotDetected = 0, + + /// + /// Detected state. + /// + Detected = 1 + } +} diff --git a/Tizen.Sensor/Tizen.Sensor/SensorErrorFactory.cs b/Tizen.Sensor/Tizen.Sensor/SensorErrorFactory.cs new file mode 100644 index 0000000..666e430 --- /dev/null +++ b/Tizen.Sensor/Tizen.Sensor/SensorErrorFactory.cs @@ -0,0 +1,54 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; +using Tizen.Internals.Errors; + +namespace Tizen.Sensor +{ + internal enum SensorError + { + None = ErrorCode.None, + IOError = ErrorCode.IoError, + InvalidParameter = ErrorCode.InvalidParameter, + NotSupported = ErrorCode.NotSupported, + PermissionDenied = ErrorCode.PermissionDenied, + OutOfMemory = ErrorCode.OutOfMemory, + NotNeedCalibration = -0x02440000 | 0x03, + OperationFailed = -0x02440000 | 0x06 + } + + internal static class SensorErrorFactory + { + static internal Exception CheckAndThrowException(int error, string msg) + { + SensorError e = (SensorError)error; + switch (e) + { + case SensorError.None: + return null; + case SensorError.IOError: + return new InvalidOperationException("I/O Error: " + msg); + case SensorError.InvalidParameter: + return new ArgumentException("Invalid Parameter: " + msg); + case SensorError.NotSupported: + return new InvalidOperationException("Not Supported: " + msg); + case SensorError.PermissionDenied: + return new InvalidOperationException("Permission Denied: " + msg); + case SensorError.OutOfMemory: + return new InvalidOperationException("Out of Memory: " + msg); + case SensorError.NotNeedCalibration: + return new InvalidOperationException("Sensor doesn't need calibration: " + msg); + case SensorError.OperationFailed: + return new InvalidOperationException("Operation Failed: " + msg); + default: + return new InvalidOperationException("Unknown Error Code: " + msg); + } + } + } +} \ No newline at end of file diff --git a/Tizen.System.Sensor/Interop/Interop.Libraries.cs b/Tizen.System.Sensor/Interop/Interop.Libraries.cs deleted file mode 100644 index 2b42537..0000000 --- a/Tizen.System.Sensor/Interop/Interop.Libraries.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -internal static partial class Interop -{ - internal static partial class Libraries - { - public const string Sensor = "libcapi-system-sensor.so.0"; - public const string Libc = "libc.so.6"; - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Interop/Interop.Sensor.cs b/Tizen.System.Sensor/Interop/Interop.Sensor.cs deleted file mode 100644 index 1777244..0000000 --- a/Tizen.System.Sensor/Interop/Interop.Sensor.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; -using System.Runtime.InteropServices; -using Tizen.System.Sensor; - -internal static partial class Interop -{ - internal static class Sensor - { - //Sensor Hardware CAPI - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_name")] - internal static extern int GetName(IntPtr sensorhandle, out String name); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_vendor")] - internal static extern int GetVendor(IntPtr sensorHandle, out String vendor); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_type")] - internal static extern int GetType(IntPtr sensorHandle, out SensorType type); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_min_range")] - internal static extern int GetMinRange(IntPtr sensorHandle, out float minRange); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_max_range")] - internal static extern int GetMaxRange(IntPtr sensorHandle, out float maxRange); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_resolution")] - internal static extern int GetResolution(IntPtr sensorHandle, out float resolution); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_min_interval")] - internal static extern int GetMinInterval(IntPtr sensorHandle, out int minInterval); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_fifo_count")] - internal static extern int GetFifoCount(IntPtr sensorHandle, out int fifoCount); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_max_batch_count")] - internal static extern int GetMaxBatchCount(IntPtr sensorHandle, out int maxBatchCount); - } - internal static class SensorListener - { - //Sensor Listener CAPI - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void SensorEventCallback(IntPtr sensorHandle, IntPtr eventData, IntPtr data); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void SensorAccuracyCallback(IntPtr sensorHandle, ulong timestamp, SensorDataAccuracy accuracy, IntPtr data); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_create_listener")] - internal static extern int CreateListener(IntPtr sensorHandle, out IntPtr listenerHandle); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_destroy_listener")] - internal static extern int DestroyListener(IntPtr listenerHandle); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_start")] - internal static extern int StartListener(IntPtr listenerHandle); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_stop")] - internal static extern int StopListener(IntPtr listenerHandle); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_event_cb")] - internal static extern int SetEventCallback(IntPtr listenerHandle, uint intervalMs, SensorEventCallback callback, IntPtr data); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_unset_event_cb")] - internal static extern int UnsetEventCallback(IntPtr listernerHandle); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_accuracy_cb")] - internal static extern int SetAccuracyCallback(IntPtr listenerHandle, uint intervalMs, SensorAccuracyCallback callback, IntPtr data); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_unset_accuracy_cb")] - internal static extern int UnsetAccuracyCallback(IntPtr listernerHandle); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_interval")] - internal static extern int SetInterval(IntPtr listenerHandle, uint intervalMs); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_max_batch_latency")] - internal static extern int SetMaxBatchLatency(IntPtr listenerHandle, uint maxBatchLatency); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_listener_set_attribute_int")] - internal static extern int SetAttribute(IntPtr listenerHandle, SensorAttribute sensorAttribute, int option); - } - - internal static class SensorManager - { - //Sensor Manager CAPI - [DllImport(Libraries.Sensor, EntryPoint = "sensor_is_supported")] - internal static extern int SensorIsSupported(SensorType type, out bool supported); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_default_sensor")] - internal static extern int GetDefaultSensor(SensorType type, out IntPtr sensor); - - [DllImport(Libraries.Sensor, EntryPoint = "sensor_get_sensor_list")] - internal static extern int GetSensorList(SensorType type, out IntPtr list, out int sensor_count); - } - - internal static partial class Libc - { - [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Free(IntPtr ptr); - } - - [StructLayout(LayoutKind.Sequential, Pack = 0)] - internal struct SensorEventStruct - { - internal SensorDataAccuracy accuracy; - internal UInt64 timestamp; - internal int value_count; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - internal float[] values; - } - - internal static IntPtr[] IntPtrToIntPtrArray(IntPtr unmanagedArray, int size) - { - IntPtr[] managedArray = new IntPtr[size]; - Marshal.Copy(unmanagedArray, managedArray, 0, size); - return managedArray; - } - - internal static SensorEventStruct IntPtrToEventStruct(IntPtr unmanagedVariable) - { - SensorEventStruct outStruct = (SensorEventStruct)Marshal.PtrToStructure(unmanagedVariable, typeof(SensorEventStruct)); - return outStruct; - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Properties/AssemblyInfo.cs b/Tizen.System.Sensor/Properties/AssemblyInfo.cs deleted file mode 100644 index 32b31bb..0000000 --- a/Tizen.System.Sensor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Tizen.System.Sensor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Samsung Electronics")] -[assembly: AssemblyProduct("Tizen.System.Sensor")] -[assembly: AssemblyCopyright("Copyright (c) 2015 Samsung Electronics Co., Ltd")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.0.0")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.Net45.csproj b/Tizen.System.Sensor/Tizen.System.Sensor.Net45.csproj deleted file mode 100644 index 98a8eb3..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor.Net45.csproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - Debug - AnyCPU - {15FBE509-20D4-4D66-A8FC-5B0AC807BB88} - Library - Properties - Tizen.System.Sensor - Tizen.System.Sensor - 512 - v4.5 - - - true - full - false - bin\Debug\Net45\ - DEBUG;TRACE - prompt - 4 - false - false - - - pdbonly - true - bin\Release\Net45\ - TRACE - prompt - 4 - false - false - - - true - - - Tizen.System.Sensor.snk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json b/Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json deleted file mode 100755 index 503a8ff..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "dependencies": { - "Tizen": "1.0.1", - "Tizen.System": "1.0.2" - }, - "frameworks": { - "net45": {} - }, - "runtimes": { - "win": {} - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.csproj b/Tizen.System.Sensor/Tizen.System.Sensor.csproj deleted file mode 100644 index 9ce46ed..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor.csproj +++ /dev/null @@ -1,137 +0,0 @@ - - - - Debug - AnyCPU - {CB655C6A-F73B-448E-913C-CA4DCBC5E401} - Library - Properties - Tizen.System.Sensor - Tizen.System.Sensor - 512 - - - .NETStandard - v1.3 - .NETStandard,Version=v1.3 - false - true - $(NoWarn);1701;1702 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - false - - - true - - - Tizen.System.Sensor.snk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) - <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) - true - - \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.nuspec b/Tizen.System.Sensor/Tizen.System.Sensor.nuspec deleted file mode 100644 index 0dd6680..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor.nuspec +++ /dev/null @@ -1,16 +0,0 @@ - - - - Tizen.System.Sensor - $version$ - Tizen Developers - Sensor API for Tizen.Net - - - - - - - - - diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.project.json b/Tizen.System.Sensor/Tizen.System.Sensor.project.json deleted file mode 100644 index 5abf875..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor.project.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "dependencies": { - "NETStandard.Library": "1.6.0", - "Tizen": "1.0.1", - "Tizen.System": "1.0.2" - }, - "frameworks": { - "netstandard1.3": {} - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.snk b/Tizen.System.Sensor/Tizen.System.Sensor.snk deleted file mode 100644 index e480db4..0000000 Binary files a/Tizen.System.Sensor/Tizen.System.Sensor.snk and /dev/null differ diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs deleted file mode 100644 index 0089c77..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Accelerometer changed event arguments. Class for storing the data returned by accelerometer - /// - public class AccelerometerDataUpdatedEventArgs : EventArgs - { - internal AccelerometerDataUpdatedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - } - - /// - /// Gets the X component of the acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the acceleration. - /// - public float Z { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/FaceDownGestureDetectorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/FaceDownGestureDetectorDataUpdatedEventArgs.cs deleted file mode 100644 index 7869fa4..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/FaceDownGestureDetectorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// FaceDownGestureDetector changed event arguments. Class for storing the data returned by face down gesture detector. - /// - public class FaceDownGestureDetectorDataUpdatedEventArgs : EventArgs - { - internal FaceDownGestureDetectorDataUpdatedEventArgs(float state) - { - FaceDown = (DetectorState) state; - } - - /// - /// Gets the face down state. - /// - public DetectorState FaceDown { get; private set; } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs deleted file mode 100644 index ed24a8f..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// GravitySensor changed event arguments. Class for storing the data returned by gravity sensor - /// - public class GravitySensorDataUpdatedEventArgs : EventArgs - { - internal GravitySensorDataUpdatedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - } - - /// - /// Gets the X component of the gravity. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the gravity. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the gravity. - /// - public float Z { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeDataUpdatedEventArgs.cs deleted file mode 100644 index 1cf91d9..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeDataUpdatedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Gyroscope changed event arguments. Class for storing the data returned by gyroscope - /// - public class GyroscopeDataUpdatedEventArgs : EventArgs - { - internal GyroscopeDataUpdatedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - } - - /// - /// Gets the X component of the gyroscope data. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the gyroscope data. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the gyroscope data. - /// - public float Z { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeRotationVectorSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeRotationVectorSensorDataUpdatedEventArgs.cs deleted file mode 100644 index a1cf5ed..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeRotationVectorSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// GyroscopeRotationVectorSensor changed event arguments. Class for storing the data returned by gyroscope rotation vector sensor - /// - public class GyroscopeRotationVectorSensorDataUpdatedEventArgs : EventArgs - { - internal GyroscopeRotationVectorSensorDataUpdatedEventArgs(float[] values, SensorDataAccuracy accuracy) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - W = values[3]; - Accuracy = accuracy; - } - - /// - /// Gets the X component of the gyroscope rotation vector. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the gyroscope rotation vector. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the gyroscope rotation vector. - /// - public float Z { get; private set; } - - /// - /// Gets the W component of the gyroscope rotation vector. - /// - public float W { get; private set; } - - /// - /// Gets the accuracy of the gyroscope rotation vector data. - /// - public SensorDataAccuracy Accuracy { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HeartRateMonitorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HeartRateMonitorDataUpdatedEventArgs.cs deleted file mode 100644 index 39f9921..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HeartRateMonitorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// HeartRateMonitor changed event arguments. Class for storing the data returned by heart rate monitor - /// - public class HeartRateMonitorDataUpdatedEventArgs : EventArgs - { - internal HeartRateMonitorDataUpdatedEventArgs(int heartRate) - { - HeartRate = heartRate; - } - - /// - /// Gets the value of the heartRate. - /// - public int HeartRate { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HumiditySensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HumiditySensorDataUpdatedEventArgs.cs deleted file mode 100644 index 5fd0d7c..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HumiditySensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// HumiditySensor changed event arguments. Class for storing the data returned by humidity sensor - /// - public class HumiditySensorDataUpdatedEventArgs : EventArgs - { - internal HumiditySensorDataUpdatedEventArgs(float humidity) - { - Humidity = humidity; - } - - /// - /// Gets the value of the humidity. - /// - public float Humidity { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/InVehicleActivityDetectorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/InVehicleActivityDetectorDataUpdatedEventArgs.cs deleted file mode 100644 index df7fa04..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/InVehicleActivityDetectorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// InVehicleActivityDetector changed event arguments. Class for storing the data returned by in-vehicle activity detector - /// - public class InVehicleActivityDetectorDataUpdatedEventArgs : EventArgs - { - internal InVehicleActivityDetectorDataUpdatedEventArgs(float state) - { - InVehicle = (DetectorState) state; - } - - /// - /// Gets the in-vehicle state. - /// - public DetectorState InVehicle { get; private set; } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs deleted file mode 100644 index d0d1896..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// LightSensor changed event arguments. Class for storing the data returned by light sensor - /// - public class LightSensorDataUpdatedEventArgs : EventArgs - { - internal LightSensorDataUpdatedEventArgs(float level) - { - Level = level; - } - - /// - /// Gets the level of the light. - /// - public float Level { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LinearAccelerationSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LinearAccelerationSensorDataUpdatedEventArgs.cs deleted file mode 100644 index cf531ca..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LinearAccelerationSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// LinearAccelerationSensor changed event arguments. Class for storing the data returned by linear acceleration sensor - /// - public class LinearAccelerationSensorDataUpdatedEventArgs : EventArgs - { - internal LinearAccelerationSensorDataUpdatedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - } - - /// - /// Gets the X component of the linear acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the linear acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the linear acceleration. - /// - public float Z { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerDataUpdatedEventArgs.cs deleted file mode 100644 index 8ca789e..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerDataUpdatedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Magnetometer changed event arguments. Class for storing the data returned by magnetometer sensor - /// - public class MagnetometerDataUpdatedEventArgs : EventArgs - { - internal MagnetometerDataUpdatedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - } - - /// - /// Gets the X component of the magnetometer. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the magnetometer. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the magnetometer. - /// - public float Z { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerRotationVectorSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerRotationVectorSensorDataUpdatedEventArgs.cs deleted file mode 100644 index abb096e..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerRotationVectorSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// MagnetometerRotationVectorSensor changed event arguments. Class for storing the data returned by magnetometer rotation vector sensor - /// - public class MagnetometerRotationVectorSensorDataUpdatedEventArgs : EventArgs - { - internal MagnetometerRotationVectorSensorDataUpdatedEventArgs(float[] values, SensorDataAccuracy accuracy) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - W = values[3]; - Accuracy = accuracy; - } - - /// - /// Gets the X component of the magnetometer rotation vector. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the magnetometer rotation vector. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the magnetometer rotation vector. - /// - public float Z { get; private set; } - - /// - /// Gets the W component of the magnetometer rotation vector. - /// - public float W { get; private set; } - - /// - /// Gets the accuracy of the magnetometer rotation vector data. - /// - public SensorDataAccuracy Accuracy { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/OrientationSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/OrientationSensorDataUpdatedEventArgs.cs deleted file mode 100644 index a95f377..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/OrientationSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// OrientationSensor changed event arguments. Class for storing the data returned by orientation sensor - /// - public class OrientationSensorDataUpdatedEventArgs : EventArgs - { - internal OrientationSensorDataUpdatedEventArgs(float[] values) - { - Azimuth = values[0]; - Pitch = values[1]; - Roll = values[2]; - } - - /// - /// Gets the azimuth component of the orientation. - /// - public float Azimuth { get; private set; } - - /// - /// Gets the pitch component of the orientation. - /// - public float Pitch { get; private set; } - - /// - /// Gets the roll component of the orientation. - /// - public float Roll { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PedometerDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PedometerDataUpdatedEventArgs.cs deleted file mode 100644 index 5b77d98..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PedometerDataUpdatedEventArgs.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Pedometer changed event arguments. Class for storing the data returned by pedometer - /// - public class PedometerDataUpdatedEventArgs : EventArgs - { - internal PedometerDataUpdatedEventArgs(float[] values) - { - StepCount = (int) values[0]; - WalkStepCount = (int) values[1]; - RunStepCount = (int) values[2]; - MovingDistance = values[3]; - CalorieBurned = values[4]; - LastSpeed = values[5]; - LastSteppingFrequency = values[6]; - LastStepStatus = (PedometerState) values[7]; - } - - /// - /// Gets the step count - /// - public int StepCount { get; private set; } - - /// - /// Gets the walking step count - /// - public int WalkStepCount { get; private set; } - - /// - /// Gets the running step count - /// - public int RunStepCount { get; private set; } - - /// - /// Gets the moving distance - /// - public float MovingDistance { get; private set; } - - /// - /// Gets the calorie burned - /// - public float CalorieBurned { get; private set; } - - /// - /// Gets the last speed - /// - public float LastSpeed { get; private set; } - - /// - /// Gets the last stepping frequency - /// - public float LastSteppingFrequency { get; private set; } - - /// - /// Gets the last step status - /// - public PedometerState LastStepStatus { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PickUpGestureDetectorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PickUpGestureDetectorDataUpdatedEventArgs.cs deleted file mode 100644 index 17a2552..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PickUpGestureDetectorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// PickUpGestureDetector changed event arguments. Class for storing the data returned by pick up gesture detector - /// - public class PickUpGestureDetectorDataUpdatedEventArgs : EventArgs - { - internal PickUpGestureDetectorDataUpdatedEventArgs(float state) - { - PickUp = (DetectorState) state; - } - - /// - /// Gets the pick up state. - /// - public DetectorState PickUp { get; private set; } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs deleted file mode 100644 index b6f6e4a..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// PressureSensor changed event arguments. Class for storing the data returned by pressure sensor - /// - public class PressureSensorDataUpdatedEventArgs : EventArgs - { - internal PressureSensorDataUpdatedEventArgs(float pressure) - { - Pressure = pressure; - } - - /// - /// Gets the value of the pressure. - /// - public float Pressure { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/ProximitySensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/ProximitySensorDataUpdatedEventArgs.cs deleted file mode 100644 index a959ad4..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/ProximitySensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// ProximitySensor changed event arguments. Class for storing the data returned by proximity sensor - /// - public class ProximitySensorDataUpdatedEventArgs : EventArgs - { - internal ProximitySensorDataUpdatedEventArgs(float proximity) - { - Proximity = (ProximitySensorState) proximity; - } - - /// - /// Gets the proximity state. - /// - public ProximitySensorState Proximity { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/RotationVectorSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/RotationVectorSensorDataUpdatedEventArgs.cs deleted file mode 100644 index 8111981..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/RotationVectorSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// RotationVectorSensor changed event arguments. Class for storing the data returned by rotation vector sensor - /// - public class RotationVectorSensorDataUpdatedEventArgs : EventArgs - { - internal RotationVectorSensorDataUpdatedEventArgs(float[] values, SensorDataAccuracy accuracy) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - W = values[3]; - Accuracy = accuracy; - } - - /// - /// Gets the X component of the rotation vector. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the rotation vector. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the rotation vector. - /// - public float Z { get; private set; } - - /// - /// Gets the W component of the rotation vector. - /// - public float W { get; private set;} - - /// - /// Gets the accuracy of the rotation vector data. - /// - public SensorDataAccuracy Accuracy { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/RunningActivityDetectorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/RunningActivityDetectorDataUpdatedEventArgs.cs deleted file mode 100644 index ccb8b27..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/RunningActivityDetectorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// RunningActivityDetector changed event arguments. Class for storing the data returned by running activity detector - /// - public class RunningActivityDetectorDataUpdatedEventArgs : EventArgs - { - internal RunningActivityDetectorDataUpdatedEventArgs(float state) - { - Running = (DetectorState) state; - } - - /// - /// Gets the running state. - /// - public DetectorState Running { get; private set; } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs deleted file mode 100644 index 5846d40..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Sensor accuracy changed event arguments Class. Contains the parameters to be returned through accuracy callback - /// - public class SensorAccuracyChangedEventArgs : EventArgs - { - internal SensorAccuracyChangedEventArgs(TimeSpan timespan, SensorDataAccuracy accuracy) - { - TimeSpan = timespan; - Accuracy = accuracy; - } - - /// - /// Gets the time stamp. - /// - public TimeSpan TimeSpan { get; private set; } - - /// - /// Gets the accuracy. - /// - public SensorDataAccuracy Accuracy { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs deleted file mode 100644 index 2a6d5ab..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// SleepMonitor changed event arguments. Class for storing the data returned by sleep monitor - /// - public class SleepMonitorDataUpdatedEventArgs : EventArgs - { - internal SleepMonitorDataUpdatedEventArgs(int sleepState) - { - SleepState = (SleepMonitorState) sleepState; - } - - /// - /// Gets the value of the sleep state. - /// - public SleepMonitorState SleepState { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/StationaryActivityDetectorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/StationaryActivityDetectorDataUpdatedEventArgs.cs deleted file mode 100644 index 6e13641..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/StationaryActivityDetectorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// StationaryActivityDetector changed event arguments. Class for storing the data returned by stationary activity detector - /// - public class StationaryActivityDetectorDataUpdatedEventArgs : EventArgs - { - internal StationaryActivityDetectorDataUpdatedEventArgs(float state) - { - Stationary = (DetectorState) state; - } - - /// - /// Gets the stationary state. - /// - public DetectorState Stationary { get; private set; } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs deleted file mode 100644 index 8e746bf..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// TemperatureSensor changed event arguments. Class for storing the data returned by temperature sensor - /// - public class TemperatureSensorDataUpdatedEventArgs : EventArgs - { - internal TemperatureSensorDataUpdatedEventArgs(float temperature) - { - Temperature = temperature; - } - - /// - /// Gets the value of the temperature. - /// - public float Temperature { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UltravioletSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UltravioletSensorDataUpdatedEventArgs.cs deleted file mode 100644 index d6a140d..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UltravioletSensorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// UltravioletSensor changed event arguments. Class for storing the data returned by ultraviolet sensor - /// - public class UltravioletSensorDataUpdatedEventArgs : EventArgs - { - internal UltravioletSensorDataUpdatedEventArgs(float ultravioletIndex) - { - UltravioletIndex = ultravioletIndex; - } - - /// - /// Gets the value of the ultraviolet index. - /// - public float UltravioletIndex { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedGyroscopeDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedGyroscopeDataUpdatedEventArgs.cs deleted file mode 100644 index 9e44476..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedGyroscopeDataUpdatedEventArgs.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// UncalibratedGyroscope changed event arguments. Class for storing the data returned by uncalibrated gyroscope - /// - public class UncalibratedGyroscopeDataUpdatedEventArgs : EventArgs - { - internal UncalibratedGyroscopeDataUpdatedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - BiasX = values[3]; - BiasY = values[4]; - BiasZ = values[5]; - } - - /// - /// Gets the X component of the uncalibrated gyroscope data. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the uncalibrated gyroscope data. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the uncalibrated gyroscope data. - /// - public float Z { get; private set; } - - /// - /// Gets the BiasX component of the uncalibrated gyroscope data. - /// - public float BiasX { get; private set; } - - /// - /// Gets the BiasY component of the uncalibrated gyroscope data. - /// - public float BiasY { get; private set; } - - /// - /// Gets the BiasZ component of the uncalibrated gyroscope data. - /// - public float BiasZ { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedMagnetometerDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedMagnetometerDataUpdatedEventArgs.cs deleted file mode 100644 index 1227e98..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedMagnetometerDataUpdatedEventArgs.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// UncalibratedMagnetometer changed event arguments. Class for storing the data returned by uncalibrated magnetometer - /// - public class UncalibratedMagnetometerDataUpdatedEventArgs : EventArgs - { - internal UncalibratedMagnetometerDataUpdatedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - BiasX = values[3]; - BiasY = values[4]; - BiasZ = values[5]; - } - - /// - /// Gets the X component of the uncalibrated magnetometer data. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the uncalibrated magnetometer data. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the uncalibrated magnetometer data. - /// - public float Z { get; private set; } - - /// - /// Gets the BiasX component of the uncalibrated magnetometer data. - /// - public float BiasX { get; private set; } - - /// - /// Gets the BiasY component of the uncalibrated magnetometer data. - /// - public float BiasY { get; private set; } - - /// - /// Gets the BiasZ component of the uncalibrated magnetometer data. - /// - public float BiasZ { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/WalkingActivityDetectorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/WalkingActivityDetectorDataUpdatedEventArgs.cs deleted file mode 100644 index aa309d0..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/WalkingActivityDetectorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// WalkingActivityDetector changed event arguments. Class for storing the data returned by walking activity detector - /// - public class WalkingActivityDetectorDataUpdatedEventArgs : EventArgs - { - internal WalkingActivityDetectorDataUpdatedEventArgs(float state) - { - Walking = (DetectorState) state; - } - - /// - /// Gets the walking state. - /// - public DetectorState Walking { get; private set; } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/WristUpGestureDetectorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/WristUpGestureDetectorDataUpdatedEventArgs.cs deleted file mode 100644 index 69d6f4a..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/WristUpGestureDetectorDataUpdatedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// WristUpGestureDetector changed event arguments. Class for storing the data returned by wrist up gesture detector - /// - public class WristUpGestureDetectorDataUpdatedEventArgs : EventArgs - { - internal WristUpGestureDetectorDataUpdatedEventArgs(float state) - { - WristUp = (DetectorState) state; - } - - /// - /// Gets the wrist up state. - /// - public DetectorState WristUp { get; private set; } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs deleted file mode 100644 index cdc01bc..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Accelerometer Sensor Class. Used for registering callbacks for accelerometer and getting accelerometer data - /// /// - public class Accelerometer : Sensor - { - private static string AccelerometerKey = "http://tizen.org/feature/sensor.accelerometer"; - /// - /// Gets the X component of the acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the acceleration. - /// - public float Z { get; private set; } - - /// - /// Returns true or false based on whether accelerometer sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the Accelerometer sensor is supported"); - return CheckIfSupported(SensorType.Accelerometer, AccelerometerKey); - } - } - - /// - /// Returns the number of accelerometer sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of accelerometer sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular accelerometer sensor in case of multiple sensors - /// - public Accelerometer(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating Accelerometer object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.Accelerometer; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in accelerometer sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.Accelerometer, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for accelerometer"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for accelerometer sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for accelerometer"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for accelerometer sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for accelerometer"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new AccelerometerDataUpdatedEventArgs(sensorData.values)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ActivityDetector.cs deleted file mode 100644 index d0189e2..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ActivityDetector.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - public abstract class ActivityDetector : Sensor - { - protected const int ActivityAttribute = (((int)SensorType.InVehicleActivityDetector << 8) | 0x80 | 0x1); - - protected enum ActivityType - { - Unknown = 1, - Stationary = 2, - Walking = 4, - Running = 8, - InVehicle = 16, - OnBicycle = 32, - }; - - /// - /// Gets the activity accuracy of activity detector - /// - public SensorDataAccuracy ActivityAccuracy { get; protected set; } - - protected abstract void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data); - - internal ActivityDetector(int index) : base(index) - { - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for activity detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for activity detector"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for activity detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for activity detector"); - } - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/FaceDownGestureDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/FaceDownGestureDetector.cs deleted file mode 100644 index 2433b43..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/FaceDownGestureDetector.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// FaceDownGestureDetector Class. Used for registering callbacks for face down gesture detector and getting the face down state - /// - public class FaceDownGestureDetector : Sensor - { - private static string GestureDetectorKey = "http://tizen.org/feature/sensor.gesture_recognition"; - - /// - /// Gets the state of the face down gesture. - /// - public DetectorState FaceDown { get; private set; } - - /// - /// Returns true or false based on whether face down gesture detector is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the face down gesture detector is supported"); - return CheckIfSupported(SensorType.FaceDownGestureDetector, GestureDetectorKey); - } - } - - /// - /// Returns the number of face down gesture detector available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of face down gesture detectors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular face down gesture detector in case of multiple sensors. - /// - public FaceDownGestureDetector(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating face down gesture detector object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.FaceDownGestureDetector; - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.FaceDownGestureDetector, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for face down gesture detector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in face down gesture detector data. - /// - public event EventHandler DataUpdated; - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for face down gesture detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for face down gesture detector"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for face down gesture detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for face down gesture detector"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - FaceDown = (DetectorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new FaceDownGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs deleted file mode 100644 index 1ce4212..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// GravitySensor Class. Used for registering callbacks for gravity sensor and getting gravity data - /// /// - public class GravitySensor : Sensor - { - private const string GravitySensorKey = "http://tizen.org/feature/sensor.gravity"; - - private event EventHandler _accuracyChanged; - /// - /// Gets the X component of the gravity. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the gravity. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the gravity. - /// - public float Z { get; private set; } - - /// - /// Returns true or false based on whether gravity sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the GravitySensor is supported"); - return CheckIfSupported(SensorType.GravitySensor, GravitySensorKey); - } - } - - /// - /// Returns the number of gravity sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of gravity sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular gravity sensor in case of multiple sensors - /// - public GravitySensor (int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating GravitySensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.GravitySensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in gravity sensor data. - /// - - public event EventHandler DataUpdated; - - /// - /// Event handler for accuracy changed events. - /// - public event EventHandler AccuracyChanged - { - add - { - if (_accuracyChanged == null) - { - AccuracyListenStart(); - } - _accuracyChanged += value; - } - remove - { - _accuracyChanged -= value; - if (_accuracyChanged == null) - { - AccuracyListenStop(); - } - } - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.GravitySensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for gravity"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for gravity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for gravity"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for gravity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gravity"); - } - } - - private void AccuracyListenStart() - { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting accuracy event callback for gravity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for gravity"); - } - } - - private void AccuracyListenStop() - { - int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for gravity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for gravity"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new GravitySensorDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs deleted file mode 100644 index 4766d4c..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Gyroscope Sensor Class. Used for registering callbacks for gyroscope and getting gyroscope data - /// /// - public class Gyroscope : Sensor - { - private const string GyroscopeKey = "http://tizen.org/feature/sensor.gyroscope"; - - /// - /// Gets the X component of the acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the acceleration. - /// - public float Z { get; private set; } - - /// - /// Returns true or false based on whether gyroscope sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the Gyroscope sensor is supported"); - return CheckIfSupported(SensorType.Gyroscope, GyroscopeKey); - } - } - - /// - /// Returns the number of gyroscope sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of gyroscope sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular gyroscope sensor in case of multiple sensors - /// - public Gyroscope(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating Gyroscope object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.Gyroscope; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in gyroscope sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.Gyroscope, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for gyroscope"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for gyroscope sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for gyroscope"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for gyroscope sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gyroscope"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new GyroscopeDataUpdatedEventArgs(sensorData.values)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs deleted file mode 100644 index 4e73e3e..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// GyroscopeRotationVectorSensor Class. Used for registering callbacks for gyroscope rotation vector sensor and getting gyroscope rotation vector data - /// /// - public class GyroscopeRotationVectorSensor : Sensor - { - private const string GyroscopeRVKey = "http://tizen.org/feature/sensor.gyroscope_rotation_vector"; - - /// - /// Gets the X component of the gyroscope rotation vector. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the gyroscope rotation vector. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the gyroscope rotation vector. - /// - public float Z { get; private set; } - - /// - /// Gets the W component of the gyroscope rotation vector. - /// - public float W { get; private set; } - - /// - /// Gets the Accuracy of the gyroscope rotation vector data. - /// - public SensorDataAccuracy Accuracy { get; private set; } - - /// - /// Returns true or false based on whether gyroscope rotation vector sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the GyroscopeRotationVectorSensor is supported"); - return CheckIfSupported(SensorType.GyroscopeRotationVectorSensor, GyroscopeRVKey); - } - } - - /// - /// Returns the number of gyroscope rotation vector sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of gyroscope rotation vector sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular gyroscope rotation vector sensor in case of multiple sensors - /// - public GyroscopeRotationVectorSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating GyroscopeRotationVectorSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.GyroscopeRotationVectorSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in gyroscope rotation vector sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.GyroscopeRotationVectorSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for gyroscope rotation vector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for gyroscope rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for gyroscope rotation vector"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for gyroscope rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gyroscope rotation vector"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - Accuracy = sensorData.accuracy; - - DataUpdated?.Invoke(this, new GyroscopeRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); - } - - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs deleted file mode 100644 index c9da6ce..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// HeartRateMonitor Class. Used for registering callbacks for heart rate monitor and getting heart rate data - /// /// - public class HeartRateMonitor : Sensor - { - private const string HRMKey = "http://tizen.org/feature/sensor.heart_rate_monitor"; - - /// - /// Gets the value of the heart rate monitor. - /// - public int HeartRate { get; private set; } - - /// - /// Returns true or false based on whether heart rate monitor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the HeartRateMonitor is supported"); - return CheckIfSupported(SensorType.HeartRateMonitor, HRMKey); - } - } - - /// - /// Returns the number of heart rate monitors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of heart rate monitors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular heart rate monitor in case of multiple sensors - /// - public HeartRateMonitor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating HeartRateMonitor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.HeartRateMonitor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in heart rate monitor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.HeartRateMonitor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for heart rate"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for heart rate monitor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for heart rate"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for heart rate monitor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for heart rate"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - HeartRate = (int)sensorData.values[0]; - - DataUpdated?.Invoke(this, new HeartRateMonitorDataUpdatedEventArgs((int)sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs deleted file mode 100644 index 27cd506..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// HumiditySensor Class. Used for registering callbacks for humidity sensor and getting humidity data - /// /// - public class HumiditySensor : Sensor - { - private const string HumiditySensorKey = "http://tizen.org/feature/sensor.humidity"; - - /// - /// Gets the value of the humidity sensor. - /// - public float Humidity { get; private set; } - - /// - /// Returns true or false based on whether humidity sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the HumiditySensor is supported"); - return CheckIfSupported(SensorType.HumiditySensor, HumiditySensorKey); - } - } - - /// - /// Returns the number of humidity sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of humidity sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular humidity sensor in case of multiple sensors - /// - public HumiditySensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating HumiditySensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.HumiditySensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in humidity sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.HumiditySensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for humidity"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for humidity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for humidity"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for humidity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for humidity"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Humidity = sensorData.values[0]; - - DataUpdated?.Invoke(this, new HumiditySensorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/InVehicleActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/InVehicleActivityDetector.cs deleted file mode 100644 index 7fec0e7..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/InVehicleActivityDetector.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// InVehicleActivityDetector Class. Used for registering callbacks for in vehicle activity detector and getting the in vehicle state - /// - public class InVehicleActivityDetector : ActivityDetector - { - private const string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; - - /// - /// Gets the state of in-vehicle activity detector - /// - public DetectorState InVehicle { get; private set; } - - /// - /// Returns true or false based on whether in-vehicle activity detector is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the in-vehicle activity detector is supported"); - return CheckIfSupported(SensorType.InVehicleActivityDetector, ActivityDetectorKey); - } - } - - /// - /// Returns the number of in-vehicle activity detector available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of in-vehicle activity detectors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular in-vehicle activity detector in case of multiple sensors. - /// - public InVehicleActivityDetector(int index = 0) : base(index) - { - SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.InVehicle); - Log.Info(Globals.LogTag, "Creating in-vehicle activity detector object"); - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.InVehicleActivityDetector, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for in-vehicle activity detector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in in-vehicle activity detector data. - /// - public event EventHandler DataUpdated; - - protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - InVehicle = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; - - DataUpdated?.Invoke(this, new InVehicleActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); - } - - internal override SensorType GetSensorType() - { - return SensorType.InVehicleActivityDetector; - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs deleted file mode 100644 index 43eee56..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// LightSensor Class. Used for registering callbacks for light sensor and getting light data - /// /// - public class LightSensor : Sensor - { - private const string LightSensorKey = "http://tizen.org/feature/sensor.photometer"; - - /// - /// Gets the Level of the light. - /// - public float Level { get; private set; } - - /// - /// Returns true or false based on whether light sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the LightSensor is supported"); - return CheckIfSupported(SensorType.LightSensor, LightSensorKey); - } - } - - /// - /// Returns the number of light sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of light sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular light sensor in case of multiple sensors - /// - public LightSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating LightSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.LightSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in light sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.LightSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for light"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for light sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for light"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for light sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for light"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Level = sensorData.values[0]; - - DataUpdated?.Invoke(this, new LightSensorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs deleted file mode 100644 index 484181a..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// LinearAccelerationSensor Class. Used for registering callbacks for linear acceleration sensor and getting linear acceleration data - /// /// - public class LinearAccelerationSensor : Sensor - { - private const string LinearAccelerationSensorKey = "http://tizen.org/feature/sensor.linear_acceleration"; - - private event EventHandler _accuracyChanged; - /// - /// Gets the X component of the linear acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the linear acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the linear acceleration. - /// - public float Z { get; private set; } - - /// - /// Returns true or false based on whether linear acceleration sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the LinearAccelerationSensor is supported"); - return CheckIfSupported(SensorType.LinearAccelerationSensor, LinearAccelerationSensorKey); - } - } - - /// - /// Returns the number of linear acceleration sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of linear acceleration sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular linear acceleration sensor in case of multiple sensors - /// - public LinearAccelerationSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating LinearAccelerationSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.LinearAccelerationSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in linear acceleration sensor data. - /// - - public event EventHandler DataUpdated; - - /// - /// Event handler for accuracy changed events. - /// - public event EventHandler AccuracyChanged - { - add - { - if (_accuracyChanged == null) - { - AccuracyListenStart(); - } - _accuracyChanged += value; - } - remove - { - _accuracyChanged -= value; - if (_accuracyChanged == null) - { - AccuracyListenStop(); - } - } - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.LinearAccelerationSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for linear acceleration sensor"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for linear acceleration sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for linear acceleration sensor"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for linear acceleration sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for linear acceleration"); - } - } - - private void AccuracyListenStart() - { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting accuracy event callback for linear acceleration sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for linear acceleration sensor"); - } - } - - private void AccuracyListenStop() - { - int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for linear acceleration sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for linear acceleration sensor"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new LinearAccelerationSensorDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs deleted file mode 100644 index 06967e9..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Magnetometer Class. Used for registering callbacks for magnetometer and getting magnetometer data - /// /// - public class Magnetometer : Sensor - { - private static string MagnetometerKey = "http://tizen.org/feature/sensor.magnetometer"; - - private event EventHandler _accuracyChanged; - /// - /// Gets the X component of the magnetometer. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the magnetometer. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the magnetometer. - /// - public float Z { get; private set; } - - /// - /// Returns true or false based on whether magnetometer is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the Magnetometer is supported"); - return CheckIfSupported(SensorType.Magnetometer, MagnetometerKey); - } - } - - /// - /// Returns the number of magnetometers available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of magnetometers"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular magnetometer in case of multiple sensors - /// - public Magnetometer(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating Magnetometer object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.Magnetometer; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in magnetometer data. - /// - - public event EventHandler DataUpdated; - - /// - /// Event handler for accuracy changed events. - /// - public event EventHandler AccuracyChanged - { - add - { - if (_accuracyChanged == null) - { - AccuracyListenStart(); - } - _accuracyChanged += value; - } - remove - { - _accuracyChanged -= value; - if (_accuracyChanged == null) - { - AccuracyListenStop(); - } - } - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.Magnetometer, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for magnetometer"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for magnetometer"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for magnetometer"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for magnetometer"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for magnetometer"); - } - } - - private void AccuracyListenStart() - { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting accuracy event callback for magnetometer"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for magnetometer"); - } - } - - private void AccuracyListenStop() - { - int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for magnetometer"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for magnetometer"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new MagnetometerDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs deleted file mode 100644 index aeff39f..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// MagnetometerRotationVectorSensor Class. Used for registering callbacks for magnetometer rotation vector sensor and getting magnetometer rotation vector data - /// /// - public class MagnetometerRotationVectorSensor : Sensor - { - private static string MagnetometerRVKey = "http://tizen.org/feature/sensor.geomagnetic_rotation_vector"; - - private event EventHandler _accuracyChanged; - /// - /// Gets the X component of the magnetometer rotation vector. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the magnetometer rotation vector. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the magnetometer rotation vector. - /// - public float Z { get; private set; } - - /// - /// Gets the W component of the magnetometer rotation vector. - /// - public float W { get; private set; } - - /// - /// Gets the Accuracy of the magnetometer rotation vector data. - /// - public SensorDataAccuracy Accuracy { get; private set; } - - /// - /// Returns true or false based on whether magnetometer rotation vector sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the MagnetometerRotationVectorSensor is supported"); - return CheckIfSupported(SensorType.MagnetometerRotationVectorSensor, MagnetometerRVKey); - } - } - - /// - /// Returns the number of magnetometer rotation vector sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of magnetometer rotation vector sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular magnetometer rotation vector sensor in case of multiple sensors - /// - public MagnetometerRotationVectorSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating MagnetometerRotationVectorSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.MagnetometerRotationVectorSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in magnetometer rotation vector sensor data. - /// - - public event EventHandler DataUpdated; - - /// - /// Event handler for accuracy changed events. - /// - public event EventHandler AccuracyChanged - { - add - { - if (_accuracyChanged == null) - { - AccuracyListenStart(); - } - _accuracyChanged += value; - } - remove - { - _accuracyChanged -= value; - if (_accuracyChanged == null) - { - AccuracyListenStop(); - } - } - } - - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.MagnetometerRotationVectorSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if magnetometer rotation vector sensor is supported"); - isSupported = false; - } - return isSupported; - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.MagnetometerRotationVectorSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for magnetometer rotation vector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for magnetometer rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for magnetometer rotation vector"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for magnetometer rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for magnetometer rotation vector"); - } - } - - private void AccuracyListenStart() - { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting accuracy event callback for magnetometer rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for magnetometer rotation vector"); - } - } - - private void AccuracyListenStop() - { - int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for magnetometer rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for magnetometer rotation vector"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - Accuracy = sensorData.accuracy; - - DataUpdated?.Invoke(this, new MagnetometerRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - Accuracy = accuracy; - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs deleted file mode 100644 index 4586b13..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). Pitchou -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// OrientationSensor Class. Used for registering callbacks for orientation sensor and getting orientation data - /// /// - public class OrientationSensor : Sensor - { - private static string OrientationSensorKey = "http://tizen.org/feature/sensor.tiltmeter"; - - private event EventHandler _accuracyChanged; - /// - /// Gets the Azimuth component of the orientation. - /// - public float Azimuth { get; private set; } - - /// - /// Gets the Pitch component of the orientation. - /// - public float Pitch { get; private set; } - - /// - /// Gets the Roll component of the orientation. - /// - public float Roll { get; private set; } - - /// - /// Returns true or false based on whether orientation sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the OrientationSensor is supported"); - return CheckIfSupported(SensorType.OrientationSensor, OrientationSensorKey); - } - } - - /// - /// Returns the number of orientation sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of orientation sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular orientation sensor in case of multiple sensors - /// - public OrientationSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating OrientationSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.OrientationSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in orientation sensor data. - /// - - public event EventHandler DataUpdated; - - /// - /// Event handler for accuracy changed events. - /// - public event EventHandler AccuracyChanged - { - add - { - if (_accuracyChanged == null) - { - AccuracyListenStart(); - } - _accuracyChanged += value; - } - remove - { - _accuracyChanged -= value; - if (_accuracyChanged == null) - { - AccuracyListenStop(); - } - } - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.OrientationSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for orientation"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for orientation sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for orientation"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for orientation sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for orientation"); - } - } - - private void AccuracyListenStart() - { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting accuracy event callback for orientation sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy accuracy event callback for orientation"); - } - } - - private void AccuracyListenStop() - { - int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for orientation sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for orientation"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Azimuth = sensorData.values[0]; - Pitch = sensorData.values[1]; - Roll = sensorData.values[2]; - - DataUpdated?.Invoke(this, new OrientationSensorDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs deleted file mode 100644 index 5e9f611..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Pedometer Sensor Class. Used for registering callbacks for pedometer and getting pedometer data - /// /// - public class Pedometer : Sensor - { - private static string PedometerKey = "http://tizen.org/feature/sensor.pedometer"; - - /// - /// Gets the step count - /// - public int StepCount { get; private set; } - - /// - /// Gets the walking step count - /// - public int WalkStepCount { get; private set; } - - /// - /// Gets the running step count - /// - public int RunStepCount { get; private set; } - - /// - /// Gets the moving distance - /// - public float MovingDistance { get; private set; } - - /// - /// Gets the calorie burned - /// - public float CalorieBurned { get; private set; } - - /// - /// Gets the last speed - /// - public float LastSpeed { get; private set; } - - /// - /// Gets the last stepping frequency - /// - public float LastSteppingFrequency { get; private set; } - - /// - /// Gets the last step status - /// - public PedometerState LastStepStatus { get; private set; } - - /// - /// Returns true or false based on whether pedometer sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the Pedometer sensor is supported"); - return CheckIfSupported(SensorType.Pedometer, PedometerKey); - } - } - - /// - /// Returns the number of pedometer sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of pedometer sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular pedometer sensor in case of multiple sensors - /// - public Pedometer(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating Pedometer object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.Pedometer; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in pedometer sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.Pedometer, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for pedometer"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for pedometer sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pedometer"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for pedometer sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pedometer"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - StepCount = (int)sensorData.values[0]; - WalkStepCount = (int)sensorData.values[1]; - RunStepCount = (int)sensorData.values[2]; - MovingDistance = sensorData.values[3]; - CalorieBurned = sensorData.values[4]; - LastSpeed = sensorData.values[5]; - LastSteppingFrequency = sensorData.values[6]; - LastStepStatus = (PedometerState)sensorData.values[7]; - - DataUpdated?.Invoke(this, new PedometerDataUpdatedEventArgs(sensorData.values)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PickUpGestureDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PickUpGestureDetector.cs deleted file mode 100644 index 254cfed..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PickUpGestureDetector.cs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// PickUpGestureDetector Class. Used for registering callbacks for pick up activity detector and getting the pick up state - /// - public class PickUpGestureDetector : Sensor - { - private static string GestureDetectorKey = "http://tizen.org/feature/sensor.gesture_recognition"; - - /// - /// Gets the state of the pick up gesture. - /// - public DetectorState PickUp { get; private set; } - - /// - /// Returns true or false based on whether pick up gesture detector is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the pick up gesture detector is supported"); - return CheckIfSupported(SensorType.PickUpGestureDetector, GestureDetectorKey); - } - } - - /// - /// Returns the number of pick up gesture detector available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of pick up gesture detectors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular pick up gesture detector in case of multiple sensors. - /// - public PickUpGestureDetector(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating pick up gesture detector object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.PickUpGestureDetector; - } - - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.PickUpGestureDetector, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if pick up gesture detector is supported"); - isSupported = false; - } - return isSupported; - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.PickUpGestureDetector, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for pick up gesture detector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in pick up gesture detector data. - /// - public event EventHandler DataUpdated; - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for pick up gesture detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pick up gesture detector"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for pick up gesture detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pick up gesture detector"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - PickUp = (DetectorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new PickUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs deleted file mode 100644 index 557cd8f..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// PressureSensor Class. Used for registering callbacks for pressure sensor and getting pressure data - /// /// - public class PressureSensor : Sensor - { - private static string PressureSensorKey = "http://tizen.org/feature/sensor.barometer"; - - /// - /// Gets the value of the pressure sensor. - /// - public float Pressure { get; private set; } - - /// - /// Returns true or false based on whether pressure sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the PressureSensor is supported"); - return CheckIfSupported(SensorType.PressureSensor, PressureSensorKey); - } - } - - /// - /// Returns the number of pressure sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of pressure sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular pressure sensor in case of multiple sensors - /// - public PressureSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating PressureSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.PressureSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in pressure sensor data. - /// - - public event EventHandler DataUpdated; - - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.PressureSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for pressure"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for pressure sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pressure"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for pressure sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pressure"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Pressure = sensorData.values[0]; - - DataUpdated?.Invoke(this, new PressureSensorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs deleted file mode 100644 index 58a8943..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// ProximitySensor Class. Used for registering callbacks for proximity sensor and getting proximity data - /// /// - public class ProximitySensor : Sensor - { - private static string ProximitySensorKey = "http://tizen.org/feature/sensor.proximity"; - - /// - /// Gets the proximity state. - /// - public ProximitySensorState Proximity { get; private set; } - - /// - /// Returns true or false based on whether proximity sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the ProximitySensor is supported"); - return CheckIfSupported(SensorType.ProximitySensor, ProximitySensorKey); - } - } - - /// - /// Returns the number of proximity sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of proximity sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular proximity sensor in case of multiple sensors - /// - public ProximitySensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating ProximitySensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.ProximitySensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in proximity sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.ProximitySensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for proximity"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for proximity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for proximity"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for proximity sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for proximity"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Proximity = (ProximitySensorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new ProximitySensorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs deleted file mode 100644 index 10e6899..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// RotationVectorSensor Class. Used for registering callbacks for rotation vector sensor and getting rotation vector data - /// /// - public class RotationVectorSensor : Sensor - { - private static string RotationVectorKey = "http://tizen.org/feature/sensor.rotation_vector"; - - private event EventHandler _accuracyChanged; - /// - /// Gets the X component of the rotation vector. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the rotation vector. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the rotation vector. - /// - public float Z { get; private set; } - - /// - /// Gets the W component of the rotation vector. - /// - public float W { get; private set; } - - /// - /// Gets the Accuracy of the rotation vector data. - /// - public SensorDataAccuracy Accuracy { get; private set; } - - /// - /// Returns true or false based on whether rotation vector sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the RotationVectorSensor is supported"); - return CheckIfSupported(SensorType.RotationVectorSensor, RotationVectorKey); - } - } - - /// - /// Returns the number of rotation vector sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of rotation vector sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular rotation vector sensor in case of multiple sensors - /// - public RotationVectorSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating RotationVectorSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.RotationVectorSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in rotation vector sensor data. - /// - - public event EventHandler DataUpdated; - - /// - /// Event handler for accuracy changed events. - /// - public event EventHandler AccuracyChanged - { - add - { - if (_accuracyChanged == null) - { - AccuracyListenStart(); - } - _accuracyChanged += value; - } - remove - { - _accuracyChanged -= value; - if (_accuracyChanged == null) - { - AccuracyListenStop(); - } - } - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.RotationVectorSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for rotation vector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for rotation vector"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for rotation vector"); - } - } - - private void AccuracyListenStart() - { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting accuracy event callback for rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for rotation vector"); - } - } - - private void AccuracyListenStop() - { - int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for rotation vector sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for rotation vector"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - Accuracy = sensorData.accuracy; - - DataUpdated?.Invoke(this, new RotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - Accuracy = accuracy; - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RunningActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RunningActivityDetector.cs deleted file mode 100644 index a799ace..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RunningActivityDetector.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// RunningActivityDetector Class. Used for registering callbacks for running activity detector and getting the running state - /// - public class RunningActivityDetector : ActivityDetector - { - private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; - - /// - /// Gets the state of running activity detector - /// - public DetectorState Running { get; private set; } - - /// - /// Returns true or false based on whether running activity detector is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the running activity detector is supported"); - return CheckIfSupported(SensorType.RunningActivityDetector, ActivityDetectorKey); - } - } - - /// - /// Returns the number of running activity detector available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of running activity detectors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular running activity detector in case of multiple sensors. - /// - public RunningActivityDetector(int index = 0) : base(index) - { - SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.Running); - Log.Info(Globals.LogTag, "Creating running activity detector object"); - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.RunningActivityDetector, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for running activity detector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in running activity detector data. - /// - public event EventHandler DataUpdated; - - protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Running = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; - - DataUpdated?.Invoke(this, new RunningActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); - } - - internal override SensorType GetSensorType() - { - return SensorType.RunningActivityDetector; - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs deleted file mode 100644 index 9d6ea16..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// SleepMonitor Class. Used for registering callbacks for sleep monitor and getting sleep data - /// /// - public class SleepMonitor : Sensor - { - private static string SleepMonitorKey = "http://tizen.org/feature/sensor.sleep_monitor"; - - /// - /// Gets the value of the sleep state. - /// - public SleepMonitorState SleepState { get; private set; } - - /// - /// Returns true or false based on whether sleep monitor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the SleepMonitor is supported"); - return CheckIfSupported(SensorType.SleepMonitor, SleepMonitorKey); - } - } - - /// - /// Returns the number of sleep monitors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of sleep monitors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular sleep monitor in case of multiple sensors - /// - public SleepMonitor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating SleepMonitor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.SleepMonitor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in sleep monitor data. - /// - - public event EventHandler DataUpdated; - - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.SleepMonitor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for sleep"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for sleep monitor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for sleep"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for sleep monitor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for sleep"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - SleepState = (SleepMonitorState)sensorData.values[0]; - - DataUpdated?.Invoke(this, new SleepMonitorDataUpdatedEventArgs((int)sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/StationaryActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/StationaryActivityDetector.cs deleted file mode 100644 index ecfff67..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/StationaryActivityDetector.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// StationaryActivityDetector Class. Used for registering callbacks for stationary activity detector and getting the stationary state - /// - public class StationaryActivityDetector : ActivityDetector - { - private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; - - /// - /// Gets the state of stationary activity detector - /// - public DetectorState Stationary { get; private set; } - - /// - /// Returns true or false based on whether stationary activity detector is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the stationary activity detector is supported"); - return CheckIfSupported(SensorType.StationaryActivityDetector, ActivityDetectorKey); - } - } - - /// - /// Returns the number of stationary activity detector available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of stationary activity detectors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular stationary activity detector in case of multiple sensors. - /// - public StationaryActivityDetector(int index = 0) : base(index) - { - SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.Stationary); - Log.Info(Globals.LogTag, "Creating stationary activity detector object"); - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.StationaryActivityDetector, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for stationary activity detector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in stationary activity detector data. - /// - public event EventHandler DataUpdated; - - protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Stationary = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; - - DataUpdated?.Invoke(this, new StationaryActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); - } - - internal override SensorType GetSensorType() - { - return SensorType.StationaryActivityDetector; - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs deleted file mode 100644 index 6f3df1b..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// TemperatureSensor Class. Used for registering callbacks for temperature sensor and getting temperature data - /// /// - public class TemperatureSensor : Sensor - { - private static string TemperatureSensorKey = "http://tizen.org/feature/sensor.temperature"; - - /// - /// Gets the value of the temperature sensor. - /// - public float Temperature { get; private set; } - - /// - /// Returns true or false based on whether temperature sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the TemperatureSensor is supported"); - return CheckIfSupported(SensorType.TemperatureSensor, TemperatureSensorKey); - } - } - - /// - /// Returns the number of temperature sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of temperature sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular temperature sensor in case of multiple sensors - /// - public TemperatureSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating TemperatureSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.TemperatureSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in temperature sensor data. - /// - - public event EventHandler DataUpdated; - - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.TemperatureSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for temperature"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for temperature sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for temperature"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for temperature sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for temperature"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Temperature = sensorData.values[0]; - - DataUpdated?.Invoke(this, new TemperatureSensorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs deleted file mode 100644 index 03c9d0a..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// UltravioletSensor Class. Used for registering callbacks for ultraviolet sensor and getting ultraviolet data - /// /// - public class UltravioletSensor : Sensor - { - private static string UltravioletSensorKey = "http://tizen.org/feature/sensor.ultraviolet"; - - /// - /// Gets the value of the ultraviolet sensor. - /// - public float UltravioletIndex { get; private set; } - - /// - /// Returns true or false based on whether ultraviolet sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the UltravioletSensor is supported"); - return CheckIfSupported(SensorType.UltravioletSensor, UltravioletSensorKey); - } - } - - /// - /// Returns the number of ultraviolet sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of ultraviolet sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular ultraviolet sensor in case of multiple sensors - /// - public UltravioletSensor(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating UltravioletSensor object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.UltravioletSensor; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in ultraviolet sensor data. - /// - - public event EventHandler DataUpdated; - - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.UltravioletSensor, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for ultraviolet"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for ultraviolet sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for ultraviolet"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for ultraviolet sensor"); - 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])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs deleted file mode 100644 index c712d83..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// UncalibratedGyroscope Sensor Class. Used for registering callbacks for uncalibrated gyroscope and getting uncalibrated gyroscope data - /// /// - public class UncalibratedGyroscope : Sensor - { - private static string UncalibratedGyroscopeKey = "http://tizen.org/feature/sensor.gyroscope.uncalibrated"; - - /// - /// Gets the X component of the acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the acceleration. - /// - public float Z { get; private set; } - - /// - /// Gets the BiasX component of the uncalibrated gyroscope data. - /// - public float BiasX { get; private set; } - - /// - /// Gets the BiasY component of the uncalibrated gyroscope data. - /// - public float BiasY { get; private set; } - - /// - /// Gets the BiasZ component of the uncalibrated gyroscope data. - /// - public float BiasZ { get; private set; } - - /// - /// Returns true or false based on whether uncalibrated gyroscope sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the UncalibratedGyroscope sensor is supported"); - return CheckIfSupported(SensorType.UncalibratedGyroscope, UncalibratedGyroscopeKey); - } - } - - /// - /// Returns the number of uncalibrated gyroscope sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of uncalibrated gyroscope sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular uncalibrated gyroscope sensor in case of multiple sensors - /// - public UncalibratedGyroscope(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating UncalibratedGyroscope object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.UncalibratedGyroscope; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in uncalibrated gyroscope sensor data. - /// - - public event EventHandler DataUpdated; - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.UncalibratedGyroscope, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for uncalibrated gyroscope"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated gyroscope sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for uncalibrated gyroscope"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for uncalibrated gyroscope sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for uncalibrated gyroscope"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - 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]; - - DataUpdated?.Invoke(this, new UncalibratedGyroscopeDataUpdatedEventArgs(sensorData.values)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs deleted file mode 100644 index 24b080f..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// UncalibratedMagnetometer Sensor Class. Used for registering callbacks for uncalibrated magnetometer and getting uncalibrated magnetometer data - /// /// - public class UncalibratedMagnetometer : Sensor - { - private static string UncalibratedMagnetometerKey = "http://tizen.org/feature/sensor.magnetometer.uncalibrated"; - - private event EventHandler _accuracyChanged; - /// - /// Gets the X component of the acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the acceleration. - /// - public float Z { get; private set; } - - /// - /// Gets the BiasX component of the uncalibrated magnetometer data. - /// - public float BiasX { get; private set; } - - /// - /// Gets the BiasY component of the uncalibrated magnetometer data. - /// - public float BiasY { get; private set; } - - /// - /// Gets the BiasZ component of the uncalibrated magnetometer data. - /// - public float BiasZ { get; private set; } - - /// - /// Returns true or false based on whether uncalibrated magnetometer sensor is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the UncalibratedMagnetometer sensor is supported"); - return CheckIfSupported(SensorType.UncalibratedMagnetometer, UncalibratedMagnetometerKey); - } - } - - /// - /// Returns the number of uncalibrated magnetometer sensors available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of uncalibrated magnetometer sensors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular uncalibrated magnetometer sensor in case of multiple sensors - /// - public UncalibratedMagnetometer(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating UncalibratedMagnetometer object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.UncalibratedMagnetometer; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in uncalibrated magnetometer sensor data. - /// - - public event EventHandler DataUpdated; - - /// - /// Event handler for accuracy changed events. - /// - public event EventHandler AccuracyChanged - { - add - { - if (_accuracyChanged == null) - { - AccuracyListenStart(); - } - _accuracyChanged += value; - } - remove - { - _accuracyChanged -= value; - if (_accuracyChanged == null) - { - AccuracyListenStop(); - } - } - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.UncalibratedMagnetometer, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for uncalibrated magnetometer"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated magnetometer sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for uncalibrated magnetometer"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for uncalibrated magnetometer sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for uncalibrated magnetometer"); - } - } - - private void AccuracyListenStart() - { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, Interval, AccuracyEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting accuracy event callback for uncalibrated magnetometer"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set accuracy event callback for uncalibrated magnetometer"); - } - } - - private void AccuracyListenStop() - { - int error = Interop.SensorListener.UnsetAccuracyCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting accuracy event callback for uncalibrated magnetometer"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for uncalibrated magnetometer"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - 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]; - - DataUpdated?.Invoke(this, new UncalibratedMagnetometerDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WalkingActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WalkingActivityDetector.cs deleted file mode 100644 index f4ff0a9..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WalkingActivityDetector.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// WalkingActivityDetector Class. Used for registering callbacks for walking activity detector and getting the walking state - /// - public class WalkingActivityDetector : ActivityDetector - { - private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; - - /// - /// Gets the state of walking activity detector - /// - public DetectorState Walking { get; private set; } - - /// - /// Returns true or false based on whether walking activity detector is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the walking activity detector is supported"); - return CheckIfSupported(SensorType.WalkingActivityDetector, ActivityDetectorKey); - } - } - - /// - /// Returns the number of walking activity detector available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of walking activity detectors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular walking activity detector in case of multiple sensors. - /// - public WalkingActivityDetector(int index = 0) : base(index) - { - SetAttribute((SensorAttribute)ActivityAttribute, (int)ActivityType.Walking); - Log.Info(Globals.LogTag, "Creating walking activity gesture detector object"); - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.WalkingActivityDetector, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for walking activity detector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in walking activity gesture detector data. - /// - public event EventHandler DataUpdated; - - protected override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Walking = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; - - DataUpdated?.Invoke(this, new WalkingActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); - } - - internal override SensorType GetSensorType() - { - return SensorType.WalkingActivityDetector; - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WristUpGestureDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WristUpGestureDetector.cs deleted file mode 100644 index 8825709..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WristUpGestureDetector.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// WristUpGestureDetector Class. Used for registering callbacks for wrist up gesture detector and getting the wrist up state - /// - public class WristUpGestureDetector : Sensor - { - private static string WristUpKey = "http://tizen.org/feature/sensor.wrist_up"; - - /// - /// Gets the state of the wrist up gesture. - /// - public DetectorState WristUp { get; private set; } - - /// - /// Returns true or false based on whether wrist up gesture detector is supported by device. - /// - public static bool IsSupported - { - get - { - Log.Info(Globals.LogTag, "Checking if the wrist up gesture detector is supported"); - return CheckIfSupported(SensorType.WristUpGestureDetector, WristUpKey); - } - } - - /// - /// Returns the number of wrist up gesture detector available on the device. - /// - public static int Count - { - get - { - Log.Info(Globals.LogTag, "Getting the count of wrist up gesture detectors"); - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular wrist up gesture detector in case of multiple sensors. - /// - public WristUpGestureDetector(int index = 0) : base(index) - { - Log.Info(Globals.LogTag, "Creating wrist up gesture detector object"); - } - - internal override SensorType GetSensorType() - { - return SensorType.WristUpGestureDetector; - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.WristUpGestureDetector, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list for wrist up gesture detector"); - count = 0; - } - else - Interop.Libc.Free(list); - return count; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in wrist up gesture detector data. - /// - public event EventHandler DataUpdated; - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for wrist up gesture detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for wrist up gesture detector"); - } - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for wrist up gesture detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for wrist up gesture detector"); - } - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - WristUp = (DetectorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new WristUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs deleted file mode 100644 index b43bdb0..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs +++ /dev/null @@ -1,499 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; -using Tizen.System; - -namespace Tizen.System.Sensor -{ - internal static class Globals - { - internal const string LogTag = "Tizen.System.Sensor"; - } - - /// - /// Sensor class for storing hardware information about a particular sensor - /// - public abstract class Sensor : IDisposable - { - private string _name; - private string _vendor; - private float _minValue; - private float _maxValue; - private float _resolution; - private int _minInterval; - private int _fifoCount; - private int _maxBatchCount; - private bool _isSensing = false; - private bool _disposed = false; - private TimeSpan _timeSpan; - private uint _interval = 0; - private uint _maxBatchLatency = 0; - private SensorPausePolicy _pausePolicy = SensorPausePolicy.None; - private IntPtr _sensorHandle = IntPtr.Zero; - private IntPtr _listenerHandle = IntPtr.Zero; - - internal abstract SensorType GetSensorType(); - protected abstract void EventListenStart(); - protected abstract void EventListenStop(); - - internal Sensor(int index) - { - SensorType type = GetSensorType(); - GetHandleList(type, index); - if (CheckSensorHandle()) - { - CreateListener(); - GetProperty(); - } - } - - ~Sensor() - { - Dispose(false); - } - - /// - /// Property: For getting the name of the sensor - /// - public string Name - { - get - { - Log.Info(Globals.LogTag, "Getting the sensor name"); - return _name; - } - } - - /// - /// Property: Gets the vendor. - /// - public string Vendor - { - get - { - Log.Info(Globals.LogTag, "Getting the sensor vendor name"); - return _vendor; - } - } - - /// - /// Property: Gets the minimum value of range of sensor data. - /// - public float MinValue - { - get - { - Log.Info(Globals.LogTag, "Getting the min value of the sensor"); - return _minValue; - } - } - - /// - /// Property: Gets the maximum value of range of sensor data. - /// - public float MaxValue - { - get - { - Log.Info(Globals.LogTag, "Getting the max value of the sensor"); - return _maxValue; - } - } - - /// - /// Property: Gets the resolution. - /// - public float Resolution - { - get - { - Log.Info(Globals.LogTag, "Getting the resolution of the sensor"); - return _resolution; - } - } - - /// - /// Property: Gets the minimum interval. - /// - public int MinInterval - { - get - { - Log.Info(Globals.LogTag, "Getting the min interval for the sensor"); - return _minInterval; - } - } - - /// - /// Property: Gets the fifo count. - /// - public int FifoCount - { - get - { - Log.Info(Globals.LogTag, "Getting the fifo count of the sensor"); - return _fifoCount; - } - } - - /// - /// Property: Gets the maximum batch count. - /// - public int MaxBatchCount - { - get - { - Log.Info(Globals.LogTag, "Getting the max batch count of the sensor"); - return _maxBatchCount; - } - } - - /// - /// Sets the interval of the sensor for sensor data event - /// Callbacks will be called at frequency of this interval - /// - public uint Interval - { - set - { - Log.Info(Globals.LogTag, "Setting the interval of the sensor"); - _interval = value; - SetInterval(); - } - get - { - Log.Info(Globals.LogTag, "Getting the interval of the sensor"); - return _interval; - } - } - - /// - /// Sets the max batch latency for the sensor corresponding to the sensor data event. - /// - public uint MaxBatchLatency - { - set - { - Log.Info(Globals.LogTag, "Setting the max batch latency of the sensor"); - _maxBatchLatency = value; - SetMaxBatchLatency(); - } - get - { - Log.Info(Globals.LogTag, "Getting the max batch latency of the sensor"); - return _maxBatchLatency; - } - } - - /// - /// Sets the pause policy of the sensor. - /// - /// - public SensorPausePolicy PausePolicy - { - set - { - Log.Info(Globals.LogTag, "Setting the pause policy of the sensor"); - _pausePolicy = value; - SetAttribute(SensorAttribute.PausePolicy, (int)_pausePolicy); - } - get - { - Log.Info(Globals.LogTag, "Getting the pause policy of the sensor"); - return _pausePolicy; - } - } - - /// - /// Gets or sets the time span. - /// - /// The time span. - public TimeSpan TimeSpan - { - set - { - Log.Info(Globals.LogTag, "Setting the timespan of the sensor values"); - _timeSpan = value; - } - get - { - Log.Info(Globals.LogTag, "Getting the timespan of the sensor values"); - return _timeSpan; - } - } - - /// - /// Indicates whether this sensor is sensing. - /// - /// true if this sensor is sensing; otherwise, false. - public bool IsSensing - { - get - { - Log.Info(Globals.LogTag, "Checking if the sensor is started"); - return _isSensing; - } - } - - internal IntPtr ListenerHandle - { - get - { - return _listenerHandle; - } - } - - internal static bool CheckIfSupported(SensorType type, String key) - { - bool isSupported = false; - bool error = SystemInfo.TryGetValue(key, out isSupported); - - if (!error || !isSupported) - { - Log.Error(Globals.LogTag, "Error checking if sensor is supported(systeminfo)"); - return false; - } - - int ret = Interop.SensorManager.SensorIsSupported(type, out isSupported); - if (ret != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if sensor is supported"); - isSupported = false; - } - - return isSupported; - } - - /// - /// Starts the sensor. - /// After this the event handlers will start receiving events. - /// - public void Start() - { - Log.Info(Globals.LogTag, "Starting the sensor"); - if (CheckListenerHandle()) - { - int error = Interop.SensorListener.StartListener(_listenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error starting sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Start Sensor Listener"); - } - EventListenStart(); - _isSensing = true; - Log.Info(Globals.LogTag, "Sensor started"); - } - } - - /// - /// Stop the sensor. - /// After this the event handlers will stop receiving the events - /// - public void Stop() - { - Log.Info(Globals.LogTag, "Stopping the sensor"); - if (_isSensing) - { - int error = Interop.SensorListener.StopListener(_listenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error stopping the sensor"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Stop Sensor Listener"); - } - EventListenStop(); - _isSensing = false; - Log.Info(Globals.LogTag, "Sensor stopped"); - } - else - { - Log.Error(Globals.LogTag, "Can't stop sensor as it is already stopped"); - throw new InvalidOperationException("Operation Failed: Sensor is already stopped"); - } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_disposed) - return; - - DestroyHandles(); - _disposed = true; - } - - protected void SetAttribute(SensorAttribute attribute, int option) - { - if (CheckListenerHandle()) - { - int error = Interop.SensorListener.SetAttribute(_listenerHandle, attribute, option); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting sensor pause policy"); - throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed"); - } - } - } - - private void GetHandleList(SensorType type, int index) - { - IntPtr list; - IntPtr[] sensorList; - int count; - int error = Interop.SensorManager.GetSensorList(type, out list, out count); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor list"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.GetSensorList Failed"); - } - sensorList = Interop.IntPtrToIntPtrArray(list, count); - _sensorHandle = sensorList[index]; - Interop.Libc.Free(list); - } - - private void GetProperty() - { - int error = (int)SensorError.None; - - error = Interop.Sensor.GetName(_sensorHandle, out _name); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor name"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Name Failed"); - } - - error = Interop.Sensor.GetVendor(_sensorHandle, out _vendor); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor vendor name"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Vendor Failed"); - } - - error = Interop.Sensor.GetMinRange(_sensorHandle, out _minValue); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor min value"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinValue Failed"); - } - - error = Interop.Sensor.GetMaxRange(_sensorHandle, out _maxValue); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor max value"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxValue Failed"); - } - - error = Interop.Sensor.GetResolution(_sensorHandle, out _resolution); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor resolution"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Resolution Failed"); - } - - error = Interop.Sensor.GetMinInterval(_sensorHandle, out _minInterval); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor min interval"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinInterval Failed"); - } - - error = Interop.Sensor.GetFifoCount(_sensorHandle, out _fifoCount); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor fifo count"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.FifoCount Failed"); - } - - error = Interop.Sensor.GetMaxBatchCount(_sensorHandle, out _maxBatchCount); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error getting sensor max batch count"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxBatchCount Failed"); - } - } - - private void CreateListener() - { - int error = Interop.SensorListener.CreateListener(_sensorHandle, out _listenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error cerating sensor listener handle"); - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.CreateListener Failed"); - } - } - - private void SetInterval() - { - if (CheckListenerHandle()) - { - if (_isSensing) - { - int error = Interop.SensorListener.SetInterval(_listenerHandle, _interval); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting sensor interval"); - throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.SetInterval Failed"); - } - } - } - } - - private void SetMaxBatchLatency() - { - if (CheckListenerHandle()) - { - int error = Interop.SensorListener.SetMaxBatchLatency(_listenerHandle, _maxBatchLatency); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting max batch latency"); - throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.MaxBatchLatency Failed"); - } - } - } - - private bool CheckListenerHandle() - { - bool result = false; - if (_listenerHandle != IntPtr.Zero) - { - result = true; - } - else - { - Log.Error(Globals.LogTag, "Sensor listener handle is null"); - throw new ArgumentException("Invalid Parameter: Sensor is null"); - } - return result; - } - - private bool CheckSensorHandle() - { - bool result = false; - if (_sensorHandle != IntPtr.Zero) - { - result = true; - } - else - { - Log.Error(Globals.LogTag, "Sensor handle is null"); - throw new ArgumentException("Invalid Parameter: Sensor is null"); - } - return result; - } - - private void DestroyHandles() - { - Interop.SensorListener.DestroyListener(_listenerHandle); - } - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs b/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs deleted file mode 100644 index aedca39..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// The SensorType Enum defintion for all sensor types. - /// - internal enum SensorType - { - /// - /// All sensors. This can be used to retrieve Sensor class object for all available sensors. - /// - All = -1, - /// - /// Accelerometer sensor. - /// - Accelerometer = 0, - /// - /// Gravity sensor. - /// - GravitySensor = 1, - /// - /// Linear Acceleration sensor. - /// - LinearAccelerationSensor = 2, - /// - /// Magnetometer sensor. - /// - Magnetometer = 3, - /// - /// Rotation Vector sensor. - /// - RotationVectorSensor = 4, - /// - /// Orientation sensor. - /// - OrientationSensor = 5, - /// - /// Gyroscope sensor. - /// - Gyroscope = 6, - /// - /// Light sensor. - /// - LightSensor = 7, - /// - /// Proximity sensor. - /// - ProximitySensor = 8, - /// - /// Pressure sensor. - /// - PressureSensor = 9, - /// - /// Ultraviolet sensor. - /// - UltravioletSensor = 10, - /// - /// Temperature sensor. - /// - TemperatureSensor = 11, - /// - /// Humidity sensor. - /// - HumiditySensor = 12, - /// - /// Hear rate monitor sensor. - /// - HeartRateMonitor = 13, - /// - /// Uncalibrated Gyroscope sensor. - /// - UncalibratedGyroscope = 17, - /// - /// Uncalibrated Geomagnetic sensor. - /// - UncalibratedMagnetometer = 18, - /// - /// Gyroscope-based rotation vector sensor. - /// - GyroscopeRotationVectorSensor = 19, - /// - /// Geomagnetic-based rotation vector sensor. - /// - MagnetometerRotationVectorSensor = 20, - /// - /// Pedometer sensor. - /// - Pedometer = 0x300, - /// - /// Sleep monitor sensor. - /// - SleepMonitor = 0x301, - /// - /// Walking activity detector. - /// - WalkingActivityDetector = 0x1A00, - /// - /// Running activity detector. - /// - RunningActivityDetector = 0x1A00, - /// - /// Stationary activity detector. - /// - StationaryActivityDetector = 0x1A00, - /// - /// InVehicle activity detector. - /// - InVehicleActivityDetector = 0x1A00, - /// - /// Wrist up gesture detector. - /// - WristUpGestureDetector = 0x1201, - /// - /// Pick up gesture detector. - /// - PickUpGestureDetector = 0x1204, - /// - /// Face down gesture detector. - /// - FaceDownGestureDetector = 0x1205 - } - - /// - /// SensorDataAccuracy Enum definition for all possible sensor data accuracy Values. - /// - public enum SensorDataAccuracy - { - /// - /// Undefined sensor data accuracy. - /// - Undefined = -1, - /// - /// Sensor data not accurate. - /// - Bad = 0, - /// - /// Moderately accurate sensor data. - /// - Normal = 1, - /// - /// Highly accurate sensor data. - /// - Good = 2, - /// - /// Very highly accurate sensor data. - /// - VeryGood = 3 - } - - /// - /// Sensor Option Enum definition for sensor option Values - /// - public enum SensorPausePolicy - { - /// - /// Does not receive data when the LCD is off and in the power save mode. - /// - None, - /// - /// Receives data when the LCD is off. - /// - DisplayOff, - /// - /// Receives data in the power save mode. - /// - PowerSaveMode, - /// - /// Receives data when the LCD is off and in the power save mode. - /// - All - } - - /// - /// Sensor attribute. - /// - public enum SensorAttribute - { - /// - /// The axis orientation. - /// - AxisOrientation, - - /// - /// The pause policy. - /// - PausePolicy - } - - /// - /// Pedometer state. - /// - public enum PedometerState - { - /// - /// Unknown. - /// - Unknown, - - /// - /// Stop state. - /// - Stop, - - /// - /// Walking state. - /// - Walk, - - /// - /// Running state. - /// - Run - } - - /// - /// Sleep monitor state. - /// - public enum SleepMonitorState - { - /// - /// Unknown. - /// - Unknown, - - /// - /// The wake state. - /// - Wake, - - /// - /// The sleeping state. - /// - Sleep - } - - /// - /// Proximity sensor state. - /// - public enum ProximitySensorState - { - /// - /// Near sate. - /// - Near = 0, - - /// - /// Far state. - /// - Far = 5 - } - - /// - /// Detector sensor state. - /// - public enum DetectorState - { - /// - /// None sate. - /// - NotDetected = 0, - - /// - /// Detected state. - /// - Detected = 1 - } -} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs b/Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs deleted file mode 100644 index 5627baf..0000000 --- a/Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; -using Tizen.Internals.Errors; - -namespace Tizen.System.Sensor -{ - internal enum SensorError - { - None = ErrorCode.None, - IOError = ErrorCode.IoError, - InvalidParameter = ErrorCode.InvalidParameter, - NotSupported = ErrorCode.NotSupported, - PermissionDenied = ErrorCode.PermissionDenied, - OutOfMemory = ErrorCode.OutOfMemory, - NotNeedCalibration = -0x02440000 | 0x03, - OperationFailed = -0x02440000 | 0x06 - } - - internal static class SensorErrorFactory - { - static internal Exception CheckAndThrowException(int error, string msg) - { - SensorError e = (SensorError)error; - switch (e) - { - case SensorError.None: - return null; - case SensorError.IOError: - return new InvalidOperationException("I/O Error: " + msg); - case SensorError.InvalidParameter: - return new ArgumentException("Invalid Parameter: " + msg); - case SensorError.NotSupported: - return new InvalidOperationException("Not Supported: " + msg); - case SensorError.PermissionDenied: - return new InvalidOperationException("Permission Denied: " + msg); - case SensorError.OutOfMemory: - return new InvalidOperationException("Out of Memory: " + msg); - case SensorError.NotNeedCalibration: - return new InvalidOperationException("Sensor doesn't need calibration: " + msg); - case SensorError.OperationFailed: - return new InvalidOperationException("Operation Failed: " + msg); - default: - return new InvalidOperationException("Unknown Error Code: " + msg); - } - } - } -} \ No newline at end of file diff --git a/packaging/csapi-sensor.manifest b/packaging/csapi-sensor.manifest new file mode 100644 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/csapi-sensor.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/csapi-sensor.spec b/packaging/csapi-sensor.spec new file mode 100644 index 0000000..6753b2f --- /dev/null +++ b/packaging/csapi-sensor.spec @@ -0,0 +1,76 @@ +%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework} + +%if 0%{?tizen_build_devel_mode} +%define BUILDCONF Debug +%else +%define BUILDCONF Release +%endif + +Name: csapi-sensor +Summary: Tizen Sensor API for C# +Version: 1.0.1 +Release: 1 +Group: Development/Libraries +License: Apache-2.0 +URL: https://www.tizen.org +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest + +AutoReqProv: no + +BuildRequires: mono-compiler +BuildRequires: mono-devel + +BuildRequires: dotnet-build-tools + +# C# API Requries +BuildRequires: csapi-tizen-nuget +BuildRequires: csapi-system-nuget + +%description +Tizen Sensor API for C# + +%prep +%setup -q +cp %{SOURCE1} . + +%define Assemblies Tizen.Sensor + +%build +for ASM in %{Assemblies}; do +# NuGet Restore +find $ASM/*.project.json -exec nuget restore {} \; +# Build +find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \; +# NuGet Pack +nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF} +done + +%install +# Runtime Binary +mkdir -p %{buildroot}%{dotnet_assembly_path} +for ASM in %{Assemblies}; do +%if 0%{?_with_corefx} + install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path} +%else + install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path} +%endif +done +# NuGet +mkdir -p %{buildroot}/nuget +install -p -m 644 *.nupkg %{buildroot}/nuget + +%files +%manifest %{name}.manifest +%license LICENSE +%attr(644,root,root) %{dotnet_assembly_path}/*.dll + +%package nuget +Summary: NuGet package for %{name} +Group: Development/Libraries + +%description nuget +NuGet package for %{name} + +%files nuget +/nuget/*.nupkg diff --git a/packaging/csapi-system-sensor.manifest b/packaging/csapi-system-sensor.manifest deleted file mode 100644 index 75b0fa5..0000000 --- a/packaging/csapi-system-sensor.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/csapi-system-sensor.spec b/packaging/csapi-system-sensor.spec deleted file mode 100644 index 09c18d6..0000000 --- a/packaging/csapi-system-sensor.spec +++ /dev/null @@ -1,76 +0,0 @@ -%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework} - -%if 0%{?tizen_build_devel_mode} -%define BUILDCONF Debug -%else -%define BUILDCONF Release -%endif - -Name: csapi-system-sensor -Summary: Tizen Sensor API for C# -Version: 1.0.1 -Release: 1 -Group: Development/Libraries -License: Apache-2.0 -URL: https://www.tizen.org -Source0: %{name}-%{version}.tar.gz -Source1: %{name}.manifest - -AutoReqProv: no - -BuildRequires: mono-compiler -BuildRequires: mono-devel - -BuildRequires: dotnet-build-tools - -# C# API Requries -BuildRequires: csapi-tizen-nuget -BuildRequires: csapi-system-nuget - -%description -Tizen Sensor API for C# - -%prep -%setup -q -cp %{SOURCE1} . - -%define Assemblies Tizen.System.Sensor - -%build -for ASM in %{Assemblies}; do -# NuGet Restore -find $ASM/*.project.json -exec nuget restore {} \; -# Build -find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \; -# NuGet Pack -nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF} -done - -%install -# Runtime Binary -mkdir -p %{buildroot}%{dotnet_assembly_path} -for ASM in %{Assemblies}; do -%if 0%{?_with_corefx} - install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path} -%else - install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path} -%endif -done -# NuGet -mkdir -p %{buildroot}/nuget -install -p -m 644 *.nupkg %{buildroot}/nuget - -%files -%manifest %{name}.manifest -%license LICENSE -%attr(644,root,root) %{dotnet_assembly_path}/*.dll - -%package nuget -Summary: NuGet package for %{name} -Group: Development/Libraries - -%description nuget -NuGet package for %{name} - -%files nuget -/nuget/*.nupkg