GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 31 / 0 / 31
Functions: 100.0% 1 / 0 / 1
Branches: 93.2% 41 / 0 / 44

src/energyplus/ForwardTranslator/ForwardTranslateScheduleDay.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 #include "../../model/Model.hpp"
8
9 #include "../../model/ScheduleTypeLimits.hpp"
10 #include "../../model/ScheduleTypeLimits_Impl.hpp"
11 #include "../../model/ScheduleDay.hpp"
12 #include "../../model/ScheduleDay_Impl.hpp"
13
14 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
15 #include "../../utilities/idf/Workspace.hpp"
16 #include "../../utilities/time/Time.hpp"
17 #include "../../utilities/core/Logger.hpp"
18 #include "../../utilities/core/Assert.hpp"
19
20 #include <utilities/idd/Schedule_Day_Interval_FieldEnums.hxx>
21 #include <utilities/idd/IddEnums.hxx>
22
23 using namespace openstudio::model;
24
25 using namespace std;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 2663 boost::optional<IdfObject> ForwardTranslator::translateScheduleDay(ScheduleDay& modelObject) {
32
2/2
✓ Branch 1 taken 2663 times.
✓ Branch 4 taken 2663 times.
2663 IdfObject scheduleDay = createRegisterAndNameIdfObject(openstudio::IddObjectType::Schedule_Day_Interval, modelObject);
33
34
1/1
✓ Branch 1 taken 2663 times.
2663 boost::optional<ScheduleTypeLimits> scheduleTypeLimits = modelObject.scheduleTypeLimits();
35
2/2
✓ Branch 0 taken 2204 times.
✓ Branch 1 taken 459 times.
2663 if (scheduleTypeLimits) {
36
2/2
✓ Branch 1 taken 2204 times.
✓ Branch 4 taken 2204 times.
2204 boost::optional<IdfObject> idfScheduleTypeLimits = translateAndMapModelObject(*scheduleTypeLimits);
37
1/2
✓ Branch 0 taken 2204 times.
✗ Branch 1 not taken.
2204 if (idfScheduleTypeLimits) {
38
4/4
✓ Branch 1 taken 2204 times.
✓ Branch 4 taken 2204 times.
✓ Branch 7 taken 2204 times.
✓ Branch 10 taken 2204 times.
2204 scheduleDay.setString(Schedule_Day_IntervalFields::ScheduleTypeLimitsName, idfScheduleTypeLimits->name().get());
39 }
40 2204 }
41
42
2/2
✓ Branch 1 taken 2663 times.
✓ Branch 4 taken 2663 times.
2663 scheduleDay.setString(Schedule_Day_IntervalFields::InterpolatetoTimestep, modelObject.interpolatetoTimestep());
43
44
1/1
✓ Branch 1 taken 2663 times.
2663 std::vector<double> values = modelObject.values();
45
1/1
✓ Branch 1 taken 2663 times.
2663 std::vector<openstudio::Time> times = modelObject.times();
46
47 2663 unsigned N = values.size();
48
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2663 times.
✗ Branch 4 not taken.
2663 OS_ASSERT(N == times.size());
49
50
1/1
✓ Branch 1 taken 2663 times.
2663 scheduleDay.clearExtensibleGroups();
51
52
2/2
✓ Branch 0 taken 10013 times.
✓ Branch 1 taken 2663 times.
12676 for (unsigned i = 0; i < N; ++i) {
53
1/1
✓ Branch 1 taken 10013 times.
10013 IdfExtensibleGroup group = scheduleDay.pushExtensibleGroup();
54
55 10013 std::string hourPrefix;
56 10013 std::string minutePrefix;
57
58
2/2
✓ Branch 2 taken 10013 times.
✓ Branch 6 taken 10013 times.
10013 int hours = times[i].hours() + 24 * times[i].days();
59
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 7325 times.
10013 if (hours < 10) {
60
1/1
✓ Branch 1 taken 2688 times.
2688 hourPrefix = "0";
61 }
62
63
2/2
✓ Branch 2 taken 10013 times.
✓ Branch 6 taken 10013 times.
10013 int minutes = times[i].minutes() + (int)std::floor((times[i].seconds() / 60.0) + 0.5);
64
2/2
✓ Branch 0 taken 9943 times.
✓ Branch 1 taken 70 times.
10013 if (minutes < 10) {
65
1/1
✓ Branch 1 taken 9943 times.
9943 minutePrefix = "0";
66 }
67
68
1/1
✓ Branch 1 taken 10013 times.
10013 std::stringstream ss;
69
5/5
✓ Branch 1 taken 10013 times.
✓ Branch 4 taken 10013 times.
✓ Branch 7 taken 10013 times.
✓ Branch 10 taken 10013 times.
✓ Branch 13 taken 10013 times.
10013 ss << hourPrefix << hours << ":" << minutePrefix << minutes;
70
71
2/2
✓ Branch 1 taken 10013 times.
✓ Branch 4 taken 10013 times.
10013 group.setString(Schedule_Day_IntervalExtensibleFields::Time, ss.str());
72
1/1
✓ Branch 2 taken 10013 times.
10013 group.setDouble(Schedule_Day_IntervalExtensibleFields::ValueUntilTime, values[i]);
73 10013 }
74
75
1/1
✓ Branch 1 taken 2663 times.
5326 return scheduleDay;
76 2663 }
77
78 } // namespace energyplus
79
80 } // namespace openstudio
81