107 lines
3.4 KiB
Swift
107 lines
3.4 KiB
Swift
public enum AtticVentilation {
|
|
|
|
public static let description = """
|
|
Calculate attic ventilation requirements and assess current conditions.
|
|
"""
|
|
|
|
public struct Request: Codable, Equatable, Sendable {
|
|
|
|
public let pressureDifferential: Double
|
|
public let outdoorTemperature: Double
|
|
public let outdoorDewpoint: Double
|
|
public let atticTemperature: Double
|
|
public let atticDewpoint: Double
|
|
public let atticFloorArea: Double
|
|
public let existingIntakeArea: Double?
|
|
public let existingExhaustArea: Double?
|
|
|
|
public init(
|
|
pressureDifferential: Double,
|
|
outdoorTemperature: Double,
|
|
outdoorDewpoint: Double,
|
|
atticTemperature: Double,
|
|
atticDewpoint: Double,
|
|
atticFloorArea: Double,
|
|
existingIntakeArea: Double? = nil,
|
|
existingExhaustArea: Double? = nil
|
|
) {
|
|
self.pressureDifferential = pressureDifferential
|
|
self.outdoorTemperature = outdoorTemperature
|
|
self.outdoorDewpoint = outdoorDewpoint
|
|
self.atticTemperature = atticTemperature
|
|
self.atticDewpoint = atticDewpoint
|
|
self.atticFloorArea = atticFloorArea
|
|
self.existingIntakeArea = existingIntakeArea
|
|
self.existingExhaustArea = existingExhaustArea
|
|
}
|
|
}
|
|
|
|
public struct Response: Codable, Equatable, Sendable {
|
|
|
|
public let pressureDifferential: Double
|
|
public let temperatureDifferential: Double
|
|
public let dewpointDifferential: Double
|
|
public let stackEffect: Double
|
|
public let requiredVentilationArea: RequiredVentilationArea
|
|
public let recommendations: [String]
|
|
public let warnings: [String]
|
|
public let ventilationStatus: VentilationStatus
|
|
|
|
public init(
|
|
pressureDifferential: Double,
|
|
temperatureDifferential: Double,
|
|
dewpointDifferential: Double,
|
|
stackEffect: Double,
|
|
requiredVentilationArea: AtticVentilation.RequiredVentilationArea,
|
|
recommendations: [String],
|
|
warnings: [String],
|
|
ventilationStatus: AtticVentilation.VentilationStatus
|
|
) {
|
|
self.pressureDifferential = pressureDifferential
|
|
self.temperatureDifferential = temperatureDifferential
|
|
self.dewpointDifferential = dewpointDifferential
|
|
self.stackEffect = stackEffect
|
|
self.requiredVentilationArea = requiredVentilationArea
|
|
self.recommendations = recommendations
|
|
self.warnings = warnings
|
|
self.ventilationStatus = ventilationStatus
|
|
}
|
|
}
|
|
|
|
public enum VentilationStatus: String, Codable, CaseIterable, Equatable, Sendable {
|
|
case adequate
|
|
case inadequate
|
|
case critical
|
|
}
|
|
|
|
public struct RequiredVentilationArea: Codable, Equatable, Sendable {
|
|
|
|
public let intake: Double
|
|
public let exhaust: Double
|
|
|
|
public init(intake: Double, exhaust: Double) {
|
|
self.intake = intake
|
|
self.exhaust = exhaust
|
|
}
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
public extension AtticVentilation.Response {
|
|
static let mock = Self(
|
|
pressureDifferential: 4,
|
|
temperatureDifferential: 15,
|
|
dewpointDifferential: 10,
|
|
stackEffect: 2,
|
|
requiredVentilationArea: .init(intake: 4.9, exhaust: 3.3),
|
|
recommendations: [
|
|
"Install 4.9 sq. ft. of intake ventilation",
|
|
"Install 3.3 sq. ft. of exhaust ventilation",
|
|
"Consider adding exhaust ventilation to balance pressure"
|
|
],
|
|
warnings: ["High pressure differential - may indicate blocked vents or insufficient ventilation."],
|
|
ventilationStatus: AtticVentilation.VentilationStatus.allCases.randomElement()!
|
|
)
|
|
}
|
|
#endif
|