GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 86.4% 38 / 0 / 44
Functions: 100.0% 1 / 0 / 1
Branches: 47.3% 52 / 0 / 110

src/energyplus/ReverseTranslator/ReverseTranslateTableLookup.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/TableLookup.hpp"
9
10 #include "../../model/TableIndependentVariable.hpp"
11 #include "../../model/TableIndependentVariable_Impl.hpp"
12
13 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
14 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
15
16 #include <utilities/idd/Table_Lookup_FieldEnums.hxx>
17 #include <utilities/idd/Table_IndependentVariableList_FieldEnums.hxx>
18
19 #include <utilities/idd/IddEnums.hxx>
20
21 using namespace openstudio::model;
22
23 namespace openstudio {
24
25 namespace energyplus {
26
27 1 boost::optional<ModelObject> ReverseTranslator::translateTableLookup(const WorkspaceObject& workspaceObject) {
28
29 // External File Name: Optional String
30
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if (boost::optional<std::string> _externalFileName = workspaceObject.getString(Table_LookupFields::ExternalFileName, false, true)) {
31 ✗ LOG(Error, workspaceObject.briefDescription()
32 << " is referencing an External File '" << _externalFileName.get() << "', which is not supported.");
33 ✗ return boost::none;
34 1 }
35
36 // Instantiate an object of the class to store the values,
37
1/1
✓ Branch 1 taken 1 time.
1 openstudio::model::TableLookup modelObject(m_model);
38
39 // Name
40
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<std::string> _name = workspaceObject.name()) {
41
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setName(_name.get());
42 1 }
43
44 // Independent Variable List Name: Required Object
45
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<WorkspaceObject> varList_ = workspaceObject.getTarget(Table_LookupFields::IndependentVariableListName)) {
46
47
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 1 time.
2 for (unsigned i = 0; const IdfExtensibleGroup& idfGroup : varList_->extensibleGroups()) {
48
1/1
✓ Branch 1 taken 1 time.
1 auto weg = idfGroup.cast<WorkspaceExtensibleGroup>();
49
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<WorkspaceObject> var_ = weg.getTarget(Table_IndependentVariableListExtensibleFields::IndependentVariableName)) {
50
51
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto mo_ = translateTableIndependentVariable(var_.get())) {
52
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto v_ = mo_->optionalCast<openstudio::model::TableIndependentVariable>()) {
53
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.addIndependentVariable(v_.get());
54 } else {
55 ✗ LOG(Warn, "For " << workspaceObject.briefDescription() << ", in the Table:IndependentVariableList named '" << varList_->nameString()
56 << "', the extensible group " << i << " has a wrong type for 'Independent Variable', skipping.");
57 1 }
58 1 }
59
60 } else {
61 ✗ LOG(Error, "For " << workspaceObject.briefDescription() << ", in the Table:IndependentVariableList named '" << varList_->nameString()
62 << "', the extensible group " << i << " does not refer to a Table:IndependentVariable, skipping.");
63 1 }
64
65 1 ++i;
66 2 }
67
68 } else {
69 ✗ LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required object 'Independent Variable List Name'");
70 ✗ return boost::none;
71 1 }
72
73 // Normalization Method: Optional String
74
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<std::string> _normalizationMethod = workspaceObject.getString(Table_LookupFields::NormalizationMethod, false, true)) {
75
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setNormalizationMethod(_normalizationMethod.get());
76 1 }
77
78 // Normalization Divisor: Optional Double
79
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<double> _normalizationDivisor = workspaceObject.getDouble(Table_LookupFields::NormalizationDivisor)) {
80
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setNormalizationDivisor(_normalizationDivisor.get());
81 }
82
83 // Minimum Output: Optional Double
84
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<double> _minimumOutput = workspaceObject.getDouble(Table_LookupFields::MinimumOutput)) {
85
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setMinimumOutput(_minimumOutput.get());
86 }
87
88 // Maximum Output: Optional Double
89
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<double> _maximumOutput = workspaceObject.getDouble(Table_LookupFields::MaximumOutput)) {
90
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setMaximumOutput(_maximumOutput.get());
91 }
92
93 // Output Unit Type: Optional String
94
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<std::string> _outputUnitType = workspaceObject.getString(Table_LookupFields::OutputUnitType, false, true)) {
95
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 modelObject.setOutputUnitType(_outputUnitType.get());
96 1 }
97
98 // // External File Column Number: Optional Integer
99 // if (boost::optional<int> _externalFileColumnNumber = workspaceObject.getInt(Table_LookupFields::ExternalFileColumnNumber)) {
100 // modelObject.setExternalFileColumnNumber(_externalFileColumnNumber.get());
101 // }
102
103 // // External File Starting Row Number: Optional Integer
104 // if (boost::optional<int> _externalFileStartingRowNumber = workspaceObject.getInt(Table_LookupFields::ExternalFileStartingRowNumber)) {
105 // modelObject.setExternalFileStartingRowNumber(_externalFileStartingRowNumber.get());
106 // }
107
108 // Extensible Output Values
109
3/3
✓ Branch 1 taken 1 time.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 1 time.
4 for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) {
110
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<double> value = eg.getDouble(Table_LookupExtensibleFields::OutputValue)) {
111
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 modelObject.addOutputValue(value.get());
112 }
113 1 }
114
115
1/1
✓ Branch 1 taken 1 time.
1 return modelObject;
116 1 } // End of translate function
117
118 } // end namespace energyplus
119 } // end namespace openstudio
120