Skip to content

Commit

Permalink
created objects (#133)
Browse files Browse the repository at this point in the history
* created objects

* home changed to an interface, example of how to use interface included in CurrentHeatingSystem

* updated remaining models to interfaces

* update to reflect changes to main

* field names changed per comments in PR

* made all model names singular

* added ' Propane' option to fuelType, provided inclusionOverride options

* updated field in Location to camel case

* example of instantiating heatLoadAnalysis object

* example of instantiating natural gas bill records

* combined interfaces into /types/index.d.ts

* added type declarations to 2 components
  • Loading branch information
jkoren authored Mar 20, 2024
1 parent 11748ee commit f542653
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { type HeatLoadAnalysis } from '#types/index.js'

export function AnalysisHeader() {
const averageIndoorTemperature = '63.5'
const dailyOtherUsage = '1.07'
const balancePoint = '60.5'
const standardDevationUA = '5.52'
const wholeHomeUA = '1,112'
const heatLoadAnalysis: HeatLoadAnalysis = {
rulesEngineVersion: 'Beta 1',
estimatedBalancePoint: 60.5,
otherFuelUsage: 1.07,
averageIndoorTemperature: 68,
differenceBetweenTiAndTbp: 0,
designTemperature: 0,
wholeHomeHeatLossRate: 1112,
standardDeviationHeatLossRate: 5.52,
averageHeatLoad: 0,
maximumHeatLoad: 0,
}

return (
<div className="section-title">
Expand All @@ -12,9 +21,15 @@ export function AnalysisHeader() {
<div className="basis-1/3">
<div className="item-title-small">
Average Indoor Temperature <br />
<div className="item">{averageIndoorTemperature} °F</div> <br />
<div className="item">
{heatLoadAnalysis.averageIndoorTemperature} °F
</div>{' '}
<br />
Balance Point Temperature (°F) <br />
<div className="item">{balancePoint}</div> <br />
<div className="item">
{heatLoadAnalysis.estimatedBalancePoint}
</div>{' '}
<br />
</div>
</div>
<div className="basis-1/3">
Expand All @@ -23,16 +38,24 @@ export function AnalysisHeader() {
<div className="item">(to be calculated)</div>
<br />
Daily non-heating Usage <br />
<div className="item">{dailyOtherUsage} therms</div>{' '}
<div className="item">
{heatLoadAnalysis.otherFuelUsage} therms
</div>{' '}
</div>
</div>
<div className="basis-1/3">
<div className="item-title-small">
Standard Deviation of UA <br />
<div className="item">{standardDevationUA} %</div> <br />
<div className="item">
{heatLoadAnalysis.standardDeviationHeatLossRate} %
</div>{' '}
<br />
Whole-home UA
<br />
<div className="item">{wholeHomeUA} BTU/h-°F</div> <br />
<div className="item">
{heatLoadAnalysis.wholeHomeHeatLossRate} BTU/h-°F
</div>{' '}
<br />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Form } from '@remix-run/react'
import { Button } from '#/app/components/ui/button.tsx'

import { Input } from '#/app/components/ui/input.tsx'
import { Label } from '#/app/components/ui/label.tsx'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type NaturalGasBillRecord } from '#types/index.js'
import { Checkbox } from '../../../../components/ui/checkbox.tsx'

import {
Expand All @@ -9,23 +10,39 @@ import {
TableRow,
} from '../../../../components/ui/table.tsx'

const months = [
{
includeData: true,
startDate: '02/02/2018',
endDate: '02/28/2018',
daysInBill: '27',
usage: 'Yes',
fUA: '10',
},
{
includeData: true,
startDate: '03/01/2018',
endDate: '03/31/2018',
daysInBill: '31',
usage: 'Modest',
fUA: '30',
},
const naturalGasBillRecord01: NaturalGasBillRecord = {
periodStartDate: new Date('12/08/2017'),
periodEndDate: new Date('01/07/2018'),
usageTherms: 197,
inclusionOverride: 'Include',
}

const naturalGasBillRecord02: NaturalGasBillRecord = {
periodStartDate: new Date('01/08/2018'),
periodEndDate: new Date('02/07/2018'),
usageTherms: 205,
inclusionOverride: 'Include',
}

const naturalGasBillRecord03: NaturalGasBillRecord = {
periodStartDate: new Date('02/08/2018'),
periodEndDate: new Date('03/07/2018'),
usageTherms: 220,
inclusionOverride: 'Include',
}

const naturalGasBillRecord04: NaturalGasBillRecord = {
periodStartDate: new Date('03/08/2018'),
periodEndDate: new Date('04/07/2018'),
usageTherms: 196,
inclusionOverride: 'Include',
}

const naturalGasBill = [
naturalGasBillRecord01,
naturalGasBillRecord02,
naturalGasBillRecord03,
naturalGasBillRecord04,
]

export function EnergyUseHistoryChart() {
Expand All @@ -39,23 +56,31 @@ export function EnergyUseHistoryChart() {
<TableHead>End Date</TableHead>
<TableHead>Days in Bill</TableHead>
<TableHead>Usage (therms)</TableHead>
<TableHead>60.5 °F UA (BTU/h-F)</TableHead>
<TableHead>Whole-home UA</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{months.map((month, index) => (
<TableRow key={index}>
<TableCell className="font-medium">{index + 1}</TableCell>
<TableCell>
<Checkbox checked={month.includeData} />
</TableCell>
<TableCell>{month.startDate}</TableCell>
<TableCell>{month.endDate}</TableCell>
<TableCell>{month.daysInBill}</TableCell>
<TableCell>{month.usage}</TableCell>
<TableCell>{month.fUA}</TableCell>
</TableRow>
))}
{naturalGasBill.map((period, index) => {
const timeInPeriod =
period.periodEndDate.getTime() - period.periodStartDate.getTime()
const daysInPeriod = Math.round(timeInPeriod / (1000 * 3600 * 24))

return (
<TableRow key={index}>
<TableCell className="font-medium">{index + 1}</TableCell>
<TableCell>
<Checkbox checked={period.inclusionOverride == 'Include'} />
</TableCell>
<TableCell>
{period.periodStartDate.toLocaleDateString()}
</TableCell>
<TableCell>{period.periodEndDate.toLocaleDateString()}</TableCell>
<TableCell>{daysInPeriod}</TableCell>
<TableCell>{period.usageTherms}</TableCell>
<TableCell>0</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
)
Expand Down
File renamed without changes.
62 changes: 62 additions & 0 deletions heat-stack/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
export interface Case {
firstName: string
lastName: string
}

export interface HeatLoadAnalysis {
rulesEngineVersion: string
estimatedBalancePoint: number
otherFuelUsage: number
averageIndoorTemperature: number
differenceBetweenTiAndTbp: number
designTemperature: number
wholeHomeHeatLossRate: number
standardDeviationHeatLossRate: number
averageHeatLoad: number
maximumHeatLoad: number
}

export interface Home {
livingArea: number
fuelType: 'Natural Gas' | 'Oil' | 'Propane'
designTemperatureOverride: number
heatingSystemEfficiency: number
thermostatSetPoint: number
setbackTemperature: number
setbackHoursPerDay: number
numberOfOccupants: number
estimatedWaterHeatingEfficiency: number
standByLosses: number
}

export interface Location {
address: string
addressLine2: string
city: string
state: string
zip: string
country: string
}

export interface NaturalGasBill {
provider: string
}

export interface NaturalGasBillRecord {
periodStartDate: Date
periodEndDate: Date
usageTherms: number
inclusionOverride: 'Include' | 'Do not include' | 'Include in other analysis'
}

export interface OilPropaneBill {
provider: string
precedingDeliveryDate: Date
}

export interface OilPropaneBillRecord {
periodStartDate: Date
periodEndDate: Date
gallons: number
inclusionOverride: 'Include' | 'Do not include' | 'Include in other analysis'
}

0 comments on commit f542653

Please sign in to comment.