GCC Code Coverage Report


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

src/energyplus/ReverseTranslator/ReverseTranslateSetpointManagerScheduled.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 #include "../../model/SetpointManagerScheduled.hpp"
8 #include "../../model/SetpointManagerScheduled_Impl.hpp"
9 #include "../../model/Node.hpp"
10 #include "../../model/Node_Impl.hpp"
11 #include "../../model/Schedule.hpp"
12 #include "../../model/Schedule_Impl.hpp"
13 #include <utilities/idd/SetpointManager_Scheduled_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::translateSetpointManagerScheduled(const WorkspaceObject& workspaceObject) {
24 ✗ if (workspaceObject.iddObject().type() != IddObjectType::SetpointManager_Scheduled) {
25 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: SetpointManager_Scheduled");
26 ✗ return boost::none;
27 }
28
29 ✗ boost::optional<WorkspaceObject> wo = workspaceObject.getTarget(SetpointManager_ScheduledFields::ScheduleName);
30 ✗ boost::optional<Schedule> schedule;
31
32 ✗ if (wo) {
33 ✗ boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get());
34 ✗ if (mo) {
35 ✗ if (!(schedule = mo->optionalCast<Schedule>())) {
36 ✗ LOG(Error, workspaceObject.briefDescription() << " does not have an associated schedule");
37
38 ✗ return boost::none;
39 }
40 }
41 ✗ }
42
43 ✗ bool nodeFound = false;
44
45 ✗ if (boost::optional<std::string> setpointNodeName = workspaceObject.getString(SetpointManager_ScheduledFields::SetpointNodeorNodeListName)) {
46 ✗ boost::optional<Node> setpointNode = m_model.getConcreteModelObjectByName<Node>(setpointNodeName.get());
47
48 ✗ if (setpointNode) {
49 ✗ nodeFound = true;
50 }
51 ✗ }
52
53 ✗ if (!nodeFound) {
54 ✗ LOG(Error, workspaceObject.briefDescription() << " is not attached to a node in the model");
55
56 ✗ return boost::none;
57 }
58
59 ✗ if (schedule) {
60 ✗ SetpointManagerScheduled mo(m_model, schedule.get());
61
62 // Name
63 ✗ boost::optional<std::string> s = workspaceObject.getString(SetpointManager_ScheduledFields::Name);
64 ✗ if (s) {
65 ✗ mo.setName(s.get());
66 }
67
68 // Setpoint Node
69 ✗ s = workspaceObject.getString(SetpointManager_ScheduledFields::SetpointNodeorNodeListName);
70 ✗ if (s) {
71 ✗ boost::optional<Node> node = m_model.getConcreteModelObjectByName<Node>(s.get());
72
73 ✗ if (node) {
74 ✗ mo.addToNode(node.get());
75 }
76 ✗ }
77
78 // Control Variable
79 ✗ s = workspaceObject.getString(SetpointManager_ScheduledFields::ControlVariable);
80 ✗ if (s) {
81 ✗ mo.setControlVariable(s.get());
82 }
83
84 ✗ if (mo.setpointNode()) {
85 ✗ return mo;
86 } else {
87 ✗ return boost::none;
88 }
89 ✗ } else {
90 ✗ return boost::none;
91 }
92 ✗ }
93
94 } // namespace energyplus
95
96 } // namespace openstudio
97