-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
113 changed files
with
3,565 additions
and
1,814 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
carp.common/src/commonMain/kotlin/dk/cachet/carp/common/application/devices/Website.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@file:Suppress( "NON_EXPORTABLE_TYPE" ) | ||
|
||
package dk.cachet.carp.common.application.devices | ||
|
||
import dk.cachet.carp.common.application.Trilean | ||
import dk.cachet.carp.common.application.data.DataType | ||
import dk.cachet.carp.common.application.sampling.DataTypeSamplingSchemeMap | ||
import dk.cachet.carp.common.application.sampling.SamplingConfiguration | ||
import dk.cachet.carp.common.application.tasks.TaskConfigurationList | ||
import dk.cachet.carp.common.infrastructure.serialization.NotSerializable | ||
import kotlinx.serialization.Required | ||
import kotlinx.serialization.Serializable | ||
import kotlin.js.JsExport | ||
import kotlin.reflect.KClass | ||
|
||
|
||
/** | ||
* A website which participates in a study as a primary device. | ||
*/ | ||
@Serializable | ||
@JsExport | ||
data class Website( | ||
override val roleName: String, | ||
override val isOptional: Boolean = false | ||
) : PrimaryDeviceConfiguration<WebsiteDeviceRegistration, WebsiteDeviceRegistrationBuilder>() | ||
{ | ||
object Sensors : DataTypeSamplingSchemeMap() | ||
object Tasks : TaskConfigurationList() | ||
|
||
override fun getSupportedDataTypes(): Set<DataType> = Sensors.keys | ||
override fun getDataTypeSamplingSchemes(): DataTypeSamplingSchemeMap = Sensors | ||
|
||
override val defaultSamplingConfiguration: Map<DataType, SamplingConfiguration> = emptyMap() | ||
|
||
override fun createDeviceRegistrationBuilder(): WebsiteDeviceRegistrationBuilder = | ||
WebsiteDeviceRegistrationBuilder() | ||
override fun getRegistrationClass(): KClass<WebsiteDeviceRegistration> = WebsiteDeviceRegistration::class | ||
override fun isValidRegistration( registration: WebsiteDeviceRegistration ): Trilean = Trilean.TRUE | ||
} | ||
|
||
|
||
/** | ||
* A [DeviceRegistration] for a [Website], specifying the [url] where the study runs. | ||
*/ | ||
@Serializable | ||
@JsExport | ||
data class WebsiteDeviceRegistration( | ||
val url: String, | ||
/** | ||
* The HTTP User-Agent header of the user agent which made the HTTP request to [url]. | ||
*/ | ||
val userAgent: String, | ||
@Required | ||
override val deviceDisplayName: String? = userAgent | ||
) : DeviceRegistration() | ||
{ | ||
@Required | ||
override val deviceId: String = url | ||
} | ||
|
||
|
||
@Suppress( "SERIALIZER_TYPE_INCOMPATIBLE" ) | ||
@Serializable( NotSerializable::class ) | ||
@JsExport | ||
class WebsiteDeviceRegistrationBuilder : DeviceRegistrationBuilder<WebsiteDeviceRegistration>() | ||
{ | ||
/** | ||
* The web URL from which the [Website] is accessed. | ||
*/ | ||
var url: String = "" | ||
|
||
/** | ||
* The HTTP User-Agent header of the user agent which made the HTTP request to [url]. | ||
*/ | ||
var userAgent: String = "" | ||
|
||
override fun build(): WebsiteDeviceRegistration = WebsiteDeviceRegistration( url, userAgent, deviceDisplayName ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.