86 lines
1.9 KiB
Swift
86 lines
1.9 KiB
Swift
import Foundation
|
|
import PsychrometricClient
|
|
|
|
public enum MoldRisk {
|
|
|
|
public static let description = """
|
|
Assess mold risk based on indoor conditions.
|
|
"""
|
|
|
|
public struct Request: Codable, Equatable, Sendable, Hashable {
|
|
|
|
public let temperature: Double
|
|
public let humidity: Double
|
|
|
|
public init(temperature: Double, humidity: Double) {
|
|
self.temperature = temperature
|
|
self.humidity = humidity
|
|
}
|
|
}
|
|
|
|
public struct Response: Codable, Equatable, Sendable {
|
|
|
|
public let psychrometricProperties: PsychrometricProperties
|
|
public let riskLevel: RiskLevel
|
|
public let daysToMold: Int?
|
|
public let recommendations: [String]
|
|
|
|
public init(
|
|
psychrometricProperties: PsychrometricProperties,
|
|
riskLevel: MoldRisk.RiskLevel,
|
|
daysToMold: Int? = nil,
|
|
recommendations: [String]
|
|
) {
|
|
self.psychrometricProperties = psychrometricProperties
|
|
self.riskLevel = riskLevel
|
|
self.daysToMold = daysToMold
|
|
self.recommendations = recommendations
|
|
}
|
|
}
|
|
|
|
public enum RiskLevel: String, Codable, Equatable, Sendable {
|
|
case low
|
|
case moderate
|
|
case high
|
|
case severe
|
|
}
|
|
}
|
|
|
|
public extension MoldRisk.Request {
|
|
|
|
var dryBulb: DryBulb {
|
|
.fahrenheit(temperature)
|
|
}
|
|
|
|
var relativeHumidity: RelativeHumidity { humidity% }
|
|
}
|
|
|
|
#if DEBUG
|
|
import Dependencies
|
|
|
|
public extension MoldRisk.Response {
|
|
static var mock: Self {
|
|
return .init(
|
|
psychrometricProperties: .init(
|
|
absoluteHumidity: .zero,
|
|
atmosphericPressure: .zero,
|
|
degreeOfSaturation: .zero,
|
|
density: .zero, dewPoint: 59.4,
|
|
dryBulb: 75,
|
|
enthalpy: .zero,
|
|
grainsOfMoisture: .zero,
|
|
humidityRatio: .zero,
|
|
relativeHumidity: 50%,
|
|
specificVolume: .zero,
|
|
vaporPressure: .zero,
|
|
wetBulb: .zero,
|
|
units: .imperial
|
|
),
|
|
riskLevel: .low,
|
|
recommendations: []
|
|
)
|
|
}
|
|
}
|
|
|
|
#endif
|