DebouncedDataTypeCondition


class DebouncedDataTypeCondition<T : Number, D : DataType<T, DataPoint<T>>>


A condition which is considered met when a data type value passes a defined threshold for a specified duration.

Summary

Public companion functions

DebouncedDataTypeCondition<T, D>
<T : Number, D : AggregateDataType<T, StatisticalDataPoint<T>>> createDebouncedDataTypeCondition(
    dataType: D,
    threshold: T,
    comparisonType: ComparisonType,
    initialDelaySeconds: Int,
    durationAtThresholdSeconds: Int
)

Creates a DebouncedDataTypeCondition for an aggregate data type, whose value represents an average value, e.g. average heart rate over the tracking period, average speed over the tracking period.

DebouncedDataTypeCondition<T, D>
<T : Number, D : DeltaDataType<T, SampleDataPoint<T>>> createDebouncedDataTypeCondition(
    dataType: D,
    threshold: T,
    comparisonType: ComparisonType,
    initialDelaySeconds: Int,
    durationAtThresholdSeconds: Int
)

Creates a DebouncedDataTypeCondition for a sample data type, whose value represents an instantaneous value, e.g. instantaneous heart rate, instantaneous speed.

Public functions

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

ComparisonType

The comparison type to use when comparing the threshold against the current value.

D

DataType which this condition applies to.

Int

The amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger.

Int

The amount of time (in seconds) that must pass before the goal can trigger.

T

The threshold at which point this condition should be met.

Public companion functions

createDebouncedDataTypeCondition

fun <T : Number, D : AggregateDataType<T, StatisticalDataPoint<T>>> createDebouncedDataTypeCondition(
    dataType: D,
    threshold: T,
    comparisonType: ComparisonType,
    initialDelaySeconds: Int,
    durationAtThresholdSeconds: Int
): DebouncedDataTypeCondition<T, D>

Creates a DebouncedDataTypeCondition for an aggregate data type, whose value represents an average value, e.g. average heart rate over the tracking period, average speed over the tracking period.

Parameters
dataType: D

an aggregate data type that is associated with StatisticalDataPoints, and whose value represents an average value over the tracking period

threshold: T

the threshold for the value of this data type to cross in order to satisfy the condition

comparisonType: ComparisonType

the way that determines how to compare the value of the data type with the threshold in the condition, e.g. greater than, less than or equal

initialDelaySeconds: Int

the amount of time (in seconds) that must pass before the goal can trigger. Must be greater or equal to zero

durationAtThresholdSeconds: Int

the amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. Must be greater or equal to zero

createDebouncedDataTypeCondition

fun <T : Number, D : DeltaDataType<T, SampleDataPoint<T>>> createDebouncedDataTypeCondition(
    dataType: D,
    threshold: T,
    comparisonType: ComparisonType,
    initialDelaySeconds: Int,
    durationAtThresholdSeconds: Int
): DebouncedDataTypeCondition<T, D>

Creates a DebouncedDataTypeCondition for a sample data type, whose value represents an instantaneous value, e.g. instantaneous heart rate, instantaneous speed.

Parameters
dataType: D

a delta data type that is associated with SampleDataPoints, and whose value represents an instantaneous value

threshold: T

the threshold for the value of this data type to cross in order to satisfy the condition

comparisonType: ComparisonType

the way that determines how to compare the value of the data type with the threshold in the condition, e.g. greater than, less than or equal

initialDelaySeconds: Int

the amount of time (in seconds) that must pass before the goal can trigger. Must be greater or equal to zero

durationAtThresholdSeconds: Int

the amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. Must be greater or equal to zero

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

comparisonType

Added in 1.1.0-alpha04
val comparisonTypeComparisonType

The comparison type to use when comparing the threshold against the current value.

dataType

Added in 1.1.0-alpha04
val dataType: D

DataType which this condition applies to.

durationAtThresholdSeconds

Added in 1.1.0-alpha04
val durationAtThresholdSecondsInt

The amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. Applicable only for sample data types.

Each time the value moves off threshold will reset durationAtThresholdSec timer. For example: For a DebouncedDataTypeCondition(HeartRate, threshold=100.00, GREATER_THAN_OR_EQUAL, initialDelaySec=60, durationAtThresholdSec=10). If user HeartRate fluctuates around 100.00bpm in the following pattern,

  1. from t=0s to t=56s: HeartRate=100

  2. at t=57s: HeartRate=99.99

  3. from t=58s: HeartRate=100.00. Then the condition will be met on t=68s, since the durationAtThreshold timer has reset at t=57s and expired at t=68s, and the initialDelay timer has expired at t=60s.

The default value is 0, which means once reached threshold, trigger immediately (if initialDelay has expired).

initialDelaySeconds

Added in 1.1.0-alpha04
val initialDelaySecondsInt

The amount of time (in seconds) that must pass before the goal can trigger. Applicable only for sample data types.

Example 1: For a DebouncedDataTypeCondition(HeartRate, threshold=100.00, GREATER_THAN_OR_EQUAL, initialDelaySec=60, durationAtThresholdSec=10). If user HeartRate stays above 100.00bpm from t=0s, then the condition will be met on t=60s, since this is when the value has exceeded threshold for consecutively 10 seconds and the 60 seconds of initialDelay has expired.

Example 2: For a DebouncedDataTypeCondition(HeartRate, threshold=100.00, GREATER_THAN_OR_EQUAL, initialDelaySec=5, durationAtThresholdSec=10). If user HeartRate stays above 100.00bpm from t=0s, then the condition will be met on t=10s, since this is when the value has exceeded threshold for consecutively 10 seconds and the 5 seconds of initialDelay has expired.

The default value is 0, which means trigger whenever the goal has reached threshold, or has reached threshold for a specified durationAtThreshold.

threshold

Added in 1.1.0-alpha04
val threshold: T

The threshold at which point this condition should be met.