Esempio n. 1
0
        /*! @brief				The default constructor.
         *      @param xmlString	the XML string to create this object from.
         */
        public HealthData(string xmlString)
        {
            xml = new XmlDocument();
            xml.LoadXml(xmlString);

            XmlNode node = xml.FirstChild["datatype"];

            if (node != null && node.InnerText != null)
            {
                this.datatype = (HKDataType)System.Enum.Parse(typeof(HKDataType), (string)node.InnerText);
            }
            else
            {
                Debug.LogError("datatype node is missing or invalid");
            }

            if (this.datatype == HKDataType.HKWorkoutTypeIdentifier)
            {
                node = xml.FirstChild["workoutType"];
                if (node != null && node.InnerText != null)
                {
                    this.workoutType = (WorkoutActivityType)Enum.ToObject(typeof(WorkoutActivityType), node.InnerText);
                }
                else
                {
                    Debug.LogError("workoutType node is missing or invalid");
                }
            }
        }
Esempio n. 2
0
 private void ReadWorkout(WorkoutActivityType activityType, DateTimeOffset startDate, DateTimeOffset endDate, bool combineSamples)
 {
     if (this.IsHealthDataAvailable())
     {
         int identifier = (int)activityType;
         _ReadWorkout(identifier, DateTimeBridge.DateToString(startDate), DateTimeBridge.DateToString(endDate), combineSamples);
     }
     else
     {
         Debug.LogError("Error: no health data is available. Are you running on an iOS device that supports HealthKit?");
     }
 }
Esempio n. 3
0
 /*! @brief              Write a workout sample.
  *      @details
  *      @param activityType	The workout activity type to write.
  *      @param startDate	The starting date of the sample to write.
  *      @param endDate		The ending date of the sample to write.
  *      @param calories		The kilocalories burned during the activity
  *      @param distance		The distance traveled during the activity (for e.g. running)
  *      @param handler		Called when the function finishes executing.
  */
 public void WriteWorkoutSample(WorkoutActivityType activityType, DateTimeOffset startDate, DateTimeOffset endDate, double calories, double distance, WroteSample handler)
 {
     this.wroteSampleHandlers[HKDataType.HKWorkoutTypeIdentifier] = handler;
     if (this.IsHealthDataAvailable())
     {
         int identifier = (int)activityType;
         _WriteWorkout(identifier, DateTimeBridge.DateToString(startDate), DateTimeBridge.DateToString(endDate), calories, distance);
     }
     else
     {
         Debug.LogError("Error: no health data is available. Are you running on an iOS device that supports HealthKit?");
     }
 }
Esempio n. 4
0
        public List <WorkoutEvent> workoutEvents;       /*!< @brief workout events contained in this sample */

        /*! @brief		The default constructor.
         *      @param node	the XmlNode to create this object from.
         */
        public WorkoutSample(XmlNode node) : base(node)
        {
            this.duration          = Int32.Parse(node["duration"].InnerText);
            this.totalDistance     = new Quantity(node["totalDistance"]);
            this.totalEnergyBurned = new Quantity(node["energyBurned"]);
            this.activityType      = (WorkoutActivityType)Int32.Parse(node["activityType"].InnerText);

            this.workoutEvents = new List <WorkoutEvent>();
            XmlNodeList eventNodes = node.SelectNodes("events");

            foreach (XmlNode sample in eventNodes)
            {
                this.workoutEvents.Add(new WorkoutEvent(sample));
            }
        }
Esempio n. 5
0
        // Workout types

        /*! @brief              Read workout samples & return a list of WorkoutSamples.
         *      @details
         *      @param activityType	The activity type to read.
         *      @param startDate	The date to start reading samples from.
         *      @param endDate		The end date to limit samples to.
         *      @param handler		Called when the function finishes executing.
         */
        public void ReadWorkoutSamples(WorkoutActivityType activityType, DateTimeOffset startDate, DateTimeOffset endDate, ReceivedWorkoutSamples handler)
        {
            this.receivedWorkoutSamplesHandlers[activityType] = handler;
            ReadWorkout(activityType, startDate, endDate, false);
        }