Sport.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*******************************************************************************
  2. Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
  3. NOTICE:All information contained herein is, and remains the property of
  4. PICO Technology Co., Ltd. The intellectual and technical concepts
  5. contained herein are proprietary to PICO Technology Co., Ltd. and may be
  6. covered by patents, patents in process, and are protected by trade secret or
  7. copyright law. Dissemination of this information or reproduction of this
  8. material is strictly forbidden unless prior written permission is obtained from
  9. PICO Technology Co., Ltd.
  10. *******************************************************************************/
  11. using System;
  12. using Pico.Platform.Models;
  13. using UnityEngine;
  14. namespace Pico.Platform
  15. {
  16. /**
  17. * \ingroup Platform
  18. *
  19. * SportService provides multiple APIs for you to access
  20. * users' exercise data from the built-in PICO app — PICO Fitness.
  21. * When users are working out with PICO VR headsets, the app records
  22. * their exercise data, including exercise duration, calories burned,
  23. * exercise plan, preferences, and more.
  24. * With the APIs provided by the service, you can gather data to
  25. * understand the exercise habits of individuals, thereby providing
  26. * users with a better exercise experience.
  27. */
  28. public static class SportService
  29. {
  30. /// <summary>
  31. /// Gets a user's basic information and exercise plan.
  32. /// </summary>
  33. /// <returns>The \ref Pico.Platform.Models.SportUserInfo class containing the following:
  34. /// * `Gender`
  35. /// * `Birthday`
  36. /// * `Stature`: The natural height in centimeters.
  37. /// * `Weight`: The weight in kilograms.
  38. /// * `SportLevel`: `1`-low; `2`-medium; `3`-high.
  39. /// * `DailyDurationInMinutes`: The planned daily exercise duration (in minutes).
  40. /// * `DaysPerWeek`: The planned days for exercise per week.
  41. /// * `SportTarget`: "lose weight" or "stay healthy".
  42. /// </returns>
  43. public static Task<SportUserInfo> GetUserInfo()
  44. {
  45. if (!CoreService.Initialized)
  46. {
  47. Debug.LogError(CoreService.NotInitializedError);
  48. return null;
  49. }
  50. return new Task<SportUserInfo>(CLIB.ppf_Sport_GetUserInfo());
  51. }
  52. /// <summary>
  53. /// Gets a summary of the user's daily exercise data for a specified period within the recent 90 days.
  54. /// For example, if the period you set is between 2022/08/16 and 2022/08/18, the exercise data generated on 08/16, 08/17, and 08/18 will be returned.
  55. /// </summary>
  56. /// <param name="beginTime">A DateTime struct defining the begin time of the period. The begin time should be no earlier than 90 days before the current time.</param>
  57. /// <param name="endTime">A DateTime struct defining the end time of the period, .</param>
  58. /// <returns>The \ref Pico.Platform.Models.SportDailySummaryList class containing the exercise data generated on each day within the specified period, including:
  59. /// * `Id`: Summary ID.
  60. /// * `Date`: The date when the data was generated.
  61. /// * `DurationInSeconds`: The actual daily exercise duration in seconds.
  62. /// * `PlanDurationInMinutes`: The planned daily exercise duration in minutes.
  63. /// * `Calorie`: The actual daily calorie burned.
  64. /// * `PlanCalorie`: The planned daily calorie to burn.
  65. /// </returns>
  66. public static Task<SportDailySummaryList> GetDailySummary(DateTime beginTime, DateTime endTime)
  67. {
  68. if (!CoreService.Initialized)
  69. {
  70. Debug.LogError(CoreService.NotInitializedError);
  71. return null;
  72. }
  73. return new Task<SportDailySummaryList>(CLIB.ppf_Sport_GetDailySummary(TimeUtil.DateTimeToMilliSeconds(beginTime), TimeUtil.DateTimeToMilliSeconds(endTime)));
  74. }
  75. /// <summary>
  76. /// Get a summary of the user's exercise data for a specified period within
  77. /// the recent 24 hours. The period should not exceed 24 hours.
  78. /// </summary>
  79. /// <param name="beginTime">A DateTime struct defining the begin time of the period. The begin time should be no earlier than 24 hours before the current time.</param>
  80. /// <param name="endTime">A DateTime struct defining the end time of the period.</param>
  81. /// <returns>The \ref Pico.Platform.Models.SportSummary class containing the following:
  82. /// * `DurationInSeconds`: The actual exercise duration.
  83. /// * `Calorie`: The actual calorie burned.
  84. /// * `StartTime`: The start time you defined.
  85. /// * `EndTime`: The end time you defined.
  86. /// </returns>
  87. public static Task<SportSummary> GetSummary(DateTime beginTime, DateTime endTime)
  88. {
  89. if (!CoreService.Initialized)
  90. {
  91. Debug.LogError(CoreService.NotInitializedError);
  92. return null;
  93. }
  94. return new Task<SportSummary>(CLIB.ppf_Sport_GetSummary(TimeUtil.DateTimeToMilliSeconds(beginTime), TimeUtil.DateTimeToMilliSeconds(endTime)));
  95. }
  96. }
  97. }
粤ICP备19079148号