WIP: Html view that prints to pdf ok.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import Foundation
|
||||
import ManualDCore
|
||||
|
||||
extension PdfClient.Request {
|
||||
@@ -13,30 +14,100 @@ extension PdfClient.Request {
|
||||
## Equipment
|
||||
|
||||
| | Value |
|
||||
|-----------------|---------------------------------|
|
||||
| Static Pressure | \(equipmentInfo.staticPressure) |
|
||||
| Heating CFM | \(equipmentInfo.heatingCFM) |
|
||||
| Cooling CFM | \(equipmentInfo.coolingCFM) |
|
||||
|:----------------|:--------------------------------|
|
||||
| Static Pressure | \(equipmentInfo.staticPressure.string()) |
|
||||
| Heating CFM | \(equipmentInfo.heatingCFM.string()) |
|
||||
| Cooling CFM | \(equipmentInfo.coolingCFM.string()) |
|
||||
|
||||
## Friction Rate
|
||||
|
||||
| | Value |
|
||||
|-----------------|---------------------------------|
|
||||
| Component Loss | Value |
|
||||
|:----------------|:--------------------------------|
|
||||
|
||||
"""
|
||||
for row in componentLosses {
|
||||
retval = """
|
||||
\(retval)
|
||||
\(componentLossRow(row))
|
||||
"""
|
||||
retval += "\(componentLossRow(row))\n"
|
||||
}
|
||||
|
||||
retval += """
|
||||
|
||||
|
||||
| Results | Value |
|
||||
|:-----------------|:---------------------------------|
|
||||
| Available Static Pressure | \(frictionRate.availableStaticPressure.string()) |
|
||||
| Total Equivalent Length | \(totalEquivalentLength.string()) |
|
||||
| Friction Rate Design Value | \(frictionRate.value.string()) |
|
||||
|
||||
## Duct Sizes
|
||||
|
||||
| Register | Dsn CFM | Round Size | Velocity | Final Size | Flex Size | Height | Width |
|
||||
|:---------|:--------|:----------------|:---------|:-----------|:----------|:-------|:------|
|
||||
|
||||
"""
|
||||
for row in ductSizes.rooms {
|
||||
retval += "\(registerRow(row))\n"
|
||||
}
|
||||
|
||||
retval += """
|
||||
|
||||
## Trunk Sizes
|
||||
|
||||
### Supply Trunks
|
||||
|
||||
| Name | Associated Supplies | Dsn CFM | Velocity | Final Size | Flex Size | Height | Width |
|
||||
|:---------|:--------------------|:--------|:---------|:-----------|:----------|:-------|:------|
|
||||
|
||||
"""
|
||||
for row in ductSizes.trunks.filter({ $0.type == .supply }) {
|
||||
retval += "\(trunkRow(row))\n"
|
||||
}
|
||||
|
||||
retval += """
|
||||
|
||||
### Return Trunks / Run Outs
|
||||
|
||||
| Name | Associated Supplies | Dsn CFM | Velocity | Final Size | Flex Size | Height | Width |
|
||||
|:---------|:--------------------|:--------|:---------|:-----------|:----------|:-------|:------|
|
||||
|
||||
"""
|
||||
for row in ductSizes.trunks.filter({ $0.type == .return }) {
|
||||
retval += "\(trunkRow(row))\n"
|
||||
}
|
||||
|
||||
return retval
|
||||
}
|
||||
|
||||
func componentLossRow(_ row: ComponentPressureLoss) -> String {
|
||||
func registerRow(_ row: DuctSizes.RoomContainer) -> String {
|
||||
return """
|
||||
| \(row.name) | \(row.value) |
|
||||
| \(row.roomName) | \(row.designCFM.value.string(digits: 0)) | \(row.roundSize.string()) | \(row.velocity.string()) | \(row.finalSize.string()) | \(row.flexSize.string()) | \(row.height?.string() ?? "") | \(row.width?.string() ?? "") |
|
||||
"""
|
||||
}
|
||||
|
||||
func trunkRow(_ row: DuctSizes.TrunkContainer) -> String {
|
||||
return """
|
||||
| \(row.name ?? "") | \(associatedSupplyString(row)) | \(row.designCFM.value.string(digits: 0)) | \(row.roundSize.string()) | \(row.velocity.string()) | \(row.finalSize.string()) | \(row.flexSize.string()) | \(row.ductSize.height?.string() ?? "") | \(row.width?.string() ?? "") |
|
||||
"""
|
||||
}
|
||||
|
||||
func componentLossRow(_ row: ComponentPressureLoss) -> String {
|
||||
return """
|
||||
| \(row.name) | \(row.value.string()) |
|
||||
"""
|
||||
}
|
||||
|
||||
var totalEquivalentLength: Double {
|
||||
maxSupplyTEL.totalEquivalentLength + maxReturnTEL.totalEquivalentLength
|
||||
}
|
||||
|
||||
func associatedSupplyString(_ row: DuctSizes.TrunkContainer) -> String {
|
||||
row.associatedSupplyString(rooms: ductSizes.rooms)
|
||||
}
|
||||
}
|
||||
|
||||
extension DuctSizes.TrunkContainer {
|
||||
|
||||
func associatedSupplyString(rooms: [DuctSizes.RoomContainer]) -> String {
|
||||
self.registerIDS(rooms: rooms)
|
||||
.joined(separator: ", ")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user