feat: Adds capacitor calculations.
This commit is contained in:
@@ -23,6 +23,7 @@ public extension SiteRoute {
|
||||
|
||||
enum Api: Equatable, Sendable {
|
||||
|
||||
case calculateCapacitor(Capacitor.Request)
|
||||
case calculateDehumidifierSize(DehumidifierSize.Request)
|
||||
case calculateHVACSystemPerformance(HVACSystemPerformance.Request)
|
||||
case calculateMoldRisk(MoldRisk.Request)
|
||||
@@ -31,6 +32,16 @@ public extension SiteRoute {
|
||||
static let rootPath = Path { "api"; "v1" }
|
||||
|
||||
public static let router = OneOf {
|
||||
Route(.case(Self.calculateCapacitor)) {
|
||||
Path { "api"; "v1"; "calculateRoomPressure" }
|
||||
Method.post
|
||||
OneOf {
|
||||
Body(.json(Capacitor.Request.SizeRequest.self))
|
||||
.map(.case(Capacitor.Request.size))
|
||||
Body(.json(Capacitor.Request.TestRequest.self))
|
||||
.map(.case(Capacitor.Request.test))
|
||||
}
|
||||
}
|
||||
Route(.case(Self.calculateDehumidifierSize)) {
|
||||
Path { "api"; "v1"; "calculateDehumidifierSize" }
|
||||
Method.post
|
||||
@@ -64,6 +75,7 @@ public extension SiteRoute {
|
||||
enum View: Equatable, Sendable {
|
||||
|
||||
case index
|
||||
case capacitor(Capacitor)
|
||||
case dehumidifierSize(DehumidifierSize)
|
||||
case hvacSystemPerformance(HVACSystemPerformance)
|
||||
case moldRisk(MoldRisk)
|
||||
@@ -73,6 +85,9 @@ public extension SiteRoute {
|
||||
Route(.case(Self.index)) {
|
||||
Method.get
|
||||
}
|
||||
Route(.case(Self.capacitor)) {
|
||||
Capacitor.router
|
||||
}
|
||||
Route(.case(Self.dehumidifierSize)) {
|
||||
DehumidifierSize.router
|
||||
}
|
||||
@@ -87,6 +102,50 @@ public extension SiteRoute {
|
||||
}
|
||||
}
|
||||
|
||||
public enum Capacitor: Equatable, Sendable {
|
||||
case index(mode: Routes.Capacitor.Mode? = nil)
|
||||
case submit(Routes.Capacitor.Request)
|
||||
|
||||
public static var index: Self { .index() }
|
||||
|
||||
static let rootPath = "capacitor-calculator"
|
||||
|
||||
public static let router = OneOf {
|
||||
Route(.case(Self.index)) {
|
||||
Path { rootPath }
|
||||
Method.get
|
||||
Query {
|
||||
Optionally { Field("mode") { Routes.Capacitor.Mode.parser() } }
|
||||
}
|
||||
}
|
||||
Route(.case(Self.submit)) {
|
||||
Path { rootPath }
|
||||
Method.post
|
||||
Body {
|
||||
OneOf {
|
||||
FormData {
|
||||
Field("runningAmps") { Double.parser() }
|
||||
Field("lineVoltage") { Double.parser() }
|
||||
Field("powerFactor") { Double.parser() }
|
||||
}
|
||||
.map(.memberwise(Routes.Capacitor.Request.SizeRequest.init))
|
||||
.map(.case(Routes.Capacitor.Request.size))
|
||||
|
||||
FormData {
|
||||
Field("startWindingAmps") { Double.parser() }
|
||||
Field("runToCommonVoltage") { Double.parser() }
|
||||
Optionally {
|
||||
Field("ratedCapacitorSize") { Int.parser() }
|
||||
}
|
||||
}
|
||||
.map(.memberwise(Routes.Capacitor.Request.TestRequest.init))
|
||||
.map(.case(Routes.Capacitor.Request.test))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum DehumidifierSize: Equatable, Sendable {
|
||||
case index
|
||||
case submit(Routes.DehumidifierSize.Request)
|
||||
|
||||
Reference in New Issue
Block a user