feat: Completes hvac-system-performance views and api call.
This commit is contained in:
80
Sources/Routes/Models/MoldRisk.swift
Normal file
80
Sources/Routes/Models/MoldRisk.swift
Normal file
@@ -0,0 +1,80 @@
|
||||
import Foundation
|
||||
import PsychrometricClient
|
||||
|
||||
public enum MoldRisk {
|
||||
public struct Request: Codable, Equatable, Sendable {
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user