From 12264cf6d04a6e93683c8a2ca9b5ece4ab650efc Mon Sep 17 00:00:00 2001 From: Ankur Date: Thu, 26 May 2016 16:03:12 +0530 Subject: [PATCH] Adding Other sensor classes and tct-test folder for accelerometer -Added the Test case file for accelerometer -Added other sensor files (apart from accelerometer) Patch-Set-2: Minor Changes Patch-Set-3: Minor CHanges Patch-Set-4: Added Lib fodler to tct Patch-Set-5: Bug Fixing for tct passing. Now 17/18 passing. Set Sensor.MaxBatchLatency not passing Patch-Set-6: Changed .Net Framwork Version to 4.5 Patch-Set-7: Removed MaxBatchLatency TCT as Batch Mode is currently not suported by sensor framework Patch-Set-8: Added Log.Info and Log.Error Tags and removed extra whitespace Patch-Set-9: Minor changes as per reviews/comments Patch-Set-10: Added GravitySensor, LinearAccelerationSensor, Magnetometer, RotationVectorSensor, OrientationSensor, Gyroscope Patch-Set-11: Added LightSensor, ProximitySensor, PressureSensor, UltravioletSensor, TemperatureSensor, HumiditySensor, HeartRateSensor Patch-Set-12: Added UncalibratedGyroscope, UncalibratedMagnetometer, GyroscopeRV, MagnetometerRV. Updates as per reviews/comments. Patch-Set-13: Added Pedometer and SleepMonitor, Renamed Sensor folder to Tizen.System.Senosr, Enumerations.cs to SensorEnumerations.cs, Removed sln file, Added LICENSE file, Renamed EventArgs classes Patch-Set-14: Changes as per reivew Patch-Set-15: Removed Tizen.System.Sensor/obj/ Patch-Set-16: Timestamp type changed to TimeSpan Patch-Set-17: Renmaing Timestamp to TimeSpan Patch-Set-18: Minor Changes Patch-Set-19: Updated Commit message Patch-Set-20: New tpk file for tct Patch-Set-21: Renamed dll from Tizen.System.Sensor.dll to Tizen.System.dll and linked snk file Patch-Set-22: Added logs to tct, updated new dll for Tizen.System.dll, Added tct for LinearAcceleration, Gravity and Proximity Sensors Patch-Set-23: Updated tpk file Patch-Set-24: Tested LinearAccel, Proximity and Gravity Sensor. Updated tpk file.. tct 62/64 working Patch-Set-25: Changes by SeungHun Choi - Bug Fixing for TCT Patch-Set-26: Minor Changes - removed extra whitespace signed-off-by:"Ankur Garg " Change-Id: I6dd6f8ca439c57f0ac8576036df39ce547adbaa6 --- LICENSE | 202 +++++++++++++++++++++ Tizen.System.Sensor.sln | 53 ------ Tizen.System.Sensor.userprefs | 29 --- Tizen.System.Sensor/Tizen.System.Sensor.csproj | 187 ++++++++++++------- .../AccelerometerDataUpdatedEventArgs.cs} | 4 +- .../EventArgs/GravitySensorDataUpdatedEventArgs.cs | 40 ++++ .../EventArgs/GyroscopeDataUpdatedEventArgs.cs | 40 ++++ ...copeRotationVectorSensorDataUpdatedEventArgs.cs | 52 ++++++ .../HeartRateMonitorDataUpdatedEventArgs.cs | 28 +++ .../HumiditySensorDataUpdatedEventArgs.cs | 28 +++ .../EventArgs/LightSensorDataUpdatedEventArgs.cs | 28 +++ ...LinearAccelerationSensorDataUpdatedEventArgs.cs | 40 ++++ .../EventArgs/MagnetometerDataUpdatedEventArgs.cs | 40 ++++ ...eterRotationVectorSensorDataUpdatedEventArgs.cs | 52 ++++++ .../OrientationSensorDataUpdatedEventArgs.cs | 40 ++++ .../EventArgs/PedometerDataUpdatedEventArgs.cs | 70 +++++++ .../PressureSensorDataUpdatedEventArgs.cs | 28 +++ .../ProximitySensorDataUpdatedEventArgs.cs | 28 +++ .../RotationVectorSensorDataUpdatedEventArgs.cs | 52 ++++++ .../EventArgs/SensorAccuracyChangedEventArgs.cs | 6 +- .../EventArgs/SleepMonitorDataUpdatedEventArgs.cs | 28 +++ .../TemperatureSensorDataUpdatedEventArgs.cs | 28 +++ .../UltravioletSensorDataUpdatedEventArgs.cs | 28 +++ .../UncalibratedGyroscopeDataUpdatedEventArgs.cs | 58 ++++++ ...UncalibratedMagnetometerDataUpdatedEventArgs.cs | 58 ++++++ .../Plugins/Accelerometer.cs | 36 ++-- .../Tizen.System.Sensor/Plugins/GravitySensor.cs | 184 +++++++++++++++++++ .../Tizen.System.Sensor/Plugins/Gyroscope.cs | 137 ++++++++++++++ .../Plugins/GyroscopeRotationVectorSensor.cs | 149 +++++++++++++++ .../Plugins/HeartRateMonitor.cs | 125 +++++++++++++ .../Tizen.System.Sensor/Plugins/HumiditySensor.cs | 125 +++++++++++++ .../Tizen.System.Sensor/Plugins/LightSensor.cs | 125 +++++++++++++ .../Plugins/LinearAccelerationSensor.cs | 184 +++++++++++++++++++ .../Tizen.System.Sensor/Plugins/Magnetometer.cs | 184 +++++++++++++++++++ .../Plugins/MagnetometerRotationVectorSensor.cs | 196 ++++++++++++++++++++ .../Plugins/OrientationSensor.cs | 184 +++++++++++++++++++ .../Tizen.System.Sensor/Plugins/Pedometer.cs | 167 +++++++++++++++++ .../Tizen.System.Sensor/Plugins/PressureSensor.cs | 125 +++++++++++++ .../Tizen.System.Sensor/Plugins/ProximitySensor.cs | 125 +++++++++++++ .../Plugins/RotationVectorSensor.cs | 196 ++++++++++++++++++++ .../Tizen.System.Sensor/Plugins/SleepMonitor.cs | 125 +++++++++++++ .../Plugins/TemperatureSensor.cs | 125 +++++++++++++ .../Plugins/UltravioletSensor.cs | 125 +++++++++++++ .../Plugins/UncalibratedGyroscope.cs | 155 ++++++++++++++++ .../Plugins/UncalibratedMagnetometer.cs | 202 +++++++++++++++++++++ .../{Sensor => Tizen.System.Sensor}/Sensor.cs | 138 +++++++++++--- .../SensorEnumerations.cs} | 33 +++- .../SensorErrorFactory.cs | 24 +-- packaging/csapi-system.sensor.spec | 2 +- 49 files changed, 4208 insertions(+), 210 deletions(-) create mode 100644 LICENSE delete mode 100644 Tizen.System.Sensor.sln delete mode 100644 Tizen.System.Sensor.userprefs rename Tizen.System.Sensor/{Sensor/EventArgs/AccelerometerChangedEventArgs.cs => Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs} (89%) create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GyroscopeRotationVectorSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HeartRateMonitorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/HumiditySensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LinearAccelerationSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/MagnetometerRotationVectorSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/OrientationSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PedometerDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/ProximitySensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/RotationVectorSensorDataUpdatedEventArgs.cs rename Tizen.System.Sensor/{Sensor => Tizen.System.Sensor}/EventArgs/SensorAccuracyChangedEventArgs.cs (82%) create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UltravioletSensorDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedGyroscopeDataUpdatedEventArgs.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/UncalibratedMagnetometerDataUpdatedEventArgs.cs rename Tizen.System.Sensor/{Sensor => Tizen.System.Sensor}/Plugins/Accelerometer.cs (75%) create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs create mode 100644 Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs rename Tizen.System.Sensor/{Sensor => Tizen.System.Sensor}/Sensor.cs (66%) rename Tizen.System.Sensor/{Sensor/Enumerations.cs => Tizen.System.Sensor/SensorEnumerations.cs} (87%) mode change 100755 => 100644 rename Tizen.System.Sensor/{Sensor => Tizen.System.Sensor}/SensorErrorFactory.cs (80%) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Tizen.System.Sensor.sln b/Tizen.System.Sensor.sln deleted file mode 100644 index 7e415e3..0000000 --- a/Tizen.System.Sensor.sln +++ /dev/null @@ -1,53 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.System.Sensor", "Tizen.System.Sensor\Tizen.System.Sensor.csproj", "{CB655C6A-F73B-448E-913C-CA4DCBC5E401}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Internals", "..\tizen\Tizen.Internals\Tizen.Internals.csproj", "{B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.Build.0 = Release|Any CPU - {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CB655C6A-F73B-448E-913C-CA4DCBC5E401}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = Tizen.System.Sensor\Tizen.System.Sensor.csproj - Policies = $0 - $0.DotNetNamingPolicy = $1 - $1.DirectoryNamespaceAssociation = None - $1.ResourceNamePolicy = FileFormatDefault - $0.TextStylePolicy = $2 - $2.inheritsSet = null - $2.scope = text/x-csharp - $0.CSharpFormattingPolicy = $3 - $3.inheritsSet = Mono - $3.inheritsScope = text/x-csharp - $3.scope = text/x-csharp - $0.StandardHeader = $4 - $4.Text = - $4.IncludeInNewFiles = True - $0.TextStylePolicy = $5 - $5.EolMarker = Unix - $5.inheritsSet = VisualStudio - $5.inheritsScope = text/plain - $5.scope = text/plain - $0.TextStylePolicy = $6 - $6.inheritsSet = Mono - $6.inheritsScope = text/plain - $6.scope = application/xml - $0.XmlFormattingPolicy = $7 - $7.inheritsSet = Mono - $7.inheritsScope = application/xml - $7.scope = application/xml - EndGlobalSection -EndGlobal diff --git a/Tizen.System.Sensor.userprefs b/Tizen.System.Sensor.userprefs deleted file mode 100644 index 2a833c1..0000000 --- a/Tizen.System.Sensor.userprefs +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.csproj b/Tizen.System.Sensor/Tizen.System.Sensor.csproj index 4856c17..4d15d61 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor.csproj +++ b/Tizen.System.Sensor/Tizen.System.Sensor.csproj @@ -1,67 +1,122 @@ - - - - Debug - AnyCPU - 10.0.0 - 2.0 - {CB655C6A-F73B-448E-913C-CA4DCBC5E401} - Library - Tizen.System.Sensor - Tizen.System.Sensor - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - false - - - none - false - bin\Release - prompt - 4 - false - - - - - - - - - - - - - - - - - - - {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0} - Tizen.Internals - - - - - - - - - - - - - - - - - + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {CB655C6A-F73B-448E-913C-CA4DCBC5E401} + Library + Tizen.System.Sensor + Tizen.System + v4.5 + + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + false + + + none + false + bin\Release + prompt + 4 + false + false + + + true + + + Tizen.System.Sensor.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0} + Tizen.Internals + + + {7659ca59-410d-41a1-9841-586e88bc78c9} + Tizen + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs similarity index 89% rename from Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs rename to Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs index 84d2cee..0089c77 100644 --- a/Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs @@ -13,9 +13,9 @@ namespace Tizen.System.Sensor /// /// Accelerometer changed event arguments. Class for storing the data returned by accelerometer /// - public class AccelerometerChangedEventArgs : EventArgs + public class AccelerometerDataUpdatedEventArgs : EventArgs { - internal AccelerometerChangedEventArgs(float[] values) + internal AccelerometerDataUpdatedEventArgs(float[] values) { X = values[0]; Y = values[1]; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..ed24a8f7 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..1cf91d9 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..a1cf5ed --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..39f9921 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..5fd0d7c --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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/LightSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/LightSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..d0d1896 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..cf531ca --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..8ca789e --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..abb096e --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..a95f377 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..5b77d98 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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/PressureSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/PressureSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..b6f6e4a --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..a959ad4 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..8111981 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs similarity index 82% rename from Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs rename to Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs index 126b555..5846d40 100644 --- a/Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs @@ -15,16 +15,16 @@ namespace Tizen.System.Sensor /// public class SensorAccuracyChangedEventArgs : EventArgs { - internal SensorAccuracyChangedEventArgs(DateTime timestamp, SensorDataAccuracy accuracy) + internal SensorAccuracyChangedEventArgs(TimeSpan timespan, SensorDataAccuracy accuracy) { - TimeStamp = timestamp; + TimeSpan = timespan; Accuracy = accuracy; } /// /// Gets the time stamp. /// - public DateTime TimeStamp { get; private set; } + public TimeSpan TimeSpan { get; private set; } /// /// Gets the accuracy. diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..2a6d5ab --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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/TemperatureSensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/TemperatureSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..8e746bf --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..d6a140d --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..9e44476 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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 new file mode 100644 index 0000000..1227e98 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.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.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/Sensor/Plugins/Accelerometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs similarity index 75% rename from Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs rename to Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs index a0f9d3c..f583f1e 100644 --- a/Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs @@ -15,8 +15,6 @@ namespace Tizen.System.Sensor /// /// public class Accelerometer : Sensor { - private uint _defaultInterval = 0; - /// /// Gets the X component of the acceleration. /// @@ -39,6 +37,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Checking if the Accelerometer sensor is supported"); return CheckIfSupported(); } } @@ -50,6 +49,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the count of accelerometer sensors"); return GetCount(); } } @@ -62,10 +62,10 @@ namespace Tizen.System.Sensor /// public Accelerometer(int index = 0) : base(index) { - Interval = _defaultInterval; + Log.Info(Globals.LogTag, "Creating Accelerometer object"); } - protected override SensorType GetSensorType() + internal override SensorType GetSensorType() { return SensorType.Accelerometer; } @@ -74,14 +74,17 @@ namespace Tizen.System.Sensor /// Event Handler for storing the callback functions for event corresponding to change in accelerometer sensor data. /// - public event EventHandler DataUpdated; + public event EventHandler DataUpdated; private static bool CheckIfSupported() { bool isSupported; int error = Interop.SensorManager.SensorIsSupported(SensorType.Accelerometer, out isSupported); - if (error != 0) + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if accelerometer sensor is supported"); isSupported = false; + } return isSupported; } @@ -90,8 +93,11 @@ namespace Tizen.System.Sensor IntPtr list; int count; int error = Interop.SensorManager.GetSensorList(SensorType.Accelerometer, out list, out count); - if (error != 0) + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for accelerometer"); count = 0; + } else Interop.Libc.Free(list); return count; @@ -100,26 +106,32 @@ namespace Tizen.System.Sensor protected override void EventListenStart() { int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != 0) + 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 != 0) + 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); - Timestamp = sensorData.timestamp; + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); X = sensorData.values[0]; Y = sensorData.values[1]; Z = sensorData.values[2]; - DataUpdated?.Invoke(this, new AccelerometerChangedEventArgs(sensorData.values)); + DataUpdated?.Invoke(this, new AccelerometerDataUpdatedEventArgs(sensorData.values)); } } -} \ No newline at end of file +} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs new file mode 100644 index 0000000..9d73e7a --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs @@ -0,0 +1,184 @@ +// 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 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(); + } + } + + /// + /// 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; + + 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.GravitySensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if gravity sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..44dab8b --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs @@ -0,0 +1,137 @@ +// 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 + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.Gyroscope, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if gyroscope sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..cc0a106 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs @@ -0,0 +1,149 @@ +// 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 + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.GyroscopeRotationVectorSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if gyroscope rotation vector sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..3cb37b1 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs @@ -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 +{ + /// + /// HeartRateMonitor Class. Used for registering callbacks for heart rate monitor and getting heart rate data + /// /// + public class HeartRateMonitor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.HeartRateMonitor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if heart rate monitor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..cb0dced --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs @@ -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 +{ + /// + /// HumiditySensor Class. Used for registering callbacks for humidity sensor and getting humidity data + /// /// + public class HumiditySensor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.HumiditySensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if humidity sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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/LightSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs new file mode 100644 index 0000000..edc401c --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs @@ -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 +{ + /// + /// LightSensor Class. Used for registering callbacks for light sensor and getting light data + /// /// + public class LightSensor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.LightSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if light sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..8a24843 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs @@ -0,0 +1,184 @@ +// 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 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(); + } + } + + /// + /// 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; + + 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.LinearAccelerationSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if linear acceleration sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..b2fd4c8 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs @@ -0,0 +1,184 @@ +// 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 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(); + } + } + + /// + /// 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; + + 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.Magnetometer, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if magnetometer is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..a1e0df6 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs @@ -0,0 +1,196 @@ +// 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 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(); + } + } + + /// + /// 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; + + 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 new file mode 100644 index 0000000..6f0d7d3 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs @@ -0,0 +1,184 @@ +// 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 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(); + } + } + + /// + /// 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; + + 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.OrientationSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if orientation sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..3ad8baa --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs @@ -0,0 +1,167 @@ +// 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 + { + /// + /// 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(); + } + } + + /// + /// 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.HumanPedometer; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in pedometer sensor data. + /// + + public event EventHandler DataUpdated; + + private static bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.HumanPedometer, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if pedometer sensor is supported"); + isSupported = false; + } + return isSupported; + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.HumanPedometer, 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/PressureSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs new file mode 100644 index 0000000..aa24f71 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs @@ -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 +{ + /// + /// PressureSensor Class. Used for registering callbacks for pressure sensor and getting pressure data + /// /// + public class PressureSensor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.PressureSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if pressure sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..55b0a28 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs @@ -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 +{ + /// + /// ProximitySensor Class. Used for registering callbacks for proximity sensor and getting proximity data + /// /// + public class ProximitySensor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.ProximitySensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if proximity sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..71a1ec2 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs @@ -0,0 +1,196 @@ +// 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 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(); + } + } + + /// + /// 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; + + 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.RotationVectorSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if rotation vector sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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/SleepMonitor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs new file mode 100644 index 0000000..f7b6c69 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs @@ -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 +{ + /// + /// SleepMonitor Class. Used for registering callbacks for sleep monitor and getting sleep data + /// /// + public class SleepMonitor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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.HumanSleepMonitor; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in sleep monitor data. + /// + + public event EventHandler DataUpdated; + + private static bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.HumanSleepMonitor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if sleep monitor is supported"); + isSupported = false; + } + return isSupported; + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.HumanSleepMonitor, 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/TemperatureSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs new file mode 100644 index 0000000..3be658c --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs @@ -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 +{ + /// + /// TemperatureSensor Class. Used for registering callbacks for temperature sensor and getting temperature data + /// /// + public class TemperatureSensor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.TemperatureSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if temperature sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..40d21cd --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs @@ -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 +{ + /// + /// UltravioletSensor Class. Used for registering callbacks for ultraviolet sensor and getting ultraviolet data + /// /// + public class UltravioletSensor : Sensor + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.UltravioletSensor, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if ultraviolet sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..8a092c1 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs @@ -0,0 +1,155 @@ +// 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 + { + /// + /// 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(); + } + } + + /// + /// 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 bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.UncalibratedGyroscope, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if uncalibrated gyroscope sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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 new file mode 100644 index 0000000..bb1bde2 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs @@ -0,0 +1,202 @@ +// 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 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(); + } + } + + /// + /// 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; + + 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.UncalibratedMagnetometer, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if uncalibrated magnetometer sensor is supported"); + isSupported = false; + } + return isSupported; + } + + 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/Sensor/Sensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs similarity index 66% rename from Tizen.System.Sensor/Sensor/Sensor.cs rename to Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs index af841b9..33bc4a3 100644 --- a/Tizen.System.Sensor/Sensor/Sensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs @@ -8,8 +8,14 @@ using 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 /// @@ -23,16 +29,16 @@ namespace Tizen.System.Sensor private int _minInterval; private int _fifoCount; private int _maxBatchCount; - private bool _sensing = false; + private bool _isSensing = false; private bool _disposed = false; - private UInt64 _timestamp; + 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; - protected abstract SensorType GetSensorType(); + internal abstract SensorType GetSensorType(); protected abstract void EventListenStart(); protected abstract void EventListenStop(); @@ -59,6 +65,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the sensor name"); return _name; } } @@ -70,6 +77,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the sensor vendor name"); return _vendor; } } @@ -81,6 +89,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the min value of the sensor"); return _minValue; } } @@ -92,6 +101,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the max value of the sensor"); return _maxValue; } } @@ -103,6 +113,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the resolution of the sensor"); return _resolution; } } @@ -114,6 +125,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the min interval for the sensor"); return _minInterval; } } @@ -125,6 +137,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the fifo count of the sensor"); return _fifoCount; } } @@ -136,6 +149,7 @@ namespace Tizen.System.Sensor { get { + Log.Info(Globals.LogTag, "Getting the max batch count of the sensor"); return _maxBatchCount; } } @@ -148,11 +162,13 @@ namespace Tizen.System.Sensor { 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; } } @@ -164,11 +180,13 @@ namespace Tizen.System.Sensor { 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; } } @@ -181,32 +199,37 @@ namespace Tizen.System.Sensor { set { + Log.Info(Globals.LogTag, "Setting the pause policy of the sensor"); _pausePolicy = value; SetPausePolicy(); } get { + Log.Info(Globals.LogTag, "Getting the pause policy of the sensor"); return _pausePolicy; } } - public UInt64 Timestamp + public TimeSpan TimeSpan { set { - _timestamp = value; + Log.Info(Globals.LogTag, "Setting the timespan of the sensor values"); + _timeSpan = value; } get { - return _timestamp; + Log.Info(Globals.LogTag, "Getting the timespan of the sensor values"); + return _timeSpan; } } - public bool Sensing + public bool IsSensing { get { - return _sensing; + Log.Info(Globals.LogTag, "Checking if the sensor is started"); + return _isSensing; } } @@ -224,13 +247,18 @@ namespace Tizen.System.Sensor /// public void Start() { + Log.Info(Globals.LogTag, "Starting the sensor"); if (CheckListenerHandle()) { int error = Interop.SensorListener.StartListener(_listenerHandle); - if (error != 0) + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error starting sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Start Sensor Listener"); + } EventListenStart(); - _sensing = true; + _isSensing = true; + Log.Info(Globals.LogTag, "Sensor started"); } } @@ -240,17 +268,23 @@ namespace Tizen.System.Sensor /// public void Stop() { - if (!_sensing) + Log.Info(Globals.LogTag, "Stopping the sensor"); + if (_isSensing) { int error = Interop.SensorListener.StopListener(_listenerHandle); - if (error != 0) + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error stopping the sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Stop Sensor Listener"); + } EventListenStop(); - _sensing = false; + _isSensing = false; + Log.Info(Globals.LogTag, "Sensor stopped"); } else { - throw new InvalidOperationException("Operation Failed: Sensor already stopped"); + Log.Error(Globals.LogTag, "Can't stop sensor as it is already stopped"); + throw new InvalidOperationException("Operation Failed: Sensor is already stopped"); } } @@ -275,8 +309,11 @@ namespace Tizen.System.Sensor IntPtr[] sensorList; int count; int error = Interop.SensorManager.GetSensorList(type, out list, out count); - if (error != 0) + 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); @@ -284,55 +321,88 @@ namespace Tizen.System.Sensor private void GetProperty() { - int error = (int)SensorErrorFactory.SensorError.None; + int error = (int)SensorError.None; error = Interop.Sensor.GetName(_sensorHandle, out _name); - if (error != 0) + 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 != 0) + 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 != 0) + 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 != 0) + 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 != 0) + 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 != 0) + 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 != 0) + 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 != 0) + 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 != 0) + 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()) { - int error = Interop.SensorListener.SetInterval(_listenerHandle, _interval); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed"); + 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"); + } + } } } @@ -341,8 +411,11 @@ namespace Tizen.System.Sensor if (CheckListenerHandle()) { int error = Interop.SensorListener.SetMaxBatchLatency(_listenerHandle, _maxBatchLatency); - if (error != 0) + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting max batch latency"); throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.MaxBatchLatency Failed"); + } } } @@ -351,8 +424,11 @@ namespace Tizen.System.Sensor if (CheckListenerHandle()) { int error = Interop.SensorListener.SetAttribute(_listenerHandle, SensorAttribute.PausePolicy, (int)_pausePolicy); - if (error != 0) + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting sensor pause policy"); throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed"); + } } } @@ -365,6 +441,7 @@ namespace Tizen.System.Sensor } else { + Log.Error(Globals.LogTag, "Sensor listener handle is null"); throw new ArgumentException("Invalid Parameter: Sensor is null"); } return result; @@ -379,6 +456,7 @@ namespace Tizen.System.Sensor } else { + Log.Error(Globals.LogTag, "Sensor handle is null"); throw new ArgumentException("Invalid Parameter: Sensor is null"); } return result; diff --git a/Tizen.System.Sensor/Sensor/Enumerations.cs b/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs old mode 100755 new mode 100644 similarity index 87% rename from Tizen.System.Sensor/Sensor/Enumerations.cs rename to Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs index 9de4515..94f071c --- a/Tizen.System.Sensor/Sensor/Enumerations.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs @@ -13,7 +13,7 @@ namespace Tizen.System.Sensor /// /// The SensorType Enum defintion for all sensor types. /// - public enum SensorType + internal enum SensorType { /// /// All sensors. This can be used to retrieve Sensor class object for all available sensors. @@ -90,7 +90,15 @@ namespace Tizen.System.Sensor /// /// Geomagnetic-based rotation vector sensor. /// - MagnetometerRotationVectorSensor = 20 + MagnetometerRotationVectorSensor = 20, + /// + /// Pedometer sensor. + /// + HumanPedometer = 0x300, + /// + /// Sleep monitor sensor. + /// + HumanSleepMonitor = 22 } /// @@ -148,4 +156,25 @@ namespace Tizen.System.Sensor AxisOrientation, PausePolicy } + + public enum PedometerState + { + Unknown, + Stop, + Walk, + Run + } + + public enum SleepMonitorState + { + Unknown, + Wake, + Sleep + } + + public enum ProximitySensorState + { + Near = 0, + Far = 5 + } } diff --git a/Tizen.System.Sensor/Sensor/SensorErrorFactory.cs b/Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs similarity index 80% rename from Tizen.System.Sensor/Sensor/SensorErrorFactory.cs rename to Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs index 620f42d..5627baf 100644 --- a/Tizen.System.Sensor/Sensor/SensorErrorFactory.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs @@ -11,20 +11,20 @@ using Tizen.Internals.Errors; namespace Tizen.System.Sensor { - internal static class SensorErrorFactory + internal enum SensorError { - 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 - } + 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; diff --git a/packaging/csapi-system.sensor.spec b/packaging/csapi-system.sensor.spec index 9c1bb71..5a5f877 100644 --- a/packaging/csapi-system.sensor.spec +++ b/packaging/csapi-system.sensor.spec @@ -1,5 +1,5 @@ %define dllpath %{_libdir}/mono/tizen -%define dllname Tizen.System.Sensor.dll +%define dllname Tizen.System.dll Name: csapi-system.sensor Summary: Tizen Sensor API for C# -- 2.7.4