Skip to content

Commit

Permalink
Ensure modification take Bl entered values for co2 emissions
Browse files Browse the repository at this point in the history
  • Loading branch information
nbintertech committed Nov 11, 2024
1 parent 9cc3c9a commit 9376ce4
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/app/fsat/fsat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ export class FsatService {
tmpModification.fsat.whatIfScenario = true;
tmpModification.fsat.fsatOperations = fsatCopy.fsatOperations;
tmpModification.fsat.fsatOperations.cO2SavingsData = fsatCopy.fsatOperations.cO2SavingsData;
tmpModification.fsat.fsatOperations.cO2SavingsData.userEnteredModificationEmissions = fsatCopy.fsatOperations.cO2SavingsData.userEnteredBaselineEmissions;
return tmpModification;
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/app/phast/add-modification/add-modification.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export class AddModificationComponent implements OnInit {
@Input()
modificationExists: boolean;



newModificationName: string;
currentTab: string;
tabSubscription: Subscription;
Expand All @@ -44,7 +42,7 @@ export class AddModificationComponent implements OnInit {

addModification() {
let exploreOppsDefault: SavingsOpportunity = { hasOpportunity: false, display: '' };
let tmpModification: Modification = {
let modification: Modification = {
phast: {
losses: {},
name: this.newModificationName,
Expand Down Expand Up @@ -85,15 +83,16 @@ export class AddModificationComponent implements OnInit {
exploreOppsShowFixtures: exploreOppsDefault,
};
if (this.currentTab === 'explore-opportunities') {
tmpModification.exploreOpportunities = true;
modification.exploreOpportunities = true;
}
if (this.phast.co2SavingsData) {
tmpModification.phast.co2SavingsData = (JSON.parse(JSON.stringify(this.phast.co2SavingsData)));
modification.phast.co2SavingsData = (JSON.parse(JSON.stringify(this.phast.co2SavingsData)));
modification.phast.co2SavingsData.userEnteredModificationEmissions = modification.phast.co2SavingsData.userEnteredBaselineEmissions;
}
tmpModification.phast.losses = (JSON.parse(JSON.stringify(this.phast.losses)));
tmpModification.phast.operatingCosts = (JSON.parse(JSON.stringify(this.phast.operatingCosts)));
tmpModification.phast.operatingHours = (JSON.parse(JSON.stringify(this.phast.operatingHours)));
tmpModification.phast.systemEfficiency = (JSON.parse(JSON.stringify(this.phast.systemEfficiency)));
this.save.emit(tmpModification);
modification.phast.losses = (JSON.parse(JSON.stringify(this.phast.losses)));
modification.phast.operatingCosts = (JSON.parse(JSON.stringify(this.phast.operatingCosts)));
modification.phast.operatingHours = (JSON.parse(JSON.stringify(this.phast.operatingHours)));
modification.phast.systemEfficiency = (JSON.parse(JSON.stringify(this.phast.systemEfficiency)));
this.save.emit(modification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export class ModificationListComponent implements OnInit {
tmpModification.exploreOpportunities = true;
}
tmpModification.phast.co2SavingsData = (JSON.parse(JSON.stringify(phast.co2SavingsData)));
tmpModification.phast.co2SavingsData.userEnteredModificationEmissions = tmpModification.phast.co2SavingsData.userEnteredBaselineEmissions;
tmpModification.phast.losses = (JSON.parse(JSON.stringify(phast.losses)));
tmpModification.phast.operatingCosts = (JSON.parse(JSON.stringify(phast.operatingCosts)));
tmpModification.phast.operatingHours = (JSON.parse(JSON.stringify(phast.operatingHours)));
Expand Down
15 changes: 8 additions & 7 deletions src/app/psat/add-modification/add-modification.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class AddModificationComponent implements OnInit {
}

addModification() {
let tmpModification: Modification = {
let modification: Modification = {
psat: {
name: this.newModificationName,
},
Expand All @@ -60,13 +60,14 @@ export class AddModificationComponent implements OnInit {
systemBasicsNotes: ''
},
}
tmpModification.psat.inputs = (JSON.parse(JSON.stringify(this.psat.inputs)));
tmpModification.psat.inputs.pump_style = 11;
tmpModification.psat.inputs.whatIfScenario = this.isWhatIfScenario;
tmpModification.exploreOpportunities = (this.currentTab == 'explore-opportunities');
modification.psat.inputs = (JSON.parse(JSON.stringify(this.psat.inputs)));
modification.psat.inputs.co2SavingsData.userEnteredModificationEmissions = modification.psat.inputs.co2SavingsData.userEnteredBaselineEmissions;
modification.psat.inputs.pump_style = 11;
modification.psat.inputs.whatIfScenario = this.isWhatIfScenario;
modification.exploreOpportunities = (this.currentTab == 'explore-opportunities');
let baselineResults: PsatOutputs = this.psatService.resultsExisting(this.psat.inputs, this.settings);
tmpModification.psat.inputs.pump_specified = baselineResults.pump_efficiency;
this.save.emit(tmpModification)
modification.psat.inputs.pump_specified = baselineResults.pump_efficiency;
this.save.emit(modification)
}

saveScenarioChange(isNewModWhatIfScenario: boolean){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export class ModificationListComponent implements OnInit {
tmpModification.exploreOpportunities = true;
}
tmpModification.psat.inputs = (JSON.parse(JSON.stringify(psat.inputs)));
tmpModification.psat.inputs.co2SavingsData.userEnteredModificationEmissions = tmpModification.psat.inputs.co2SavingsData.userEnteredModificationEmissions;
let baselineResults: PsatOutputs = this.psatService.resultsExisting(this.psat.inputs, this.settings);
tmpModification.psat.inputs.pump_specified = baselineResults.pump_efficiency;
tmpModification.psat.inputs.whatIfScenario = true;
Expand Down
13 changes: 7 additions & 6 deletions src/app/psat/psat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export class PsatComponent implements OnInit {

addNewMod() {
let modName: string = 'Scenario ' + (this._psat.modifications.length + 1);
let tmpModification: Modification = {
let modification: Modification = {
psat: {
name: modName,
},
Expand All @@ -448,12 +448,13 @@ export class PsatComponent implements OnInit {
},
exploreOpportunities: this.currentTab == 'explore-opportunities'
}
tmpModification.psat.inputs = (JSON.parse(JSON.stringify(this._psat.inputs)));
tmpModification.psat.inputs.pump_style = 11;
tmpModification.psat.inputs.whatIfScenario = true;
modification.psat.inputs = (JSON.parse(JSON.stringify(this._psat.inputs)));
modification.psat.inputs.co2SavingsData.userEnteredModificationEmissions = modification.psat.inputs.co2SavingsData.userEnteredBaselineEmissions;
modification.psat.inputs.pump_style = 11;
modification.psat.inputs.whatIfScenario = true;
let baselineResults: PsatOutputs = this.psatService.resultsExisting(this._psat.inputs, this.settings);
tmpModification.psat.inputs.pump_specified = baselineResults.pump_efficiency;
this.saveNewMod(tmpModification)
modification.psat.inputs.pump_specified = baselineResults.pump_efficiency;
this.saveNewMod(modification)
}

async addSettings(settings: Settings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export class AssessmentCo2SavingsComponent implements OnInit {
}

setModificationSubregionForm() {
// set selected baseline subregion value
this.form.controls.eGridSubregion.patchValue(this.co2SavingsData.eGridSubregion);
this.hasValidSubRegion = true;
this.setSubregionControlStatus();
Expand Down
15 changes: 8 additions & 7 deletions src/app/ssmt/add-modification/add-modification.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ export class AddModificationComponent implements OnInit {
addModification() {
let ssmtCopy: SSMT = (JSON.parse(JSON.stringify(this.ssmt)));
delete ssmtCopy.modifications;
let tmpModification: Modification = {
let modification: Modification = {
ssmt: ssmtCopy,
exploreOpportunities: (this.assessmentTab === 'explore-opportunities')
};
tmpModification.ssmt.name = this.newModificationName;
if (tmpModification.ssmt.headerInput.lowPressureHeader) {
tmpModification.ssmt.headerInput.lowPressureHeader.useBaselineProcessSteamUsage = true;
modification.ssmt.co2SavingsData.userEnteredModificationEmissions = modification.ssmt.co2SavingsData.userEnteredBaselineEmissions;
modification.ssmt.name = this.newModificationName;
if (modification.ssmt.headerInput.lowPressureHeader) {
modification.ssmt.headerInput.lowPressureHeader.useBaselineProcessSteamUsage = true;
}
if (tmpModification.ssmt.headerInput.mediumPressureHeader) {
tmpModification.ssmt.headerInput.mediumPressureHeader.useBaselineProcessSteamUsage = true;
if (modification.ssmt.headerInput.mediumPressureHeader) {
modification.ssmt.headerInput.mediumPressureHeader.useBaselineProcessSteamUsage = true;
}
this.save.emit(tmpModification);
this.save.emit(modification);
}
}
3 changes: 3 additions & 0 deletions src/app/ssmt/modification-list/modification-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class ModificationListComponent implements OnInit {
let ssmtCopy: SSMT = (JSON.parse(JSON.stringify(ssmt)));
delete ssmtCopy.modifications;
ssmtCopy.name = this.newModificationName;

if (ssmtCopy.headerInput.lowPressureHeader) {
ssmtCopy.headerInput.lowPressureHeader.useBaselineProcessSteamUsage = true;
}
Expand All @@ -146,6 +147,8 @@ export class ModificationListComponent implements OnInit {
ssmt: ssmtCopy,
exploreOpportunities: (this.assessmentTab === 'explore-opportunities')
};

tmpModification.ssmt.co2SavingsData.userEnteredModificationEmissions = tmpModification.ssmt.co2SavingsData.userEnteredBaselineEmissions;
this.dropdown.push(false);
this.rename.push(false);
this.deleteArr.push(false);
Expand Down
7 changes: 4 additions & 3 deletions src/app/ssmt/operations/operations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ export class OperationsComponent implements OnInit {
this.co2SavingsData.zipcode = co2SavingsData.zipcode,
this.save();
}

setCo2SavingsData() {
let co2SavingsData: Co2SavingsData = this.ssmt.co2SavingsData;
// todo 6993 - simplify duplicated co2SavingsData objects
let co2SavingsData: Co2SavingsData = copyObject(this.ssmt.co2SavingsData);
// todo weird
if (this.ssmt.co2SavingsData) {
this.co2SavingsData = co2SavingsData;
} else {
Expand All @@ -139,7 +141,6 @@ export class OperationsComponent implements OnInit {
}
this.setEnergySource(shouldSetOutputRate);
}

canCompare() {
if (this.compareService.baselineSSMT && this.compareService.modifiedSSMT && !this.inSetup) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/app/ssmt/ssmt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ export class SsmtComponent implements OnInit {
} else {
mod.ssmt.co2SavingsData.zipcode = ssmt.co2SavingsData.zipcode;
mod.ssmt.co2SavingsData.eGridSubregion = ssmt.co2SavingsData.eGridSubregion;
if (!mod.ssmt.co2SavingsData.totalEmissionOutputRate) {
if (mod.ssmt.co2SavingsData.totalEmissionOutputRate === undefined) {
mod.ssmt.co2SavingsData.totalEmissionOutputRate = ssmt.co2SavingsData.totalEmissionOutputRate;
}
if (!mod.ssmt.co2SavingsData.totalFuelEmissionOutputRate) {
if (mod.ssmt.co2SavingsData.totalFuelEmissionOutputRate === undefined) {
mod.ssmt.co2SavingsData.totalFuelEmissionOutputRate = ssmt.co2SavingsData.totalFuelEmissionOutputRate;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class AddModificationModalComponent implements OnInit {
addModification() {
let wasteWater: WasteWater = this.wasteWaterService.wasteWater.getValue();
let modification: WasteWaterData = JSON.parse(JSON.stringify(wasteWater.baselineData));
modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions;
modification.exploreOpportunities = (this.assessmentTab == 'explore-opportunities');
modification.name = this.newModificationName;
modification.id = Math.random().toString(36).substr(2, 9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class ExploreOpportunitiesFormComponent implements OnInit {
addNewMod() {
let wasteWater: WasteWater = this.wasteWaterService.wasteWater.getValue();
let modification: WasteWaterData = JSON.parse(JSON.stringify(wasteWater.baselineData));
modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions;
modification.exploreOpportunities = true;
modification.name = 'Scenario ' + (wasteWater.modifications.length + 1);
modification.id = Math.random().toString(36).substr(2, 9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ExploreOpportunitiesComponent implements OnInit {
addExploreOpp() {
let wasteWater: WasteWater = this.wasteWaterService.wasteWater.getValue();
let modification: WasteWaterData = JSON.parse(JSON.stringify(wasteWater.baselineData));
modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions;
modification.exploreOpportunities = true;
modification.name = 'Scenario ' + (wasteWater.modifications.length + 1);
modification.id = Math.random().toString(36).substr(2, 9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class ModificationListModalComponent implements OnInit {

addNewModification() {
let modification: WasteWaterData = JSON.parse(JSON.stringify(this.wasteWater.baselineData));
modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions;
modification.name = this.newModificationName;
modification.id = Math.random().toString(36).substr(2, 9);
this.wasteWater.modifications.push(modification);
Expand Down

0 comments on commit 9376ce4

Please sign in to comment.