GCC Code Coverage Report


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

src/energyplus/ReverseTranslator/ReverseTranslateMeterCustomDecrement.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/MeterCustomDecrement.hpp"
9 #include "../../model/MeterCustomDecrement_Impl.hpp"
10
11 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
12
13 #include <utilities/idd/Meter_CustomDecrement_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::translateMeterCustomDecrement(const WorkspaceObject& workspaceObject) {
24 ✗ if (workspaceObject.iddObject().type() != IddObjectType::Meter_CustomDecrement) {
25 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Meter:CustomDecrement");
26 ✗ return boost::none;
27 }
28
29 ✗ boost::optional<MeterCustomDecrement> optMeterCustomDecrement;
30 ✗ boost::optional<std::string> s;
31
32 // Source Meter Name: get it and pass it to the constructor
33 ✗ s = workspaceObject.getString(Meter_CustomDecrementFields::SourceMeterName);
34 ✗ if (s) {
35 // Create an OS:Meter:CustomDecrement object
36 ✗ optMeterCustomDecrement = MeterCustomDecrement(m_model, s.get());
37 } else {
38 ✗ LOG(Error, workspaceObject.briefDescription() << " does not have a Source Meter Name which is required. It will not be translated!");
39 }
40
41 ✗ MeterCustomDecrement meterCustomDecrement = optMeterCustomDecrement.get();
42
43 // Name
44 ✗ s = workspaceObject.getString(Meter_CustomDecrementFields::Name);
45 ✗ if (s) {
46 ✗ meterCustomDecrement.setName(s.get());
47 }
48
49 // Fuel Type
50 ✗ s = workspaceObject.getString(Meter_CustomDecrementFields::ResourceType);
51 ✗ if (s) {
52 // TODO: JM to DLM: should I also check it's part of the validFuelTypes?
53 ✗ meterCustomDecrement.setFuelType(s.get());
54 }
55
56 // Get all the (key, var) extensible groups from IDF
57 ✗ std::vector<IdfExtensibleGroup> keyVarGroups = workspaceObject.extensibleGroups();
58
59 // Clean out the (key, var) groups (just in case: the constructor doesn't default any, for now at least!)
60 ✗ meterCustomDecrement.removeAllKeyVarGroups();
61
62 // Push them all to the object
63 ✗ for (const auto& keyVarGroup : keyVarGroups) {
64 ✗ meterCustomDecrement.pushExtensibleGroup(keyVarGroup.fields());
65 }
66
67 ✗ return meterCustomDecrement;
68 ✗ }
69
70 } // namespace energyplus
71
72 } // namespace openstudio
73