Introduce Sensor implementation
authorAnkur <ankur29.garg@samsung.com>
Tue, 24 May 2016 06:47:36 +0000 (12:17 +0530)
committerAnkur <ankur29.garg@samsung.com>
Thu, 26 May 2016 06:32:09 +0000 (12:02 +0530)
Patch-Set-3
  Changes as per reviews/comments.
  Auto-implemented properties, dont throw exception in the error factory, protected/private tags, enums as per 3.0
Patch-Set-4
  Changes as per reviews/comments
  Separate function for destroying handles, renaming of one function etc.
Patch-Set-5: Minor Changes
Patch-Set-6: Minor Changes
Patch-Set-7: Changes as per review - removed exceptions from getters.
Patch-Set-8: Removed Stopwatch
Patch-Set-9: Minor Changes
Patch-Set-10: Minor Changes as per reviews/comments

signed-off-by:"Ankur Garg <ankur29.garg@samsung.com>"
Change-Id: I15ba1686d8954165781d4a8d4a63ff71b9a92d08

19 files changed:
Makefile [new file with mode: 0644]
Tizen.System.Sensor.sln [new file with mode: 0644]
Tizen.System.Sensor.userprefs [new file with mode: 0644]
Tizen.System.Sensor/Interop/Interop.Libraries.cs [new file with mode: 0644]
Tizen.System.Sensor/Interop/Interop.Sensor.cs [new file with mode: 0644]
Tizen.System.Sensor/Properties/AssemblyInfo.cs [new file with mode: 0644]
Tizen.System.Sensor/Sensor/Enumerations.cs [new file with mode: 0755]
Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs [new file with mode: 0644]
Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs [new file with mode: 0644]
Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs [new file with mode: 0644]
Tizen.System.Sensor/Sensor/Sensor.cs [new file with mode: 0644]
Tizen.System.Sensor/Sensor/SensorErrorFactory.cs [new file with mode: 0644]
Tizen.System.Sensor/Tizen.System.Sensor.csproj [new file with mode: 0644]
Tizen.System.Sensor/Tizen.System.Sensor.pidb [new file with mode: 0644]
Tizen.System.Sensor/Tizen.System.Sensor.snk [new file with mode: 0644]
Tizen.System.Sensor/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache [new file with mode: 0644]
packaging/csapi-system.sensor.manifest [new file with mode: 0755]
packaging/csapi-system.sensor.pc.in [new file with mode: 0755]
packaging/csapi-system.sensor.spec [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..f6f9a65
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+ASM_DIRS := Tizen.System.Sensor
+ASM_DLLS := $(addsuffix .dll,$(ASM_DIRS))
+
+FLAGS := 
+
+ALL: $(ASM_DLLS)
+
+define make-dll
+$(eval ASM = $(strip $1))
+$(eval SRC = $(shell find $(ASM) -path $(ASM)/obj -prune -o -name '*.cs' -print))
+$(eval PKG = $(shell echo $2 | tr ' ' ','))
+$(ASM).dll: $(SRC)
+       @echo "[BUILD] $$@"
+       @mcs /nologo /out:$$@ /t:library /keyfile:$(ASM)/$(ASM).snk $(addprefix /pkg:,$(PKG)) $(FLAGS) $(SRC)
+       @echo "[CHECK] $$@"
+       @RET=`mono-shlib-cop $$@`; \
+  CNT=`echo $$$$RET | grep -e '^error:' | wc -l`; \
+  if [ $$$$CNT -gt 0 ]; then echo $$$$RET; rm -f $$@ exit 1; fi
+endef
+
+$(eval $(call make-dll, Tizen.System.Sensor, csapi-tizen))
+
+clean:
+       @rm -f $(ASM_DLLS)
diff --git a/Tizen.System.Sensor.sln b/Tizen.System.Sensor.sln
new file mode 100644 (file)
index 0000000..7e415e3
--- /dev/null
@@ -0,0 +1,53 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual Studio 2010\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.System.Sensor", "Tizen.System.Sensor\Tizen.System.Sensor.csproj", "{CB655C6A-F73B-448E-913C-CA4DCBC5E401}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Internals", "..\tizen\Tizen.Internals\Tizen.Internals.csproj", "{B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Release|Any CPU.Build.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(MonoDevelopProperties) = preSolution\r
+               StartupItem = Tizen.System.Sensor\Tizen.System.Sensor.csproj\r
+               Policies = $0\r
+               $0.DotNetNamingPolicy = $1\r
+               $1.DirectoryNamespaceAssociation = None\r
+               $1.ResourceNamePolicy = FileFormatDefault\r
+               $0.TextStylePolicy = $2\r
+               $2.inheritsSet = null\r
+               $2.scope = text/x-csharp\r
+               $0.CSharpFormattingPolicy = $3\r
+               $3.inheritsSet = Mono\r
+               $3.inheritsScope = text/x-csharp\r
+               $3.scope = text/x-csharp\r
+               $0.StandardHeader = $4\r
+               $4.Text = \r
+               $4.IncludeInNewFiles = True\r
+               $0.TextStylePolicy = $5\r
+               $5.EolMarker = Unix\r
+               $5.inheritsSet = VisualStudio\r
+               $5.inheritsScope = text/plain\r
+               $5.scope = text/plain\r
+               $0.TextStylePolicy = $6\r
+               $6.inheritsSet = Mono\r
+               $6.inheritsScope = text/plain\r
+               $6.scope = application/xml\r
+               $0.XmlFormattingPolicy = $7\r
+               $7.inheritsSet = Mono\r
+               $7.inheritsScope = application/xml\r
+               $7.scope = application/xml\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/Tizen.System.Sensor.userprefs b/Tizen.System.Sensor.userprefs
new file mode 100644 (file)
index 0000000..2a833c1
--- /dev/null
@@ -0,0 +1,29 @@
+<Properties>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs">
+    <Files>
+      <File FileName="Tizen.System.Sensor/Sensor/Sensor.cs" Line="74" Column="14" />
+      <File FileName="Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs" Line="146" Column="34" />
+      <File FileName="Tizen.System.Sensor/Interop/Interop.Sensor.cs" Line="57" Column="75" />
+      <File FileName="Tizen.System.Sensor/Sensor/SensorErrorFactory.cs" Line="36" Column="60" />
+    </Files>
+    <Pads>
+      <Pad Id="ProjectPad">
+        <State expanded="True" selected="True">
+          <Node name="Tizen.Internals" expanded="True" />
+          <Node name="Tizen.System.Sensor" expanded="True">
+            <Node name="Interop" expanded="True" />
+            <Node name="Sensor" expanded="True">
+              <Node name="EventArgs" expanded="True" />
+              <Node name="Plugins" expanded="True" />
+            </Node>
+          </Node>
+        </State>
+      </Pad>
+    </Pads>
+  </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService.Breakpoints>
+    <BreakpointStore />
+  </MonoDevelop.Ide.DebuggingService.Breakpoints>
+  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
+</Properties>
\ No newline at end of file
diff --git a/Tizen.System.Sensor/Interop/Interop.Libraries.cs b/Tizen.System.Sensor/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..2b42537
--- /dev/null
@@ -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.System.Sensor/Interop/Interop.Sensor.cs b/Tizen.System.Sensor/Interop/Interop.Sensor.cs
new file mode 100644 (file)
index 0000000..1777244
--- /dev/null
@@ -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.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
new file mode 100644 (file)
index 0000000..32b31bb
--- /dev/null
@@ -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.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/Sensor/Enumerations.cs b/Tizen.System.Sensor/Sensor/Enumerations.cs
new file mode 100755 (executable)
index 0000000..9de4515
--- /dev/null
@@ -0,0 +1,151 @@
+// 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
+{
+    /// <summary>
+    /// The SensorType Enum defintion for all sensor types.
+    /// </summary>
+    public enum SensorType
+    {
+        /// <summary>
+        /// All sensors. This can be used to retrieve Sensor class object for all available sensors.
+        /// </summary>
+        All = -1,
+        /// <summary>
+        /// Accelerometer sensor.
+        /// </summary>
+        Accelerometer = 0,
+        /// <summary>
+        /// Gravity sensor.
+        /// </summary>
+        GravitySensor = 1,
+        /// <summary>
+        /// Linear Acceleration sensor.
+        /// </summary>
+        LinearAccelerationSensor = 2,
+        /// <summary>
+        /// Magnetometer sensor.
+        /// </summary>
+        Magnetometer = 3,
+        /// <summary>
+        /// Rotation Vector sensor.
+        /// </summary>
+        RotationVectorSensor = 4,
+        /// <summary>
+        /// Orientation sensor.
+        /// </summary>
+        OrientationSensor = 5,
+        /// <summary>
+        /// Gyroscope sensor.
+        /// </summary>
+        Gyroscope = 6,
+        /// <summary>
+        /// Light sensor.
+        /// </summary>
+        LightSensor = 7,
+        /// <summary>
+        /// Proximity sensor.
+        /// </summary>
+        ProximitySensor = 8,
+        /// <summary>
+        /// Pressure sensor.
+        /// </summary>
+        PressureSensor = 9,
+        /// <summary>
+        /// Ultraviolet sensor.
+        /// </summary>
+        UltravioletSensor = 10,
+        /// <summary>
+        /// Temperature sensor.
+        /// </summary>
+        TemperatureSensor = 11,
+        /// <summary>
+        /// Humidity sensor.
+        /// </summary>
+        HumiditySensor = 12,
+        /// <summary>
+        /// Hear rate monitor sensor.
+        /// </summary>
+        HeartRateMonitor = 13,
+        /// <summary>
+        /// Uncalibrated Gyroscope sensor.
+        /// </summary>
+        UncalibratedGyroscope = 17,
+        /// <summary>
+        /// Uncalibrated Geomagnetic sensor.
+        /// </summary>
+        UncalibratedMagnetometer = 18,
+        /// <summary>
+        /// Gyroscope-based rotation vector sensor.
+        /// </summary>
+        GyroscopeRotationVectorSensor = 19,
+        /// <summary>
+        /// Geomagnetic-based rotation vector sensor.
+        /// </summary>
+        MagnetometerRotationVectorSensor = 20
+    }
+
+    /// <summary>
+    /// SensorDataAccuracy Enum definition for all possible sensor data accuracy Values.
+    /// </summary>
+    public enum SensorDataAccuracy
+    {
+        /// <summary>
+        /// Undefined sensor data accuracy.
+        /// </summary>
+        Undefined = -1,
+        /// <summary>
+        /// Sensor data not accurate.
+        /// </summary>
+        Bad = 0,
+        /// <summary>
+        /// Moderately accurate sensor data.
+        /// </summary>
+        Normal = 1,
+        /// <summary>
+        /// Highly accurate sensor data.
+        /// </summary>
+        Good = 2,
+        /// <summary>
+        /// Very highly accurate sensor data.
+        /// </summary>
+        VeryGood = 3
+    }
+
+    /// <summary>
+    /// Sensor Option Enum definition for sensor option Values
+    /// </summary>
+    public enum SensorPausePolicy
+    {
+        /// <summary>
+        /// Does not receive data when the LCD is off and in the power save mode.
+        /// </summary>
+        None,
+        /// <summary>
+        /// Receives data when the LCD is off.
+        /// </summary>
+        DisplayOff,
+        /// <summary>
+        /// Receives data in the power save mode.
+        /// </summary>
+        PowerSaveMode,
+        /// <summary>
+        /// Receives data when the LCD is off and in the power save mode.
+        /// </summary>
+        All
+    }
+
+    public enum SensorAttribute
+    {
+        AxisOrientation,
+        PausePolicy
+    }
+}
diff --git a/Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs b/Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..84d2cee
--- /dev/null
@@ -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.System.Sensor
+{
+    /// <summary>
+    /// Accelerometer changed event arguments. Class for storing the data returned by accelerometer
+    /// </summary>
+    public class AccelerometerChangedEventArgs : EventArgs
+    {
+        internal AccelerometerChangedEventArgs(float[] values)
+        {
+            X = values[0];
+            Y = values[1];
+            Z = values[2];
+        }
+
+        /// <summary>
+        /// Gets the X component of the acceleration.
+        /// </summary>
+        public float X { get; private set; }
+
+        /// <summary>
+        /// Gets the Y component of the acceleration.
+        /// </summary>
+        public float Y { get; private set; }
+
+        /// <summary>
+        /// Gets the Z component of the acceleration.
+        /// </summary>
+        public float Z { get; private set; }
+    }
+}
\ No newline at end of file
diff --git a/Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs b/Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..126b555
--- /dev/null
@@ -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.System.Sensor
+{
+    /// <summary>
+    /// Sensor accuracy changed event arguments Class. Contains the parameters to be returned through accuracy callback
+    /// </summary>
+    public class SensorAccuracyChangedEventArgs : EventArgs
+    {
+        internal SensorAccuracyChangedEventArgs(DateTime timestamp, SensorDataAccuracy accuracy)
+        {
+            TimeStamp = timestamp;
+            Accuracy = accuracy;
+        }
+
+        /// <summary>
+        /// Gets the time stamp.
+        /// </summary>
+        public DateTime TimeStamp { get; private set; }
+
+        /// <summary>
+        /// Gets the accuracy.
+        /// </summary>
+        public SensorDataAccuracy Accuracy { get; private set; }
+    }
+}
\ No newline at end of file
diff --git a/Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs b/Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs
new file mode 100644 (file)
index 0000000..a0f9d3c
--- /dev/null
@@ -0,0 +1,125 @@
+// 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
+{
+    /// <summary>
+    /// Accelerometer Sensor Class. Used for registering callbacks for accelerometer and getting accelerometer data
+    /// /// </summary>
+    public class Accelerometer : Sensor
+    {
+        private uint _defaultInterval = 0;
+
+        /// <summary>
+        /// Gets the X component of the acceleration.
+        /// </summary>
+        public float X { get; private set; }
+
+        /// <summary>
+        /// Gets the Y component of the acceleration.
+        /// </summary>
+        public float Y { get; private set; }
+
+        /// <summary>
+        /// Gets the Z component of the acceleration.
+        /// </summary>
+        public float Z { get; private set; }
+
+        /// <summary>
+        /// Returns true or false based on whether accelerometer sensor is supported by device.
+        /// </summary>
+        public static bool IsSupported
+        {
+            get
+            {
+                return CheckIfSupported();
+            }
+        }
+
+        /// <summary>
+        /// Returns the number of accelerometer sensors available on the device.
+        /// </summary>
+        public static int Count
+        {
+            get
+            {
+                return GetCount();
+            }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Tizen.System.Sensor.Accelerometer"/> class.
+        /// </summary>
+        /// <param name='index'>
+        /// Index. Default value for this is 0. Index refers to a particular accelerometer sensor in case of multiple sensors
+        /// </param>
+        public Accelerometer(int index = 0) : base(index)
+        {
+            Interval = _defaultInterval;
+        }
+
+        protected override SensorType GetSensorType()
+        {
+            return SensorType.Accelerometer;
+        }
+
+        /// <summary>
+        /// Event Handler for storing the callback functions for event corresponding to change in accelerometer sensor data.
+        /// </summary>
+
+        public event EventHandler<AccelerometerChangedEventArgs> DataUpdated;
+
+        private static bool CheckIfSupported()
+        {
+            bool isSupported;
+            int error = Interop.SensorManager.SensorIsSupported(SensorType.Accelerometer, out isSupported);
+            if (error != 0)
+                isSupported = false;
+            return isSupported;
+        }
+
+        private static int GetCount()
+        {
+            IntPtr list;
+            int count;
+            int error = Interop.SensorManager.GetSensorList(SensorType.Accelerometer, out list, out count);
+            if (error != 0)
+                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 != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for accelerometer");
+        }
+
+        protected override void EventListenStop()
+        {
+            int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle);
+            if (error != 0)
+                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);
+            Timestamp = sensorData.timestamp;
+            X = sensorData.values[0];
+            Y = sensorData.values[1];
+            Z = sensorData.values[2];
+
+            DataUpdated?.Invoke(this, new AccelerometerChangedEventArgs(sensorData.values));
+        }
+    }
+}
\ No newline at end of file
diff --git a/Tizen.System.Sensor/Sensor/Sensor.cs b/Tizen.System.Sensor/Sensor/Sensor.cs
new file mode 100644 (file)
index 0000000..af841b9
--- /dev/null
@@ -0,0 +1,392 @@
+// 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
+{
+    /// <summary>
+    /// Sensor class for storing hardware information about a particular sensor
+    /// </summary>
+    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 _sensing = false;
+        private bool _disposed = false;
+        private UInt64 _timestamp;
+        private uint _interval = 0;
+        private uint _maxBatchLatency = 0;
+        private SensorPausePolicy _pausePolicy = SensorPausePolicy.None;
+        private IntPtr _sensorHandle = IntPtr.Zero;
+        private IntPtr _listenerHandle = IntPtr.Zero;
+
+        protected 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);
+        }
+
+        /// <summary>
+        /// Property: For getting the name of the sensor
+        /// </summary>
+        public string Name
+        {
+            get
+            {
+                return _name;
+            }
+        }
+
+        /// <summary>
+        /// Property: Gets the vendor.
+        /// </summary>
+        public string Vendor
+        {
+            get
+            {
+                return _vendor;
+            }
+        }
+
+        /// <summary>
+        /// Property: Gets the minimum value of range of sensor data.
+        /// </summary>
+        public float MinValue
+        {
+            get
+            {
+                return _minValue;
+            }
+        }
+
+        /// <summary>
+        /// Property: Gets the maximum value of range of sensor data.
+        /// </summary>
+        public float MaxValue
+        {
+            get
+            {
+                return _maxValue;
+            }
+        }
+
+        /// <summary>
+        /// Property: Gets the resolution.
+        /// </summary>
+        public float Resolution
+        {
+            get
+            {
+                return _resolution;
+            }
+        }
+
+        /// <summary>
+        /// Property: Gets the minimum interval.
+        /// </summary>
+        public int MinInterval
+        {
+            get
+            {
+                return _minInterval;
+            }
+        }
+
+        /// <summary>
+        /// Property: Gets the fifo count.
+        /// </summary>
+        public int FifoCount
+        {
+            get
+            {
+                return _fifoCount;
+            }
+        }
+
+        /// <summary>
+        /// Property: Gets the maximum batch count.
+        /// </summary>
+        public int MaxBatchCount
+        {
+            get
+            {
+                return _maxBatchCount;
+            }
+        }
+
+        /// <summary>
+        /// Sets the interval of the sensor for sensor data event
+        /// Callbacks will be called at frequency of this interval
+        /// </summary>
+        public uint Interval
+        {
+            set
+            {
+                _interval = value;
+                SetInterval();
+            }
+            get
+            {
+                return _interval;
+            }
+        }
+
+        /// <summary>
+        /// Sets the max batch latency for the sensor corresponding to the sensor data event.
+        /// </summary>
+        public uint MaxBatchLatency
+        {
+            set
+            {
+                _maxBatchLatency = value;
+                SetMaxBatchLatency();
+            }
+            get
+            {
+                return _maxBatchLatency;
+            }
+        }
+
+        /// <summary>
+        /// Gets the attribute.
+        /// </summary>
+        /// <value>
+        public SensorPausePolicy PausePolicy
+        {
+            set
+            {
+                _pausePolicy = value;
+                SetPausePolicy();
+            }
+            get
+            {
+                return _pausePolicy;
+            }
+        }
+
+        public UInt64 Timestamp
+        {
+            set
+            {
+                _timestamp = value;
+            }
+            get
+            {
+                return _timestamp;
+            }
+        }
+
+        public bool Sensing
+        {
+            get
+            {
+                return _sensing;
+            }
+        }
+
+        protected IntPtr ListenerHandle
+        {
+            get
+            {
+                return _listenerHandle;
+            }
+        }
+
+        /// <summary>
+        /// Starts the sensor.
+        /// After this the event handlers will start receiving events.
+        /// </summary>
+        public void Start()
+        {
+            if (CheckListenerHandle())
+            {
+                int error = Interop.SensorListener.StartListener(_listenerHandle);
+                if (error != 0)
+                    throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Start Sensor Listener");
+                EventListenStart();
+                _sensing = true;
+            }
+        }
+
+        /// <summary>
+        /// Stop the sensor.
+        /// After this the event handlers will stop receiving the events
+        /// </summary>
+        public void Stop()
+        {
+            if (!_sensing)
+            {
+                int error = Interop.SensorListener.StopListener(_listenerHandle);
+                if (error != 0)
+                    throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Stop Sensor Listener");
+                EventListenStop();
+                _sensing = false;
+            }
+            else
+            {
+                throw new InvalidOperationException("Operation Failed: Sensor already stopped");
+            }
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            DestroyHandles();
+            _disposed = true;
+        }
+
+        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 != 0)
+                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)SensorErrorFactory.SensorError.None;
+
+            error = Interop.Sensor.GetName(_sensorHandle, out _name);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Name Failed");
+
+            error = Interop.Sensor.GetVendor(_sensorHandle, out _vendor);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Vendor Failed");
+
+            error = Interop.Sensor.GetMinRange(_sensorHandle, out _minValue);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinValue Failed");
+
+            error = Interop.Sensor.GetMaxRange(_sensorHandle, out _maxValue);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxValue Failed");
+
+            error = Interop.Sensor.GetResolution(_sensorHandle, out _resolution);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Resolution Failed");
+
+            error = Interop.Sensor.GetMinInterval(_sensorHandle, out _minInterval);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinInterval Failed");
+
+            error = Interop.Sensor.GetFifoCount(_sensorHandle, out _fifoCount);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.FifoCount Failed");
+
+            error = Interop.Sensor.GetMaxBatchCount(_sensorHandle, out _maxBatchCount);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxBatchCount Failed");
+        }
+
+        private void CreateListener()
+        {
+            int error = Interop.SensorListener.CreateListener(_sensorHandle, out _listenerHandle);
+            if (error != 0)
+                throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.CreateListener Failed");
+        }
+
+        private void SetInterval()
+        {
+            if (CheckListenerHandle())
+            {
+                int error = Interop.SensorListener.SetInterval(_listenerHandle, _interval);
+                if (error != 0)
+                    throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed");
+            }
+        }
+
+        private void SetMaxBatchLatency()
+        {
+            if (CheckListenerHandle())
+            {
+                int error = Interop.SensorListener.SetMaxBatchLatency(_listenerHandle, _maxBatchLatency);
+                if (error != 0)
+                    throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.MaxBatchLatency Failed");
+            }
+        }
+
+        private void SetPausePolicy()
+        {
+            if (CheckListenerHandle())
+            {
+                int error = Interop.SensorListener.SetAttribute(_listenerHandle, SensorAttribute.PausePolicy, (int)_pausePolicy);
+                if (error != 0)
+                    throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed");
+            }
+        }
+
+        private bool CheckListenerHandle()
+        {
+            bool result = false;
+            if (_listenerHandle != IntPtr.Zero)
+            {
+                result = true;
+            }
+            else
+            {
+                throw new ArgumentException("Invalid Parameter: Sensor is null");
+            }
+            return result;
+        }
+
+        private bool CheckSensorHandle()
+        {
+            bool result = false;
+            if (_sensorHandle != IntPtr.Zero)
+            {
+                result = true;
+            }
+            else
+            {
+                throw new ArgumentException("Invalid Parameter: Sensor is null");
+            }
+            return result;
+        }
+
+        private void DestroyHandles()
+        {
+            Interop.SensorListener.DestroyListener(_listenerHandle);
+        }
+    }
+}
diff --git a/Tizen.System.Sensor/Sensor/SensorErrorFactory.cs b/Tizen.System.Sensor/Sensor/SensorErrorFactory.cs
new file mode 100644 (file)
index 0000000..620f42d
--- /dev/null
@@ -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.System.Sensor
+{
+    internal static class SensorErrorFactory
+    {
+        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
+        }
+
+        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/Tizen.System.Sensor.csproj b/Tizen.System.Sensor/Tizen.System.Sensor.csproj
new file mode 100644 (file)
index 0000000..4856c17
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{CB655C6A-F73B-448E-913C-CA4DCBC5E401}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>Tizen.System.Sensor</RootNamespace>
+    <AssemblyName>Tizen.System.Sensor</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Interop\Interop.Sensor.cs" />
+    <Compile Include="Sensor\Enumerations.cs" />
+    <Compile Include="Sensor\Sensor.cs" />
+    <Compile Include="Interop\Interop.Libraries.cs" />
+    <Compile Include="Sensor\Plugins\Accelerometer.cs" />
+    <Compile Include="Sensor\EventArgs\SensorAccuracyChangedEventArgs.cs" />
+    <Compile Include="Sensor\EventArgs\AccelerometerChangedEventArgs.cs" />
+    <Compile Include="Sensor\SensorErrorFactory.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <ProjectReference Include="..\..\tizen\Tizen.Internals\Tizen.Internals.csproj">
+      <Project>{B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}</Project>
+      <Name>Tizen.Internals</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ProjectExtensions>
+    <MonoDevelop>
+      <Properties>
+        <Policies>
+          <TextStylePolicy EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
+          <CSharpFormattingPolicy inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
+          <DotNetNamingPolicy DirectoryNamespaceAssociation="None" ResourceNamePolicy="FileFormatDefault" />
+          <StandardHeader Text="" IncludeInNewFiles="True" />
+          <TextStylePolicy EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
+          <TextStylePolicy inheritsSet="Mono" inheritsScope="text/plain" scope="application/xml" />
+          <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
+        </Policies>
+      </Properties>
+    </MonoDevelop>
+  </ProjectExtensions>
+</Project>
\ No newline at end of file
diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.pidb b/Tizen.System.Sensor/Tizen.System.Sensor.pidb
new file mode 100644 (file)
index 0000000..78ae299
Binary files /dev/null and b/Tizen.System.Sensor/Tizen.System.Sensor.pidb differ
diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.snk b/Tizen.System.Sensor/Tizen.System.Sensor.snk
new file mode 100644 (file)
index 0000000..e480db4
Binary files /dev/null and b/Tizen.System.Sensor/Tizen.System.Sensor.snk differ
diff --git a/Tizen.System.Sensor/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Tizen.System.Sensor/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
new file mode 100644 (file)
index 0000000..ece1079
Binary files /dev/null and b/Tizen.System.Sensor/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/packaging/csapi-system.sensor.manifest b/packaging/csapi-system.sensor.manifest
new file mode 100755 (executable)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
diff --git a/packaging/csapi-system.sensor.pc.in b/packaging/csapi-system.sensor.pc.in
new file mode 100755 (executable)
index 0000000..72354d8
--- /dev/null
@@ -0,0 +1,5 @@
+Name: csapi-system-sensor
+Description: Tizen Sensor API for C#
+Version: @version@
+Libs: -r:@dllpath@/@dllname@
+Requires:
diff --git a/packaging/csapi-system.sensor.spec b/packaging/csapi-system.sensor.spec
new file mode 100644 (file)
index 0000000..9c1bb71
--- /dev/null
@@ -0,0 +1,86 @@
+%define dllpath %{_libdir}/mono/tizen
+%define dllname Tizen.System.Sensor.dll
+
+Name:       csapi-system.sensor
+Summary:    Tizen Sensor API for C#
+Version:    1.0.0
+Release:    1
+Group:      Development/Libraries
+License:    Apache-2.0
+URL:        https://www.tizen.org
+Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}.manifest
+Source2:    %{name}.pc.in
+
+# TODO: replace mono-compiler, mono-devel to mcs, mono-shlib-cop
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+#BuildRequires: mcs
+#BuildRequires: mono-shlib-cop
+BuildRequires: pkgconfig(csapi-tizen)
+BuildRequires: pkgconfig(glib-2.0)
+
+# TODO: replace mono-core to gacutil.
+#       mono-core should provide the symbol 'gacutil'
+Requires(post): mono-core
+Requires(postun): mono-core
+
+# P/Invoke Dependencies
+BuildRequires: pkgconfig(capi-system-sensor)
+
+# P/Invoke Runtime Dependencies
+# TODO: It should be removed after fix tizen-rpm-config
+Requires: capi-system-sensor
+# DLL Dependencies
+#BuildRequires: ...
+
+%description
+Tizen Sensor API for C#
+
+%package devel
+Summary:    Development package for %{name}
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+Development package for %{name}
+
+%prep
+%setup -q
+
+cp %{SOURCE1} .
+
+%build
+# build dll
+mcs -target:library -out:%{dllname} -keyfile:Tizen.System.Sensor/Tizen.System.Sensor.snk -pkg:'csapi-tizen'\
+  Tizen.System.Sensor/Properties/AssemblyInfo.cs \
+  Tizen.System.Sensor/Sensor/Plugins/*.cs \
+  Tizen.System.Sensor/Sensor/EventArgs/*.cs \
+  Tizen.System.Sensor/Sensor/*.cs \
+  Tizen.System.Sensor/Interop/*.cs
+# check p/invoke
+if [ -x %{dllname} ]; then
+  RET=`mono-shlib-cop %{dllname}`; \
+  CNT=`echo $RET | grep -E "^error:" | wc -l`; \
+  if [ $CNT -gt 0 ]; then exit 1; fi
+fi
+
+%install
+# copy dll
+mkdir -p %{buildroot}%{dllpath}
+install -p -m 644 %{dllname} %{buildroot}%{dllpath}
+
+# generate pkgconfig
+mkdir -p %{buildroot}%{_libdir}/pkgconfig
+sed -e "s#@version@#%{version}#g" \
+    -e "s#@dllpath@#%{dllpath}#g" \
+    -e "s#@dllname@#%{dllname}#g" \
+    %{SOURCE2} > %{buildroot}%{_libdir}/pkgconfig/%{name}.pc
+%post
+gacutil -i %{dllpath}/%{dllname}
+
+%files
+%{dllpath}/%{dllname}
+
+%files devel
+%{_libdir}/pkgconfig/%{name}.pc