GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 88.9% 16 / 0 / 18
Functions: 100.0% 1 / 0 / 1
Branches: 75.0% 24 / 0 / 32

src/energyplus/ReverseTranslator/ReverseTranslateScheduleConstant.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/ScheduleConstant.hpp"
9 #include "../../model/ScheduleConstant_Impl.hpp"
10
11 #include <utilities/idd/Schedule_Constant_FieldEnums.hxx>
12 #include <utilities/idd/OS_Schedule_Constant_FieldEnums.hxx>
13 #include "../../utilities/idd/IddEnums.hpp"
14 #include <utilities/idd/IddEnums.hxx>
15
16 using namespace openstudio::model;
17
18 namespace openstudio {
19
20 namespace energyplus {
21
22 178 OptionalModelObject ReverseTranslator::translateScheduleConstant(const WorkspaceObject& workspaceObject) {
23
4/5
✓ Branch 1 taken 178 times.
✓ Branch 4 taken 178 times.
✓ Branch 7 taken 178 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 178 times.
178 if (workspaceObject.iddObject().type() != IddObjectType::Schedule_Constant) {
24 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Schedule:Constant");
25 ✗ return boost::none;
26 }
27
28
1/1
✓ Branch 1 taken 178 times.
178 ScheduleConstant scheduleConstant(m_model);
29
30
2/3
✓ Branch 1 taken 178 times.
✓ Branch 3 taken 178 times.
✗ Branch 4 not taken.
356 if (OptionalString os = workspaceObject.name()) {
31
2/2
✓ Branch 1 taken 178 times.
✓ Branch 4 taken 178 times.
178 scheduleConstant.setName(*os);
32 178 }
33
34
1/1
✓ Branch 1 taken 178 times.
178 boost::optional<WorkspaceObject> target = workspaceObject.getTarget(Schedule_ConstantFields::ScheduleTypeLimitsName);
35
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 82 times.
178 if (target) {
36
2/2
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
96 OptionalModelObject scheduleTypeLimits = translateAndMapWorkspaceObject(*target);
37
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if (scheduleTypeLimits) {
38
3/3
✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 7 taken 96 times.
96 scheduleConstant.setPointer(OS_Schedule_ConstantFields::ScheduleTypeLimitsName, scheduleTypeLimits->handle());
39 }
40 96 }
41
3/3
✓ Branch 1 taken 178 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 32 times.
356 if (OptionalDouble val = workspaceObject.getDouble(Schedule_ConstantFields::HourlyValue)) {
42
2/2
✓ Branch 1 taken 146 times.
✓ Branch 4 taken 146 times.
146 scheduleConstant.setValue(*val);
43 }
44
45
1/1
✓ Branch 1 taken 178 times.
178 return scheduleConstant;
46 178 }
47
48 } // namespace energyplus
49
50 } // namespace openstudio
51