@@ -72,6 +72,15 @@ enum ChargeRecordState {
|
||
| 72 | 72 |
|
| 73 | 73 |
class Meter : NSObject, ObservableObject, Identifiable {
|
| 74 | 74 |
|
| 75 |
+ private static func shouldLogOperationalStateTransition(from oldValue: OperationalState, to newValue: OperationalState) -> Bool {
|
|
| 76 |
+ switch (oldValue, newValue) {
|
|
| 77 |
+ case (.comunicating, .dataIsAvailable), (.dataIsAvailable, .comunicating): |
|
| 78 |
+ return false |
|
| 79 |
+ default: |
|
| 80 |
+ return true |
|
| 81 |
+ } |
|
| 82 |
+ } |
|
| 83 |
+ |
|
| 75 | 84 |
enum OperationalState: Int, Comparable {
|
| 76 | 85 |
case notPresent |
| 77 | 86 |
case peripheralNotConnected |
@@ -89,7 +98,9 @@ class Meter : NSObject, ObservableObject, Identifiable {
|
||
| 89 | 98 |
@Published var operationalState = OperationalState.peripheralNotConnected {
|
| 90 | 99 |
didSet {
|
| 91 | 100 |
guard operationalState != oldValue else { return }
|
| 92 |
- track("\(name) - Operational state changed from \(oldValue) to \(operationalState)")
|
|
| 101 |
+ if Self.shouldLogOperationalStateTransition(from: oldValue, to: operationalState) {
|
|
| 102 |
+ track("\(name) - Operational state changed from \(oldValue) to \(operationalState)")
|
|
| 103 |
+ } |
|
| 93 | 104 |
switch operationalState {
|
| 94 | 105 |
case .notPresent: |
| 95 | 106 |
cancelPendingDataDumpRequest(reason: "meter missing") |