Skip to content

Commit

Permalink
Add special unit to track emissions units: default metric
Browse files Browse the repository at this point in the history
  • Loading branch information
nbintertech committed Nov 12, 2024
1 parent 20e583a commit ce42fc6
Show file tree
Hide file tree
Showing 51 changed files with 336 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class CompressedAirAssessmentResultsService {
if (compressedAirAssessment.systemInformation.co2SavingsData) {
compressedAirAssessment.systemInformation.co2SavingsData.electricityUse = baselineResults.power;
dayTypeAnnualEmissionsOutput = this.assessmentCo2SavingsService.getCo2EmissionsResult(compressedAirAssessment.systemInformation.co2SavingsData, settings);
// * converts annualEmissionOutput to tonne
// * handle offset result - electricity use is passed here as kWh but the method is meant to accept MWh
dayTypeAnnualEmissionsOutput = dayTypeAnnualEmissionsOutput / 1000;
}
dayTypeResults.push({
Expand Down Expand Up @@ -198,9 +198,9 @@ export class CompressedAirAssessmentResultsService {
if (baselineResults && compressedAirAssessment.systemInformation.co2SavingsData) {
compressedAirAssessment.systemInformation.co2SavingsData.electricityUse = allSavingsResults.adjustedResults.power;
allSavingsResults.adjustedResults.annualEmissionOutput = this.assessmentCo2SavingsService.getCo2EmissionsResult(compressedAirAssessment.systemInformation.co2SavingsData, settings);
// * converts annualEmissionOutput to tonne
// * handle offset result - electricity use is passed here as kWh but the method is meant to accept MWh
allSavingsResults.adjustedResults.annualEmissionOutput = allSavingsResults.adjustedResults.annualEmissionOutput / 1000;

let currentDayTypeBaselineResult: BaselineResult = baselineResults.dayTypeResults.find(result => result.dayTypeId === dayType.dayTypeId);
allSavingsResults.savings.annualEmissionOutputSavings = currentDayTypeBaselineResult.annualEmissionOutput - allSavingsResults.adjustedResults.annualEmissionOutput;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ <h4 class="show-print print-section-header">Assessment Executive Summary</h4>
</td>
</tr>
<tr class="bold-row">
<td>Annual Emission Output Rate (tonne CO<sub>2</sub>)
<td>Annual Emission Output Rate
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</td>
<td [ngClass]="{'selected-modification': selectedModificationIndex == -1}">
{{baselineResults.total.annualEmissionOutput | number:'1.0-0'}}</td>
Expand Down Expand Up @@ -261,7 +263,9 @@ <h4 class="show-print print-section-header">Assessment Executive Summary</h4>
</tr>

<tr class="bold-row row-stripe bg-row">
<td>Annual Emission Savings (tonne CO<sub>2</sub>)
<td>Annual Emission Savings
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</td>
<td [ngClass]="{'selected-modification': selectedModificationIndex == -1}">&mdash; &mdash;</td>
<td *ngFor="let result of combinedDayTypeResults; let index = index;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,17 @@
</div>
<div class="d-flex align-items-center pl-1 pr-1 col-4">
<span class="bold table-text">{{dayTypeBaselineResult.annualEmissionOutput |
number:'1.0-0'}} tonne CO<sub>2</sub></span>
number:'1.0-0'}}
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</span>
</div>
<div class="col-4 d-flex align-items-center pl-1 pr-1">
<span class="bold table-text">{{dayTypeModificationResult.annualEmissionOutput
| number:'1.0-0'}} tonne CO<sub>2</sub></span>
| number:'1.0-0'}}
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</span>
</div>
</div>

Expand Down Expand Up @@ -221,7 +227,10 @@
</div>
<div class="col-4 d-flex align-items-center pl-1 pr-1">
<span class="bold table-text">{{dayTypeModificationResult.allSavingsResults.savings.annualEmissionOutputSavings
| number:'1.0-0'}} tonne CO<sub>2</sub></span>
| number:'1.0-0'}}
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</span>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BaselineResult, BaselineResults, CompressedAirAssessmentResult, Compres
import { CompressedAirAssessmentService } from '../../compressed-air-assessment.service';
import { ExploreOpportunitiesValidationService } from '../explore-opportunities-validation.service';
import { ExploreOpportunitiesService } from '../explore-opportunities.service';
import { Settings } from '../../../shared/models/settings';

@Component({
selector: 'app-explore-opportunities-results',
Expand All @@ -28,9 +29,6 @@ export class ExploreOpportunitiesResultsComponent implements OnInit {
baselineResults: BaselineResults;
dayTypeBaselineResult: BaselineResult;




addReceiverVolumeValid: boolean;
addReceiverVolumeValidSub: Subscription;
adjustCascadingSetPointsValid: boolean;
Expand All @@ -47,11 +45,13 @@ export class ExploreOpportunitiesResultsComponent implements OnInit {
useAutomaticSequencerValidSub: Subscription;
hasInvalidData: boolean;
isInit: boolean = true;
settings: Settings;
constructor(private compressedAirAssessmentService: CompressedAirAssessmentService,
private exploreOpportunitiesService: ExploreOpportunitiesService, private compressedAirAssessmentResultsService: CompressedAirAssessmentResultsService,
private exploreOpportunitiesValidationService: ExploreOpportunitiesValidationService) { }

ngOnInit(): void {
this.settings = this.compressedAirAssessmentService.settings.getValue();
this.setValidationSubs();
this.compressedAirAssessmentSub = this.compressedAirAssessmentService.compressedAirAssessment.subscribe(val => {
if (val) {
Expand Down
1 change: 1 addition & 0 deletions src/app/examples/mockCompressedAirAssessment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17360,6 +17360,7 @@ export const MockCompressedAirAssessmentSettings: Settings = {
"language": "English",
"currency": "$",
"unitsOfMeasure": "Imperial",
"emissionsUnit": "Metric",
"distanceMeasurement": "ft",
"flowMeasurement": "gpm",
"powerMeasurement": "hp",
Expand Down
1 change: 1 addition & 0 deletions src/app/examples/mockFsat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export const MockFsatSettings: Settings = {
language: "English",
currency: "$",
unitsOfMeasure: "Imperial",
emissionsUnit: "Metric",
distanceMeasurement: "ft",
flowMeasurement: "gpm",
powerMeasurement: "hp",
Expand Down
1 change: 1 addition & 0 deletions src/app/examples/mockPhast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,7 @@ export const MockPhastSettings: Settings = {
co2SavingsEnergySource: "Natural Gas",
co2SavingsFuelType: "Natural Gas",
totalEmissionOutputRate: 401.07,
emissionsUnit: 'Metric',
totalFuelEmissionOutputRate: 0,
totalNaturalGasEmissionOutputRate: 53.06,
totalCoalEmissionOutputRate: 0,
Expand Down
1 change: 1 addition & 0 deletions src/app/examples/mockPsat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const MockPsatSettings: Settings = {
"language": "English",
"currency": "$",
"unitsOfMeasure": "Imperial",
"emissionsUnit": "Metric",
"distanceMeasurement": "ft",
"flowMeasurement": "gpm",
"powerMeasurement": "hp",
Expand Down
1 change: 1 addition & 0 deletions src/app/examples/mockSsmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export const MockSsmtSettings: Settings = {
"language": "English",
"currency": "$",
"unitsOfMeasure": "Imperial",
"emissionsUnit": "Metric",
"distanceMeasurement": "ft",
"flowMeasurement": "gpm",
"powerMeasurement": "hp",
Expand Down
1 change: 1 addition & 0 deletions src/app/examples/mockTreasureHunt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ export const MockTreasureHuntSettings: Settings = {
"language": "English",
"currency": "$",
"unitsOfMeasure": "Imperial",
"emissionsUnit": "Metric",
"distanceMeasurement": "ft",
"flowMeasurement": "gpm",
"powerMeasurement": "hp",
Expand Down
1 change: 1 addition & 0 deletions src/app/examples/mockWasteWater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const MockWasteWaterSettings: Settings = {
"language": "English",
"currency": "$",
"unitsOfMeasure": "Imperial",
"emissionsUnit": "Metric",
"distanceMeasurement": "ft",
"flowMeasurement": "MGD",
"powerMeasurement": "hp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ <h4 class="show-print">Report Results</h4>
</tr>

<tr class="callout">
<th>Annual CO2 Emissions (tonne CO<sub>2</sub>)</th>
<th>Annual CO2 Emissions
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</th>
<th [ngClass]="{'selected-modification': selectedModificationIndex == -1}">{{fsat.outputs.co2EmissionsOutput |
number:'1.1-1'}}</th>
<th *ngFor="let modification of fsat.modifications; let index = index;"
Expand All @@ -149,7 +152,10 @@ <h4 class="show-print">Report Results</h4>
</th>
</tr>
<tr class="callout">
<th>Annual CO2 Emissions Savings (tonne CO<sub>2</sub>)</th>
<th>Annual CO2 Emissions Savings
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</th>
<th [ngClass]="{'selected-modification': selectedModificationIndex == -1}">&mdash;</th>
<th *ngFor="let modification of fsat.modifications; let index = index;"
[ngClass]="{'positive-savings': modification.fsat.outputs.percentSavings > 10, 'selected-modification': index == selectedModificationIndex}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@

<div class="d-flex stripe my-table-bg my-table-item">
<div class="d-flex align-items-center pl-1 pr-1" [ngClass]="{'col-4': !inSetup, 'col-6': inSetup}">
<span class="bold table-text">Annual CO2 Emissions (tonne CO<sub>2</sub>)</span>
<span class="bold table-text">Annual CO2 Emissions
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</span>
</div>
<div class="d-flex align-items-center pl-1 pr-1" [ngClass]="{'col-4': !inSetup, 'col-6': inSetup}">
<span class="bold table-text">{{baselineResults.co2EmissionsOutput | number:'1.1-1'}} </span>
Expand All @@ -238,7 +241,10 @@

<div class="d-flex stripe my-table-bg my-table-item">
<div class="d-flex align-items-center pl-1 pr-1" [ngClass]="{'col-4': !inSetup, 'col-6': inSetup}">
<span class="bold table-text">Annual CO2 Emissions Savings (tonne CO<sub>2</sub>)</span>
<span class="bold table-text">Annual CO2 Emissions Savings
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</span>
</div>
<div class="d-flex align-items-center pl-1 pr-1" [ngClass]="{'col-4': !inSetup, 'col-6': inSetup}">
<span class="bold table-text">&mdash;</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class FsatResultsPanelComponent implements OnInit {
constructor(private fsatService: FsatService) { }

ngOnInit() {
console.log('settings', this.settings);
this.updateDataSub = this.fsatService.updateData.subscribe(() => { this.getResults(); });
if (this.fsat.modifications && this.fsat.modifications.length > 0) {
this.isWhatIfScenario = this.fsat.modifications[this.modificationIndex].fsat.whatIfScenario;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@
</td>
<td>
<span *ngIf="departmentSummaryItem.co2EmissionOutput">
{{departmentSummaryItem.co2EmissionOutput | number :'1.0-0'}} tonne CO<sub>2</sub>
{{departmentSummaryItem.co2EmissionOutput | number :'1.0-0'}}
</span>
<span *ngIf="!departmentSummaryItem.co2EmissionOutput">
&mdash; tonne CO<sub>2</sub>
&mdash;
</span>
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -82,11 +84,13 @@
</td>
<td>
<span *ngIf="inventorySummary.totalEmissions">
{{inventorySummary.totalEmissions | number :'1.0-0'}} tonne CO<sub>2</sub>
{{inventorySummary.totalEmissions | number :'1.0-0'}}
</span>
<span *ngIf="!inventorySummary.totalEmissions">
&mdash; tonne CO<sub>2</sub>
&mdash;
</span>
<span *ngIf="settings.emissionsUnit === 'Imperial'">(ton CO<sub>2</sub>)</span>
<span *ngIf="settings.emissionsUnit === 'Metric'">(tonne CO<sub>2</sub>)</span>
</td>
</tr>
</tfoot>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
import { Subscription } from 'rxjs';
import { InventorySummaryOverviewService, InventorySummary } from '../inventory-summary-overview.service';
import { Settings } from '../../../../shared/models/settings';

@Component({
selector: 'app-inventory-overview-table',
Expand All @@ -10,6 +11,8 @@ import { InventorySummaryOverviewService, InventorySummary } from '../inventory-
export class InventoryOverviewTableComponent implements OnInit {
@ViewChild('copyTable', { static: false }) copyTable: ElementRef;
tableString: any;
@Input()
settings: Settings;
inventorySummary: InventorySummary;
invetorySummarySub: Subscription;
constructor(private inventorySummaryOverviewService: InventorySummaryOverviewService) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row no-gutters w-100 h-50 min-row-height">
<div class="col-lg-6 col-12">
<app-inventory-overview-table></app-inventory-overview-table>
<app-inventory-overview-table [settings]="settings"></app-inventory-overview-table>
</div>
<div class="col-lg-6 col-12 h-50 min-row-height">
<app-inventory-overview-pie-chart></app-inventory-overview-pie-chart>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { MotorInventoryService } from '../../motor-inventory.service';
import { InventorySummaryOverviewService } from './inventory-summary-overview.service';
import { Subscription } from 'rxjs';
import { Settings } from '../../../shared/models/settings';
@Component({
selector: 'app-inventory-summary-overview',
templateUrl: './inventory-summary-overview.component.html',
Expand All @@ -10,9 +11,11 @@ import { Subscription } from 'rxjs';
export class InventorySummaryOverviewComponent implements OnInit {

filterInventorySummarySub: Subscription;
settings: Settings;
constructor(private motorInventoryService: MotorInventoryService, private inventorySummaryOverviewService: InventorySummaryOverviewService) { }

ngOnInit(): void {
this.settings = this.motorInventoryService.settings.getValue();
this.filterInventorySummarySub = this.motorInventoryService.filterInventorySummary.subscribe(val => {
this.inventorySummaryOverviewService.setDepartmentSummaryItems();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ export class Co2SavingsPhastService {
return energyValue;
}

/**
* Returns total emissions output in tons (imperial) or tonne (metric)
* @param phast - emissions output rates in GJ/MMBtu
*/
setCo2EmissionsResults(phast: PHAST, results: PhastResults, settings: Settings): PhastCo2EmissionsOutput {
let phastCopy: PHAST = JSON.parse(JSON.stringify(phast));
let resultsCopy: PhastResults = JSON.parse(JSON.stringify(results));
Expand Down Expand Up @@ -261,6 +265,16 @@ export class Co2SavingsPhastService {
co2EmissionsOutput.totalEmissionOutput = co2EmissionsOutput.hourlyTotalEmissionOutput * phastCopy.operatingHours.hoursPerYear;
}

if (settings.emissionsUnit !== 'Metric') {
co2EmissionsOutput.hourlyTotalEmissionOutput = co2EmissionsOutput.hourlyTotalEmissionOutput !== undefined? this.convertUnitsService.value(co2EmissionsOutput.hourlyTotalEmissionOutput).from('tonne').to('ton') : undefined;
co2EmissionsOutput.emissionsSavings = co2EmissionsOutput.emissionsSavings !== undefined? this.convertUnitsService.value(co2EmissionsOutput.emissionsSavings).from('tonne').to('ton') : undefined;
co2EmissionsOutput.totalEmissionOutput = co2EmissionsOutput.totalEmissionOutput !== undefined? this.convertUnitsService.value(co2EmissionsOutput.totalEmissionOutput).from('tonne').to('ton') : undefined;
co2EmissionsOutput.fuelEmissionOutput = co2EmissionsOutput.fuelEmissionOutput !== undefined? this.convertUnitsService.value(co2EmissionsOutput.fuelEmissionOutput).from('tonne').to('ton') : undefined;
co2EmissionsOutput.electricityEmissionOutput = co2EmissionsOutput.electricityEmissionOutput !== undefined? this.convertUnitsService.value(co2EmissionsOutput.electricityEmissionOutput).from('tonne').to('ton') : undefined;
co2EmissionsOutput.electrodeEmissionsOutput = co2EmissionsOutput.electrodeEmissionsOutput !== undefined? this.convertUnitsService.value(co2EmissionsOutput.electrodeEmissionsOutput).from('tonne').to('ton') : undefined;
co2EmissionsOutput.otherFuelEmissionsOutput = co2EmissionsOutput.otherFuelEmissionsOutput !== undefined? this.convertUnitsService.value(co2EmissionsOutput.otherFuelEmissionsOutput).from('tonne').to('ton') : undefined;
co2EmissionsOutput.coalCarbonEmissionsOutput = co2EmissionsOutput.coalCarbonEmissionsOutput !== undefined? this.convertUnitsService.value(co2EmissionsOutput.coalCarbonEmissionsOutput).from('tonne').to('ton') : undefined;
}
return co2EmissionsOutput;
}

Expand Down
Loading

0 comments on commit ce42fc6

Please sign in to comment.