All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.dk.cachet.carp.common.application.sampling.AdaptiveGranularitySampling.kt Maven / Gradle / Ivy

Go to download

Helper classes and base types relied upon by all subsystems. This library does not contain any domain logic.

The newest version!
@file:Suppress( "MatchingDeclarationName" )

package dk.cachet.carp.common.application.sampling

import dk.cachet.carp.common.application.data.DataTypeMetaData
import dk.cachet.carp.common.application.devices.DeviceConfiguration
import kotlin.js.JsExport


/**
 * Sampling scheme which provides only indirect control over how data is sampled by specifying a desired level of [Granularity].
 * The levels of granularity correspond to expected degrees of power consumption.
 * By default, [Granularity.Balanced] is used; when the battery is low, [Granularity.Coarse]; when battery is critically low, sampling stops.
 */
@JsExport
class AdaptiveGranularitySamplingScheme( dataType: DataTypeMetaData ) :
    BatteryAwareSamplingScheme(
        dataType,
        { GranularitySamplingConfigurationBuilder( Granularity.Balanced ) },
        normal = GranularitySamplingConfiguration( Granularity.Balanced ),
        low = GranularitySamplingConfiguration( Granularity.Coarse )
    )
{
    override fun isValidBatteryLevelConfiguration( configuration: GranularitySamplingConfiguration ): Boolean = true
}

/**
 * A helper class to configure and construct immutable [BatteryAwareSamplingConfiguration] objects
 * using [GranularitySamplingConfiguration] as part of setting up a [DeviceConfiguration].
 */
typealias AdaptiveGranularitySamplingConfigurationBuilder =
    BatteryAwareSamplingConfigurationBuilder<
        GranularitySamplingConfiguration,
        GranularitySamplingConfigurationBuilder
    >




© 2015 - 2024 Weber Informatics LLC | Privacy Policy