Skip to content

Probe

Collects data for one Measure.

The data comes from a sensor, a connected device or a service. A probe is the leaf of the executor tree. Each measure in a task gets its own probe, created by the measure type's SamplingPackage through SamplingPackageRegistry.create. Write a probe when you add a new measure type to a sampling package; most extend one of the specialized probes below.

Key points:

Specialized probes: MeasurementProbe (one measurement), IntervalProbe (polling), StreamProbe (continuous stream), PeriodicStreamProbe, BufferingPeriodicProbe, BufferingIntervalStreamProbe and BufferingPeriodicStreamProbe.

Inheritance
Implementers

Constructors

Probe

Probe()

Properties

deviceManager

The device manager of the device this probe collects data from.

Set by SamplingPackageRegistry.create.

enabled

bool enabled
getter/setter pair

Whether this probe is enabled.

Not used by the CAMS runtime itself.

measure

Measure? get measure

The Measure that configures this probe.

permissions

List<Permission> get permissions

The permissions this probe needs. Empty if none.

Taken from the CamsDataTypeMetaData of its data type.

samplingConfiguration

SamplingConfiguration? get samplingConfiguration

The sampling configuration for this probe.

Configuration is obtained in the following order:

Returns null in case no configuration is found.

See also the section on Sampling schemes and configurations in the CARP Core Framework. In addition to CARP Core, CARP Mobile Sensing also supports sampling schemes in the sampling packages, which are used as the 4th possible configuration in the list above.

type

String? get type

The data type this probe collects, e.g. dk.cachet.carp.steps.

Methods

addMeasurement

void addMeasurement(
  1. Measurement measurement
)
override

Adds measurement to measurements.

If the samplingConfiguration is a PersistentSamplingConfiguration, also sets its lastTime to now and saves the deployment, at most once per second.

arePermissionsGranted

Future<bool> arePermissionsGranted()

Whether all permissions are granted. Returns false if checking fails.

hasRequiredPermissions

Future<bool> hasRequiredPermissions()

Whether this probe is allowed to run.

The SmartphoneStudyController asks for all deployment permissions up front (SmartphoneStudyController.askForAllPermissions), so probes only check. Always true on iOS: permission_handler reports Android-only groups (e.g. activityRecognition, phone) as denied there, and iOS prompts on first use.

onInitialize

bool onInitialize()
override

Called by initialize. Returns true if successfully initialized.

If false, the executor stays in ExecutorState.Created. This is a synchronous method and must be light-weight.

onPause

Future<bool> onPause()
override

Called by pause. Returns true if successfully paused.

If false, the state is not changed.

onResume

Future<bool> onResume()
override

Called by resume. Returns true if successfully resumed.

If false, the executor moves to ExecutorState.PausedButShouldBeResumed.

requestPermissions

Future<bool> requestPermissions()

Asks the user for any permissions not yet granted.

Goes through SmartPhoneClientManager.requestPermissions. Returns true if all permissions are granted afterwards.