Skip to content

Study

A study deployment that this client device takes part in with one role.

The study deployment is identified by studyDeploymentId, and the device takes part as deviceRoleName. A study is created by the app and added with ClientManager.addStudy; it then holds what the client knows about the deployment: its deploymentStatus and, once received, its deployment.

Key points:

See also StudyDeploymentProxy, which updates a study during deployment. CARP Mobile Sensing extends this class as SmartphoneStudy.

Mixed-in types

Constructors

Study

Study<TDeviceDeployment extends PrimaryDeviceDeployment>(
  1. String studyDeploymentId,
  2. String deviceRoleName, [
  3. DateTime? createdOn,
  4. StudyDeploymentStatus? deploymentStatus,
  5. TDeviceDeployment? deployment,
])

Create a study uniquely identified by its studyDeploymentId and deviceRoleName.

Properties

createdOn

DateTime get createdOn

The date and time when this study was created and added to the ClientManager.

deployment

TDeviceDeployment? get deployment

The deployment for this study; null until received from the deployment service.

deploymentStatus

StudyDeploymentStatus? get deploymentStatus

The deployment status of this study; null until received from the deployment service.

deviceRoleName

String get deviceRoleName

The role name of the primary device in the deployment this study runtime participates in.

events

Stream of study status events.

hashCode

int get hashCode
override

The hash code for this object.

A hash code is a single integer which represents the state of the object that affects operator == comparisons.

All objects have hash codes. The default hash code implemented by Object represents only the identity of the object, the same way as the default operator == implementation only considers objects equal if they are identical (see identityHashCode).

If operator == is overridden to use the object state instead, the hash code must also be changed to represent that state, otherwise the object cannot be used in hash based data structures like the default Set and Map implementations.

Hash codes must be the same for objects that are equal to each other according to operator ==. The hash code of an object should only change if the object changes in a way that affects equality. There are no further requirements for the hash codes. They need not be consistent between executions of the same program and there are no distribution guarantees.

Objects that are not equal are allowed to have the same hash code. It is even technically allowed that all instances have the same hash code, but if clashes happen too often, it may reduce the efficiency of hash-based data structures like HashSet or HashMap.

If a subclass overrides hashCode, it should override the operator == operator as well to maintain consistency.

status

StudyStatus get status

The status of this study, derived from deploymentStatus.

StudyStatus.DeploymentNotAvailable if no deployment status has been received yet.

studyDeploymentId

String get studyDeploymentId

The ID of the deployed study for which to collect data.

Methods

createEvent

void createEvent(
  1. StudyStatusEvent<Study<PrimaryDeviceDeployment>> event
)

Emits event on the events stream.

deploymentError

void deploymentError([
  1. String? message
])

The deployment is in an error state. Print the optional message and notify listeners of a deployment error event.

deploymentStatusReceived

void deploymentStatusReceived([
  1. StudyDeploymentStatus? deploymentStatus
])

An updated deploymentStatus has been received.

Keeps the latest status. If deploymentStatus is not specified, the previously received status is marked as updated. Emits StudyStatusEventTypes.DeploymentStatusReceived and notifies listeners.

deploymentUpdated

void deploymentUpdated([
  1. String? message
])

Mark the deployment as updated. Print the optional message and notify listeners of a deployment update event. If deployment is null, nothing happens.

deviceDeploymentReceived

void deviceDeploymentReceived([
  1. TDeviceDeployment? deployment
])

A new primary device deployment determining what data to collect for this study has been received.

If deployment is not specified, the previously received deployment is marked as updated. An already held deployment is not replaced. Reports a deployment error instead if no deploymentStatus has been received yet, or if the deployment is for another device role name. Otherwise emits StudyStatusEventTypes.DeviceDeploymentReceived and listens to updates of the deployment.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Operators

operator ==

bool operator ==(
  1. Object other
)
override

The equality operator.

The default behavior for all Objects is to return true if and only if this object and other are the same object.

Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:

  • Total: It must return a boolean for all arguments. It should never throw.

  • Reflexive: For all objects o, o == o must be true.

  • Symmetric: For all objects o1 and o2, o1 == o2 and o2 == o1 must either both be true, or both be false.

  • Transitive: For all objects o1, o2, and o3, if o1 == o2 and o2 == o3 are true, then o1 == o3 must be true.

The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.

If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.