GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 87.7% 50 / 0 / 57
Functions: 100.0% 1 / 0 / 1
Branches: 86.6% 71 / 0 / 82

src/energyplus/ForwardTranslator/ForwardTranslateRunPeriod.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/RunPeriod.hpp"
8 #include "../../model/YearDescription.hpp"
9 #include "../../model/YearDescription_Impl.hpp"
10 #include <utilities/idd/RunPeriod_FieldEnums.hxx>
11 #include <utilities/idd/IddEnums.hxx>
12 #include "../../utilities/time/Date.hpp"
13
14 using namespace openstudio::model;
15
16 using namespace std;
17
18 namespace openstudio {
19
20 namespace energyplus {
21
22 856 boost::optional<IdfObject> ForwardTranslator::translateRunPeriod(RunPeriod& modelObject) {
23
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 IdfObject runPeriod(openstudio::IddObjectType::RunPeriod);
24
25
1/1
✓ Branch 1 taken 856 times.
856 m_idfObjects.push_back(runPeriod);
26
27 856 OptionalString s;
28
29
1/1
✓ Branch 1 taken 856 times.
856 s = modelObject.name();
30
1/2
✓ Branch 0 taken 856 times.
✗ Branch 1 not taken.
856 if (s) {
31
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 runPeriod.setName(*s);
32 }
33
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 runPeriod.setInt(openstudio::RunPeriodFields::BeginMonth, modelObject.getBeginMonth());
34
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 runPeriod.setInt(openstudio::RunPeriodFields::BeginDayofMonth, modelObject.getBeginDayOfMonth());
35
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 runPeriod.setInt(openstudio::RunPeriodFields::EndMonth, modelObject.getEndMonth());
36
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 runPeriod.setInt(openstudio::RunPeriodFields::EndDayofMonth, modelObject.getEndDayOfMonth());
37
38
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 model::YearDescription yd = modelObject.model().getUniqueModelObject<model::YearDescription>();
39
3/3
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
✓ Branch 7 taken 856 times.
856 Date firstDay = yd.makeDate(modelObject.getBeginMonth(), modelObject.getBeginDayOfMonth());
40
3/3
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
✓ Branch 7 taken 856 times.
856 Date endDay = yd.makeDate(modelObject.getEndMonth(), modelObject.getEndDayOfMonth());
41
42
1/1
✓ Branch 1 taken 856 times.
856 int beginYear = firstDay.year();
43 856 int endYear = 0;
44
3/3
✓ Branch 1 taken 856 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 855 times.
856 if (endDay < firstDay) {
45 // e.g. 4/1 - 3/31
46
1/1
✓ Branch 1 taken 1 time.
1 endYear = beginYear + modelObject.getNumTimePeriodRepeats();
47 } else {
48 // e.g. 1/1 - 12/31
49
1/1
✓ Branch 1 taken 855 times.
855 endYear = beginYear + modelObject.getNumTimePeriodRepeats() - 1;
50 }
51
52
1/1
✓ Branch 1 taken 856 times.
856 runPeriod.setInt(openstudio::RunPeriodFields::BeginYear, beginYear);
53
1/1
✓ Branch 1 taken 856 times.
856 runPeriod.setInt(openstudio::RunPeriodFields::EndYear, endYear);
54
55 // ETH@20121219 - This always hard codes a day of the week to start on, even if the user
56 // specified "UseWeatherFile". It is important to keep it this way for now, since we are
57 // not parsing the start day out of the weather file, and we are hard-setting the day schedules
58 // based on the settings/assumptions of YearDescription (assumes 2009 if 'UseWeatherFile').
59
7/10
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 826 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
856 switch (firstDay.dayOfWeek().value()) {
60 20 case DayOfWeek::Sunday:
61
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 runPeriod.setString(openstudio::RunPeriodFields::DayofWeekforStartDay, "Sunday");
62 20 break;
63 ✗ case DayOfWeek::Monday:
64 ✗ runPeriod.setString(openstudio::RunPeriodFields::DayofWeekforStartDay, "Monday");
65 ✗ break;
66 2 case DayOfWeek::Tuesday:
67
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 runPeriod.setString(openstudio::RunPeriodFields::DayofWeekforStartDay, "Tuesday");
68 2 break;
69 7 case DayOfWeek::Wednesday:
70
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 runPeriod.setString(openstudio::RunPeriodFields::DayofWeekforStartDay, "Wednesday");
71 7 break;
72 826 case DayOfWeek::Thursday:
73
2/2
✓ Branch 1 taken 826 times.
✓ Branch 4 taken 826 times.
826 runPeriod.setString(openstudio::RunPeriodFields::DayofWeekforStartDay, "Thursday");
74 826 break;
75 ✗ case DayOfWeek::Friday:
76 ✗ runPeriod.setString(openstudio::RunPeriodFields::DayofWeekforStartDay, "Friday");
77 ✗ break;
78 1 case DayOfWeek::Saturday:
79
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 runPeriod.setString(openstudio::RunPeriodFields::DayofWeekforStartDay, "Saturday");
80 1 break;
81 856 default:;
82 }
83
84 // ETH@20121219 - We don't currently support holidays. This makes sure that default day schedules
85 // do not get used unintentionally.
86 // if( modelObject.getUseWeatherFileHolidays() )
87 // {
88 // runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileHolidaysandSpecialDays,"Yes");
89 // }
90 // else
91 // {
92
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
1712 runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileHolidaysandSpecialDays, "No");
93 // }
94
95 // ETH@20121219 - We also do not support pulling the daylight savings period in from the weather
96 // file. Explicit RunPeriodControl:DaylightSavingTime objects already override this field, so
97 // making this change only affects files without such objects (and likely doesn't change results
98 // for those since weather files from the E+ website have no such designations).
99 // if( modelObject.getUseWeatherFileDaylightSavings() )
100 // {
101 // runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileDaylightSavingPeriod,"Yes");
102 // }
103 // else
104 // {
105
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
856 runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileDaylightSavingPeriod, "No");
106 // }
107
108
2/3
✓ Branch 1 taken 856 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 856 times.
856 if (modelObject.getApplyWeekendHolidayRule()) {
109 ✗ runPeriod.setString(openstudio::RunPeriodFields::ApplyWeekendHolidayRule, "Yes");
110 } else {
111
2/2
✓ Branch 1 taken 856 times.
✓ Branch 4 taken 856 times.
1712 runPeriod.setString(openstudio::RunPeriodFields::ApplyWeekendHolidayRule, "No");
112 }
113
114
3/3
✓ Branch 1 taken 856 times.
✓ Branch 3 taken 855 times.
✓ Branch 4 taken 1 time.
856 if (modelObject.getUseWeatherFileRainInd()) {
115
2/2
✓ Branch 1 taken 855 times.
✓ Branch 4 taken 855 times.
1710 runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileRainIndicators, "Yes");
116 } else {
117
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileRainIndicators, "No");
118 }
119
120
3/3
✓ Branch 1 taken 856 times.
✓ Branch 3 taken 855 times.
✓ Branch 4 taken 1 time.
856 if (modelObject.getUseWeatherFileSnowInd()) {
121
2/2
✓ Branch 1 taken 855 times.
✓ Branch 4 taken 855 times.
1710 runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileSnowIndicators, "Yes");
122 } else {
123
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 runPeriod.setString(openstudio::RunPeriodFields::UseWeatherFileSnowIndicators, "No");
124 }
125
126 //runPeriod.setInt(openstudio::RunPeriodFields::NumberofTimesRunperiodtobeRepeated,modelObject.getNumTimePeriodRepeats());
127
128
1/1
✓ Branch 1 taken 856 times.
1712 return boost::optional<IdfObject>(runPeriod);
129 856 }
130
131 } // namespace energyplus
132
133 } // namespace openstudio
134