Structure
FlowManager
public struct FlowManager
Main object of the library implementing data transformation and generating events for anomalies and alarm conditions. It process a stream of sample input data using a Finite State Machine design pattern.
Example:
let params = FlowParameters(expectedTimeInterval: 1.0, acceptedDelay: 1.0, ignoreFirstSamples: 3, device: .appleWatch, enableLogging: false, immediateAlarm: ParamsRange(min: 50, max: 130), normalRange: ParamsRange(min: 70, max: 110), lightSleepRange: ParamsRange(min: 81, max: 95), deepSleepRange: ParamsRange(min: 70, max: 80), anomalyMaxLenghtSeconds: 10, bpmSpeedAlarm: 0.0) var flowManager = FlowManager(parameters: params)
let sample = Sample(time: measureTime, bpm: bpmValue)
let result: ProcessedFlowResult = flowManager.processSample(sample: sample)
Pseudo code example for update HRV label on UI hrvLabel.text = result.hrv
Pseudo code example for managing alerts for event in result.events { switch event { case .missingData: logMissingData() case .warning: logWarning() case .alarm: sendAlertToParent() default: break } }
Initializers
init(parameters:delegate:)
public init(parameters: FlowParameters, delegate: FlowManagerExtension? = nil)
Initialize a FlowManager object with FlowParameters.
Properties
parameters
var parameters: FlowParameters
The configuration parameters with all range and rules for the dynamic behavior of the FlowManager object.
currentStateEnteredTime
var currentStateEnteredTime: TimeInterval!
The exact time it entered the last internal state.
startTime
var startTime: TimeInterval!
The time it start receiving the first sample input data.
bpmCounters
var bpmCounters: [Int : StatisticsValue]
The dictionary containing number of occurences for each BPM sample input data processed.
Methods
processSample(sample:)
public mutating func processSample(sample: Sample) -> ProcessedFlowResult
Main method. It process an input sample data and return a ProcessedFlowResult containing transformed data such as HRV, BPM Speed, Sleep quality and other values and an optional list of generated events such as alarm or warning conditions.
Parameters
Name | Type | Description |
---|---|---|
sample | Sample |
The input sample data. |
calcMovementIndex(accelerometer:)
public func calcMovementIndex(accelerometer: (Double, Double, Double)) -> Double?
printReport()
public func printReport()