FileDataManager class
A data manager that writes Measurements as JSON to files on the phone.
Used when the protocol's data endpoint is a FileDataEndPoint. Each file holds a JSON array of measurements. When a file grows beyond FileDataEndPoint.bufferSize bytes, it is closed, optionally zipped, and a new file is started.
Key points:
- Emits FileDataManagerEvents on events when files are created and closed, so e.g. an upload manager can pick up closed files.
- Encryption (FileDataEndPoint.encrypt) is not implemented yet. Only the FileDataManagerEventTypes.fileEncrypted event is emitted.
- If a write fails, the file is reset and the write is retried.
The path and filename format is
~/carp/deployments/<study_deployment_id>/data/carp-data-yyyy-mm-dd-hh-mm-ss-ms.json.zip
where ~ is the folder where an application can place files that are private
to the application (see Settings.getDataBasePath).
On iOS, this is the NSDocumentsDirectory and the files can be accessed via
the MacOS Finder.
On Android, Flutter files are stored in the AppData directory, which is
located in the data/data/<package_name>/app_flutter folder.
Files can be accessed via AndroidStudio.
- Inheritance
-
- Object
- AbstractDataManager
- FileDataManager
Constructors
Properties
- dataEndPoint → DataEndPoint?
-
The DataEndPoint that this data manager is handling.
no setterinherited
- deployment → SmartphoneDeployment
-
The deployment using this data manager.
no setterinherited
-
events
→ Stream<
DataManagerEvent> -
Stream of data manager events, see DataManagerEventTypes.
no setterinherited
-
file
→ Future<
File> -
The current file being written to.
no setter
- fileDataEndPoint → FileDataEndPoint
-
The dataEndPoint cast to a FileDataEndPoint.
Only valid after configure has been called.
no setter
-
filename
→ Future<
String> -
Full path and filename of the current file, on the format
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
path
→ Future<
String> -
The full path where data files are stored on the device.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sink
→ Future<
IOSink> -
The IOSink used to append to the current file.
no setter
- studyDeploymentId → String
-
The ID of the study deployment that this manager is handling.
no setterinherited
- type → String
-
The type of this data manager as enumerated in DataEndPointTypes.
no setteroverride
Methods
-
addEvent(
DataManagerEvent event) → void -
Adds
eventto the events stream.inherited -
close(
) → Future< void> -
Flushes any buffered data and closes this data manager.
override
-
configure(
{required DataEndPoint dataEndPoint, required SmartphoneDeployment deployment, required Stream< Measurement> measurements}) → Future<void> -
Configures the data manager with the study
deployment, thedataEndPoint, and the stream ofmeasurementsto handle.override -
flush(
File flushFile, IOSink flushSink) → Future< void> -
Closes
flushFileand itsflushSink, and zips the file if FileDataEndPoint.zip is true. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDone(
) → Future< void> -
When the data stream closes, the onDone handler is called.
Default implementation is a no-op function. If another behavior is wanted,
implementations of this abstract data manager should handle closing of
the data stream.
override
-
onError(
Object? error) → Future< void> -
Saves
erroras anErrormeasurement via onMeasurement.inherited -
onMeasurement(
Measurement measurement) → Future< void> -
On each measurement collected, the onMeasurement handler is called.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
Measurement measurement) → Future< void> -
Writes a JSON encoded
measurementto the current file.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited