GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 47
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 80

src/energyplus/ReverseTranslator/ReverseTranslateElectricLoadCenterStorageConverter.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "../ReverseTranslator.hpp"
7
8 #include "../../model/ElectricLoadCenterStorageConverter.hpp"
9 #include "../../model/ElectricLoadCenterStorageConverter_Impl.hpp"
10
11 #include "../../model/Schedule.hpp"
12 #include "../../model/Schedule_Impl.hpp"
13 #include "../../model/ThermalZone.hpp"
14 #include "../../model/ThermalZone_Impl.hpp"
15 #include "../../model/Space.hpp"
16 #include "../../model/Space_Impl.hpp"
17 #include "../../model/Curve.hpp"
18 #include "../../model/Curve_Impl.hpp"
19
20 #include <utilities/idd/ElectricLoadCenter_Storage_Converter_FieldEnums.hxx>
21
22 #include "../../utilities/idd/IddEnums.hpp"
23 #include <utilities/idd/IddEnums.hxx>
24 #include "../../utilities/core/Compare.hpp"
25
26 using namespace openstudio::model;
27
28 namespace openstudio {
29
30 namespace energyplus {
31
32 ✗ OptionalModelObject ReverseTranslator::translateElectricLoadCenterStorageConverter(const WorkspaceObject& workspaceObject) {
33
34 ✗ OptionalModelObject omo;
35 ✗ OptionalDouble optD;
36 ✗ boost::optional<WorkspaceObject> owo;
37 ✗ OptionalString optS;
38 ✗ bool isSimpleFixed = true;
39
40 ✗ openstudio::model::ElectricLoadCenterStorageConverter elcConv(m_model);
41
42 // Name
43 ✗ optS = workspaceObject.name();
44 ✗ if (optS) {
45 ✗ elcConv.setName(*optS);
46 }
47
48 // AvailabilityScheduleName
49 ✗ if ((owo = workspaceObject.getTarget(ElectricLoadCenter_Storage_ConverterFields::AvailabilityScheduleName))) {
50 ✗ if ((omo = translateAndMapWorkspaceObject(*owo))) {
51 ✗ if (boost::optional<Schedule> schedule = omo->optionalCast<Schedule>()) {
52 ✗ elcConv.setAvailabilitySchedule(schedule.get());
53 ✗ }
54 }
55 }
56
57 // PowerConversionEfficiencyMethod, string
58 ✗ optS = workspaceObject.getString(ElectricLoadCenter_Storage_ConverterFields::PowerConversionEfficiencyMethod);
59 ✗ if (optS) {
60 ✗ if (istringEqual(*optS, "FunctionOfPower")) {
61 ✗ isSimpleFixed = false;
62 }
63 }
64
65 ✗ if (isSimpleFixed) {
66 // SimpleFixedEfficiency, optD
67 ✗ optD = workspaceObject.getDouble(ElectricLoadCenter_Storage_ConverterFields::SimpleFixedEfficiency);
68 ✗ if (optD) {
69 ✗ elcConv.setSimpleFixedEfficiency(*optD);
70 }
71 } else {
72 // designMaximumContinuousInputPower, optD
73 ✗ optD = workspaceObject.getDouble(ElectricLoadCenter_Storage_ConverterFields::DesignMaximumContinuousInputPower);
74 ✗ if (optD) {
75 ✗ elcConv.setDesignMaximumContinuousInputPower(*optD);
76 }
77
78 // efficiencyFunctionofPowerCurveName, optCurve
79 ✗ if ((owo = workspaceObject.getTarget(ElectricLoadCenter_Storage_ConverterFields::EfficiencyFunctionofPowerCurveName))) {
80 ✗ if ((omo = translateAndMapWorkspaceObject(*owo))) {
81 // Should technically make sure the curve is the right type, but in this case it's UnivariateCurves, lots of possibilities.
82 ✗ if (boost::optional<Curve> effFPower = omo->optionalCast<Curve>()) {
83 ✗ elcConv.setEfficiencyFunctionofPowerCurve(effFPower.get());
84 ✗ }
85 }
86 }
87 }
88
89 // AncillaryPowerConsumedInStandby, defaults (double)
90 ✗ optD = workspaceObject.getDouble(ElectricLoadCenter_Storage_ConverterFields::AncillaryPowerConsumedInStandby);
91 ✗ if (optD) {
92 ✗ elcConv.setAncillaryPowerConsumedInStandby(*optD);
93 }
94
95 // ZoneName
96 ✗ if ((owo = workspaceObject.getTarget(ElectricLoadCenter_Storage_ConverterFields::ZoneName))) {
97 ✗ if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(owo.get())) {
98 // Zone is translated, and a Space is returned instead
99 ✗ if (boost::optional<Space> space_ = mo->optionalCast<Space>()) {
100 ✗ if (auto z_ = space_->thermalZone()) {
101 ✗ elcConv.setThermalZone(z_.get());
102 ✗ }
103 ✗ }
104 ✗ }
105 }
106
107 // Radiative Fraction, defaults (double)
108 ✗ optD = workspaceObject.getDouble(ElectricLoadCenter_Storage_ConverterFields::RadiativeFraction);
109 ✗ if (optD) {
110 ✗ elcConv.setRadiativeFraction(*optD);
111 }
112
113 ✗ return elcConv;
114 ✗ }
115
116 } // namespace energyplus
117
118 } // namespace openstudio
119