Skip to content

Commit 0198f29

Browse files
committed
chore: update sensor configuration docs
Changes:\nM README.md M Sources/com.awareframework.ios.sensor.processor/ProcessorSensor.swift\n\nNotes:\n- Updated implementation, tests, and/or README formatting for this package.\n- agent, ai, and context packages are intentionally excluded.
1 parent cfb0a11 commit 0198f29

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎README.md‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AWARE Processor Sensor
1+
# AWARE: Processor
22

33
The processor sensor samples app process resource usage and device processor state on iOS.
44
It is designed for periodic, low-overhead monitoring of the AwareClient process, not for
@@ -20,11 +20,11 @@ Then import the module:
2020
import com_awareframework_ios_sensor_processor
2121
```
2222

23-
## Usage
23+
## Example Usage
2424

2525
```swift
2626
let sensor = ProcessorSensor(ProcessorSensor.Config().apply { config in
27-
config.interval = 60 // seconds
27+
config.sampleIntervalSeconds = 60
2828
})
2929

3030
sensor.start()
@@ -36,18 +36,18 @@ To stop collection:
3636
sensor.stop()
3737
```
3838

39-
## Configuration
39+
### ProcessorSensor.Config
4040

41-
`ProcessorSensor.Config` extends the common AWARE `SensorConfig`.
41+
Class to hold the configuration of the sensor.
4242

43-
| Property | Type | Default | Description |
44-
| --- | --- | --- | --- |
45-
| `interval` | `Int` | `60` | Sampling interval in seconds. Values less than `1` are ignored. |
46-
| `sensorObserver` | `ProcessorObserver?` | `nil` | Callback for live processor samples. |
47-
| `dbPath` | `String` | `aware_processor` | SQLite database path stem. |
48-
| `dbTableName` | `String?` | `ios_processor` in AwareClient | Active database table name. |
43+
#### Fields
4944

50-
## Data Model
45+
+ `sampleIntervalSeconds: Int`: Sampling interval in seconds. Values less than `1` are ignored. (default = `60`)
46+
+ `sensorObserver: ProcessorObserver?`: Callback for live processor samples. (default = `nil`)
47+
+ `dbPath: String`: SQLite database path stem. (default = `"aware_processor"`)
48+
+ `dbTableName: String?`: Active database table name. (default = `"ios_processor"` in AwareClient)
49+
50+
## Data Representations
5151

5252
`ProcessorData` stores the following fields:
5353

@@ -66,7 +66,7 @@ sensor.stop()
6666
| `thermalState` | `Int` | `0` nominal, `1` fair, `2` serious, `3` critical, `-1` unknown. |
6767
| `lowPowerMode` | `Int` | `1` when Low Power Mode is enabled, otherwise `0`. |
6868

69-
## Notifications
69+
## Broadcasts
7070

7171
| Notification | Description |
7272
| --- | --- |
@@ -87,7 +87,7 @@ final class Observer: ProcessorObserver {
8787
}
8888

8989
let config = ProcessorSensor.Config().apply { config in
90-
config.interval = 30
90+
config.sampleIntervalSeconds = 30
9191
config.sensorObserver = Observer()
9292
}
9393

‎Sources/com.awareframework.ios.sensor.processor/ProcessorSensor.swift‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public class ProcessorSensor: AwareSensor {
4343

4444
public class Config: SensorConfig {
4545
public var sensorObserver: ProcessorObserver?
46-
public var interval: Int = 60 {
46+
public var sampleIntervalSeconds: Int = 60 {
4747
didSet {
48-
if interval <= 0 {
48+
if sampleIntervalSeconds <= 0 {
4949
if debug {
5050
print(
5151
ProcessorSensor.TAG,
52-
"The interval parameter must be greater than 0. Keeping \(oldValue).")
52+
"The sampleIntervalSeconds parameter must be greater than 0. Keeping \(oldValue).")
5353
}
54-
interval = oldValue
54+
sampleIntervalSeconds = oldValue
5555
}
5656
}
5757
}
@@ -64,8 +64,8 @@ public class ProcessorSensor: AwareSensor {
6464
public convenience init(_ config: Dictionary<String, Any>) {
6565
self.init()
6666
set(config: config)
67-
if let interval = config["interval"] as? Int {
68-
self.interval = interval
67+
if let sampleIntervalSeconds = config["sampleIntervalSeconds"] as? Int {
68+
self.sampleIntervalSeconds = sampleIntervalSeconds
6969
}
7070
}
7171

@@ -100,8 +100,8 @@ public class ProcessorSensor: AwareSensor {
100100

101101
let timer = DispatchSource.makeTimerSource(queue: sampleQueue)
102102
timer.schedule(
103-
deadline: .now() + .seconds(max(1, CONFIG.interval)),
104-
repeating: .seconds(max(1, CONFIG.interval)))
103+
deadline: .now() + .seconds(max(1, CONFIG.sampleIntervalSeconds)),
104+
repeating: .seconds(max(1, CONFIG.sampleIntervalSeconds)))
105105
timer.setEventHandler { [weak self] in
106106
self?.sample()
107107
}

0 commit comments

Comments
 (0)