feat: Adds hydronic system pressure calculator.
Some checks are pending
CI / macOS (debug, 16.2) (push) Waiting to run
CI / macOS (release, 16.2) (push) Waiting to run
CI / ubuntu (push) Successful in 6m58s

This commit is contained in:
2025-03-07 15:15:28 -05:00
parent bdbe89e101
commit 159031a023
15 changed files with 358 additions and 2 deletions

View File

@@ -0,0 +1,74 @@
import Elementary
import ElementaryHTMX
import PsychrometricClient
import Routes
import Styleguide
struct HydronicSystemPressureForm: HTML, Sendable {
let response: HydronicSystemPressure.Response?
typealias Key = HydronicSystemPressure.Request.FieldKey
var content: some HTML {
FormHeader(label: "Hydronic System Pressure", svg: .circleGauge)
form(
.hx.post(route: .hydronicSystemPressure(.index)),
.hx.target("#result")
) {
div(.class("space-y-6")) {
div(.class("grid grid-cols-2 gap-4")) {
LabeledContent(label: "Height (ft.)") {
Input(id: Key.height, placeholder: "Building height")
.attributes(.type(.number), .min("0.1"), .step("0.1"), .autofocus, .required)
}
LabeledContent(label: "Water Temperature (\(String.fahrenheit))") {
Input(id: Key.waterTemperature, placeholder: "Temperature (optional)")
.attributes(.type(.number), .min("32.0"), .step("0.1"))
}
}
Note {
"""
Water temperature should be the coldest water temperature the system sees, which for boilers will be
when the system is filled with water.
"""
}
div {
SubmitButton(label: "Calculate System Pressure")
}
}
}
div(.id("result")) {
if let response {
HydronicSystemPressureResponse(response: response)
}
}
}
}
struct HydronicSystemPressureResponse: HTML, Sendable {
let response: HydronicSystemPressure.Response
var content: some HTML {
ResultContainer(reset: .hydronicSystemPressure(.index)) {
ResultBox {
div(.class("grid grid-cols-2")) {
VerticalGroup(label: "Pressure", value: "\(double: response.pressure)", valueLabel: "psi")
VerticalGroup(
label: "Water Density",
value: "\(double: response.waterDensity.value)",
valueLabel: response.waterDensity.units.rawValue
)
}
}
WarningBox(warnings: response.warnings)
Note {
"Expansion tank pressure should match system fill pressure."
}
}
}
}