DeviceManager<TDeviceConfiguration extends DeviceConfiguration<TRegistration> , TRegistration extends DeviceRegistration> class
abstract
Manages one device or service used for data collection.
It configures the device, connects to it, and starts and stops sampling on it. Examples include a hardware device like a smartwatch or fitness band, an onboard service on the smartphone like a location service, or an online service, like a weather service. Each SamplingPackage provides one, and the DeviceController keeps them by device type.
Key points:
- Lifecycle: configure, then connect; disconnect stops sampling
first. Subclasses implement the
on...callbacks (onConfigure, onConnect, onDisconnect, onRequestPermissions). - status drives sampling: DeviceStatus.connected resumes all executors, DeviceStatus.disconnecting pauses them (to be resumed), and DeviceStatus.reconnected resumes them again after 15 seconds.
- connect checks hasPermissions first and fails if they are missing.
See ServiceManager, HardwareDeviceManager, BLEDeviceManager and SmartphoneDeviceManager for the main subtypes.
- Implemented types
-
- DeviceDataCollector
- Implementers
Constructors
- DeviceManager(String deviceType, {TDeviceConfiguration? configuration})
-
Create a new DeviceManager specifying its
deviceType.
Properties
- canConnect → bool
-
Determines whether a connection can be made at this point in time to the device.
no setterinherited
- configuration → TDeviceConfiguration?
-
The configuration for this device.
no setter
- deviceType → String
-
The type of the device managed by this device manager, e.g.
dk.cachet.carp.common.application.devices.Smartphone.no setter - displayName → String?
-
A human-readable name for this device, or null if unknown.
no setter
-
executors
→ Set<
TaskControlExecutor> -
The task control executors whose tasks run on this device.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConfigured → bool
-
Has this device manager been configured?
no setter
- isConnected → bool
-
Is this device manager connected to the real device?
no setter
- isConnecting → bool
-
Is this device manager connecting or already connected to a device?
no setter
- registration → TRegistration?
-
The latest registration for this device.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldConnect → bool
-
Whether to connect to the real device, based on the last registration.
no setter
- status ↔ DeviceStatus
-
The runtime status of this device.
getter/setter pair
-
statusEvents
→ Stream<
DeviceStatus> -
The stream of status events for this device.
no setter
-
supportedDataTypes
→ Set<
DataType> -
The set of data types defining which data can be collected on this device.
no setteroverride
- typeName → String
-
The name of the deviceType without the namespace.
no setter
Methods
-
configure(
TDeviceConfiguration configuration, [DeviceRegistration? registration]) → void -
Configures this device manager with its
configuration. -
connect(
) → Future< DeviceStatus> - Connects to the device and returns its new DeviceStatus.
-
createRegistration(
) → TRegistration - Creates a registration of this device for the deployment.
-
disconnect(
) → Future< bool> - Disconnects from the device.
-
hasPermissions(
) → Future< bool> - Whether this device manager has the permissions it needs to run.
-
isDisconnecting(
) → Future< void> - Called when the device is lost for a while.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onConfigure(
) → void - Callback on configure.
-
onConnect(
) → Future< DeviceStatus> - Callback on connect. Returns the DeviceStatus of the device.
-
onDisconnect(
) → Future< bool> - Callback on disconnect.
-
onHasPermissions(
) → Future< bool> - Callback on hasPermissions.
-
onRequestPermissions(
) → Future< void> - Callback on requestPermissions.
-
requestPermissions(
) → Future< void> - Asks the user for the permissions this device manager needs. Calls onRequestPermissions.
-
restart(
) → void - Restarts sampling of the measures using this device.
-
start(
) → void - Starts sampling of all measures using this device.
-
stop(
{bool shouldBeResumed = false}) → void - Stops sampling the measures using this device.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited