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:
- status is derived from deploymentStatus; it is not stored.
- Two studies are equal if they have the same type, studyDeploymentId and deviceRoleName.
- Is a ChangeNotifier: listeners are notified when the deployment status or deployment changes.
- The events stream emits a StudyStatusEvent on each change, including errors (StudyStatusEventTypes.DeploymentError).
See also StudyDeploymentProxy, which updates a study during deployment. CARP Mobile Sensing extends this class as SmartphoneStudy.
- Mixed-in types
Constructors
Study
- String studyDeploymentId,
- String deviceRoleName, [
- DateTime? createdOn,
- StudyDeploymentStatus? deploymentStatus,
- TDeviceDeployment? deployment,
Create a study uniquely identified by its studyDeploymentId and deviceRoleName.
Properties
createdOn
The date and time when this study was created and added to the ClientManager.
deployment
The deployment for this study; null until received from the deployment service.
deploymentStatus
The deployment status of this study; null until received from the deployment service.
deviceRoleName
The role name of the primary device in the deployment this study runtime participates in.
events
Stream of study status events.
hashCode
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
The status of this study, derived from deploymentStatus.
StudyStatus.DeploymentNotAvailable if no deployment status has been received yet.
studyDeploymentId
The ID of the deployed study for which to collect data.
Methods
createEvent
Emits event on the events stream.
deploymentError
- String? message
The deployment is in an error state. Print the optional message and notify listeners of a deployment error event.
deploymentStatusReceived
- 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
- 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
- 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
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 ==
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 == omust be true. -
Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false. -
Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must 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.