feat: Begins thermal balance point
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
public enum HeatingBalancePoint {
|
||||
|
||||
public static let description: String = """
|
||||
Calculate the heating balance point.
|
||||
"""
|
||||
|
||||
public enum Mode: String, CaseIterable, Codable, Equatable, Sendable {
|
||||
case economic
|
||||
case thermal
|
||||
}
|
||||
|
||||
@@ -13,14 +18,14 @@ public enum HeatingBalancePoint {
|
||||
public let capacityAt47: Double?
|
||||
public let capacityAt17: Double?
|
||||
public let heatingDesignTemperature: Double
|
||||
public let buildingHeatLoss: Double
|
||||
public let buildingHeatLoss: HeatingBalancePoint.HeatLoss
|
||||
|
||||
public init(
|
||||
systemSize: Double,
|
||||
capacityAt47: Double? = nil,
|
||||
capacityAt17: Double? = nil,
|
||||
heatingDesignTemperature: Double,
|
||||
buildingHeatLoss: Double
|
||||
buildingHeatLoss: HeatingBalancePoint.HeatLoss
|
||||
) {
|
||||
self.systemSize = systemSize
|
||||
self.capacityAt47 = capacityAt47
|
||||
@@ -47,4 +52,15 @@ public enum HeatingBalancePoint {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum HeatLoss: Codable, Equatable, Sendable {
|
||||
|
||||
public enum Mode: String, CaseIterable, Codable, Equatable, Sendable {
|
||||
case estimated
|
||||
case known
|
||||
}
|
||||
|
||||
case known(btu: Double)
|
||||
case estimated(squareFeet: Double)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ public extension SiteRoute {
|
||||
case capacitor(Capacitor)
|
||||
case dehumidifierSize(DehumidifierSize)
|
||||
case filterPressureDrop(FilterPressureDrop)
|
||||
case heatingBalancePoint(HeatingBalancePoint)
|
||||
case hvacSystemPerformance(HVACSystemPerformance)
|
||||
case moldRisk(MoldRisk)
|
||||
case roomPressure(RoomPressure)
|
||||
@@ -122,6 +123,9 @@ public extension SiteRoute {
|
||||
Route(.case(Self.filterPressureDrop)) {
|
||||
FilterPressureDrop.router
|
||||
}
|
||||
Route(.case(Self.heatingBalancePoint)) {
|
||||
HeatingBalancePoint.router
|
||||
}
|
||||
Route(.case(Self.hvacSystemPerformance)) {
|
||||
HVACSystemPerformance.router
|
||||
}
|
||||
@@ -281,6 +285,56 @@ public extension SiteRoute {
|
||||
}
|
||||
}
|
||||
|
||||
public enum HeatingBalancePoint: Equatable, Sendable {
|
||||
case index(mode: Routes.HeatingBalancePoint.Mode? = nil, heatLossMode: Routes.HeatingBalancePoint.HeatLoss.Mode? = nil)
|
||||
case heatLossFields(mode: Routes.HeatingBalancePoint.HeatLoss.Mode)
|
||||
case submit(Routes.HeatingBalancePoint.Request)
|
||||
|
||||
public static var index: Self { index() }
|
||||
|
||||
static let rootPath = "balance-point"
|
||||
|
||||
public static let router = OneOf {
|
||||
Route(.case(Self.index)) {
|
||||
Path { rootPath }
|
||||
Method.get
|
||||
Query {
|
||||
Optionally { Field("mode") { Routes.HeatingBalancePoint.Mode.parser() } }
|
||||
Optionally { Field("heatLossMode") { Routes.HeatingBalancePoint.HeatLoss.Mode.parser() } }
|
||||
}
|
||||
}
|
||||
Route(.case(Self.heatLossFields)) {
|
||||
Path { rootPath; "heat-loss" }
|
||||
Method.get
|
||||
Query {
|
||||
Field("mode") { Routes.HeatingBalancePoint.HeatLoss.Mode.parser() }
|
||||
}
|
||||
}
|
||||
Route(.case(Self.submit)) {
|
||||
Path { rootPath }
|
||||
Method.post
|
||||
Body {
|
||||
OneOf {
|
||||
FormData {
|
||||
Field("systemSize") { Double.parser() }
|
||||
Optionally { Field("capcityAt47") { Double.parser() } }
|
||||
Optionally { Field("capcityAt17") { Double.parser() } }
|
||||
Field("heatingDesignTemperature") { Double.parser() }
|
||||
OneOf {
|
||||
Field("knownHeatLoss") { Double.parser() }
|
||||
.map(.case(Routes.HeatingBalancePoint.HeatLoss.known))
|
||||
Field("simplifiedHeatLoss") { Double.parser() }
|
||||
.map(.case(Routes.HeatingBalancePoint.HeatLoss.estimated))
|
||||
}
|
||||
}
|
||||
.map(.memberwise(Routes.HeatingBalancePoint.Request.Thermal.init))
|
||||
.map(.case(Routes.HeatingBalancePoint.Request.thermal))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum HVACSystemPerformance: Equatable, Sendable {
|
||||
case index
|
||||
case submit(Routes.HVACSystemPerformance.Request)
|
||||
|
||||
Reference in New Issue
Block a user