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 / 31

src/energyplus/ForwardTranslator/ForwardTranslateMeterCustomDecrement.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 "../ForwardTranslator.hpp"
7
8 #include "../../model/Model.hpp"
9 #include "../../model/MeterCustomDecrement.hpp"
10 #include "../../model/MeterCustomDecrement_Impl.hpp"
11
12 #include "../../utilities/core/Logger.hpp"
13 #include "../../utilities/core/Assert.hpp"
14
15 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
16 #include <utilities/idd/Meter_CustomDecrement_FieldEnums.hxx>
17
18 #include "../../utilities/idd/IddEnums.hpp"
19 #include <utilities/idd/IddEnums.hxx>
20 #include <utilities/idd/IddFactory.hxx>
21
22 using namespace openstudio::model;
23
24 // I don't think I'm using this
25 //using namespace std;
26
27 // I don't know if I need this
28 using namespace openstudio::model;
29
30 namespace openstudio {
31
32 namespace energyplus {
33
34 ✗ boost::optional<IdfObject> ForwardTranslator::translateMeterCustomDecrement(MeterCustomDecrement& modelObject) {
35
36 ✗ boost::optional<std::string> s;
37 ✗ boost::optional<double> value;
38
39 ✗ IdfObject idfObject(IddObjectType::Meter_CustomDecrement);
40
41 ✗ m_idfObjects.push_back(idfObject);
42
43 ✗ s = modelObject.name();
44 ✗ if (s) {
45 ✗ idfObject.setName(*s);
46 }
47
48 // FuelType
49 ✗ if ((s = modelObject.fuelType())) {
50 ✗ idfObject.setString(Meter_CustomDecrementFields::ResourceType, s.get());
51 }
52
53 // Source Meter Name
54 ✗ std::string sourceMeterName = modelObject.sourceMeterName();
55 ✗ idfObject.setString(Meter_CustomDecrementFields::SourceMeterName, sourceMeterName);
56
57 // Handle the (Key Name, Output Variable or Meter Name) pairs
58 ✗ std::vector<std::pair<std::string, std::string>> keyVarGroups = modelObject.keyVarGroups();
59
60 ✗ if (!keyVarGroups.empty()) {
61 ✗ for (const auto& keyVarGroup : keyVarGroups) {
62 ✗ IdfExtensibleGroup eg = idfObject.pushExtensibleGroup();
63
64 ✗ eg.setString(Meter_CustomDecrementExtensibleFields::KeyName, keyVarGroup.first);
65 ✗ eg.setString(Meter_CustomDecrementExtensibleFields::OutputVariableorMeterName, keyVarGroup.second);
66 ✗ }
67 } else {
68 ✗ LOG(Error, modelObject.briefDescription() << ": At least one pair of (Key Name, Output Variable or Meter Name) required");
69 ✗ return boost::none;
70 }
71
72 ✗ return boost::optional<IdfObject>(idfObject);
73 ✗ }
74
75 } // namespace energyplus
76
77 } // namespace openstudio
78