GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 85.0% 17 / 0 / 20
Functions: 100.0% 1 / 0 / 1
Branches: 62.9% 22 / 0 / 35

src/energyplus/ReverseTranslator/ReverseTranslateScheduleDayHourly.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/ScheduleDay.hpp"
9 #include "../../model/ScheduleDay_Impl.hpp"
10
11 #include "../../utilities/time/Time.hpp"
12
13 #include <utilities/idd/Schedule_Day_Hourly_FieldEnums.hxx>
14 #include <utilities/idd/OS_Schedule_Day_FieldEnums.hxx>
15 #include "../../utilities/idd/IddEnums.hpp"
16 #include <utilities/idd/IddEnums.hxx>
17
18 using namespace openstudio::model;
19
20 namespace openstudio {
21
22 namespace energyplus {
23
24 3 OptionalModelObject ReverseTranslator::translateScheduleDayHourly(const WorkspaceObject& workspaceObject) {
25
4/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
3 if (workspaceObject.iddObject().type() != IddObjectType::Schedule_Day_Hourly) {
26 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Schedule:Day:Hourly");
27 ✗ return boost::none;
28 }
29
30 // create the schedule
31
1/1
✓ Branch 1 taken 3 times.
3 ScheduleDay scheduleDay(m_model);
32
33
1/1
✓ Branch 1 taken 3 times.
3 OptionalString s = workspaceObject.name();
34
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
35
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 scheduleDay.setName(*s);
36 }
37
38
1/1
✓ Branch 1 taken 3 times.
3 OptionalWorkspaceObject target = workspaceObject.getTarget(Schedule_Day_HourlyFields::ScheduleTypeLimitsName);
39
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (target) {
40
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 OptionalModelObject scheduleTypeLimits = translateAndMapWorkspaceObject(*target);
41
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (scheduleTypeLimits) {
42 ✗ scheduleDay.setPointer(OS_Schedule_DayFields::ScheduleTypeLimitsName, scheduleTypeLimits->handle());
43 }
44 3 }
45
46
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 3 times.
75 for (unsigned i = 0; i < 24; ++i) {
47
1/1
✓ Branch 1 taken 72 times.
72 OptionalDouble d = workspaceObject.getDouble(Schedule_Day_HourlyFields::Hour1 + i, true);
48
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if (d) {
49
3/3
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
72 scheduleDay.addValue(openstudio::Time(0, i + 1, 0, 0), *d);
50 }
51 }
52
53
1/1
✓ Branch 1 taken 3 times.
3 return scheduleDay;
54 3 }
55
56 } // namespace energyplus
57
58 } // namespace openstudio
59