From: Ankur Date: Thu, 26 May 2016 10:33:12 +0000 (+0530) Subject: Adding Other sensor classes and tct-test folder for accelerometer X-Git-Tag: submit/tizen/20161214.063015~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b92c022320605774917532d5a3d98994756f90c6;p=platform%2Fcore%2Fcsapi%2Fsensor.git 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 --- 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/Sensor/Enumerations.cs b/Tizen.System.Sensor/Sensor/Enumerations.cs deleted file mode 100755 index 9de4515..0000000 --- a/Tizen.System.Sensor/Sensor/Enumerations.cs +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// The SensorType Enum defintion for all sensor types. - /// - public enum SensorType - { - /// - /// All sensors. This can be used to retrieve Sensor class object for all available sensors. - /// - All = -1, - /// - /// Accelerometer sensor. - /// - Accelerometer = 0, - /// - /// Gravity sensor. - /// - GravitySensor = 1, - /// - /// Linear Acceleration sensor. - /// - LinearAccelerationSensor = 2, - /// - /// Magnetometer sensor. - /// - Magnetometer = 3, - /// - /// Rotation Vector sensor. - /// - RotationVectorSensor = 4, - /// - /// Orientation sensor. - /// - OrientationSensor = 5, - /// - /// Gyroscope sensor. - /// - Gyroscope = 6, - /// - /// Light sensor. - /// - LightSensor = 7, - /// - /// Proximity sensor. - /// - ProximitySensor = 8, - /// - /// Pressure sensor. - /// - PressureSensor = 9, - /// - /// Ultraviolet sensor. - /// - UltravioletSensor = 10, - /// - /// Temperature sensor. - /// - TemperatureSensor = 11, - /// - /// Humidity sensor. - /// - HumiditySensor = 12, - /// - /// Hear rate monitor sensor. - /// - HeartRateMonitor = 13, - /// - /// Uncalibrated Gyroscope sensor. - /// - UncalibratedGyroscope = 17, - /// - /// Uncalibrated Geomagnetic sensor. - /// - UncalibratedMagnetometer = 18, - /// - /// Gyroscope-based rotation vector sensor. - /// - GyroscopeRotationVectorSensor = 19, - /// - /// Geomagnetic-based rotation vector sensor. - /// - MagnetometerRotationVectorSensor = 20 - } - - /// - /// SensorDataAccuracy Enum definition for all possible sensor data accuracy Values. - /// - public enum SensorDataAccuracy - { - /// - /// Undefined sensor data accuracy. - /// - Undefined = -1, - /// - /// Sensor data not accurate. - /// - Bad = 0, - /// - /// Moderately accurate sensor data. - /// - Normal = 1, - /// - /// Highly accurate sensor data. - /// - Good = 2, - /// - /// Very highly accurate sensor data. - /// - VeryGood = 3 - } - - /// - /// Sensor Option Enum definition for sensor option Values - /// - public enum SensorPausePolicy - { - /// - /// Does not receive data when the LCD is off and in the power save mode. - /// - None, - /// - /// Receives data when the LCD is off. - /// - DisplayOff, - /// - /// Receives data in the power save mode. - /// - PowerSaveMode, - /// - /// Receives data when the LCD is off and in the power save mode. - /// - All - } - - public enum SensorAttribute - { - AxisOrientation, - PausePolicy - } -} diff --git a/Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs b/Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs deleted file mode 100644 index 84d2cee..0000000 --- a/Tizen.System.Sensor/Sensor/EventArgs/AccelerometerChangedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Accelerometer changed event arguments. Class for storing the data returned by accelerometer - /// - public class AccelerometerChangedEventArgs : EventArgs - { - internal AccelerometerChangedEventArgs(float[] values) - { - X = values[0]; - Y = values[1]; - Z = values[2]; - } - - /// - /// Gets the X component of the acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the acceleration. - /// - public float Z { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs b/Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs deleted file mode 100644 index 126b555..0000000 --- a/Tizen.System.Sensor/Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Sensor accuracy changed event arguments Class. Contains the parameters to be returned through accuracy callback - /// - public class SensorAccuracyChangedEventArgs : EventArgs - { - internal SensorAccuracyChangedEventArgs(DateTime timestamp, SensorDataAccuracy accuracy) - { - TimeStamp = timestamp; - Accuracy = accuracy; - } - - /// - /// Gets the time stamp. - /// - public DateTime TimeStamp { get; private set; } - - /// - /// Gets the accuracy. - /// - public SensorDataAccuracy Accuracy { get; private set; } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs b/Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs deleted file mode 100644 index a0f9d3c..0000000 --- a/Tizen.System.Sensor/Sensor/Plugins/Accelerometer.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Accelerometer Sensor Class. Used for registering callbacks for accelerometer and getting accelerometer data - /// /// - public class Accelerometer : Sensor - { - private uint _defaultInterval = 0; - - /// - /// Gets the X component of the acceleration. - /// - public float X { get; private set; } - - /// - /// Gets the Y component of the acceleration. - /// - public float Y { get; private set; } - - /// - /// Gets the Z component of the acceleration. - /// - public float Z { get; private set; } - - /// - /// Returns true or false based on whether accelerometer sensor is supported by device. - /// - public static bool IsSupported - { - get - { - return CheckIfSupported(); - } - } - - /// - /// Returns the number of accelerometer sensors available on the device. - /// - public static int Count - { - get - { - return GetCount(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Index. Default value for this is 0. Index refers to a particular accelerometer sensor in case of multiple sensors - /// - public Accelerometer(int index = 0) : base(index) - { - Interval = _defaultInterval; - } - - protected override SensorType GetSensorType() - { - return SensorType.Accelerometer; - } - - /// - /// Event Handler for storing the callback functions for event corresponding to change in accelerometer sensor data. - /// - - public event EventHandler DataUpdated; - - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.Accelerometer, out isSupported); - if (error != 0) - isSupported = false; - return isSupported; - } - - private static int GetCount() - { - IntPtr list; - int count; - int error = Interop.SensorManager.GetSensorList(SensorType.Accelerometer, out list, out count); - if (error != 0) - count = 0; - else - Interop.Libc.Free(list); - return count; - } - - protected override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for accelerometer"); - } - - protected override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for accelerometer"); - } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - Timestamp = sensorData.timestamp; - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new AccelerometerChangedEventArgs(sensorData.values)); - } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Sensor/Sensor.cs b/Tizen.System.Sensor/Sensor/Sensor.cs deleted file mode 100644 index af841b9..0000000 --- a/Tizen.System.Sensor/Sensor/Sensor.cs +++ /dev/null @@ -1,392 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; - -namespace Tizen.System.Sensor -{ - /// - /// Sensor class for storing hardware information about a particular sensor - /// - public abstract class Sensor : IDisposable - { - private string _name; - private string _vendor; - private float _minValue; - private float _maxValue; - private float _resolution; - private int _minInterval; - private int _fifoCount; - private int _maxBatchCount; - private bool _sensing = false; - private bool _disposed = false; - private UInt64 _timestamp; - private uint _interval = 0; - private uint _maxBatchLatency = 0; - private SensorPausePolicy _pausePolicy = SensorPausePolicy.None; - private IntPtr _sensorHandle = IntPtr.Zero; - private IntPtr _listenerHandle = IntPtr.Zero; - - protected abstract SensorType GetSensorType(); - protected abstract void EventListenStart(); - protected abstract void EventListenStop(); - - internal Sensor(int index) - { - SensorType type = GetSensorType(); - GetHandleList(type, index); - if (CheckSensorHandle()) - { - CreateListener(); - GetProperty(); - } - } - - ~Sensor() - { - Dispose(false); - } - - /// - /// Property: For getting the name of the sensor - /// - public string Name - { - get - { - return _name; - } - } - - /// - /// Property: Gets the vendor. - /// - public string Vendor - { - get - { - return _vendor; - } - } - - /// - /// Property: Gets the minimum value of range of sensor data. - /// - public float MinValue - { - get - { - return _minValue; - } - } - - /// - /// Property: Gets the maximum value of range of sensor data. - /// - public float MaxValue - { - get - { - return _maxValue; - } - } - - /// - /// Property: Gets the resolution. - /// - public float Resolution - { - get - { - return _resolution; - } - } - - /// - /// Property: Gets the minimum interval. - /// - public int MinInterval - { - get - { - return _minInterval; - } - } - - /// - /// Property: Gets the fifo count. - /// - public int FifoCount - { - get - { - return _fifoCount; - } - } - - /// - /// Property: Gets the maximum batch count. - /// - public int MaxBatchCount - { - get - { - return _maxBatchCount; - } - } - - /// - /// Sets the interval of the sensor for sensor data event - /// Callbacks will be called at frequency of this interval - /// - public uint Interval - { - set - { - _interval = value; - SetInterval(); - } - get - { - return _interval; - } - } - - /// - /// Sets the max batch latency for the sensor corresponding to the sensor data event. - /// - public uint MaxBatchLatency - { - set - { - _maxBatchLatency = value; - SetMaxBatchLatency(); - } - get - { - return _maxBatchLatency; - } - } - - /// - /// Gets the attribute. - /// - /// - public SensorPausePolicy PausePolicy - { - set - { - _pausePolicy = value; - SetPausePolicy(); - } - get - { - return _pausePolicy; - } - } - - public UInt64 Timestamp - { - set - { - _timestamp = value; - } - get - { - return _timestamp; - } - } - - public bool Sensing - { - get - { - return _sensing; - } - } - - protected IntPtr ListenerHandle - { - get - { - return _listenerHandle; - } - } - - /// - /// Starts the sensor. - /// After this the event handlers will start receiving events. - /// - public void Start() - { - if (CheckListenerHandle()) - { - int error = Interop.SensorListener.StartListener(_listenerHandle); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Start Sensor Listener"); - EventListenStart(); - _sensing = true; - } - } - - /// - /// Stop the sensor. - /// After this the event handlers will stop receiving the events - /// - public void Stop() - { - if (!_sensing) - { - int error = Interop.SensorListener.StopListener(_listenerHandle); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Stop Sensor Listener"); - EventListenStop(); - _sensing = false; - } - else - { - throw new InvalidOperationException("Operation Failed: Sensor already stopped"); - } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_disposed) - return; - - DestroyHandles(); - _disposed = true; - } - - private void GetHandleList(SensorType type, int index) - { - IntPtr list; - IntPtr[] sensorList; - int count; - int error = Interop.SensorManager.GetSensorList(type, out list, out count); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.GetSensorList Failed"); - sensorList = Interop.IntPtrToIntPtrArray(list, count); - _sensorHandle = sensorList[index]; - Interop.Libc.Free(list); - } - - private void GetProperty() - { - int error = (int)SensorErrorFactory.SensorError.None; - - error = Interop.Sensor.GetName(_sensorHandle, out _name); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Name Failed"); - - error = Interop.Sensor.GetVendor(_sensorHandle, out _vendor); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Vendor Failed"); - - error = Interop.Sensor.GetMinRange(_sensorHandle, out _minValue); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinValue Failed"); - - error = Interop.Sensor.GetMaxRange(_sensorHandle, out _maxValue); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxValue Failed"); - - error = Interop.Sensor.GetResolution(_sensorHandle, out _resolution); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Resolution Failed"); - - error = Interop.Sensor.GetMinInterval(_sensorHandle, out _minInterval); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinInterval Failed"); - - error = Interop.Sensor.GetFifoCount(_sensorHandle, out _fifoCount); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.FifoCount Failed"); - - error = Interop.Sensor.GetMaxBatchCount(_sensorHandle, out _maxBatchCount); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxBatchCount Failed"); - } - - private void CreateListener() - { - int error = Interop.SensorListener.CreateListener(_sensorHandle, out _listenerHandle); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.CreateListener Failed"); - } - - private void SetInterval() - { - if (CheckListenerHandle()) - { - int error = Interop.SensorListener.SetInterval(_listenerHandle, _interval); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed"); - } - } - - private void SetMaxBatchLatency() - { - if (CheckListenerHandle()) - { - int error = Interop.SensorListener.SetMaxBatchLatency(_listenerHandle, _maxBatchLatency); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.MaxBatchLatency Failed"); - } - } - - private void SetPausePolicy() - { - if (CheckListenerHandle()) - { - int error = Interop.SensorListener.SetAttribute(_listenerHandle, SensorAttribute.PausePolicy, (int)_pausePolicy); - if (error != 0) - throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed"); - } - } - - private bool CheckListenerHandle() - { - bool result = false; - if (_listenerHandle != IntPtr.Zero) - { - result = true; - } - else - { - throw new ArgumentException("Invalid Parameter: Sensor is null"); - } - return result; - } - - private bool CheckSensorHandle() - { - bool result = false; - if (_sensorHandle != IntPtr.Zero) - { - result = true; - } - else - { - throw new ArgumentException("Invalid Parameter: Sensor is null"); - } - return result; - } - - private void DestroyHandles() - { - Interop.SensorListener.DestroyListener(_listenerHandle); - } - } -} diff --git a/Tizen.System.Sensor/Sensor/SensorErrorFactory.cs b/Tizen.System.Sensor/Sensor/SensorErrorFactory.cs deleted file mode 100644 index 620f42d..0000000 --- a/Tizen.System.Sensor/Sensor/SensorErrorFactory.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; -using Tizen.Internals.Errors; - -namespace Tizen.System.Sensor -{ - internal static class SensorErrorFactory - { - internal enum SensorError - { - None = ErrorCode.None, - IOError = ErrorCode.IoError, - InvalidParameter = ErrorCode.InvalidParameter, - NotSupported = ErrorCode.NotSupported, - PermissionDenied = ErrorCode.PermissionDenied, - OutOfMemory = ErrorCode.OutOfMemory, - NotNeedCalibration = -0x02440000 | 0x03, - OperationFailed = -0x02440000 | 0x06 - } - - static internal Exception CheckAndThrowException(int error, string msg) - { - SensorError e = (SensorError)error; - switch (e) - { - case SensorError.None: - return null; - case SensorError.IOError: - return new InvalidOperationException("I/O Error: " + msg); - case SensorError.InvalidParameter: - return new ArgumentException("Invalid Parameter: " + msg); - case SensorError.NotSupported: - return new InvalidOperationException("Not Supported: " + msg); - case SensorError.PermissionDenied: - return new InvalidOperationException("Permission Denied: " + msg); - case SensorError.OutOfMemory: - return new InvalidOperationException("Out of Memory: " + msg); - case SensorError.NotNeedCalibration: - return new InvalidOperationException("Sensor doesn't need calibration: " + msg); - case SensorError.OperationFailed: - return new InvalidOperationException("Operation Failed: " + msg); - default: - return new InvalidOperationException("Unknown Error Code: " + msg); - } - } - } -} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.csproj b/Tizen.System.Sensor/Tizen.System.Sensor.csproj 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/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs new file mode 100644 index 0000000..0089c77 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/AccelerometerDataUpdatedEventArgs.cs @@ -0,0 +1,40 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.System.Sensor +{ + /// + /// Accelerometer changed event arguments. Class for storing the data returned by accelerometer + /// + public class AccelerometerDataUpdatedEventArgs : EventArgs + { + internal AccelerometerDataUpdatedEventArgs(float[] values) + { + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// + /// Gets the X component of the acceleration. + /// + public float X { get; private set; } + + /// + /// Gets the Y component of the acceleration. + /// + public float Y { get; private set; } + + /// + /// Gets the Z component of the acceleration. + /// + public float Z { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/GravitySensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..ed24a8f --- /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/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs new file mode 100644 index 0000000..5846d40 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SensorAccuracyChangedEventArgs.cs @@ -0,0 +1,34 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.System.Sensor +{ + /// + /// Sensor accuracy changed event arguments Class. Contains the parameters to be returned through accuracy callback + /// + public class SensorAccuracyChangedEventArgs : EventArgs + { + internal SensorAccuracyChangedEventArgs(TimeSpan timespan, SensorDataAccuracy accuracy) + { + TimeSpan = timespan; + Accuracy = accuracy; + } + + /// + /// Gets the time stamp. + /// + public TimeSpan TimeSpan { get; private set; } + + /// + /// Gets the accuracy. + /// + public SensorDataAccuracy Accuracy { get; private set; } + } +} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs b/Tizen.System.Sensor/Tizen.System.Sensor/EventArgs/SleepMonitorDataUpdatedEventArgs.cs 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/Tizen.System.Sensor/Plugins/Accelerometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs new file mode 100644 index 0000000..f583f1e --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.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 +{ + /// + /// Accelerometer Sensor Class. Used for registering callbacks for accelerometer and getting accelerometer data + /// /// + public class Accelerometer : 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 accelerometer sensor is supported by device. + /// + public static bool IsSupported + { + get + { + Log.Info(Globals.LogTag, "Checking if the Accelerometer sensor is supported"); + return CheckIfSupported(); + } + } + + /// + /// Returns the number of accelerometer sensors available on the device. + /// + public static int Count + { + get + { + Log.Info(Globals.LogTag, "Getting the count of accelerometer sensors"); + return GetCount(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Index. Default value for this is 0. Index refers to a particular accelerometer sensor in case of multiple sensors + /// + public Accelerometer(int index = 0) : base(index) + { + Log.Info(Globals.LogTag, "Creating Accelerometer object"); + } + + internal override SensorType GetSensorType() + { + return SensorType.Accelerometer; + } + + /// + /// Event Handler for storing the callback functions for event corresponding to change in accelerometer sensor data. + /// + + public event EventHandler DataUpdated; + + private static bool CheckIfSupported() + { + bool isSupported; + int error = Interop.SensorManager.SensorIsSupported(SensorType.Accelerometer, out isSupported); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if accelerometer sensor is supported"); + isSupported = false; + } + return isSupported; + } + + private static int GetCount() + { + IntPtr list; + int count; + int error = Interop.SensorManager.GetSensorList(SensorType.Accelerometer, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list for accelerometer"); + count = 0; + } + else + Interop.Libc.Free(list); + return count; + } + + protected override void EventListenStart() + { + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for accelerometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for accelerometer"); + } + } + + protected override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for accelerometer sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for accelerometer"); + } + } + + private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new AccelerometerDataUpdatedEventArgs(sensorData.values)); + } + } +} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/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/Tizen.System.Sensor/Sensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs new file mode 100644 index 0000000..33bc4a3 --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs @@ -0,0 +1,470 @@ +// 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 +{ + internal static class Globals + { + internal const string LogTag = "Tizen.System.Sensor"; + } + + /// + /// Sensor class for storing hardware information about a particular sensor + /// + public abstract class Sensor : IDisposable + { + private string _name; + private string _vendor; + private float _minValue; + private float _maxValue; + private float _resolution; + private int _minInterval; + private int _fifoCount; + private int _maxBatchCount; + private bool _isSensing = false; + private bool _disposed = false; + private TimeSpan _timeSpan; + private uint _interval = 0; + private uint _maxBatchLatency = 0; + private SensorPausePolicy _pausePolicy = SensorPausePolicy.None; + private IntPtr _sensorHandle = IntPtr.Zero; + private IntPtr _listenerHandle = IntPtr.Zero; + + internal abstract SensorType GetSensorType(); + protected abstract void EventListenStart(); + protected abstract void EventListenStop(); + + internal Sensor(int index) + { + SensorType type = GetSensorType(); + GetHandleList(type, index); + if (CheckSensorHandle()) + { + CreateListener(); + GetProperty(); + } + } + + ~Sensor() + { + Dispose(false); + } + + /// + /// Property: For getting the name of the sensor + /// + public string Name + { + get + { + Log.Info(Globals.LogTag, "Getting the sensor name"); + return _name; + } + } + + /// + /// Property: Gets the vendor. + /// + public string Vendor + { + get + { + Log.Info(Globals.LogTag, "Getting the sensor vendor name"); + return _vendor; + } + } + + /// + /// Property: Gets the minimum value of range of sensor data. + /// + public float MinValue + { + get + { + Log.Info(Globals.LogTag, "Getting the min value of the sensor"); + return _minValue; + } + } + + /// + /// Property: Gets the maximum value of range of sensor data. + /// + public float MaxValue + { + get + { + Log.Info(Globals.LogTag, "Getting the max value of the sensor"); + return _maxValue; + } + } + + /// + /// Property: Gets the resolution. + /// + public float Resolution + { + get + { + Log.Info(Globals.LogTag, "Getting the resolution of the sensor"); + return _resolution; + } + } + + /// + /// Property: Gets the minimum interval. + /// + public int MinInterval + { + get + { + Log.Info(Globals.LogTag, "Getting the min interval for the sensor"); + return _minInterval; + } + } + + /// + /// Property: Gets the fifo count. + /// + public int FifoCount + { + get + { + Log.Info(Globals.LogTag, "Getting the fifo count of the sensor"); + return _fifoCount; + } + } + + /// + /// Property: Gets the maximum batch count. + /// + public int MaxBatchCount + { + get + { + Log.Info(Globals.LogTag, "Getting the max batch count of the sensor"); + return _maxBatchCount; + } + } + + /// + /// Sets the interval of the sensor for sensor data event + /// Callbacks will be called at frequency of this interval + /// + public uint Interval + { + set + { + Log.Info(Globals.LogTag, "Setting the interval of the sensor"); + _interval = value; + SetInterval(); + } + get + { + Log.Info(Globals.LogTag, "Getting the interval of the sensor"); + return _interval; + } + } + + /// + /// Sets the max batch latency for the sensor corresponding to the sensor data event. + /// + public uint MaxBatchLatency + { + set + { + Log.Info(Globals.LogTag, "Setting the max batch latency of the sensor"); + _maxBatchLatency = value; + SetMaxBatchLatency(); + } + get + { + Log.Info(Globals.LogTag, "Getting the max batch latency of the sensor"); + return _maxBatchLatency; + } + } + + /// + /// Gets the attribute. + /// + /// + public SensorPausePolicy PausePolicy + { + 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 TimeSpan TimeSpan + { + set + { + Log.Info(Globals.LogTag, "Setting the timespan of the sensor values"); + _timeSpan = value; + } + get + { + Log.Info(Globals.LogTag, "Getting the timespan of the sensor values"); + return _timeSpan; + } + } + + public bool IsSensing + { + get + { + Log.Info(Globals.LogTag, "Checking if the sensor is started"); + return _isSensing; + } + } + + protected IntPtr ListenerHandle + { + get + { + return _listenerHandle; + } + } + + /// + /// Starts the sensor. + /// After this the event handlers will start receiving events. + /// + public void Start() + { + Log.Info(Globals.LogTag, "Starting the sensor"); + if (CheckListenerHandle()) + { + int error = Interop.SensorListener.StartListener(_listenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error starting sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Start Sensor Listener"); + } + EventListenStart(); + _isSensing = true; + Log.Info(Globals.LogTag, "Sensor started"); + } + } + + /// + /// Stop the sensor. + /// After this the event handlers will stop receiving the events + /// + public void Stop() + { + Log.Info(Globals.LogTag, "Stopping the sensor"); + if (_isSensing) + { + int error = Interop.SensorListener.StopListener(_listenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error stopping the sensor"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to Stop Sensor Listener"); + } + EventListenStop(); + _isSensing = false; + Log.Info(Globals.LogTag, "Sensor stopped"); + } + else + { + Log.Error(Globals.LogTag, "Can't stop sensor as it is already stopped"); + throw new InvalidOperationException("Operation Failed: Sensor is already stopped"); + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (_disposed) + return; + + DestroyHandles(); + _disposed = true; + } + + private void GetHandleList(SensorType type, int index) + { + IntPtr list; + IntPtr[] sensorList; + int count; + int error = Interop.SensorManager.GetSensorList(type, out list, out count); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor list"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.GetSensorList Failed"); + } + sensorList = Interop.IntPtrToIntPtrArray(list, count); + _sensorHandle = sensorList[index]; + Interop.Libc.Free(list); + } + + private void GetProperty() + { + int error = (int)SensorError.None; + + error = Interop.Sensor.GetName(_sensorHandle, out _name); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor name"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Name Failed"); + } + + error = Interop.Sensor.GetVendor(_sensorHandle, out _vendor); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor vendor name"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Vendor Failed"); + } + + error = Interop.Sensor.GetMinRange(_sensorHandle, out _minValue); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor min value"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinValue Failed"); + } + + error = Interop.Sensor.GetMaxRange(_sensorHandle, out _maxValue); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor max value"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxValue Failed"); + } + + error = Interop.Sensor.GetResolution(_sensorHandle, out _resolution); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor resolution"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.Resolution Failed"); + } + + error = Interop.Sensor.GetMinInterval(_sensorHandle, out _minInterval); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor min interval"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MinInterval Failed"); + } + + error = Interop.Sensor.GetFifoCount(_sensorHandle, out _fifoCount); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor fifo count"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.FifoCount Failed"); + } + + error = Interop.Sensor.GetMaxBatchCount(_sensorHandle, out _maxBatchCount); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error getting sensor max batch count"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.MaxBatchCount Failed"); + } + } + + private void CreateListener() + { + int error = Interop.SensorListener.CreateListener(_sensorHandle, out _listenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error cerating sensor listener handle"); + throw SensorErrorFactory.CheckAndThrowException(error, "Sensor.CreateListener Failed"); + } + } + + private void SetInterval() + { + if (CheckListenerHandle()) + { + if (_isSensing) + { + int error = Interop.SensorListener.SetInterval(_listenerHandle, _interval); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting sensor interval"); + throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.SetInterval Failed"); + } + } + } + } + + private void SetMaxBatchLatency() + { + if (CheckListenerHandle()) + { + int error = Interop.SensorListener.SetMaxBatchLatency(_listenerHandle, _maxBatchLatency); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting max batch latency"); + throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.MaxBatchLatency Failed"); + } + } + } + + private void SetPausePolicy() + { + if (CheckListenerHandle()) + { + int error = Interop.SensorListener.SetAttribute(_listenerHandle, SensorAttribute.PausePolicy, (int)_pausePolicy); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting sensor pause policy"); + throw SensorErrorFactory.CheckAndThrowException(error, "Setting Sensor.PausePolicy Failed"); + } + } + } + + private bool CheckListenerHandle() + { + bool result = false; + if (_listenerHandle != IntPtr.Zero) + { + result = true; + } + else + { + Log.Error(Globals.LogTag, "Sensor listener handle is null"); + throw new ArgumentException("Invalid Parameter: Sensor is null"); + } + return result; + } + + private bool CheckSensorHandle() + { + bool result = false; + if (_sensorHandle != IntPtr.Zero) + { + result = true; + } + else + { + Log.Error(Globals.LogTag, "Sensor handle is null"); + throw new ArgumentException("Invalid Parameter: Sensor is null"); + } + return result; + } + + private void DestroyHandles() + { + Interop.SensorListener.DestroyListener(_listenerHandle); + } + } +} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs b/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs new file mode 100644 index 0000000..94f071c --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/SensorEnumerations.cs @@ -0,0 +1,180 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.System.Sensor +{ + /// + /// The SensorType Enum defintion for all sensor types. + /// + internal enum SensorType + { + /// + /// All sensors. This can be used to retrieve Sensor class object for all available sensors. + /// + All = -1, + /// + /// Accelerometer sensor. + /// + Accelerometer = 0, + /// + /// Gravity sensor. + /// + GravitySensor = 1, + /// + /// Linear Acceleration sensor. + /// + LinearAccelerationSensor = 2, + /// + /// Magnetometer sensor. + /// + Magnetometer = 3, + /// + /// Rotation Vector sensor. + /// + RotationVectorSensor = 4, + /// + /// Orientation sensor. + /// + OrientationSensor = 5, + /// + /// Gyroscope sensor. + /// + Gyroscope = 6, + /// + /// Light sensor. + /// + LightSensor = 7, + /// + /// Proximity sensor. + /// + ProximitySensor = 8, + /// + /// Pressure sensor. + /// + PressureSensor = 9, + /// + /// Ultraviolet sensor. + /// + UltravioletSensor = 10, + /// + /// Temperature sensor. + /// + TemperatureSensor = 11, + /// + /// Humidity sensor. + /// + HumiditySensor = 12, + /// + /// Hear rate monitor sensor. + /// + HeartRateMonitor = 13, + /// + /// Uncalibrated Gyroscope sensor. + /// + UncalibratedGyroscope = 17, + /// + /// Uncalibrated Geomagnetic sensor. + /// + UncalibratedMagnetometer = 18, + /// + /// Gyroscope-based rotation vector sensor. + /// + GyroscopeRotationVectorSensor = 19, + /// + /// Geomagnetic-based rotation vector sensor. + /// + MagnetometerRotationVectorSensor = 20, + /// + /// Pedometer sensor. + /// + HumanPedometer = 0x300, + /// + /// Sleep monitor sensor. + /// + HumanSleepMonitor = 22 + } + + /// + /// SensorDataAccuracy Enum definition for all possible sensor data accuracy Values. + /// + public enum SensorDataAccuracy + { + /// + /// Undefined sensor data accuracy. + /// + Undefined = -1, + /// + /// Sensor data not accurate. + /// + Bad = 0, + /// + /// Moderately accurate sensor data. + /// + Normal = 1, + /// + /// Highly accurate sensor data. + /// + Good = 2, + /// + /// Very highly accurate sensor data. + /// + VeryGood = 3 + } + + /// + /// Sensor Option Enum definition for sensor option Values + /// + public enum SensorPausePolicy + { + /// + /// Does not receive data when the LCD is off and in the power save mode. + /// + None, + /// + /// Receives data when the LCD is off. + /// + DisplayOff, + /// + /// Receives data in the power save mode. + /// + PowerSaveMode, + /// + /// Receives data when the LCD is off and in the power save mode. + /// + All + } + + public enum SensorAttribute + { + 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/Tizen.System.Sensor/SensorErrorFactory.cs b/Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs new file mode 100644 index 0000000..5627baf --- /dev/null +++ b/Tizen.System.Sensor/Tizen.System.Sensor/SensorErrorFactory.cs @@ -0,0 +1,54 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; +using Tizen.Internals.Errors; + +namespace Tizen.System.Sensor +{ + internal enum SensorError + { + None = ErrorCode.None, + IOError = ErrorCode.IoError, + InvalidParameter = ErrorCode.InvalidParameter, + NotSupported = ErrorCode.NotSupported, + PermissionDenied = ErrorCode.PermissionDenied, + OutOfMemory = ErrorCode.OutOfMemory, + NotNeedCalibration = -0x02440000 | 0x03, + OperationFailed = -0x02440000 | 0x06 + } + + internal static class SensorErrorFactory + { + static internal Exception CheckAndThrowException(int error, string msg) + { + SensorError e = (SensorError)error; + switch (e) + { + case SensorError.None: + return null; + case SensorError.IOError: + return new InvalidOperationException("I/O Error: " + msg); + case SensorError.InvalidParameter: + return new ArgumentException("Invalid Parameter: " + msg); + case SensorError.NotSupported: + return new InvalidOperationException("Not Supported: " + msg); + case SensorError.PermissionDenied: + return new InvalidOperationException("Permission Denied: " + msg); + case SensorError.OutOfMemory: + return new InvalidOperationException("Out of Memory: " + msg); + case SensorError.NotNeedCalibration: + return new InvalidOperationException("Sensor doesn't need calibration: " + msg); + case SensorError.OperationFailed: + return new InvalidOperationException("Operation Failed: " + msg); + default: + return new InvalidOperationException("Unknown Error Code: " + msg); + } + } + } +} \ No newline at end of file diff --git a/Tizen.System.Sensor/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Tizen.System.Sensor/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index ece1079..0000000 Binary files a/Tizen.System.Sensor/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and /dev/null differ 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# diff --git a/tct-system-sensor-tizen-tests/Makefile b/tct-system-sensor-tizen-tests/Makefile new file mode 100755 index 0000000..12753bd --- /dev/null +++ b/tct-system-sensor-tizen-tests/Makefile @@ -0,0 +1,48 @@ + +ifndef config + config=debug +endif + +ifndef verbose + SILENT = @ +endif + +PROJECTS := tct-system-sensor-tizen-tests + +CSC = mcs + +.PHONY: all clean help $(PROJECTS) prebuild prelink + +ifeq ($(config),debug) + FLAGS = /debug /noconfig /d:DEBUG +endif + +ifeq ($(config),release) + FLAGS = /optimize /noconfig /d:NDEBUG +endif + +FLAGS += /t:exe + +TARGETDIR = bin +OBJDIR = obj +TARGET = $(TARGETDIR)/$(PROJECTS).exe +SOURCES = $(wildcard src/**/*.cs src/*.cs) +null := +space := $(null) # +comma := , +DLLS = $(wildcard lib/*.dll) +ifneq ("$(DLLS)", "") + REFERENCE = "/reference:$(subst $(space),$(comma),$(DLLS))" +endif + +all: $(TARGETDIR) $(TARGET) + +$(TARGET): $(SOURCES) $(DLLS) + @echo "=== Building $(PROJECTS) ($(config))" + $(SILENT) $(CSC) /nologo /out:$@ $(REFERENCE) $(FLAGS) $(SOURCES) + +$(TARGETDIR): + $(SILENT) mkdir -p $(TARGETDIR) + +clean: + $(SILENT) rm -rf $(TARGETDIR) diff --git a/tct-system-sensor-tizen-tests/Properties/AssemblyInfo.cs b/tct-system-sensor-tizen-tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..397144f --- /dev/null +++ b/tct-system-sensor-tizen-tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("tct-system-sensor-tizen-tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Samsung Electronics")] +[assembly: AssemblyProduct("tct-system-sensor-tizen-tests")] +[assembly: AssemblyCopyright("Copyright © 2016 Samsung Electronics Co., Ltd")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fdaa3944-fcce-4319-b93e-61ff53137edb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tct-system-sensor-tizen-tests/ReadMe.md b/tct-system-sensor-tizen-tests/ReadMe.md new file mode 100755 index 0000000..29816b0 --- /dev/null +++ b/tct-system-sensor-tizen-tests/ReadMe.md @@ -0,0 +1,15 @@ +tct-suite-tizen-tests +├── src - Directory containing main method and test cases. +│ ├── Program.cs - Main method of the application. +│ ├── testcase +│ │ ├── TSApplicationManager.cs - Test case file of ApplicationManager Class. +│ │ └── …… - Other test case files. +│ └── support +│ └── ApplicationCommon.cs - A Support file which supports test cases. +├── bin - Contains executable file which is created by make file. +├── lib - Library files which needs to be packed. +├── res - Resource folder for any resources needed to run test. +├── share +├── Makefile - Script which builds package. +├── TCTCert.p12 - A Certificate file for building package. (pw:test) +└── tizen-manifest.xml - A Tizen Manifest file for declaring privilege and controls. diff --git a/tct-system-sensor-tizen-tests/TCTCert.p12 b/tct-system-sensor-tizen-tests/TCTCert.p12 new file mode 100644 index 0000000..26eb3a6 Binary files /dev/null and b/tct-system-sensor-tizen-tests/TCTCert.p12 differ diff --git a/tct-system-sensor-tizen-tests/bin/tct-system-sensor-tizen-tests.exe b/tct-system-sensor-tizen-tests/bin/tct-system-sensor-tizen-tests.exe new file mode 100755 index 0000000..7a3661f Binary files /dev/null and b/tct-system-sensor-tizen-tests/bin/tct-system-sensor-tizen-tests.exe differ diff --git a/tct-system-sensor-tizen-tests/lib/TestFramework.dll b/tct-system-sensor-tizen-tests/lib/TestFramework.dll new file mode 100644 index 0000000..7cee03e Binary files /dev/null and b/tct-system-sensor-tizen-tests/lib/TestFramework.dll differ diff --git a/tct-system-sensor-tizen-tests/lib/Tizen.Applications.dll b/tct-system-sensor-tizen-tests/lib/Tizen.Applications.dll new file mode 100644 index 0000000..f9d692c Binary files /dev/null and b/tct-system-sensor-tizen-tests/lib/Tizen.Applications.dll differ diff --git a/tct-system-sensor-tizen-tests/lib/Tizen.Internals.dll b/tct-system-sensor-tizen-tests/lib/Tizen.Internals.dll new file mode 100755 index 0000000..30c421b Binary files /dev/null and b/tct-system-sensor-tizen-tests/lib/Tizen.Internals.dll differ diff --git a/tct-system-sensor-tizen-tests/lib/Tizen.System.dll b/tct-system-sensor-tizen-tests/lib/Tizen.System.dll new file mode 100644 index 0000000..7dc3fcd Binary files /dev/null and b/tct-system-sensor-tizen-tests/lib/Tizen.System.dll differ diff --git a/tct-system-sensor-tizen-tests/lib/Tizen.dll b/tct-system-sensor-tizen-tests/lib/Tizen.dll new file mode 100755 index 0000000..f656769 Binary files /dev/null and b/tct-system-sensor-tizen-tests/lib/Tizen.dll differ diff --git a/tct-system-sensor-tizen-tests/org.test.tizen.system.sensor.tpk b/tct-system-sensor-tizen-tests/org.test.tizen.system.sensor.tpk new file mode 100644 index 0000000..ac12ebc Binary files /dev/null and b/tct-system-sensor-tizen-tests/org.test.tizen.system.sensor.tpk differ diff --git a/tct-system-sensor-tizen-tests/res/ReadMe.md b/tct-system-sensor-tizen-tests/res/ReadMe.md new file mode 100755 index 0000000..85fa0b5 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/ReadMe.md @@ -0,0 +1,27 @@ +# Naming conventions + +1) "TC application" refers to "org.test.tizen.application". +2) "sample applications" refers to those whose name contains string "Sample". + +# purpose of those scripts + +1) "push.sh" - this script is made for pushing the TC application, the sample applications and "install.sh", "run.sh" scripts to Tizen device. Run it in Ubuntu. + +2) "install.sh" - this script is made for installing the sample applications in Tizen device. This script will be pushed to "/home/owner" directory of Tizen device. Manually run it. + +3) "run.sh" - this script is made for launching & relaunching TC application for Application API. This script will be pushed to "/home/owner" directory of Tizen device. Manually run it. + +# how to install your sample applications using those script + +1) Put your sample applications in the directory of the scripts. + +2) Add your sample application's name to "install.sh" script as below: + pkgcmd -u -n + pkgcmd -t tpk -i -p .tpk -q + app_launcher -l | grep + +3) Add your sample application's name to "run.sh" script as below: + app_launcher -k + +# the end +-- nothing here--- diff --git a/tct-system-sensor-tizen-tests/res/Result/System.xml b/tct-system-sensor-tizen-tests/res/Result/System.xml new file mode 100644 index 0000000..1a43557 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/Result/System.xml @@ -0,0 +1,1107 @@ + + + + + + + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + + + + + PASS + + + + + + + + + + + + + \ No newline at end of file diff --git a/tct-system-sensor-tizen-tests/res/Result/style/application.js b/tct-system-sensor-tizen-tests/res/Result/style/application.js new file mode 100755 index 0000000..147094f --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/Result/style/application.js @@ -0,0 +1,194 @@ +function getScrollTop() { + return f_scrollTop(); +} + +function f_scrollTop() { + return f_filterResults($(window) ? $(window).scrollTop() : 0, + document.documentElement ? document.documentElement.scrollTop : 0, + document.body ? document.body.scrollTop : 0); +} +function f_filterResults(n_win, n_docel, n_body) { + var n_result = n_win ? n_win : 0; + if (n_docel && (!n_result || (n_result > n_docel))) + n_result = n_docel; + return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; +} + +function setScrollTop() { + $(window) ? $(window).scrollTop(0) : 0; + document.documentElement ? document.documentElement.scrollTop = 0 : 0; + document.body ? document.body.scrollTop = 0 : 0; +} + +function goTopEx() { + $node = $('#goTopBtn'); + if (getScrollTop() > 0) { + $node.show(); + } else { + $node.hide(); + } + + $(window).scroll(function() { + if (getScrollTop() > 0) { + $node.show(); + } else { + $node.hide(); + } + }); + + $node.click(function() { + setScrollTop(); + }); +} + +function drawRatio() { + $('.suite_item').each(function(i, node) { + drawSuiteRatio(node) + }); +} + +$(".see_all").click(function(){ + $("#see_all").show(); + $("#see_fail").hide(); + $("#see_block").hide(); + $("#see_na").hide(); + updateToggles(); + return false; +}); + +$(".see_failed").click(function(){ + $("#see_all").hide(); + $("#see_fail").show(); + $("#see_block").hide(); + $("#see_na").hide(); + updateToggles(); + return false; +}); + +$(".see_blocked").click(function(){ + $("#see_all").hide(); + $("#see_fail").hide(); + $("#see_block").show(); + $("#see_na").hide(); + updateToggles(); + return false; +}); + +$(".see_na").click(function(){ + $("#see_all").hide(); + $("#see_fail").hide(); + $("#see_block").hide(); + $("#see_na").show(); + updateToggles(); + return false; +}); + +$("a.test_case_popup").click(function(){ + var $this = $(this); + Popup.show($this.attr('id')); + return false; +}); + +$(".see_capabilities").click(function(){ + if ($('#capability_table').css('display') == 'none') { + $("#capability_table").show(); + }else{ + $("#capability_table").hide(); + } + return false; +}); + +function drawSuiteRatio(node) { + arrTitle = new Array("Passed", "Failed", "Blocked", "Not Executed"); + var $node = $(node); + var $total = $node.find('.total'); + var $pass = $node.find('.pass'); + var $fail = $node.find('.fail'); + var $block = $node.find('.block'); + var $na = $node.find('.na'); + var $div = $node.find('.RatioGraphic'); + + var total_int = parseInt($total.text()); + var pass_int = parseInt($pass.text()); + var fail_int = parseInt($fail.text()); + var block_int = parseInt($block.text()); + var na_int = parseInt($na.text()); + + var pass_rate = pass_int * 100 / total_int; + var fail_rate = fail_int * 100 / total_int; + var block_rate = block_int * 100 / total_int; + var na_rate = na_int * 100 / total_int; + + var areaWidth = 380; + + var pass_width = areaWidth * pass_rate / 100; + var fail_width = areaWidth * fail_rate / 100; + var block_width = areaWidth * block_rate / 100; + var na_width = areaWidth * na_rate / 100; + + pass_rate = pass_rate.toFixed(2); + fail_rate = fail_rate.toFixed(2); + block_rate = block_rate.toFixed(2); + na_rate = na_rate.toFixed(2); + + var pass_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/blue.jpg");" + var fail_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/red.jpg");" + var block_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/orange.jpg");" + var na_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/gray.jpg");" + + var html = ""; + if (pass_width > 0){ + html += ""; + } + if (fail_width > 0){ + html += ""; + } + if (block_width > 0){ + html += ""; + } + if (na_width > 0){ + html += ""; + } + html += "
"; + if (pass_width > 20){ + html += pass_rate + "%" + } + html += ""; + if (fail_width > 20){ + html += fail_rate + "%" + } + html += ""; + if (block_width > 20){ + html += block_rate + "%" + } + html += ""; + if (na_width > 20){ + html += na_rate + "%" + } + html += "
"; + $div.html(html); +} diff --git a/tct-system-sensor-tizen-tests/res/Result/style/back_top.png b/tct-system-sensor-tizen-tests/res/Result/style/back_top.png new file mode 100755 index 0000000..19cbd76 Binary files /dev/null and b/tct-system-sensor-tizen-tests/res/Result/style/back_top.png differ diff --git a/tct-system-sensor-tizen-tests/res/Result/style/blue.jpg b/tct-system-sensor-tizen-tests/res/Result/style/blue.jpg new file mode 100755 index 0000000..d1db8f7 Binary files /dev/null and b/tct-system-sensor-tizen-tests/res/Result/style/blue.jpg differ diff --git a/tct-system-sensor-tizen-tests/res/Result/style/gray.jpg b/tct-system-sensor-tizen-tests/res/Result/style/gray.jpg new file mode 100755 index 0000000..f1acfdb Binary files /dev/null and b/tct-system-sensor-tizen-tests/res/Result/style/gray.jpg differ diff --git a/tct-system-sensor-tizen-tests/res/Result/style/jquery.min.js b/tct-system-sensor-tizen-tests/res/Result/style/jquery.min.js new file mode 100755 index 0000000..198b3ff --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/Result/style/jquery.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/tct-system-sensor-tizen-tests/res/Result/style/orange.jpg b/tct-system-sensor-tizen-tests/res/Result/style/orange.jpg new file mode 100755 index 0000000..ac4c749 Binary files /dev/null and b/tct-system-sensor-tizen-tests/res/Result/style/orange.jpg differ diff --git a/tct-system-sensor-tizen-tests/res/Result/style/popup.js b/tct-system-sensor-tizen-tests/res/Result/style/popup.js new file mode 100755 index 0000000..5f994f4 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/Result/style/popup.js @@ -0,0 +1,1215 @@ +/** + * Copyright (c)2005-2009 Matt Kruse (javascripttoolbox.com) + * + * Dual licensed under the MIT and GPL licenses. + * This basically means you can use this code however you want for + * free, but don't claim to have written it yourself! + * Donations always accepted: http://www.JavascriptToolbox.com/donate/ + * + * Please do not link to the .js files on javascripttoolbox.com from + * your site. Copy the files locally to your server instead. + * + */ +/* ******************************************************************* */ +/* UTIL FUNCTIONS */ +/* ******************************************************************* */ +var Util = {'$VERSION':1.06}; + +// Util functions - these are GLOBAL so they +// look like built-in functions. + +// Determine if an object is an array +function isArray(o) { + return (o!=null && typeof(o)=="object" && typeof(o.length)=="number" && (o.length==0 || defined(o[0]))); +}; + +// Determine if an object is an Object +function isObject(o) { + return (o!=null && typeof(o)=="object" && defined(o.constructor) && o.constructor==Object && !defined(o.nodeName)); +}; + +// Determine if a reference is defined +function defined(o) { + return (typeof(o)!="undefined"); +}; + +// Iterate over an array, object, or list of items and run code against each item +// Similar functionality to Perl's map() function +function map(func) { + var i,j,o; + var results = []; + if (typeof(func)=="string") { + func = new Function('$_',func); + } + for (i=1; i>>=4; + } + while(hex.length<6) { hex='0'+hex; } + return "#" + hex; + }; + + // Convert hyphen style names like border-width to camel case like borderWidth + css.hyphen2camel = function(property) { + if (!defined(property) || property==null) { return null; } + if (property.indexOf("-")<0) { return property; } + var str = ""; + var c = null; + var l = property.length; + for (var i=0; i0) { + return bodies[0]; + } + } + return null; + }; + + // Get the amount that the main document has scrolled from top + // -------------------------------------------------------------------- + screen.getScrollTop = function() { + if (document.documentElement && defined(document.documentElement.scrollTop) && document.documentElement.scrollTop>0) { + return document.documentElement.scrollTop; + } + if (document.body && defined(document.body.scrollTop)) { + return document.body.scrollTop; + } + return null; + }; + + // Get the amount that the main document has scrolled from left + // -------------------------------------------------------------------- + screen.getScrollLeft = function() { + if (document.documentElement && defined(document.documentElement.scrollLeft) && document.documentElement.scrollLeft>0) { + return document.documentElement.scrollLeft; + } + if (document.body && defined(document.body.scrollLeft)) { + return document.body.scrollLeft; + } + return null; + }; + + // Util function to default a bad number to 0 + // -------------------------------------------------------------------- + screen.zero = function(n) { + return (!defined(n) || isNaN(n))?0:n; + }; + + // Get the width of the entire document + // -------------------------------------------------------------------- + screen.getDocumentWidth = function() { + var width = 0; + var body = screen.getBody(); + if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + var rightMargin = parseInt(CSS.get(body,'marginRight'),10) || 0; + var leftMargin = parseInt(CSS.get(body,'marginLeft'), 10) || 0; + width = Math.max(body.offsetWidth + leftMargin + rightMargin, document.documentElement.clientWidth); + } + else { + width = Math.max(body.clientWidth, body.scrollWidth); + } + if (isNaN(width) || width==0) { + width = screen.zero(self.innerWidth); + } + return width; + }; + + // Get the height of the entire document + // -------------------------------------------------------------------- + screen.getDocumentHeight = function() { + var body = screen.getBody(); + var innerHeight = (defined(self.innerHeight)&&!isNaN(self.innerHeight))?self.innerHeight:0; + if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + var topMargin = parseInt(CSS.get(body,'marginTop'),10) || 0; + var bottomMargin = parseInt(CSS.get(body,'marginBottom'), 10) || 0; + return Math.max(body.offsetHeight + topMargin + bottomMargin, document.documentElement.clientHeight, document.documentElement.scrollHeight, screen.zero(self.innerHeight)); + } + return Math.max(body.scrollHeight, body.clientHeight, screen.zero(self.innerHeight)); + }; + + // Get the width of the viewport (viewable area) in the browser window + // -------------------------------------------------------------------- + screen.getViewportWidth = function() { + if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + return document.documentElement.clientWidth; + } + else if (document.compatMode && document.body) { + return document.body.clientWidth; + } + return screen.zero(self.innerWidth); + }; + + // Get the height of the viewport (viewable area) in the browser window + // -------------------------------------------------------------------- + screen.getViewportHeight = function() { + if (!window.opera && document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + return document.documentElement.clientHeight; + } + else if (document.compatMode && !window.opera && document.body) { + return document.body.clientHeight; + } + return screen.zero(self.innerHeight); + }; + + return screen; +})();var Sort = (function(){ + var sort = {}; + sort.AlphaNumeric = function(a,b) { + if (a==b) { return 0; } + if (a0 && document.anchors[0].x) { + for (var i=0; i0) { + top -= el.scrollTop; + } + if (el.scrollLeft && el.scrollLeft>0) { + left -= el.scrollLeft; + } + } + } + // If this node is also the offsetParent, add on the offsets and reset to the new offsetParent + if (el == offsetParent) { + left += o.offsetLeft; + if (el.clientLeft && el.nodeName!="TABLE") { + left += el.clientLeft; + } + top += o.offsetTop; + if (el.clientTop && el.nodeName!="TABLE") { + top += el.clientTop; + } + o = el; + if (o.offsetParent==null) { + if (o.offsetLeft) { + left += o.offsetLeft; + } + if (o.offsetTop) { + top += o.offsetTop; + } + } + offsetParent = o.offsetParent; + } + } + + + if (originalObject.offsetWidth) { + width = originalObject.offsetWidth; + } + if (originalObject.offsetHeight) { + height = originalObject.offsetHeight; + } + + return {'left':left, 'top':top, 'width':width, 'height':height + }; + }; + + // Retrieve the position of an object's center point + // ================================================= + pos.getCenter = function(o) { + var c = this.get(o); + if (c==null) { return null; } + c.left = c.left + (c.width/2); + c.top = c.top + (c.height/2); + return c; + }; + + return pos; +})();// CLASS CONSTRUCTOR +// -------------------------------------------------------------------- +var Popup = function(div, options) { + this.div = defined(div)?div:null; + this.index = Popup.maxIndex++; + this.ref = "Popup.objects["+this.index+"]"; + Popup.objects[this.index] = this; + // Store a reference to the DIV by id, also + if (typeof(this.div)=="string") { + Popup.objectsById[this.div] = this; + } + if (defined(this.div) && this.div!=null && defined(this.div.id)) { + Popup.objectsById[this.div.id] = this.div.id; + } + // Apply passed-in options + if (defined(options) && options!=null && typeof(options)=="object") { + for (var i in options) { + this[i] = options[i]; + } + } + return this; +}; + +// CLASS PROPERTIES +// -------------------------------------------------------------------- +// Index of popup objects, to maintain a global reference if necessary +Popup.maxIndex = 0; +Popup.objects = {}; +Popup.objectsById = {}; + +// The z-index value that popups will start at +Popup.minZIndex = 101; + +// Class names to assign to other objects +Popup.screenClass = "PopupScreen"; +Popup.iframeClass = "PopupIframe"; +Popup.screenIframeClass = "PopupScreenIframe"; + +// CLASS METHODS +// -------------------------------------------------------------------- + +// Hide all currently-visible non-modal dialogs +Popup.hideAll = function() { + for (var i in Popup.objects) { + var p = Popup.objects[i]; + if (!p.modal && p.autoHide) { + p.hide(); + } + } +}; +// Catch global events as a trigger to hide auto-hide popups +Event.add(document, "mouseup", Popup.hideAll, false); + +// A simple class method to show a popup without creating an instance +Popup.show = function(divObject, referenceObject, position, options, modal) { + var popup; + if (defined(divObject)) { + popup = new Popup(divObject); + } + else { + popup = new Popup(); + popup.destroyDivOnHide = true; + } + if (defined(referenceObject)) { popup.reference = DOM.resolve(referenceObject); } + if (defined(position)) { popup.position = position; } + if (defined(options) && options!=null && typeof(options)=="object") { + for (var i in options) { + popup[i] = options[i]; + } + } + if (typeof(modal)=="boolean") { + popup.modal = modal; + } + popup.destroyObjectsOnHide = true; + popup.show(); + return popup; +}; + +// A simple class method to show a modal popup +Popup.showModal = function(divObject, referenceObject, position, options) { + Popup.show(divObject, referenceObject, position, options, true); +}; + +// A method to retrieve a popup object based on a div ID +Popup.get = function(divId) { + if (defined(Popup.objectsById[divId])) { + return Popup.objectsById[divId]; + } + return null; +}; + +// A method to hide a popup based on a div id +Popup.hide = function(divId) { + var popup = Popup.get(divId); + if (popup!=null) { + popup.hide(); + } +}; + +// PROTOTYPE PROPERTIES +// -------------------------------------------------------------------- +Popup.prototype.content = null; +Popup.prototype.className = "PopupDiv"; +Popup.prototype.style = null; // Styles to be applied to the DIV +Popup.prototype.width = null; +Popup.prototype.height = null; +Popup.prototype.top = null; +Popup.prototype.left = null; +Popup.prototype.offsetLeft = 0; +Popup.prototype.offsetTop = 0; +Popup.prototype.constrainToScreen = true; +Popup.prototype.autoHide = true; +Popup.prototype.useIframeShim = false; /*@cc_on @*/ /*@if (@_win32) {Popup.prototype.useIframeShim = true;} @end @*/ +Popup.prototype.iframe = null; +Popup.prototype.position = null; // vertical: "above top center bottom below", horizontal: "adjacent-left,left,center,right,adjacent-right" +Popup.prototype.reference = null; +Popup.prototype.modal = false; +Popup.prototype.destroyDivOnHide = false; +Popup.prototype.destroyObjectsOnHide = false; +Popup.prototype.screen = null; +Popup.prototype.screenIframeShim = null; +Popup.prototype.screenOpacity=.4; +Popup.prototype.screenColor="#cccccc"; + +// INSTANCE METHODS +// -------------------------------------------------------------------- + +// Show the popup +// -------------------------------------------------------------------- +Popup.prototype.show = function(options, modal) { + this.modal = this.modal || (typeof(modal)=="boolean" && modal); + if (defined(options) && options!=null && typeof(options)=="object") { + for (var i in options) { + this[i] = options[i]; + } + } + this.div = DOM.resolve(this.div); + CSS.setStyle(this.div,'position','absolute'); + + // If there is no div pre-defined to use, create one + if (this.div==null) { + this.div = this.createDiv(); + } + if (this.content!=null) { + this.div.innerHTML = this.content; + this.content = null; + } + if (this.className!=null) { + this.div.className = this.className; + } + if (this.style!=null) { + this.applyStyle(); + } + if (this.width!=null) { + this.div.style.width = this.width+"px"; + this.div.style.overflowX="auto"; + } + if (this.height!=null) { + this.div.style.height = this.height+"px"; + this.div.style.overflowY="auto"; + } + + // Do the actual display - this is a separate method so display transitions can be implemented + this.transition(); + + // Make sure clicks on the DIV don't bubble up to the document + this.div.onclick = function(e) { + Event.cancelBubble(Event.resolve(e)); + }; + this.div.onmouseup = this.div.onclick; + + // Focus to the DIV if possible + if (this.modal && this.div.focus) { + this.div.focus(); + } +}; + +// Show the popup but make it modal +// -------------------------------------------------------------------- +Popup.prototype.transition = function() { + if (this.modal) { + this.addScreen(); + } + + // Make the DIV displayed but hidden so its size can be measured + CSS.setStyle(this.div,'visibility','hidden'); + CSS.setStyle(this.div,'display','block'); + + // Position the popup + this.setPosition(); + + // Add the shim if necessary + if (this.useIframeShim) { + this.addIframeShim(); + } + + // Make sure the DIV is higher than the shim + this.div.style.zIndex = Popup.minZIndex++; + + CSS.setStyle(this.div,'display','block'); + CSS.setStyle(this.div,'visibility','visible'); +}; + +// Show the popup but make it modal +// -------------------------------------------------------------------- +Popup.prototype.showModal = function(options) { + this.show(options,true); +}; + +// Apply user styles to the DIV +// -------------------------------------------------------------------- +Popup.prototype.applyStyle = function() { + if (this.div!=null && this.style!=null && typeof(this.style)=="object") { + for (var i in this.style) { + this.div.style[i] = this.style[i]; + } + } +}; + +// Hide the popup +// -------------------------------------------------------------------- +Popup.prototype.hide = function() { + // If this was a temp object creating on-the-fly, then remove objects from the DOM so + // The document doesn't get littered with extra objects + if (this.destroyDivOnHide) { + DOM.removeNode(this.div); + this.div = null; + delete Popup.objects[this.id]; + } + else if (this.div!=null) { + CSS.setStyle(this.div,'display','none'); + } + + if (this.destroyObjectsOnHide) { + DOM.removeNode(this.iframe); + DOM.removeNode(this.screen); + DOM.removeNode(this.screenIframeShim); + } + else { + if (this.iframe!=null) { + this.iframe.style.display = "none"; + } + if (this.screen!=null) { + this.screen.style.display = "none"; + } + if (this.screenIframeShim!=null) { + this.screenIframeShim.style.display = "none"; + } + } +}; + +// Util funcs for position +// -------------------------------------------------------------------- +Popup.prototype.setTop = function(top) { + this.div.style.top = top+"px"; +}; +Popup.prototype.setLeft = function(left) { + this.div.style.left = left+"px"; +}; +Popup.prototype.getTop = function() { + return parseInt(CSS.getStyle(this.div,"top"),10); +}; +Popup.prototype.getLeft = function() { + return parseInt(CSS.getStyle(this.div,"left"),10); +}; + +// All the logic to position the popup based on various criteria +// -------------------------------------------------------------------- +Popup.prototype.setPosition = function() { + if (this.position!=null) { + var m = this.position.match(/^(\S+)\s+(\S+)/); + if (m!=null && m.length==3) { + var v = m[1]; + var h = m[2]; + + var ref = this.reference; + if (ref==null) { ref = Screen.getBody(); } + var p = Position.get(ref); + var refTop = p.top; + var refLeft = p.left; + var refWidth = DOM.getOuterWidth(ref); + var refHeight = DOM.getOuterHeight(ref); + + var width = DOM.getOuterWidth(this.div); + var height = DOM.getOuterHeight(this.div); + + var scrollLeft = Screen.getScrollLeft(); + var scrollTop = Screen.getScrollTop(); + + // Set vertical position relative to reference object + if (v=="above") { this.setTop(refTop-height+this.offsetTop); } + else if (v=="top") { this.setTop(refTop+this.offsetTop); } + else if (v=="center") { this.setTop(refTop+(refHeight/2)-(height/2)+this.offsetTop); } + else if (v=="bottom") { this.setTop(refTop+refHeight-height+this.offsetTop); } + else if (v=="below") { this.setTop(refTop+refHeight+this.offsetTop); } + + // Set horizontal position relative to reference object + if (h=="adjacent-left") { this.setLeft(refLeft-width+this.offsetLeft); } + else if (h=="left") { this.setLeft(refLeft+this.offsetLeft); } + else if (h=="center") { this.setLeft(refLeft+(refWidth/2)-(width/2)+this.offsetLeft); } + else if (h=="right") { this.setLeft(refLeft+refWidth-width+this.offsetLeft); } + else if (h=="adjacent-right") { this.setLeft(refLeft+refWidth+this.offsetLeft); } + } + } + else if (this.top==null && this.left==null) { + this.center(); + } + else { + if (this.top==null) { this.top=0; } + if (this.left==null) { this.left=0; } + this.div.style.top = this.top+this.offsetTop+"px"; + this.div.style.left = this.left+this.offsetLeft+"px"; + } + + // Re-position to make sure it stays on the screen + if (this.constrainToScreen) { + this.fitToScreen(); + } +}; + +// Append an object to the body +// -------------------------------------------------------------------- +Popup.prototype.appendToBody = function(o) { + var body = Screen.getBody(); + if (body && body.appendChild) { + body.appendChild(o); + } +}; + +// Create a new DIV object to be used for a popup +// -------------------------------------------------------------------- +Popup.prototype.createDiv = function() { + if (document.createElement) { + var d = document.createElement("DIV"); + d.style.position="absolute"; + d.style.display="block"; + d.style.visibility="hidden"; + this.appendToBody(d); + return d; + } + alert("ERROR: Couldn't create DIV element in Popup.prototype.createDiv()"); + return null; +}; + +// Create a new IFRAME object to be used behind the popup +// -------------------------------------------------------------------- +Popup.prototype.createIframe = function() { + if (document.createElement) { + var i= document.createElement("IFRAME"); + i.style.position="absolute"; + i.style.display="block"; + i.style.visibility="hidden"; + i.style.background="none"; + this.appendToBody(i); + return i; + } + else { + alert("ERROR: Couldn't create IFRAME object in Popup.prototype.createIframe()"); + } +}; + +// Add an IFRAME shim for the DIV +// -------------------------------------------------------------------- +Popup.prototype.addIframeShim = function() { + if (this.iframe==null) { + this.iframe = this.createIframe(); + } + this.iframe.className = Popup.iframeClass; + CSS.setStyle(this.iframe,'top',this.getTop()+"px"); + CSS.setStyle(this.iframe,'left',this.getLeft()+"px"); + CSS.setStyle(this.iframe,'width',DOM.getOuterWidth(this.div) + "px"); + CSS.setStyle(this.iframe,'height',DOM.getOuterHeight(this.div) + "px"); + CSS.setStyle(this.iframe,'zIndex',Popup.minZIndex++); + CSS.setStyle(this.iframe,'opacity',0); + CSS.setStyle(this.iframe,'visibility','visible'); + CSS.setStyle(this.iframe,'display','block'); +}; + +// Create a "screen" to make a popup modal +// -------------------------------------------------------------------- +Popup.prototype.addScreen = function() { + if (this.screen==null) { + this.screen = this.createDiv(); + this.screen.style.top="0px"; + this.screen.style.left="0px"; + this.screen.style.backgroundColor = this.screenColor; + this.screen.className=Popup.screenClass;; + CSS.setStyle(this.screen,"opacity",this.screenOpacity); + this.screen.onclick = function(e) { Event.cancelBubble(Event.resolve(e)); } + } + if (this.screenIframeShim==null) { + this.screenIframeShim = this.createIframe(); + this.screenIframeShim.style.top="0px"; + this.screenIframeShim.style.left="0px"; + this.screenIframeShim.className=Popup.screenIframeClass; + CSS.setStyle(this.screenIframeShim,"opacity",0); + } + this.screen.style.width = Screen.getDocumentWidth()+"px"; + this.screen.style.height = Screen.getDocumentHeight()+"px"; + this.screenIframeShim.style.width = Screen.getDocumentWidth()+"px"; + this.screenIframeShim.style.height = Screen.getDocumentHeight()+"px"; + this.screenIframeShim.style.zIndex = Popup.minZIndex++; + this.screenIframeShim.style.visibility="visible"; + this.screenIframeShim.style.display="block"; + this.screen.style.zIndex = Popup.minZIndex++; + this.screen.style.visibility="visible"; + this.screen.style.display="block"; +}; + +// Re-position the DIV so it stays on the screen +// -------------------------------------------------------------------- +Popup.prototype.fitToScreen = function() { + var width = DOM.getOuterWidth(this.div); + var height = DOM.getOuterHeight(this.div); + var top = this.getTop(); + var left = this.getLeft(); + + var clientWidth = Screen.getViewportWidth(); + var clientHeight = Screen.getViewportHeight(); + + var scrollLeft = Screen.getScrollLeft(); + var scrollTop = Screen.getScrollTop(); + + if (top-scrollTop+height>clientHeight) { + top = top - ((top+height) - (scrollTop+clientHeight)); + this.div.style.top = top + "px"; + } + if (left-scrollLeft+width>clientWidth) { + left = left - ((left+width) - (scrollLeft+clientWidth)); + this.div.style.left = left + "px"; + } + if (top + + + + + + + + + + + + + + \n + + + + +
+ + + +
+ + + +
+
+
diff --git a/tct-system-sensor-tizen-tests/res/Result/style/testresult.xsl b/tct-system-sensor-tizen-tests/res/Result/style/testresult.xsl new file mode 100755 index 0000000..9cfbd84 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/Result/style/testresult.xsl @@ -0,0 +1,571 @@ + + + + + + + + + + + + + + + \n + + + + +
+ + + +
+ + + +
+
+
diff --git a/tct-system-sensor-tizen-tests/res/Result/style/tests.css b/tct-system-sensor-tizen-tests/res/Result/style/tests.css new file mode 100755 index 0000000..487bca0 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/Result/style/tests.css @@ -0,0 +1,195 @@ +@charset "UTF-8"; +/* CSS Document */ +#testcasepage div,#testcasepage h1,#testcasepage p,#testcasepage table,#testcasepage tr,#testcasepage th,#testcasepage td + { + margin: 0; + padding: 0; + border: 0; + font-weight: inherit; + font-style: inherit; + font-size: 0.96em; + font-family: arial; + vertical-align: baseline; +} + +#title td, #btc td{ + margin: 0; + padding: 0; + border: 0; + font-weight: inherit; + font-style: inherit; + font-size: 0.96em; + font-family: arial; + vertical-align: baseline; +} + +td.Ratio { + text-align: left; + font-weight: normal; + padding: 4px 10px 4px 5px; + vertical-align: middle; +} + +th.Ratio { + width: 400px; +} + +#testcasepage p { + text-align: left; +} + +#suite_title { + text-align: left; +} + +#btc { + text-align: right; +} + +#btc table { + position: absolute; + right: 0px; + width: 600px; +} + +#testcasepage table { + border-collapse: separate; + border-spacing: 0; + margin-bottom: 1.4em; + vertical-align: middle; +} + +#testcasepage th,#testcasepage td { + text-align: left; + font-weight: normal; + padding: 4px 10px 4px 5px; + vertical-align: middle; +} + +#cases table { + width: 101%; +} + +#cases td { + border-left: 0px; + font-weight: normal; + border-bottom: 0px; +} + +#suite_summary table { + width: 100%; +} + + +#overview table { + width: 101%; +} + +#overview table, #overview td, #overview tr { + border-left: none; + border-bottom: none; + border-right: none; + vertical-align: top; +} + +#overview td{ + width: 50%; +} + +#capability table { + width: 50%; +} + +#fail_cases table { + width: 101%; +} + +#title table { + width: 101%; +} + +#device table { + width: 100%; +} + +#summary table { + width: 100%; +} + +#testcasepage th { + border-bottom: 1px solid #000; + background-color: #AAAAAA; + border-left: 1px solid #000; + border-top: 1px solid #000; + color: #000; + font-weight: bold; + vertical-align: bottom; +} + +#summary th:last-child,#summary td:last-child, #device th:last-child,#device td:last-child, #suite_summary th:last-child,#suite_summary td:last-child,#cases th:last-child,#cases td:last-child,#capability th:last-child,#capability td:last-child { + border-right: 1px solid #000; +} + +#testcasepage td { + font-weight: normal; +} + +#summary td, #device td, #capability td, #suite_summary td, #cases td{ + border-left: 1px solid; + font-weight: normal; + border-bottom: 1px solid; +} + +#testcasepage td.yellow_rate { + background-color: #ffcc00; +} + +#testcasepage td.green_rate { + background-color: #1E90FF; +} + +#testcasepage td.dgreen_rate { + background-color: #339933; +} + +#testcasepage td.red_rate { + background-color: #FF3333; +} + +#testcasepage td.orange_rate { + background-color: #FFA500; +} + +#testcasepage td.gray_rate { + background-color: #AAAAAA; +} + +#title table,#title tr,#title td { + border-left: none; + border-bottom: none; + text-align: center; +} + +#title td:last-child { + border-right: none; +} + +#testcasepage h1 { + font-size: 2em; + font-family: Arial, sans-serif; + font-weight: bold; + line-height: 1; + color: #000; + margin-bottom: 0.75em; + padding-top: 0.25em; + font-weight: bold; +} + +#goTopBtn { + right: 0px; + bottom: 0px; + position: fixed; + + position: absolute; + top: expression(parseInt(document.body.scrollTop)+document.body.clientHeight-40 + ); +} diff --git a/tct-system-sensor-tizen-tests/res/Result/summary.xml b/tct-system-sensor-tizen-tests/res/Result/summary.xml new file mode 100644 index 0000000..919391e --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/Result/summary.xml @@ -0,0 +1,21 @@ + + + + + + + + 2016-04-20_18_37_38 + 2016-04-20_18_37_38 + + + 64 + 64 + 100 + 0 + 0 + 0 + 0 + 0 + + \ No newline at end of file diff --git a/tct-system-sensor-tizen-tests/res/install.sh b/tct-system-sensor-tizen-tests/res/install.sh new file mode 100755 index 0000000..1b08974 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/install.sh @@ -0,0 +1,9 @@ +# uninstall sample applications +pkgcmd -u -n org.test.tizen.system.sensor + +#install sample applications +pkgcmd -t tpk -i -p org.test.tizen.system.sensor.tpk -q + +#list installed sample applications +echo "Successful installed the following packages: " +app_launcher -l | grep UIApplication diff --git a/tct-system-sensor-tizen-tests/res/pull.sh b/tct-system-sensor-tizen-tests/res/pull.sh new file mode 100755 index 0000000..49bfbf0 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/pull.sh @@ -0,0 +1,4 @@ +# pull result file +sdb root on +sdb pull /home/owner/share/System/System.xml Result/ +sdb pull /home/owner/share/System/summary.xml Result/ diff --git a/tct-system-sensor-tizen-tests/res/push.sh b/tct-system-sensor-tizen-tests/res/push.sh new file mode 100755 index 0000000..46ef848 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/push.sh @@ -0,0 +1,2 @@ +sdb root on +sdb push ../org.test.tizen.system.sensor.tpk install.sh run.sh /home/owner diff --git a/tct-system-sensor-tizen-tests/res/run.sh b/tct-system-sensor-tizen-tests/res/run.sh new file mode 100755 index 0000000..d891886 --- /dev/null +++ b/tct-system-sensor-tizen-tests/res/run.sh @@ -0,0 +1,4 @@ +# install & run TC application +pkgcmd -u -n org.test.tizen.system.sensor +pkgcmd -t tpk -i -p org.test.tizen.system.sensor.tpk -q +app_launcher -s org.test.tizen.system.sensor diff --git a/tct-system-sensor-tizen-tests/src/Program.cs b/tct-system-sensor-tizen-tests/src/Program.cs new file mode 100755 index 0000000..aea223d --- /dev/null +++ b/tct-system-sensor-tizen-tests/src/Program.cs @@ -0,0 +1,29 @@ +using Tizen.Applications; + +namespace TestFramework { + public class MyApplication : UIApplication { + protected override void OnCreate() { + Assert.Init(); + TestManager manager = new TestManager(); + manager.RunTestFromTCList(); + } + + protected override void OnResume() { + LogUtils.write(LogUtils.DEBUG, LogUtils.INFO, "Resumed!"); + } + + protected override void OnPause() { + LogUtils.write(LogUtils.DEBUG, LogUtils.INFO, "Paused!"); + } + + protected override void OnTerminate() { + LogUtils.write(LogUtils.DEBUG, LogUtils.INFO, "Terminated!"); + } + } + class Program { + static void Main(string[] args) { + MyApplication app = new MyApplication(); + app.Run(args); + } + } +} diff --git a/tct-system-sensor-tizen-tests/src/Testcase/TSAccelerometer.cs b/tct-system-sensor-tizen-tests/src/Testcase/TSAccelerometer.cs new file mode 100644 index 0000000..3e7887b --- /dev/null +++ b/tct-system-sensor-tizen-tests/src/Testcase/TSAccelerometer.cs @@ -0,0 +1,400 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Tizen.System.Sensor; +using TestFramework; +using Tizen; + +namespace TizenTest.System.Sensor { + [TestFixture] + [Description("Testing Tizen.System.Sensor.Accelerometer class")] + public static class TSAccelerometer { + public static bool bFlag = false; + public static int count; + private const string LogTag = "TizenTest.System.Sensor.Accelerometer"; + + [SetUp] + public static void Init() { + count = 0; + bFlag = false; + Log.Info(LogTag, "Accelerometer Test Init"); + } + + [TearDown] + public static void Destroy() { + Log.Info(LogTag, "Accelerometer Test Destroy"); + } + + [Test] + [Category("P1")] + [Description("Test Accelerometer class construction")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.Accelerometer C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Accelerometer_INIT() + { + /* + * 1. Create an instane of Accelerometer + * */ + Log.Info(LogTag, "Accelerometer Test Constructor starting"); + Accelerometer lacc = null; + lacc = new Accelerometer(); + + Assert.IsNotNull(lacc, "Accelerometer object should not be null after construction"); + Log.Info(LogTag, "Accelerometer Test Constructor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.IsSupported")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.IsSupported A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void IsSupported_RETURN_TYPE() + { + Log.Info(LogTag, "Accelerometer Test IsSupported Starting"); + object ret = Accelerometer.IsSupported; + Assert.IsNotNull(ret, "IsSupported value returned is null"); + Assert.True((ret is bool), "IsSupported value returned is not of type bool"); + Log.Info(LogTag, "Accelerometer Test IsSupported finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and value of Accelerometer.Count")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.Count A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Count_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "Accelerometer Test Count starting"); + object ret = Accelerometer.Count; + Assert.IsNotNull(ret, "Count value returned should not be null"); + Assert.True((ret is int), "Count value returned is not of type int"); + Assert.Greater((int) ret, -1, "Count of accelerometer cant be negative"); + Log.Info(LogTag, "Accelerometer Test Count finished"); + } + + public static void EventCallback(object sender, AccelerometerDataUpdatedEventArgs args) { + Log.Info(LogTag, "Accelerometer X : " + args.X); + Log.Info(LogTag, "Accelerometer Y : " + args.Y); + Log.Info(LogTag, "Accelerometer Z : " + args.Z); + bFlag = true; + } + + [Test] + [Category("P1")] + [Description("Accelerometer DataUpdated Callback")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.DataUpdated U")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static async Task DataUpdated_CB() { + Log.Info(LogTag, "Accelerometer Test DataUpdated event starting"); + Accelerometer lacc = new Accelerometer(); + lacc.DataUpdated += EventCallback; + lacc.Start(); + lacc.Interval = 100; + await Task.Delay(3000); + lacc.Stop(); + + /* TEST CODE + * 1 Create an instance of Accelerometer + * 2 Add function EventCallback to event SensorChanged + * 3 Start accelerometer + * 4 Change bFlag to true in EventCallbcak. + * 5 Stop accelerometer + * 6 Check bFlag is true + */ + + Assert.True(bFlag, "SensorEventOccured should have occurred for accelerometer"); + Log.Info(LogTag, "Accelerometer Test DataUpdated event finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.Name")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.Name A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Name_RETURN_TYPE() + { + Log.Info(LogTag, "Accelerometer Test Name starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.Name; + Assert.IsNotNull(ret, "Name value returned is null"); + Assert.True((ret is string), "Name value returned is not of type string"); + Log.Info(LogTag, "Accelerometer Test Name finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.Vendor")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.Vendor A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Vendor_RETURN_TYPE() + { + Log.Info(LogTag, "Accelerometer Test Vendor starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.Vendor; + Assert.IsNotNull(ret, "Vendor value returned is null"); + Assert.True((ret is string), "Vendor value returned is not of type string"); + Log.Info(LogTag, "Accelerometer Test Vendor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.MinValue")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.MinValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinValue_RETURN_TYPE() + { + Log.Info(LogTag, "Accelerometer Test minvalue starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.MinValue; + Assert.IsNotNull(ret, "MinValue returned is null"); + Assert.True((ret is float), "MinValue returned is not of type float"); + Log.Info(LogTag, "Accelerometer Test minvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.MaxValue")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.MaxValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxValue_RETURN_TYPE() + { + Log.Info(LogTag, "Accelerometer Test maxvalue starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.MaxValue; + Assert.IsNotNull(ret, "MaxValue returned is null"); + Assert.True((ret is float), "MaxValue returned is not of type float"); + Log.Info(LogTag, "Accelerometer Test maxvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.Resolution")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.Resolution A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Resolution_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "Accelerometer Test Resolution starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.Resolution; + Assert.IsNotNull(ret, "Resolution value returned is null"); + Assert.True((ret is float), "Resolution value returned is not of type float"); + Log.Info(LogTag, "Accelerometer Test Resolution finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of Accelerometer.MinInterval")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.MinInterval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinInterval_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "Accelerometer Test MinInterval starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.MinInterval; + Assert.IsNotNull(ret, "MinInterval value returned is null"); + Assert.True((ret is int), "MinInterval value returned is not of type int"); + Assert.Greater((int) ret, -1, "MinInterval cant be negative"); + Log.Info(LogTag, "Accelerometer Test MinInterval finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and value of Accelerometer.MaxBatchCount")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.MaxBatchCout A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchCount_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "Accelerometer Test MaxBatchCount starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.MaxBatchCount; + Assert.IsNotNull(ret, "MaxBatchCount value returned is null"); + Assert.True((ret is int), "MaxBatchCount value returned is not of type int"); + Log.Info(LogTag, "Accelerometer Test MaxBatchCount finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.IsSensing")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.IsSensing A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Sensing_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "Accelerometer Test IsSensing Starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.IsSensing; + Assert.IsNotNull(ret, "IsSensing value returned is null"); + Assert.True((ret is bool), "IsSensing value returned is not of type bool"); + Log.Info(LogTag, "Accelerometer Test IsSensing finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of Accelerometer.Interval")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.Interval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_RETURN_TYPE() + { + Log.Info(LogTag, "Accelerometer Test Interval read starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.Interval; + Assert.IsNotNull(ret, "Interval value returned is null"); + Assert.True((ret is uint), "Interval value returned is not of type uint"); + Log.Info(LogTag, "Accelerometer Test Interval read finished"); + } + + [Test] + [Category("P1")] + [Description("Setting the testing the return value of Accelerometer.Interval")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.Intetrval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_SET_VALUE() + { + Log.Info(LogTag, "Accelerometer Test interval write/read starting"); + Accelerometer lacc = new Accelerometer(); + lacc.DataUpdated += EventCallback; + lacc.Start(); + uint interval = 123; + lacc.Interval = interval; + uint ret = lacc.Interval; + string msg = "Interval is not the same as initially set 123 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + interval = 1; + lacc.Interval = interval; + ret = lacc.Interval; + msg = "Interval is not the same as initially set 1 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + lacc.Stop(); + Log.Info(LogTag, "Accelerometer Test interval write/read finished"); + } +/* + * MaxBatchLatency Not Supported right now. + + [Test] + [Category("P1")] + [Description("Return type of Accelerometer.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_TYPE_RETURN_VALUE() + { + Accelerometer lacc = new Accelerometer(); + object ret = lacc.MaxBatchLatency; + Assert.IsNotNull(ret, "MaxBatchLatency value returned is null"); + Assert.True((ret is uint), "MaxBatchLatency value returned is not of type uint"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing the return value of Accelerometer.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_SET_VALUE() + { + Accelerometer lacc = new Accelerometer(); + lacc.DataUpdated += EventCallback; + lacc.Start(); + uint latency = 123; + + lacc.MaxBatchLatency = latency; + uint ret = lacc.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + + lacc.MaxBatchLatency = 50; + ret = lacc.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + } +*/ + [Test] + [Category("P1")] + [Description("Return type of Acceleorometer.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_RETURN_TYPE() + { + Log.Info(LogTag, "Accelerometer Test pause policy get starting"); + Accelerometer lacc = new Accelerometer(); + object ret = lacc.PausePolicy; + Assert.IsNotNull(ret, "PausePolicy value returned is null"); + Assert.True((ret is SensorPausePolicy), "PausePolicy value returned is not of type SensorPausePolicy"); + Assert.Greater((int) ret, -1, "PausePolicy cant be negative"); + Log.Info(LogTag, "Accelerometer Test pause policy get finished"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing Accelerometer.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.Accelerometer.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_SET_RETURN_VALUE() + { + Log.Info(LogTag, "Accelerometer Test PausePolicy set starting"); + Accelerometer lacc = new Accelerometer(); + SensorPausePolicy ret; + lacc.PausePolicy = SensorPausePolicy.PowerSaveMode; + ret = lacc.PausePolicy; + if (ret != SensorPausePolicy.PowerSaveMode) + Assert.True(false, "Accelerometer.PausePolicy is not same as intially set"); + + lacc.PausePolicy = SensorPausePolicy.DisplayOff; + ret = lacc.PausePolicy; + if (ret != SensorPausePolicy.DisplayOff) + Assert.True(false, "Accelerometer.PausePolicy is not same as intially set"); + + lacc.PausePolicy = SensorPausePolicy.All; + ret = lacc.PausePolicy; + if (ret != SensorPausePolicy.All) + Assert.True(false, "Accelerometer.PausePolicy is not same as intially set"); + + lacc.PausePolicy = SensorPausePolicy.None; + ret = lacc.PausePolicy; + if (ret != SensorPausePolicy.None) + Assert.True(false, "Accelerometer.PausePolicy is not same as intially set"); + + Log.Info(LogTag, "Accelerometer Test PausePolicy set finished"); + + Log.Info(LogTag, "Accelerometer Sensing "+ lacc.IsSensing); + } + } +} + diff --git a/tct-system-sensor-tizen-tests/src/Testcase/TSGravitySensor.cs b/tct-system-sensor-tizen-tests/src/Testcase/TSGravitySensor.cs new file mode 100644 index 0000000..79ef980 --- /dev/null +++ b/tct-system-sensor-tizen-tests/src/Testcase/TSGravitySensor.cs @@ -0,0 +1,398 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Tizen.System.Sensor; +using TestFramework; +using Tizen; + +namespace TizenTest.System.Sensor { + [TestFixture] + [Description("Testing Tizen.System.Sensor.GravitySensor class")] + public static class TSGravitySensor { + public static bool bFlag = false; + public static int count; + private const string LogTag = "TizenTest.System.Sensor.GravitySensor"; + + [SetUp] + public static void Init() { + count = 0; + bFlag = false; + Log.Info(LogTag, "GravitySensor Test Init"); + } + + [TearDown] + public static void Destroy() { + Log.Info(LogTag, "GravitySensor Test Destroy"); + } + + [Test] + [Category("P1")] + [Description("Test GravitySensor class construction")] + [Property("SPEC", "TizenTest.System.Sensor.SenosrTestFixture.GravitySensor.GravitySensor C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void GravitySensor_INIT() + { + /* + * 1. Create an instane of GravitySensor + * */ + Log.Info(LogTag, "GravitySensor Test Constructor starting"); + GravitySensor gravity = null; + gravity = new GravitySensor(); + + Assert.IsNotNull(gravity, "GravitySensor object should not be null after construction"); + Log.Info(LogTag, "GravitySensor Test Constructor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.IsSupported")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.IsSupported A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void IsSupported_RETURN_TYPE() + { + Log.Info(LogTag, "GravitySensor Test IsSupported Starting"); + object ret = GravitySensor.IsSupported; + Assert.IsNotNull(ret, "IsSupported value returned is null"); + Assert.True((ret is bool), "IsSupported value returned is not of type bool"); + Log.Info(LogTag, "GravitySensor Test IsSupported finished" + (bool) ret); + } + + [Test] + [Category("P1")] + [Description("Return type and value of GravitySensor.Count")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.Count A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Count_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "GravitySensor Test Count starting"); + object ret = GravitySensor.Count; + Assert.IsNotNull(ret, "Count value returned should not be null"); + Assert.True((ret is int), "Count value returned is not of type int"); + Assert.Greater((int) ret, -1, "Count of GravitySensor cant be negative"); + Log.Info(LogTag, "GravitySensor Test Count finished"); + } + + public static void EventCallbackGravity(object sender, GravitySensorDataUpdatedEventArgs args) { + Log.Info(LogTag, "GravitySensor X : "+args.X); + Log.Info(LogTag, "GravitySensor Y : " + args.Y); + Log.Info(LogTag, "GravitySensor Z : " + args.Z); + bFlag = true; + } + + [Test] + [Category("P1")] + [Description("GravitySensor DataUpdated Callback")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.DataUpdated U")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static async Task DataUpdated_CB() { + Log.Info(LogTag, "GravitySensor Test DataUpdated event starting"); + GravitySensor gravity = new GravitySensor(); + gravity.DataUpdated += EventCallbackGravity; + gravity.Start(); + gravity.Interval = 100; + await Task.Delay(3000); + gravity.Stop(); + + /* TEST CODE + * 1 Create an instance of GravitySensor + * 2 Add function EventCallback to event SensorChanged + * 3 Start GravitySensor + * 4 Change bFlag to true in EventCallbcak. + * 5 Stop GravitySensor + * 6 Check bFlag is true + */ + + Assert.True(bFlag, "SensorEventOccured should have occurred for GravitySensor"); + Log.Info(LogTag, "GravitySensor Test DataUpdated event finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.Name")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.Name A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Name_RETURN_TYPE() + { + Log.Info(LogTag, "GravitySensor Test Name starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.Name; + Assert.IsNotNull(ret, "Name value returned is null"); + Assert.True((ret is string), "Name value returned is not of type string"); + Log.Info(LogTag, "GravitySensor Test Name finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.Vendor")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.Vendor A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Vendor_RETURN_TYPE() + { + Log.Info(LogTag, "GravitySensor Test Vendor starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.Vendor; + Assert.IsNotNull(ret, "Vendor value returned is null"); + Assert.True((ret is string), "Vendor value returned is not of type string"); + Log.Info(LogTag, "GravitySensor Test Vendor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.MinValue")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.MinValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinValue_RETURN_TYPE() + { + Log.Info(LogTag, "GravitySensor Test minvalue starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.MinValue; + Assert.IsNotNull(ret, "MinValue returned is null"); + Assert.True((ret is float), "MinValue returned is not of type float"); + Log.Info(LogTag, "GravitySensor Test minvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.MaxValue")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.MaxValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxValue_RETURN_TYPE() + { + Log.Info(LogTag, "GravitySensor Test maxvalue starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.MaxValue; + Assert.IsNotNull(ret, "MaxValue returned is null"); + Assert.True((ret is float), "MaxValue returned is not of type float"); + Log.Info(LogTag, "GravitySensor Test maxvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.Resolution")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.Resolution A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Resolution_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "GravitySensor Test Resolution starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.Resolution; + Assert.IsNotNull(ret, "Resolution value returned is null"); + Assert.True((ret is float), "Resolution value returned is not of type float"); + Log.Info(LogTag, "GravitySensor Test Resolution finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of GravitySensor.MinInterval")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.MinInterval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinInterval_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "GravitySensor Test MinInterval starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.MinInterval; + Assert.IsNotNull(ret, "MinInterval value returned is null"); + Assert.True((ret is int), "MinInterval value returned is not of type int"); + Assert.Greater((int) ret, -1, "MinInterval cant be negative"); + Log.Info(LogTag, "GravitySensor Test MinInterval finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and value of GravitySensor.MaxBatchCount")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.MaxBatchCout A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchCount_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "GravitySensor Test MaxBatchCount starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.MaxBatchCount; + Assert.IsNotNull(ret, "MaxBatchCount value returned is null"); + Assert.True((ret is int), "MaxBatchCount value returned is not of type int"); + Log.Info(LogTag, "GravitySensor Test MaxBatchCount finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.IsSensing")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.IsSensing A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Sensing_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "GravitySensor Test IsSensing Starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.IsSensing; + Assert.IsNotNull(ret, "IsSensing value returned is null"); + Assert.True((ret is bool), "IsSensing value returned is not of type bool"); + Log.Info(LogTag, "GravitySensor Test IsSensing finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of GravitySensor.Interval")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.Interval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_RETURN_TYPE() + { + Log.Info(LogTag, "GravitySensor Test Interval read starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.Interval; + Assert.IsNotNull(ret, "Interval value returned is null"); + Assert.True((ret is uint), "Interval value returned is not of type uint"); + Log.Info(LogTag, "GravitySensor Test Interval read finished"); + } + + [Test] + [Category("P1")] + [Description("Setting the testing the return value of GravitySensor.Interval")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.Intetrval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_SET_VALUE() + { + Log.Info(LogTag, "GravitySensor Test interval write/read starting"); + GravitySensor gravity = new GravitySensor(); + gravity.DataUpdated += EventCallbackGravity; + gravity.Start(); + uint interval = 123; + gravity.Interval = interval; + uint ret = gravity.Interval; + string msg = "Interval is not the same as initially set 123 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + interval = 1; + gravity.Interval = interval; + ret = gravity.Interval; + msg = "Interval is not the same as initially set 1 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + gravity.Stop(); + Log.Info(LogTag, "GravitySensor Test interval write/read finished"); + } +/* + * MaxBatchLatency Not Supported right now. + + [Test] + [Category("P1")] + [Description("Return type of GravitySensor.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_TYPE_RETURN_VALUE() + { + GravitySensor gravity = new GravitySensor(); + object ret = gravity.MaxBatchLatency; + Assert.IsNotNull(ret, "MaxBatchLatency value returned is null"); + Assert.True((ret is uint), "MaxBatchLatency value returned is not of type uint"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing the return value of GravitySensor.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_SET_VALUE() + { + GravitySensor gravity = new GravitySensor(); + gravity.DataUpdated += EventCallbackGravity; + gravity.Start(); + uint latency = 123; + + gravity.MaxBatchLatency = latency; + uint ret = gravity.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + + gravity.MaxBatchLatency = 50; + ret = gravity.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + } +*/ + [Test] + [Category("P1")] + [Description("Return type of Acceleorometer.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_RETURN_TYPE() + { + Log.Info(LogTag, "GravitySensor Test pause policy get starting"); + GravitySensor gravity = new GravitySensor(); + object ret = gravity.PausePolicy; + Assert.IsNotNull(ret, "PausePolicy value returned is null"); + Assert.True((ret is SensorPausePolicy), "PausePolicy value returned is not of type SensorPausePolicy"); + Assert.Greater((int) ret, -1, "PausePolicy cant be negative"); + Log.Info(LogTag, "GravitySensor Test pause policy get finished"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing GravitySensor.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.GravitySensor.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_SET_RETURN_VALUE() + { + Log.Info(LogTag, "GravitySensor Test PausePolicy set starting"); + GravitySensor gravity = new GravitySensor(); + SensorPausePolicy ret; + gravity.PausePolicy = SensorPausePolicy.PowerSaveMode; + ret = gravity.PausePolicy; + if (ret != SensorPausePolicy.PowerSaveMode) + Assert.True(false, "GravitySensor.PausePolicy is not same as intially set"); + + gravity.PausePolicy = SensorPausePolicy.DisplayOff; + ret = gravity.PausePolicy; + if (ret != SensorPausePolicy.DisplayOff) + Assert.True(false, "GravitySensor.PausePolicy is not same as intially set"); + + gravity.PausePolicy = SensorPausePolicy.All; + ret = gravity.PausePolicy; + if (ret != SensorPausePolicy.All) + Assert.True(false, "GravitySensor.PausePolicy is not same as intially set"); + + gravity.PausePolicy = SensorPausePolicy.None; + ret = gravity.PausePolicy; + if (ret != SensorPausePolicy.None) + Assert.True(false, "GravitySensor.PausePolicy is not same as intially set"); + + Log.Info(LogTag, "GravitySensor Test PausePolicy set finished"); + } + } +} + diff --git a/tct-system-sensor-tizen-tests/src/Testcase/TSLinearAccelerationSensor.cs b/tct-system-sensor-tizen-tests/src/Testcase/TSLinearAccelerationSensor.cs new file mode 100644 index 0000000..6afe85f --- /dev/null +++ b/tct-system-sensor-tizen-tests/src/Testcase/TSLinearAccelerationSensor.cs @@ -0,0 +1,396 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Tizen.System.Sensor; +using TestFramework; +using Tizen; + +namespace TizenTest.System.Sensor { + [TestFixture] + [Description("Testing Tizen.System.Sensor.LinearAccelerationSensor class")] + public static class TSLinearAccelerationSensor { + public static bool bFlag = false; + public static int count; + private const string LogTag = "TizenTest.System.Sensor.LinearAccelerationSensor"; + + [SetUp] + public static void Init() { + count = 0; + bFlag = false; + Log.Info(LogTag, "LinearAccelerationSensor Test Init"); + } + + [TearDown] + public static void Destroy() { + Log.Info(LogTag, "LinearAccelerationSensor Test Destroy"); + } + + [Test] + [Category("P1")] + [Description("Test LinearAccelerationSensor class construction")] + [Property("SPEC", "TizenTest.System.Sensor.SenosrTestFixture.LinearAccelerationSensor.LinearAccelerationSensor C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void LinearAccelerationSensor_INIT() + { + /* + * 1. Create an instane of LinearAccelerationSensor + * */ + Log.Info(LogTag, "LinearAccelerationSensor Test Constructor starting"); + LinearAccelerationSensor linear = null; + linear = new LinearAccelerationSensor(); + + Assert.IsNotNull(linear, "LinearAccelerationSensor object should not be null after construction"); + Log.Info(LogTag, "LinearAccelerationSensor Test Constructor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.IsSupported")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.IsSupported A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void IsSupported_RETURN_TYPE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test IsSupported Starting"); + object ret = LinearAccelerationSensor.IsSupported; + Assert.IsNotNull(ret, "IsSupported value returned is null"); + Assert.True((ret is bool), "IsSupported value returned is not of type bool"); + Log.Info(LogTag, "LinearAccelerationSensor Test IsSupported finished" + (bool) ret); + } + + [Test] + [Category("P1")] + [Description("Return type and value of LinearAccelerationSensor.Count")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.Count A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Count_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test Count starting"); + object ret = LinearAccelerationSensor.Count; + Assert.IsNotNull(ret, "Count value returned should not be null"); + Assert.True((ret is int), "Count value returned is not of type int"); + Assert.Greater((int) ret, -1, "Count of LinearAccelerationSensor cant be negative"); + Log.Info(LogTag, "LinearAccelerationSensor Test Count finished"); + } + + public static void EventCallbackLinear(object sender, LinearAccelerationSensorDataUpdatedEventArgs args) { + Log.Info(LogTag, "Linear X : " + args.X +"Linear Y : " + args.Y+ "Linear Z : " + args.Z); + bFlag = true; + } + + [Test] + [Category("P1")] + [Description("LinearAccelerationSensor DataUpdated Callback")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.DataUpdated U")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static async Task DataUpdated_CB() { + Log.Info(LogTag, "LinearAccelerationSensor Test DataUpdated event starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + linear.DataUpdated += EventCallbackLinear; + linear.Start(); + linear.Interval = 100; + await Task.Delay(3000); + linear.Stop(); + + /* TEST CODE + * 1 Create an instance of LinearAccelerationSensor + * 2 Add function EventCallback to event SensorChanged + * 3 Start LinearAccelerationSensor + * 4 Change bFlag to true in EventCallbcak. + * 5 Stop LinearAccelerationSensor + * 6 Check bFlag is true + */ + + Assert.True(bFlag, "SensorEventOccured should have occurred for LinearAccelerationSensor"); + Log.Info(LogTag, "LinearAccelerationSensor Test DataUpdated event finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.Name")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.Name A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Name_RETURN_TYPE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test Name starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.Name; + Assert.IsNotNull(ret, "Name value returned is null"); + Assert.True((ret is string), "Name value returned is not of type string"); + Log.Info(LogTag, "LinearAccelerationSensor Test Name finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.Vendor")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.Vendor A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Vendor_RETURN_TYPE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test Vendor starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.Vendor; + Assert.IsNotNull(ret, "Vendor value returned is null"); + Assert.True((ret is string), "Vendor value returned is not of type string"); + Log.Info(LogTag, "LinearAccelerationSensor Test Vendor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.MinValue")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.MinValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinValue_RETURN_TYPE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test minvalue starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.MinValue; + Assert.IsNotNull(ret, "MinValue returned is null"); + Assert.True((ret is float), "MinValue returned is not of type float"); + Log.Info(LogTag, "LinearAccelerationSensor Test minvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.MaxValue")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.MaxValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxValue_RETURN_TYPE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test maxvalue starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.MaxValue; + Assert.IsNotNull(ret, "MaxValue returned is null"); + Assert.True((ret is float), "MaxValue returned is not of type float"); + Log.Info(LogTag, "LinearAccelerationSensor Test maxvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.Resolution")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.Resolution A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Resolution_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test Resolution starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.Resolution; + Assert.IsNotNull(ret, "Resolution value returned is null"); + Assert.True((ret is float), "Resolution value returned is not of type float"); + Log.Info(LogTag, "LinearAccelerationSensor Test Resolution finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of LinearAccelerationSensor.MinInterval")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.MinInterval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinInterval_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test MinInterval starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.MinInterval; + Assert.IsNotNull(ret, "MinInterval value returned is null"); + Assert.True((ret is int), "MinInterval value returned is not of type int"); + Assert.Greater((int) ret, -1, "MinInterval cant be negative"); + Log.Info(LogTag, "LinearAccelerationSensor Test MinInterval finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and value of LinearAccelerationSensor.MaxBatchCount")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.MaxBatchCout A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchCount_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test MaxBatchCount starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.MaxBatchCount; + Assert.IsNotNull(ret, "MaxBatchCount value returned is null"); + Assert.True((ret is int), "MaxBatchCount value returned is not of type int"); + Log.Info(LogTag, "LinearAccelerationSensor Test MaxBatchCount finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.IsSensing")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.IsSensing A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Sensing_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test IsSensing Starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.IsSensing; + Assert.IsNotNull(ret, "IsSensing value returned is null"); + Assert.True((ret is bool), "IsSensing value returned is not of type bool"); + Log.Info(LogTag, "LinearAccelerationSensor Test IsSensing finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of LinearAccelerationSensor.Interval")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.Interval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_RETURN_TYPE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test Interval read starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.Interval; + Assert.IsNotNull(ret, "Interval value returned is null"); + Assert.True((ret is uint), "Interval value returned is not of type uint"); + Log.Info(LogTag, "LinearAccelerationSensor Test Interval read finished"); + } + + [Test] + [Category("P1")] + [Description("Setting the testing the return value of LinearAccelerationSensor.Interval")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.Intetrval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_SET_VALUE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test interval write/read starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + linear.DataUpdated += EventCallbackLinear; + linear.Start(); + uint interval = 123; + linear.Interval = interval; + uint ret = linear.Interval; + string msg = "Interval is not the same as initially set 123 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + interval = 1; + linear.Interval = interval; + ret = linear.Interval; + msg = "Interval is not the same as initially set 1 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + linear.Stop(); + Log.Info(LogTag, "LinearAccelerationSensor Test interval write/read finished"); + } +/* + * MaxBatchLatency Not Supported right now. + + [Test] + [Category("P1")] + [Description("Return type of LinearAccelerationSensor.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_TYPE_RETURN_VALUE() + { + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.MaxBatchLatency; + Assert.IsNotNull(ret, "MaxBatchLatency value returned is null"); + Assert.True((ret is uint), "MaxBatchLatency value returned is not of type uint"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing the return value of LinearAccelerationSensor.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_SET_VALUE() + { + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + linear.DataUpdated += EventCallback; + linear.Start(); + uint latency = 123; + + linear.MaxBatchLatency = latency; + uint ret = linear.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + + linear.MaxBatchLatency = 50; + ret = linear.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + } +*/ + [Test] + [Category("P1")] + [Description("Return type of Acceleorometer.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_RETURN_TYPE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test pause policy get starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + object ret = linear.PausePolicy; + Assert.IsNotNull(ret, "PausePolicy value returned is null"); + Assert.True((ret is SensorPausePolicy), "PausePolicy value returned is not of type SensorPausePolicy"); + Assert.Greater((int) ret, -1, "PausePolicy cant be negative"); + Log.Info(LogTag, "LinearAccelerationSensor Test pause policy get finished"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing LinearAccelerationSensor.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.LinearAccelerationSensor.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_SET_RETURN_VALUE() + { + Log.Info(LogTag, "LinearAccelerationSensor Test PausePolicy set starting"); + LinearAccelerationSensor linear = new LinearAccelerationSensor(); + SensorPausePolicy ret; + linear.PausePolicy = SensorPausePolicy.PowerSaveMode; + ret = linear.PausePolicy; + if (ret != SensorPausePolicy.PowerSaveMode) + Assert.True(false, "LinearAccelerationSensor.PausePolicy is not same as intially set"); + + linear.PausePolicy = SensorPausePolicy.DisplayOff; + ret = linear.PausePolicy; + if (ret != SensorPausePolicy.DisplayOff) + Assert.True(false, "LinearAccelerationSensor.PausePolicy is not same as intially set"); + + linear.PausePolicy = SensorPausePolicy.All; + ret = linear.PausePolicy; + if (ret != SensorPausePolicy.All) + Assert.True(false, "LinearAccelerationSensor.PausePolicy is not same as intially set"); + + linear.PausePolicy = SensorPausePolicy.None; + ret = linear.PausePolicy; + if (ret != SensorPausePolicy.None) + Assert.True(false, "LinearAccelerationSensor.PausePolicy is not same as intially set"); + + Log.Info(LogTag, "LinearAccelerationSensor Test PausePolicy set finished"); + } + } +} + diff --git a/tct-system-sensor-tizen-tests/src/Testcase/TSProximitySensor.cs b/tct-system-sensor-tizen-tests/src/Testcase/TSProximitySensor.cs new file mode 100644 index 0000000..24cce18 --- /dev/null +++ b/tct-system-sensor-tizen-tests/src/Testcase/TSProximitySensor.cs @@ -0,0 +1,396 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Tizen.System.Sensor; +using TestFramework; +using Tizen; + +namespace TizenTest.System.Sensor { + [TestFixture] + [Description("Testing Tizen.System.Sensor.ProximitySensor class")] + public static class TSProximitySensor { + public static bool bFlag = false; + public static int count; + private const string LogTag = "TizenTest.System.Sensor.ProximitySensor"; + + [SetUp] + public static void Init() { + count = 0; + bFlag = false; + Log.Info(LogTag, "ProximitySensor Test Init"); + } + + [TearDown] + public static void Destroy() { + Log.Info(LogTag, "ProximitySensor Test Destroy"); + } + + [Test] + [Category("P1")] + [Description("Test ProximitySensor class construction")] + [Property("SPEC", "TizenTest.System.Sensor.SenosrTestFixture.ProximitySensor.ProximitySensor C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void ProximitySensor_INIT() + { + /* + * 1. Create an instane of ProximitySensor + * */ + Log.Info(LogTag, "ProximitySensor Test Constructor starting"); + ProximitySensor proximity = null; + proximity = new ProximitySensor(); + + Assert.IsNotNull(proximity, "ProximitySensor object should not be null after construction"); + Log.Info(LogTag, "ProximitySensor Test Constructor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.IsSupported")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.IsSupported A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void IsSupported_RETURN_TYPE() + { + Log.Info(LogTag, "ProximitySensor Test IsSupported Starting"); + object ret = ProximitySensor.IsSupported; + Assert.IsNotNull(ret, "IsSupported value returned is null"); + Assert.True((ret is bool), "IsSupported value returned is not of type bool"); + Log.Info(LogTag, "ProximitySensor Test IsSupported finished" + (bool) ret); + } + + [Test] + [Category("P1")] + [Description("Return type and value of ProximitySensor.Count")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.Count A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Count_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "ProximitySensor Test Count starting"); + object ret = ProximitySensor.Count; + Assert.IsNotNull(ret, "Count value returned should not be null"); + Assert.True((ret is int), "Count value returned is not of type int"); + Assert.Greater((int) ret, -1, "Count of ProximitySensor cant be negative"); + Log.Info(LogTag, "ProximitySensor Test Count finished"); + } + + public static void EventCallbackProximity(object sender, ProximitySensorDataUpdatedEventArgs args) { + Log.Info(LogTag, "Proximity : "+args.Proximity); + bFlag = true; + } + + [Test] + [Category("P1")] + [Description("ProximitySensor DataUpdated Callback")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.DataUpdated U")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static async Task DataUpdated_CB() { + ProximitySensor proximity = new ProximitySensor(); + Log.Info(LogTag, "ProximitySensor Test DataUpdated event starting"); + proximity.DataUpdated += EventCallbackProximity; + proximity.Start(); + proximity.Interval = 100; + await Task.Delay(10000); + proximity.Stop(); + + /* TEST CODE + * 1 Create an instance of ProximitySensor + * 2 Add function EventCallback to event SensorChanged + * 3 Start ProximitySensor + * 4 Change bFlag to true in EventCallbcak. + * 5 Stop ProximitySensor + * 6 Check bFlag is true + */ + + Assert.True(bFlag, "SensorEventOccured should have occurred for ProximitySensor"); + Log.Info(LogTag, "ProximitySensor Test DataUpdated event finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.Name")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.Name A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Name_RETURN_TYPE() + { + Log.Info(LogTag, "ProximitySensor Test Name starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.Name; + Assert.IsNotNull(ret, "Name value returned is null"); + Assert.True((ret is string), "Name value returned is not of type string"); + Log.Info(LogTag, "ProximitySensor Test Name finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.Vendor")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.Vendor A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Vendor_RETURN_TYPE() + { + Log.Info(LogTag, "ProximitySensor Test Vendor starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.Vendor; + Assert.IsNotNull(ret, "Vendor value returned is null"); + Assert.True((ret is string), "Vendor value returned is not of type string"); + Log.Info(LogTag, "ProximitySensor Test Vendor finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.MinValue")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.MinValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinValue_RETURN_TYPE() + { + Log.Info(LogTag, "ProximitySensor Test minvalue starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.MinValue; + Assert.IsNotNull(ret, "MinValue returned is null"); + Assert.True((ret is float), "MinValue returned is not of type float"); + Log.Info(LogTag, "ProximitySensor Test minvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.MaxValue")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.MaxValue A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxValue_RETURN_TYPE() + { + Log.Info(LogTag, "ProximitySensor Test maxvalue starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.MaxValue; + Assert.IsNotNull(ret, "MaxValue returned is null"); + Assert.True((ret is float), "MaxValue returned is not of type float"); + Log.Info(LogTag, "ProximitySensor Test maxvalue finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.Resolution")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.Resolution A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Resolution_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "ProximitySensor Test Resolution starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.Resolution; + Assert.IsNotNull(ret, "Resolution value returned is null"); + Assert.True((ret is float), "Resolution value returned is not of type float"); + Log.Info(LogTag, "ProximitySensor Test Resolution finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of ProximitySensor.MinInterval")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.MinInterval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MinInterval_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "ProximitySensor Test MinInterval starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.MinInterval; + Assert.IsNotNull(ret, "MinInterval value returned is null"); + Assert.True((ret is int), "MinInterval value returned is not of type int"); + Assert.Greater((int) ret, -1, "MinInterval cant be negative"); + Log.Info(LogTag, "ProximitySensor Test MinInterval finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and value of ProximitySensor.MaxBatchCount")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.MaxBatchCout A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchCount_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "ProximitySensor Test MaxBatchCount starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.MaxBatchCount; + Assert.IsNotNull(ret, "MaxBatchCount value returned is null"); + Assert.True((ret is int), "MaxBatchCount value returned is not of type int"); + Log.Info(LogTag, "ProximitySensor Test MaxBatchCount finished"); + } + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.IsSensing")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.IsSensing A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Sensing_TYPE_RETURN_VALUE() + { + Log.Info(LogTag, "ProximitySensor Test IsSensing Starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.IsSensing; + Assert.IsNotNull(ret, "IsSensing value returned is null"); + Assert.True((ret is bool), "IsSensing value returned is not of type bool"); + Log.Info(LogTag, "ProximitySensor Test IsSensing finished"); + } + + [Test] + [Category("P1")] + [Description("Return type and Value of ProximitySensor.Interval")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.Interval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_RETURN_TYPE() + { + Log.Info(LogTag, "ProximitySensor Test Interval read starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.Interval; + Assert.IsNotNull(ret, "Interval value returned is null"); + Assert.True((ret is uint), "Interval value returned is not of type uint"); + Log.Info(LogTag, "ProximitySensor Test Interval read finished"); + } + + [Test] + [Category("P1")] + [Description("Setting the testing the return value of ProximitySensor.Interval")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.Intetrval A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void Interval_SET_VALUE() + { + Log.Info(LogTag, "ProximitySensor Test interval write/read starting"); + ProximitySensor proximity = new ProximitySensor(); + proximity.DataUpdated += EventCallbackProximity; + proximity.Start(); + uint interval = 123; + proximity.Interval = interval; + uint ret = proximity.Interval; + string msg = "Interval is not the same as initially set 123 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + interval = 1; + proximity.Interval = interval; + ret = proximity.Interval; + msg = "Interval is not the same as initially set 1 - " + ret; + if (ret != interval) + Assert.True(false, msg); + + proximity.Stop(); + Log.Info(LogTag, "ProximitySensor Test interval write/read finished"); + } +/* + * MaxBatchLatency Not Supported right now. + + [Test] + [Category("P1")] + [Description("Return type of ProximitySensor.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_TYPE_RETURN_VALUE() + { + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.MaxBatchLatency; + Assert.IsNotNull(ret, "MaxBatchLatency value returned is null"); + Assert.True((ret is uint), "MaxBatchLatency value returned is not of type uint"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing the return value of ProximitySensor.MaxBatchLatency")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.MaxBatchLatency A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void MaxBatchLatency_SET_VALUE() + { + ProximitySensor proximity = new ProximitySensor(); + proximity.DataUpdated += EventCallback; + proximity.Start(); + uint latency = 123; + + proximity.MaxBatchLatency = latency; + uint ret = proximity.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + + proximity.MaxBatchLatency = 50; + ret = proximity.MaxBatchLatency; + if (ret != latency) + Assert.True(false, "MaxBatchLatency is not the same as initially set"); + } +*/ + [Test] + [Category("P1")] + [Description("Return type of Acceleorometer.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_RETURN_TYPE() + { + Log.Info(LogTag, "ProximitySensor Test pause policy get starting"); + ProximitySensor proximity = new ProximitySensor(); + object ret = proximity.PausePolicy; + Assert.IsNotNull(ret, "PausePolicy value returned is null"); + Assert.True((ret is SensorPausePolicy), "PausePolicy value returned is not of type SensorPausePolicy"); + Assert.Greater((int) ret, -1, "PausePolicy cant be negative"); + Log.Info(LogTag, "ProximitySensor Test pause policy get finished"); + } + + [Test] + [Category("P1")] + [Description("Setting and testing ProximitySensor.PausePolicy")] + [Property("SPEC", "Tizen.System.Sensor.ProximitySensor.PausePolicy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")] + public static void PausePolicy_SET_RETURN_VALUE() + { + Log.Info(LogTag, "ProximitySensor Test PausePolicy set starting"); + ProximitySensor proximity = new ProximitySensor(); + SensorPausePolicy ret; + proximity.PausePolicy = SensorPausePolicy.PowerSaveMode; + ret = proximity.PausePolicy; + if (ret != SensorPausePolicy.PowerSaveMode) + Assert.True(false, "ProximitySensor.PausePolicy is not same as intially set"); + + proximity.PausePolicy = SensorPausePolicy.DisplayOff; + ret = proximity.PausePolicy; + if (ret != SensorPausePolicy.DisplayOff) + Assert.True(false, "ProximitySensor.PausePolicy is not same as intially set"); + + proximity.PausePolicy = SensorPausePolicy.All; + ret = proximity.PausePolicy; + if (ret != SensorPausePolicy.All) + Assert.True(false, "ProximitySensor.PausePolicy is not same as intially set"); + + proximity.PausePolicy = SensorPausePolicy.None; + ret = proximity.PausePolicy; + if (ret != SensorPausePolicy.None) + Assert.True(false, "ProximitySensor.PausePolicy is not same as intially set"); + + Log.Info(LogTag, "ProximitySensor Test PausePolicy set finished"); + } + } +} + diff --git a/tct-system-sensor-tizen-tests/tct-system-sensor-tizen-tests.csproj b/tct-system-sensor-tizen-tests/tct-system-sensor-tizen-tests.csproj new file mode 100644 index 0000000..c0e79b0 --- /dev/null +++ b/tct-system-sensor-tizen-tests/tct-system-sensor-tizen-tests.csproj @@ -0,0 +1,104 @@ + + + + Debug + AnyCPU + {FDAA3944-FCCE-4319-B93E-61FF53137EDB} + Library + Properties + tct_system_sensor_tizen_tests + tct-system-sensor-tizen-tests + v4.5.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + lib\TestFramework.dll + + + lib\Tizen.dll + + + lib\Tizen.Applications.dll + + + lib\Tizen.Internals.dll + + + lib\Tizen.System.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/tct-system-sensor-tizen-tests/tizen-manifest.xml b/tct-system-sensor-tizen-tests/tizen-manifest.xml new file mode 100755 index 0000000..f9633d8 --- /dev/null +++ b/tct-system-sensor-tizen-tests/tizen-manifest.xml @@ -0,0 +1,9 @@ + + + + icon.png + + + + +