feat: Adding improvements to pressure estimations feature.
This commit is contained in:
@@ -37,21 +37,31 @@ public struct SharedPressureEstimationState: Equatable, Sendable {
|
||||
}
|
||||
|
||||
#warning("Needs to hold onto estimation state, so it can be editable")
|
||||
@dynamicMemberLookup
|
||||
public struct FlaggedEstimationContainer: Equatable, Identifiable, Sendable {
|
||||
public let id: UUID
|
||||
public var estimationState: EstimationState
|
||||
public var flaggedMeasurement: EquipmentMeasurement.FlaggedMeasurement
|
||||
public var name: String
|
||||
|
||||
public init(
|
||||
id: UUID,
|
||||
name: String,
|
||||
estimationState: EstimationState,
|
||||
flaggedMeasurement: EquipmentMeasurement.FlaggedMeasurement
|
||||
) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.estimationState = estimationState
|
||||
self.flaggedMeasurement = flaggedMeasurement
|
||||
}
|
||||
|
||||
public subscript<T>(dynamicMember keyPath: WritableKeyPath<EstimationState, T>) -> T {
|
||||
get { estimationState[keyPath: keyPath] }
|
||||
set { estimationState[keyPath: keyPath] = newValue }
|
||||
}
|
||||
|
||||
public subscript<T>(dynamicMember keyPath: KeyPath<EstimationState, T>) -> T {
|
||||
get { estimationState[keyPath: keyPath] }
|
||||
}
|
||||
|
||||
public struct EstimationState: Equatable, Sendable {
|
||||
public var cfm: CFMContainer
|
||||
public var filterPressureDrop: Double?
|
||||
@@ -67,6 +77,14 @@ public struct SharedPressureEstimationState: Equatable, Sendable {
|
||||
self.name = name
|
||||
}
|
||||
|
||||
internal init(state: EstimationForm.State) {
|
||||
self.init(
|
||||
cfm: .init(state: state),
|
||||
filterPressureDrop: state.filterPressureDrop,
|
||||
name: state.name.isEmpty ? nil : state.name
|
||||
)
|
||||
}
|
||||
|
||||
var displayName: String {
|
||||
guard let name else {
|
||||
return "@\(Int(cfm.airflow)) CFM"
|
||||
@@ -78,6 +96,15 @@ public struct SharedPressureEstimationState: Equatable, Sendable {
|
||||
case cfm(Int)
|
||||
case cfmPerTon(Int, EquipmentMetadata.CoolingCapacity)
|
||||
|
||||
init(state: EstimationForm.State) {
|
||||
switch state.airflowSelection {
|
||||
case .cfmPerTon:
|
||||
self = .cfmPerTon(state.cfmTextField ?? 0, state.coolingCapacity)
|
||||
case .cfm:
|
||||
self = .cfm(state.cfmTextField ?? 0)
|
||||
}
|
||||
}
|
||||
|
||||
var airflow: Double {
|
||||
switch self {
|
||||
case let .cfm(cfm):
|
||||
|
||||
Reference in New Issue
Block a user