/// <summary>
        /// Calculates distance travelled in m.
        /// </summary>
        /// <param name="message1">The most recent WheelTorqueDataPage message recieved.</param>
        /// <param name="message2">The second most recent WheelTorqueDataPage message recieved.
        /// </param>
        /// <param name="circumference">The circumference of the bicycle wheel, in m.</param>
        /// <returns>The distance travelled in m.</returns>
        public static float CalculateDistance(WheelTorqueDataPage message1, WheelTorqueDataPage message2, float circumference)
        {
            // See ANT+ Device Profile - Bicycle Power, page 37 (ver. 4.2)
            // https://www.thisisant.com/resources/bicycle-power/

            return(circumference * AntUtilFunctions.rolloverDiff(message1.WheelTicks, message2.WheelTicks));
        }
        /// <summary>
        /// Calculates the average power in W.
        ///
        /// Under normal conditions with complete RF reception, average power equals instantaneous
        /// power. In conditions where packets are lost, average power accurately calculates power
        /// over the interval between the received messages.
        /// </summary>
        /// <param name="message1">The most recent WheelTorqueDataPage message recieved.</param>
        /// <param name="message2">The second most recent WheelTorqueDataPage message recieved.
        /// </param>
        /// <returns>The average power in W.</returns>
        public static float CalculateAvgPower(PowerOnlyDataPage message1, PowerOnlyDataPage message2)
        {
            // See ANT+ Device Profile - Bicycle Power, page 33 (ver. 4.2)
            // https://www.thisisant.com/resources/bicycle-power/

            return(AntUtilFunctions.rolloverDiff(message1.AccumulatedPower, message2.AccumulatedPower) /
                   ((float)AntUtilFunctions.rolloverDiff(message1.UpdateEventCount, message2.UpdateEventCount)));
        }
        /// <summary>
        /// Calculates the average speed in m/s.
        /// </summary>
        /// <param name="message1">The most recent WheelTorqueDataPage message recieved.</param>
        /// <param name="message2">The second most recent WheelTorqueDataPage message recieved.
        /// </param>
        /// <param name="circumference">The circumference of the bicycle wheel, in m.</param>
        /// <returns>The average linear speed of the bike in m/s.</returns>
        public static float CalculateAvgSpeed(WheelTorqueDataPage message1, WheelTorqueDataPage message2, float circumference)
        {
            // See ANT+ Device Profile - Bicycle Power, page 36 (ver. 4.2)
            // https://www.thisisant.com/resources/bicycle-power/

            return(circumference * AntUtilFunctions.rolloverDiff(message1.UpdateEventCount, message2.UpdateEventCount) /
                   (AntUtilFunctions.rolloverDiff(message1.WheelPeriod, message2.WheelPeriod) / 2048f));
        }
예제 #4
0
        /// <summary>
        /// Builds the <see cref="dataPageDictionary"/>, mapping from data page numbers to their
        /// respective data page types.
        /// </summary>
        /// <returns></returns>
        private static Dictionary <byte, Type> BuildDataPageDictionary()
        {
            Dictionary <byte, Type> dataPageDictionary = new Dictionary <byte, Type>();

            foreach (Type dataPageType in AntUtilFunctions.GetEnumerableOfType <DataPage>())
            {
                if (dataPageType != typeof(GenericDataPage))
                {
                    dataPageDictionary.Add(GetNewDataPageInstanceFromType(dataPageType).DataPageNumber, dataPageType);
                }
            }

            return(dataPageDictionary);
        }