GCC Code Coverage Report


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

src/energyplus/ReverseTranslator/ReverseTranslateMeterCustom.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/MeterCustom.hpp"
9 #include "../../model/MeterCustom_Impl.hpp"
10
11 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
12
13 #include <utilities/idd/Meter_Custom_FieldEnums.hxx>
14 #include "../../utilities/idd/IddEnums.hpp"
15 #include <utilities/idd/IddEnums.hxx>
16
17 using namespace openstudio::model;
18
19 namespace openstudio {
20
21 namespace energyplus {
22
23 ✗ OptionalModelObject ReverseTranslator::translateMeterCustom(const WorkspaceObject& workspaceObject) {
24 ✗ if (workspaceObject.iddObject().type() != IddObjectType::Meter_Custom) {
25 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Meter:Custom");
26 ✗ return boost::none;
27 }
28
29 // Create an OS:Meter:Custom object
30 ✗ MeterCustom meterCustom = MeterCustom(m_model);
31
32 // Name
33 ✗ boost::optional<std::string> s = workspaceObject.getString(Meter_CustomFields::Name);
34 ✗ if (s) {
35 ✗ meterCustom.setName(s.get());
36 }
37
38 // Fuel Type
39 ✗ s = workspaceObject.getString(Meter_CustomFields::ResourceType);
40 ✗ if (s) {
41 // TODO: JM to DLM: should I also check it's part of the validFuelTypes?
42 ✗ meterCustom.setFuelType(s.get());
43 }
44
45 // Get all the (key, var) extensible groups from IDF
46 ✗ std::vector<IdfExtensibleGroup> keyVarGroups = workspaceObject.extensibleGroups();
47
48 // Clean out the (key, var) groups (just in case: the constructor doesn't default any, for now at least!)
49 ✗ meterCustom.removeAllKeyVarGroups();
50
51 // Push them all to the object
52 ✗ for (const auto& keyVarGroup : keyVarGroups) {
53 ✗ meterCustom.pushExtensibleGroup(keyVarGroup.fields());
54 }
55
56 ✗ return meterCustom;
57 ✗ }
58
59 } // namespace energyplus
60
61 } // namespace openstudio
62