diff --git a/Mobile/NUI/Sensor/.gitignore b/Mobile/NUI/Sensor/.gitignore new file mode 100755 index 00000000..3c4efe20 --- /dev/null +++ b/Mobile/NUI/Sensor/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/Mobile/NUI/Sensor/LICENSE b/Mobile/NUI/Sensor/LICENSE new file mode 100755 index 00000000..51a2cd23 --- /dev/null +++ b/Mobile/NUI/Sensor/LICENSE @@ -0,0 +1,201 @@ + 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 2017 Samsung + + 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/Mobile/NUI/Sensor/README.md b/Mobile/NUI/Sensor/README.md new file mode 100755 index 00000000..e30bbc1d --- /dev/null +++ b/Mobile/NUI/Sensor/README.md @@ -0,0 +1,25 @@ +# Sensor +The Sensor sample application demonstrates how you can manage sensors and retrieve sensor data from various tizen sensor types, such as acceleration, device orientation and gravity sensor. +This sample is following Portable Class Libraries (PCL) application model and using some NUI Xaml features such as XAML files for GUI. + + + + + + + +
+
+
+
+
+ + +### Verified Version +* Tizen.NET : 10.0.0.17606 + +### Supported Profile +* Mobile + +### Author +* Guowei Wang(guowei.wang@samsung.com) diff --git a/Mobile/NUI/Sensor/Screenshots/Tizen/Accelerometer.png b/Mobile/NUI/Sensor/Screenshots/Tizen/Accelerometer.png new file mode 100755 index 00000000..5b4585d7 Binary files /dev/null and b/Mobile/NUI/Sensor/Screenshots/Tizen/Accelerometer.png differ diff --git a/Mobile/NUI/Sensor/Screenshots/Tizen/Main.png b/Mobile/NUI/Sensor/Screenshots/Tizen/Main.png new file mode 100755 index 00000000..0e10c44a Binary files /dev/null and b/Mobile/NUI/Sensor/Screenshots/Tizen/Main.png differ diff --git a/Mobile/NUI/Sensor/src/Sensor.sln b/Mobile/NUI/Sensor/src/Sensor.sln new file mode 100755 index 00000000..5e034c3f --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31229.75 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sensor.Tizen.Mobile", "Sensor\Sensor.Tizen.Mobile\Sensor.Tizen.Mobile.csproj", "{73243086-7137-4247-8349-DA0B80EF0F6D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {73243086-7137-4247-8349-DA0B80EF0F6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {73243086-7137-4247-8349-DA0B80EF0F6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73243086-7137-4247-8349-DA0B80EF0F6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {73243086-7137-4247-8349-DA0B80EF0F6D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F98B7925-D0AD-4FBD-9041-9AC9757AD495} + EndGlobalSection +EndGlobal diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Log.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Log.cs new file mode 100755 index 00000000..ce33dd99 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Log.cs @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using Sensor.Tizen.Mobile; +using System.Runtime.CompilerServices; + +namespace Sensor.Tizen.Mobile +{ + /// + /// Implementation class of ILog interface + /// + public class Log: ILog + { + /// + /// Log tag + /// + public static readonly string LogTag = "Sensor.Tizen.Mobile"; + + /// + /// Constructor of Log + /// + public Log() + { + } + + /// + /// Print a log message with error priority + /// + /// Log message + /// File name + /// Method name + /// Line Number + public void Error(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) + { + global::Tizen.Log.Error(LogTag, message, file, func, line); + } + + /// + /// Print a log message with info priority + /// + /// Log message + /// File name + /// Method name + /// Line Number + public void Info(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) + { + global::Tizen.Log.Info(LogTag, message, file, func, line); + } + + /// + /// Print a log message with debug priority + /// + /// Log message + /// File name + /// Method name + /// Line Number + public void Debug(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) + { + global::Tizen.Log.Debug(LogTag, message, file, func, line); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/PrivacyChecker.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/PrivacyChecker.cs new file mode 100755 index 00000000..b2583bcd --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/PrivacyChecker.cs @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using Sensor.Tizen.Mobile; +using System; +using Tizen.Security; + +namespace Sensor.Tizen.Mobile +{ + /// + /// Check the privacy privilege permission + /// + public static class PrivacyChecker + { + /// + /// Check whether the application has the specific permission or not. + /// + /// Privilege + public static void CheckPermission(string privilege) + { + try + { + CheckResult result = PrivacyPrivilegeManager.CheckPermission(privilege); + + switch (result) + { + case CheckResult.Allow: + break; + case CheckResult.Deny: + break; + case CheckResult.Ask: + // Request permission to user + PrivacyPrivilegeManager.RequestPermission(privilege); + break; + } + } + catch (Exception e) + { + global::Tizen.Log.Error(Log.LogTag, e.Message); + } + } + } +} + diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor - Backup.Tizen.Mobile.csproj b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor - Backup.Tizen.Mobile.csproj new file mode 100755 index 00000000..d5cebb05 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor - Backup.Tizen.Mobile.csproj @@ -0,0 +1,168 @@ + + + + Exe + netcoreapp3.1 + Sensor.Tizen.Mobile + 1 + true + + + + portable + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + + + + + + + + + + + + + + + + SensorMain.xaml + + + GravitySensorPage.xaml + + + GyroscopeRotationVectorSensorPage.xaml + + + MagnetometerRotationVectorSensorPage.xaml + + + diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor.Tizen.Mobile.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor.Tizen.Mobile.cs new file mode 100755 index 00000000..4c757d11 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor.Tizen.Mobile.cs @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ +using Sensor.Pages; +using System; +using System.Threading; +using Tizen.NUI; +using Tizen.NUI.Components; + +namespace Sensor.Tizen.Mobile +{ + class Program : NUIApplication + { + public static Window window; + public static Navigator navigator; + public static SensorManager sensorManager; + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + navigator.Push(new SensorMain()); + } + + void Initialize() + { + window = GetDefaultWindow(); + window.Title = "Sensor"; + window.KeyEvent += OnKeyEvent; + navigator = window.GetDefaultNavigator(); + sensorManager = new SensorManager(); + } + + public void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) + { + Exit(); + } + } + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor.Tizen.Mobile.csproj b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor.Tizen.Mobile.csproj new file mode 100755 index 00000000..6ebfe26f --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor.Tizen.Mobile.csproj @@ -0,0 +1,169 @@ + + + + Exe + netcoreapp3.1 + Sensor.Tizen.Mobile + 1 + true + + + + portable + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + + + + + + + + + + + + SensorMain.xaml + + + GravitySensorPage.xaml + + + GyroscopeRotationVectorSensorPage.xaml + + + MagnetometerRotationVectorSensorPage.xaml + + + diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ILog.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ILog.cs new file mode 100755 index 00000000..0ed4144a --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ILog.cs @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System.Runtime.CompilerServices; + +namespace Sensor +{ + /// + /// Interface to log a message + /// + public interface ILog + { + /// + /// Print a log message with error priority + /// + /// Log message + /// File name + /// Method name + /// Line Number + void Error(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0); + + /// + /// Print a log message with info priority + /// + /// Log message + /// File name + /// Method name + /// Line Number + void Info(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0); + + /// + /// Print a log message with debug priority + /// + /// Log message + /// File name + /// Method name + /// Line Number + void Debug(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0); + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ISensorAdapter.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ISensorAdapter.cs new file mode 100755 index 00000000..375a726b --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ISensorAdapter.cs @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; + +namespace Sensor +{ + /// + /// Interface to get information and control sensor. + /// + public interface ISensorAdapter + { + /// + /// Gets sensor information. + /// + /// Sensor information + SensorInfo GetSensorInfo(); + + /// + /// Starts sensor. + /// + /// Event handler to listen sensor events + void Start(EventHandler listener); + + /// + /// Stops sensor + /// + /// Event handler registered + void Stop(EventHandler listener); + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ISensorManager.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ISensorManager.cs new file mode 100755 index 00000000..cae17581 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/ISensorManager.cs @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; + +namespace Sensor +{ + /// + /// Interface to manage sensors. + /// + public interface ISensorManager + { + /// + /// Gets the supported sensor types on the current device. + /// + /// Supported sensor types + List GetSensorTypeList(); + + /// + /// Gets the specific sensor information. + /// + /// Sensor type + /// Sensor information + SensorInfo GetSensorInfo(string type); + + /// + /// Starts the sensor of the specific type. + /// + /// Sensor type + /// Event handler to listen sensor events + void StartSensor(string type, EventHandler listener); + + /// + /// Stops the sensor of the specific type. + /// + /// Sensor type + /// Event handler registered + void StopSensor(string type, EventHandler listener); + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/AccelerometerViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/AccelerometerViewModel.cs new file mode 100755 index 00000000..e5aceee5 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/AccelerometerViewModel.cs @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Accelerometer Data View Model + /// + public class AccelerometerViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/FaceDownGestureDetectorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/FaceDownGestureDetectorViewModel.cs new file mode 100755 index 00000000..3cd1e6d2 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/FaceDownGestureDetectorViewModel.cs @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System.ComponentModel; +using System.Runtime.CompilerServices; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Face Down Gesture Detector Data View Model + /// + public class FaceDownGestureDetectorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private DetectorState state = DetectorState.Unknown; + + /// + /// Updates face down state view with the new value. + /// + /// The face down state. + public DetectorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GravitySensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GravitySensorViewModel.cs new file mode 100755 index 00000000..5189e1dc --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GravitySensorViewModel.cs @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Gravity Sensor Data View Model + /// + public class GravitySensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GyroscopeRotationVectorSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GyroscopeRotationVectorSensorViewModel.cs new file mode 100755 index 00000000..a985a0fe --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GyroscopeRotationVectorSensorViewModel.cs @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Gyroscope Rotation Vector Sensor Data View Model + /// + public class GyroscopeRotationVectorSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + private float w = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + /// + /// Updates W value view with the new value. + /// + /// W + public float W + { + get { return w; } + set { w = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GyroscopeViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GyroscopeViewModel.cs new file mode 100755 index 00000000..c47b18e6 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/GyroscopeViewModel.cs @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Gyroscope Data View Model + /// + public class GyroscopeViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/HeartRateMonitorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/HeartRateMonitorViewModel.cs new file mode 100755 index 00000000..7cd342b8 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/HeartRateMonitorViewModel.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Heart Rate Monitor Data View Model + /// + public class HeartRateMonitorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float heartrate = 0.0f; + + /// + /// Updates heart rate value view with the new value. + /// + /// The heart rate. + public float HeartRate + { + get { return heartrate; } + set { heartrate = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/HumiditySensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/HumiditySensorViewModel.cs new file mode 100755 index 00000000..f9a048d3 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/HumiditySensorViewModel.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Humidity Sensor Data View Model + /// + public class HumiditySensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float humidity = 0.0f; + + /// + /// Updates humidity value view with the new value. + /// + /// The humidity. + public float Humidity + { + get { return humidity; } + set { humidity = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/InVehicleActivityDetectorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/InVehicleActivityDetectorViewModel.cs new file mode 100755 index 00000000..58149379 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/InVehicleActivityDetectorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The In Vehicle Actvity Detector Data View Model + /// + public class InVehicleActivityDetectorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private DetectorState state = DetectorState.Unknown; + + /// + /// Updates in vehicle state view with the new value. + /// + /// The in vehicle state. + public DetectorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/LightSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/LightSensorViewModel.cs new file mode 100755 index 00000000..cf1c22ef --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/LightSensorViewModel.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Light Sensor Data View Model + /// + public class LightSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float level = 0.0f; + + /// + /// Updates light level value view with the new value. + /// + /// The light level. + public float Level + { + get { return level; } + set { level = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/LinearAccelerationSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/LinearAccelerationSensorViewModel.cs new file mode 100755 index 00000000..e11d8dfd --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/LinearAccelerationSensorViewModel.cs @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Linear Acceleration Sensor Data View Model + /// + public class LinearAccelerationSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/MagnetometerRotationVectorSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/MagnetometerRotationVectorSensorViewModel.cs new file mode 100755 index 00000000..328fedad --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/MagnetometerRotationVectorSensorViewModel.cs @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Magnetometer Rotation Vector Sensor Data View Model + /// + public class MagnetometerRotationVectorSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + private float w = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + /// + /// Updates W value view with the new value. + /// + /// W + public float W + { + get { return w; } + set { w = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/MagnetometerViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/MagnetometerViewModel.cs new file mode 100755 index 00000000..fe1d2610 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/MagnetometerViewModel.cs @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Magnetometer Data View Model + /// + public class MagnetometerViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/OrientationSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/OrientationSensorViewModel.cs new file mode 100755 index 00000000..0c32de7f --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/OrientationSensorViewModel.cs @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Orientation Sensor Data View Model + /// + public class OrientationSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float azimuth = 0.0f; + private float pitch = 0.0f; + private float roll = 0.0f; + + /// + /// Updates azimuth value view with the new value. + /// + /// The azimuth + public float Azimuth + { + get { return azimuth; } + set { azimuth = value; RaisePropertyChanged(); } + } + + /// + /// Updates pitch value view with the new value. + /// + /// The pitch. + public float Pitch + { + get { return pitch; } + set { pitch = value; RaisePropertyChanged(); } + } + + /// + /// Updates roll value view with the new value. + /// + /// The roll. + public float Roll + { + get { return roll; } + set { roll = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PedometerViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PedometerViewModel.cs new file mode 100755 index 00000000..50b0af01 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PedometerViewModel.cs @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Pedometer Data View Model + /// + public class PedometerViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private uint stepCount = 0; + private uint walkStepCount = 0; + private uint runStepCount = 0; + private float movingDistance = 0.0f; + private float lastSpeed = 0.0f; + private float lastSteppingFrequency = 0.0f; + private PedometerState lastStepStatus = PedometerState.Unknown; + + /// + /// Updates step count value view with the new value. + /// + /// The step count. + public uint StepCount + { + get { return stepCount; } + set { stepCount = value; RaisePropertyChanged(); } + } + + /// + /// Updates walk step count value view with the new value. + /// + /// The walk step count. + public uint WalkStepCount + { + get { return walkStepCount; } + set { walkStepCount = value; RaisePropertyChanged(); } + } + + /// + /// Updates run step count value view with the new value. + /// + /// The run step count. + public uint RunStepCount + { + get { return runStepCount; } + set { runStepCount = value; RaisePropertyChanged(); } + } + + /// + /// Updates moving distance value view with the new value. + /// + /// The moving distance. + public float MovingDistance + { + get { return movingDistance; } + set { movingDistance = value; RaisePropertyChanged(); } + } + + /// + /// Updates last speed value view with the new value. + /// + /// The last speed. + public float LastSpeed + { + get { return lastSpeed; } + set { lastSpeed = value; RaisePropertyChanged(); } + } + + /// + /// Updates last stepping frequency value view with the new value. + /// + /// The last stepping frequency + public float LastSteppingFrequency + { + get { return lastSteppingFrequency; } + set { lastSteppingFrequency = value; RaisePropertyChanged(); } + } + + /// + /// Updates last step status value view with the new value. + /// + /// The last step status + public PedometerState LastStepStatus + { + get { return lastStepStatus; } + set { lastStepStatus = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PickUpGestureDetectorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PickUpGestureDetectorViewModel.cs new file mode 100755 index 00000000..dc576eb6 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PickUpGestureDetectorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The PickUp Gesture Detector Data View Model + /// + public class PickUpGestureDetectorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private DetectorState state = DetectorState.Unknown; + + /// + /// Updates pick up state view with the new value. + /// + /// The pick up state + public DetectorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PressureSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PressureSensorViewModel.cs new file mode 100755 index 00000000..8a69d28c --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/PressureSensorViewModel.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Pressure Sensor Data View Model + /// + public class PressureSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float pressure = 0.0f; + + /// + /// Updates pressure value view with the new value. + /// + /// The pressure. + public float Pressure + { + get { return pressure; } + set { pressure = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/ProximitySensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/ProximitySensorViewModel.cs new file mode 100755 index 00000000..ee29db3e --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/ProximitySensorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Proximity Data View Model + /// + public class ProximitySensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private ProximityState state = ProximityState.Unknown; + + /// + /// Updates proximity state view with the new value. + /// + /// The proximity state. + public ProximityState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/RotationVectorSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/RotationVectorSensorViewModel.cs new file mode 100755 index 00000000..6521bacc --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/RotationVectorSensorViewModel.cs @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Rotation Vector Sensor Data View Model + /// + public class RotationVectorSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + private float w = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + /// + /// Updates W value view with the new value. + /// + /// W + public float W + { + get { return w; } + set { w = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/RunningActivityDetectorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/RunningActivityDetectorViewModel.cs new file mode 100755 index 00000000..3a2e1f53 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/RunningActivityDetectorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Running Activity Detector Data View Model + /// + public class RunningActivityDetectorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private DetectorState state = DetectorState.Unknown; + + /// + /// Updates running state view with the new value. + /// + /// The running state. + public DetectorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/SleepMonitorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/SleepMonitorViewModel.cs new file mode 100755 index 00000000..18e7bb47 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/SleepMonitorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Sleep Monitor Data View Model + /// + public class SleepMonitorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private SleepMonitorState state = SleepMonitorState.Unknown; + + /// + /// Updates sleep state view with the new value. + /// + /// The sleep state. + public SleepMonitorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/StationaryActivityDetectorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/StationaryActivityDetectorViewModel.cs new file mode 100755 index 00000000..ad619dcc --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/StationaryActivityDetectorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Stationary Activity Detector Data View Model + /// + public class StationaryActivityDetectorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private DetectorState state = DetectorState.Unknown; + + /// + /// Updates stationary state view with the new value. + /// + /// The stationary state. + public DetectorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/TemperatureSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/TemperatureSensorViewModel.cs new file mode 100755 index 00000000..f0bcb259 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/TemperatureSensorViewModel.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Temperature Sensor Data View Model + /// + public class TemperatureSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float temperature = 0.0f; + + /// + /// Updates temperature value view with the new value. + /// + /// The temperature. + public float Temperature + { + get { return temperature; } + set { temperature = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UltravioletSensorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UltravioletSensorViewModel.cs new file mode 100755 index 00000000..49018915 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UltravioletSensorViewModel.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Ultraviolet Sensor Data View Model + /// + public class UltravioletSensorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float index = 0.0f; + + /// + /// Updates ultraviolet index value view with the new value. + /// + /// The ultraviolet index. + public float Index + { + get { return index; } + set { index = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UncalibratedGyroscopeViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UncalibratedGyroscopeViewModel.cs new file mode 100755 index 00000000..d724669e --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UncalibratedGyroscopeViewModel.cs @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Uncalibrated Gyroscope Data View Model + /// + public class UncalibratedGyroscopeViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UncalibratedMagnetometerViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UncalibratedMagnetometerViewModel.cs new file mode 100755 index 00000000..ddf99b63 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/UncalibratedMagnetometerViewModel.cs @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Sensor.Models +{ + /// + /// The Uncalibrated Magnetometer Data View Model + /// + public class UncalibratedMagnetometerViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private float x = 0.0f; + private float y = 0.0f; + private float z = 0.0f; + + /// + /// Updates X value view with the new value. + /// + /// X + public float X + { + get { return x; } + set { x = value; RaisePropertyChanged(); } + } + + /// + /// Updates Y value view with the new value. + /// + /// Y + public float Y + { + get { return y; } + set { y = value; RaisePropertyChanged(); } + } + + /// + /// Updates Z value view with the new value. + /// + /// Z + public float Z + { + get { return z; } + set { z = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/WalkingActivityDetectorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/WalkingActivityDetectorViewModel.cs new file mode 100755 index 00000000..2d315031 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/WalkingActivityDetectorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Walking Activity Detector Data View Model + /// + public class WalkingActivityDetectorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private DetectorState state = DetectorState.Unknown; + + /// + /// Updates walking state view with the new value. + /// + /// The walking state. + public DetectorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/WristUpGestureDetectorViewModel.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/WristUpGestureDetectorViewModel.cs new file mode 100755 index 00000000..6c61e31e --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Models/WristUpGestureDetectorViewModel.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text; +using static Sensor.SensorEventArgs; + +namespace Sensor.Models +{ + /// + /// The Wrist Up Gesture Detector Data View Model + /// + public class WristUpGestureDetectorViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private DetectorState state = DetectorState.Unknown; + + /// + /// Updates wrist up state view with the new value. + /// + /// The wrist up state. + public DetectorState State + { + get { return state; } + set { state = value; RaisePropertyChanged(); } + } + + public void RaisePropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorMain.xaml b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorMain.xaml new file mode 100755 index 00000000..5b721f43 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorMain.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorMain.xaml.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorMain.xaml.cs new file mode 100755 index 00000000..43c02d2d --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorMain.xaml.cs @@ -0,0 +1,270 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Tizen.NUI; +using Tizen.NUI.Components; +using Sensor.Tizen.Mobile; +using System.ComponentModel; + +namespace Sensor.Pages +{ + public class ItemClass : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + private void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + public ItemClass(string type, Color itemColor) + { + Text = type; + BgColor = itemColor; + } + + string text; + public string Text + { + get => text; + set + { + text = value; + OnPropertyChanged("Text"); + } + } + + Color color; + public Color BgColor + { + get => color; + set { color = value; OnPropertyChanged("BgColor"); } + } + } + + public class ViewModel + { + public ObservableCollection Items { get; private set; } + public ViewModel() + { + Items = new ObservableCollection(); + + List types = new SensorManager().GetSensorTypeList(); + global::Tizen.Log.Info("Sensor", "types count : " + types.Count); + + int i = 0; + foreach (var type in types) + { + global::Tizen.Log.Info("Sensor", "type : " + type); + + if (i % 2 == 0) + { + Items.Add(new ItemClass(type, new Color(0.0f, 0.0f, 0.0f, 0.0f))); + } + else + { + Items.Add(new ItemClass(type, new Color(0.0f, 0.0f, 0.0f, 0.02f))); + } + + i++; + } + } + } + + /// + /// Main Content Page with the supported sensor list on the current device. + /// + public partial class SensorMain : ContentPage + { + SensorManager sensorManager = new SensorManager(); + + public ObservableCollection Items { get; set; } + + /// + /// The constructor of SensorMain. + /// + public SensorMain() + { + InitializeComponent(); + BindingContext = new ViewModel(); + } + + /// + /// This method will be called when a list item is selected. + /// + /// Event sender + /// Event arguments + void OnItemSelected(object sender, SelectionChangedEventArgs e) + { + List cur = new List(e.CurrentSelection); + + foreach (ItemClass item in e.PreviousSelection) + { + if (cur.Contains(item)) continue; + + } + foreach (ItemClass item in cur) + { + SensorInfo info = sensorManager.GetSensorInfo((cur[0] as ItemClass).Text); + OpenSensorPage(info); + } + } + + /// + /// Opens specific sensor page. + /// + /// Sensor information + public void OpenSensorPage(SensorInfo info) + { + if (info.Type == SensorTypes.AccelerometerType) + { + Program.navigator.Push(new AccelerometerPage(info)); + } + + if (info.Type == SensorTypes.FaceDownGestureDetectorType) + { + Program.navigator.Push(new FaceDownGestureDetectorPage(info)); + } + + if (info.Type == SensorTypes.GravitySensorType) + { + Program.navigator.Push(new GravitySensorPage(info)); + } + + if (info.Type == SensorTypes.GyroscopeType) + { + Program.navigator.Push(new GyroscopePage(info)); + } + + if (info.Type == SensorTypes.GyroscopeRotationVectorType) + { + Program.navigator.Push(new GyroscopeRotationVectorSensorPage(info)); + } + + if (info.Type == SensorTypes.HeartRateMonitorType) + { + Program.navigator.Push(new HeartRateMonitorPage(info)); + } + + if (info.Type == SensorTypes.HumiditySensorType) + { + Program.navigator.Push(new HumiditySensorPage(info)); + } + + if (info.Type == SensorTypes.InVehicleActivityDetectorType) + { + Program.navigator.Push(new InVehicleActivityDetectorPage(info)); + } + + if (info.Type == SensorTypes.LightSensorType) + { + Program.navigator.Push(new LightSensorPage(info)); + } + + if (info.Type == SensorTypes.LinearAccelerationSensorType) + { + Program.navigator.Push(new LinearAccelerationSensorPage(info)); + } + + if (info.Type == SensorTypes.MagnetometerType) + { + Program.navigator.Push(new MagnetometerPage(info)); + } + + if (info.Type == SensorTypes.MagnetometerRotationVectorType) + { + Program.navigator.Push(new MagnetometerRotationVectorSensorPage(info)); + } + + if (info.Type == SensorTypes.OrientationSensorType) + { + Program.navigator.Push(new OrientationSensorPage(info)); + } + + if (info.Type == SensorTypes.PedometerType) + { + Program.navigator.Push(new PedometerPage(info)); + } + + if (info.Type == SensorTypes.PickUpGestureDetectorType) + { + Program.navigator.Push(new PickUpGestureDetectorPage(info)); + } + + if (info.Type == SensorTypes.PressureSensorType) + { + Program.navigator.Push(new PressureSensorPage(info)); + } + + if (info.Type == SensorTypes.ProximitySensorType) + { + Program.navigator.Push(new ProximitySensorPage(info)); + } + + if (info.Type == SensorTypes.RotationVectorSensorType) + { + Program.navigator.Push(new RotationVectorSensorPage(info)); + } + + if (info.Type == SensorTypes.RunningActivityDetectorType) + { + Program.navigator.Push(new RunningActivityDetectorPage(info)); + } + + if (info.Type == SensorTypes.SleepMonitorType) + { + Program.navigator.Push(new SleepMonitorPage(info)); + } + + if (info.Type == SensorTypes.StationaryActivityDetectorType) + { + Program.navigator.Push(new StationaryActivityDetectorPage(info)); + } + + if (info.Type == SensorTypes.TemperatureSensorType) + { + Program.navigator.Push(new TemperatureSensorPage(info)); + } + + if (info.Type == SensorTypes.UltravioletSensorType) + { + Program.navigator.Push(new UltravioletSensorPage(info)); + } + + if (info.Type == SensorTypes.UncalibratedGyroscopeType) + { + Program.navigator.Push(new UncalibratedGyroscopePage(info)); + } + + if (info.Type == SensorTypes.UncalibratedMagnetometerType) + { + Program.navigator.Push(new UncalibratedMagnetometerPage(info)); + } + + if (info.Type == SensorTypes.WalkingActivityDetectorType) + { + Program.navigator.Push(new WalkingActivityDetectorPage(info)); + } + + if (info.Type == SensorTypes.WristUpGestureDetectorType) + { + Program.navigator.Push(new WristUpGestureDetectorPage(info)); + } + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorManager.cs b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorManager.cs new file mode 100755 index 00000000..b29ecf33 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/SensorManager.cs @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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. +*/ + +using Sensor.Tizen.Mobile; +using Sensor.Tizen.Mobile.Sensors; +using System; +using System.Collections.Generic; +using Tizen.Sensor; +using Tizen.NUI.Binding; + +namespace Sensor.Tizen.Mobile +{ + /// + /// SensorManager Implementation class + /// + public class SensorManager : ISensorManager + { + private static Dictionary sensorList = new Dictionary(); + + /// + /// Initialize sensor list. + /// + private void Initialize() + { + if (Accelerometer.IsSupported) + { + sensorList.Add(SensorTypes.AccelerometerType, new AccelerometerAdapter()); + } + + if (FaceDownGestureDetector.IsSupported) + { + sensorList.Add(SensorTypes.FaceDownGestureDetectorType, new FaceDownGestureDetectorAdapter()); + } + + if (GravitySensor.IsSupported) + { + sensorList.Add(SensorTypes.GravitySensorType, new GravitySensorAdapter()); + } + + if (Gyroscope.IsSupported) + { + sensorList.Add(SensorTypes.GyroscopeType, new GyroscopeAdapter()); + } + + if (GyroscopeRotationVectorSensor.IsSupported) + { + sensorList.Add(SensorTypes.GyroscopeRotationVectorType, new GyroscopeRotationVectorSensorAdapter()); + } + + if (HeartRateMonitor.IsSupported) + { + sensorList.Add(SensorTypes.HeartRateMonitorType, new HeartRateMonitorAdapter()); + } + + if (HumiditySensor.IsSupported) + { + sensorList.Add(SensorTypes.HumiditySensorType, new HumiditySensorAdapter()); + } + + if (InVehicleActivityDetector.IsSupported) + { + sensorList.Add(SensorTypes.InVehicleActivityDetectorType, new InVehicleActivityDetectorAdapter()); + } + + if (LightSensor.IsSupported) + { + sensorList.Add(SensorTypes.LightSensorType, new LightSensorAdapter()); + } + + if (LinearAccelerationSensor.IsSupported) + { + sensorList.Add(SensorTypes.LinearAccelerationSensorType, new LinearAccelerationSensorAdapter()); + } + + if (Magnetometer.IsSupported) + { + sensorList.Add(SensorTypes.MagnetometerType, new MagnetometerAdapter()); + } + + if (MagnetometerRotationVectorSensor.IsSupported) + { + sensorList.Add(SensorTypes.MagnetometerRotationVectorType, new MagnetometerRotationVectorSensorAdapter()); + } + + if (OrientationSensor.IsSupported) + { + sensorList.Add(SensorTypes.OrientationSensorType, new OrientationSensorAdapter()); + } + + if (Pedometer.IsSupported) + { + sensorList.Add(SensorTypes.PedometerType, new PedometerAdapter()); + } + + if (PickUpGestureDetector.IsSupported) + { + sensorList.Add(SensorTypes.PickUpGestureDetectorType, new PickUpGestureDetectorAdapter()); + } + + if (PressureSensor.IsSupported) + { + sensorList.Add(SensorTypes.PressureSensorType, new PressureSensorAdapter()); + } + + if (ProximitySensor.IsSupported) + { + sensorList.Add(SensorTypes.ProximitySensorType, new ProximitySensorAdapter()); + } + + if (RotationVectorSensor.IsSupported) + { + sensorList.Add(SensorTypes.RotationVectorSensorType, new RotationVectorSensorAdapter()); + } + + if (RunningActivityDetector.IsSupported) + { + sensorList.Add(SensorTypes.RunningActivityDetectorType, new RunningActivityDetectorAdapter()); + } + + if (SleepMonitor.IsSupported) + { + sensorList.Add(SensorTypes.SleepMonitorType, new SleepMonitorAdapter()); + } + + if (StationaryActivityDetector.IsSupported) + { + sensorList.Add(SensorTypes.StationaryActivityDetectorType, new StationaryActivityDetectorAdapter()); + } + + if (TemperatureSensor.IsSupported) + { + sensorList.Add(SensorTypes.TemperatureSensorType, new TemperatureSensorAdapter()); + } + + if (UltravioletSensor.IsSupported) + { + sensorList.Add(SensorTypes.UltravioletSensorType, new UltravioletSensorAdapter()); + } + + if (UncalibratedGyroscope.IsSupported) + { + sensorList.Add(SensorTypes.UncalibratedGyroscopeType, new UncalibratedGyroscopeAdapter()); + } + + if (UncalibratedMagnetometer.IsSupported) + { + sensorList.Add(SensorTypes.UncalibratedMagnetometerType, new UncalibratedMagnetometerAdapter()); + } + + if (WalkingActivityDetector.IsSupported) + { + sensorList.Add(SensorTypes.WalkingActivityDetectorType, new WalkingActivityDetectorAdapter()); + } + + if (WristUpGestureDetector.IsSupported) + { + sensorList.Add(SensorTypes.WristUpGestureDetectorType, new WristUpGestureDetectorAdapter()); + } + } + + /// + /// Gets supported sensor types on the current device. + /// + /// Sensor types + public List GetSensorTypeList() + { + List sensorTypeList = new List(); + + PrivacyChecker.CheckPermission("http://tizen.org/privilege/healthinfo"); + + Initialize(); + + foreach (var sensor in sensorList) + { + sensorTypeList.Add(sensor.Key); + } + + return sensorTypeList; + } + + /// + /// Gets sensor information. + /// + /// Sensor type + /// Sensor Information + public SensorInfo GetSensorInfo(string type) + { + return sensorList[type].GetSensorInfo(); + } + + /// + /// Start sensor. + /// + /// Sensor type + /// Event handler + public void StartSensor(string type, EventHandler listener) + { + global::Tizen.Log.Error("Sensor", "type : " + type); + sensorList[type].Start(listener); + } + + /// + /// Stop sensor. + /// + /// Sensor type + /// Event handler + public void StopSensor(string type, EventHandler listener) + { + sensorList[type].Stop(listener); + } + } +} diff --git a/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/Sensors/AccelerometerPage.xaml b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/Sensors/AccelerometerPage.xaml new file mode 100755 index 00000000..15c7ff14 --- /dev/null +++ b/Mobile/NUI/Sensor/src/Sensor/Sensor.Tizen.Mobile/Sensor/Pages/Sensors/AccelerometerPage.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +