GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 56.8% 79 / 0 / 139
Functions: 47.2% 17 / 0 / 36
Branches: 48.3% 70 / 0 / 145

src/model/LightingDesignDay.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 "LightingDesignDay.hpp"
7 #include "LightingDesignDay_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "ModelExtensibleGroup.hpp"
11 #include "Site.hpp"
12 #include "Site_Impl.hpp"
13
14 #include <utilities/idd/IddFactory.hxx>
15
16 #include <utilities/idd/OS_LightingDesignDay_FieldEnums.hxx>
17 #include <utilities/idd/IddEnums.hxx>
18
19 #include "../utilities/time/DateTime.hpp"
20 #include "../utilities/core/Assert.hpp"
21
22 namespace openstudio {
23 namespace model {
24
25 namespace detail {
26
27 1 LightingDesignDay_Impl::LightingDesignDay_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
28 1 : ModelObject_Impl(idfObject, model, keepHandle) {
29
4/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
1 OS_ASSERT(idfObject.iddObject().type() == LightingDesignDay::iddObjectType());
30 1 }
31
32 ✗ LightingDesignDay_Impl::LightingDesignDay_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
33 ✗ : ModelObject_Impl(other, model, keepHandle) {
34 ✗ OS_ASSERT(other.iddObject().type() == LightingDesignDay::iddObjectType());
35 ✗ }
36
37 ✗ LightingDesignDay_Impl::LightingDesignDay_Impl(const LightingDesignDay_Impl& other, Model_Impl* model, bool keepHandle)
38 ✗ : ModelObject_Impl(other, model, keepHandle) {}
39
40 ✗ boost::optional<ParentObject> LightingDesignDay_Impl::parent() const {
41 ✗ boost::optional<ParentObject> result(model().getOptionalUniqueModelObject<Site>());
42 ✗ return result;
43 }
44
45 ✗ const std::vector<std::string>& LightingDesignDay_Impl::outputVariableNames() const {
46 ✗ static const std::vector<std::string> result;
47 ✗ return result;
48 }
49
50 ✗ IddObjectType LightingDesignDay_Impl::iddObjectType() const {
51 ✗ return LightingDesignDay::iddObjectType();
52 }
53
54 1 std::string LightingDesignDay_Impl::cieSkyModel() const {
55
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<std::string> value = getString(OS_LightingDesignDayFields::CIESkyModel, true);
56
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
1 OS_ASSERT(value);
57
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 return value.get();
58 1 }
59
60 ✗ int LightingDesignDay_Impl::snowIndicator() const {
61 ✗ boost::optional<int> value = getInt(OS_LightingDesignDayFields::SnowIndicator, true);
62 ✗ OS_ASSERT(value);
63 ✗ return value.get();
64 }
65
66 ✗ bool LightingDesignDay_Impl::isSnowIndicatorDefaulted() const {
67 ✗ return isEmpty(OS_LightingDesignDayFields::SnowIndicator);
68 }
69
70 1 bool LightingDesignDay_Impl::setCIESkyModel(const std::string& cIESkyModel) {
71 1 bool result = setString(OS_LightingDesignDayFields::CIESkyModel, cIESkyModel);
72 1 return result;
73 }
74
75 ✗ bool LightingDesignDay_Impl::setSnowIndicator(int snowIndicator) {
76 ✗ bool result = setInt(OS_LightingDesignDayFields::SnowIndicator, snowIndicator);
77 ✗ return result;
78 }
79
80 ✗ void LightingDesignDay_Impl::resetSnowIndicator() {
81 ✗ bool result = setString(OS_LightingDesignDayFields::SnowIndicator, "");
82 ✗ OS_ASSERT(result);
83 ✗ }
84
85 2 openstudio::Date LightingDesignDay_Impl::date() const {
86
1/1
✓ Branch 1 taken 2 times.
2 OptionalInt month = getInt(OS_LightingDesignDayFields::Month, true);
87
1/1
✓ Branch 1 taken 2 times.
2 OptionalInt dayofMonth = getInt(OS_LightingDesignDayFields::DayofMonth, true);
88
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(month);
89
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(dayofMonth);
90
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 return {MonthOfYear(*month), static_cast<unsigned int>(*dayofMonth)};
91 }
92
93 1 bool LightingDesignDay_Impl::setDate(const openstudio::Date& date) {
94
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 bool test = setInt(OS_LightingDesignDayFields::Month, date.monthOfYear().value(), false);
95
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(test);
96 1 test = setInt(OS_LightingDesignDayFields::DayofMonth, date.dayOfMonth());
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(test);
98 1 return true;
99 }
100
101 3 std::vector<openstudio::Time> LightingDesignDay_Impl::simulationTimes() const {
102 3 std::vector<openstudio::Time> result;
103
104
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
6 for (const ModelExtensibleGroup& group : castVector<ModelExtensibleGroup>(extensibleGroups())) {
105
1/1
✓ Branch 1 taken 3 times.
3 OptionalInt hour = group.getInt(OS_LightingDesignDayExtensibleFields::HourtoSimulate, true);
106
1/1
✓ Branch 1 taken 3 times.
3 OptionalInt minute = group.getInt(OS_LightingDesignDayExtensibleFields::MinutetoSimulate, true);
107
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(hour);
108
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(minute);
109
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 result.emplace_back(0, *hour, *minute);
110 3 }
111
112 3 return result;
113 ✗ }
114
115 1 std::vector<openstudio::DateTime> LightingDesignDay_Impl::simulationDateTimes() const {
116
1/1
✓ Branch 1 taken 1 time.
1 Date date = this->date();
117 1 std::vector<openstudio::DateTime> result;
118
119
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 1 time.
4 for (const ModelExtensibleGroup& group : castVector<ModelExtensibleGroup>(extensibleGroups())) {
120
1/1
✓ Branch 1 taken 3 times.
3 OptionalInt hour = group.getInt(OS_LightingDesignDayExtensibleFields::HourtoSimulate, true);
121
1/1
✓ Branch 1 taken 3 times.
3 OptionalInt minute = group.getInt(OS_LightingDesignDayExtensibleFields::MinutetoSimulate, true);
122
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(hour);
123
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(minute);
124
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 result.emplace_back(date, Time(0, *hour, *minute));
125 1 }
126
127 2 return result;
128 ✗ }
129
130 5 bool LightingDesignDay_Impl::addSimulationTime(const openstudio::Time& time) {
131
1/1
✓ Branch 1 taken 5 times.
5 double totalDays = time.totalDays();
132
1/1
✓ Branch 1 taken 5 times.
5 unsigned hours = time.hours();
133
1/1
✓ Branch 1 taken 5 times.
5 unsigned minutes = time.minutes();
134
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 3 times.
5 if ((totalDays > 1) || (totalDays < 0)) {
135 2 return false;
136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 } else if (totalDays == 1) {
137 ✗ hours = 24;
138 ✗ minutes = 0;
139 }
140
141
3/5
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12 std::vector<std::string> temp{std::to_string(hours), std::to_string(minutes)};
142
143
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 auto group = pushExtensibleGroup(temp).cast<ModelExtensibleGroup>();
144
1/1
✓ Branch 1 taken 3 times.
3 return (!group.empty());
145 6 }
146
147 ✗ void LightingDesignDay_Impl::clearSimulationTimes() {
148 ✗ clearExtensibleGroups();
149 ✗ }
150
151 ✗ void LightingDesignDay_Impl::ensureNoLeapDays() {
152 ✗ boost::optional<int> month;
153 ✗ boost::optional<int> day;
154
155 ✗ month = getInt(OS_LightingDesignDayFields::Month);
156 ✗ if (month && (month.get() == 2)) {
157 ✗ day = this->getInt(OS_LightingDesignDayFields::DayofMonth);
158 ✗ if (day && (day.get() == 29)) {
159 ✗ this->setInt(OS_LightingDesignDayFields::DayofMonth, 28);
160 }
161 }
162 ✗ }
163
164 } // namespace detail
165
166 1 LightingDesignDay::LightingDesignDay(const std::string& cieSkyModel, const openstudio::Date& date, const Model& model)
167 1 : ModelObject(LightingDesignDay::iddObjectType(), model) {
168
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 5 not taken.
1 OS_ASSERT(getImpl<detail::LightingDesignDay_Impl>());
169
1/1
✓ Branch 1 taken 1 time.
1 setCIESkyModel(cieSkyModel);
170
1/1
✓ Branch 1 taken 1 time.
1 setDate(date);
171 1 }
172
173 7685 IddObjectType LightingDesignDay::iddObjectType() {
174
1/1
✓ Branch 1 taken 7685 times.
7685 IddObjectType result(IddObjectType::OS_LightingDesignDay);
175 7685 return result;
176 }
177
178 ✗ std::vector<std::string> LightingDesignDay::validCIESkyModelValues() {
179 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_LightingDesignDayFields::CIESkyModel);
180 }
181
182 1 std::string LightingDesignDay::cieSkyModel() const {
183
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::LightingDesignDay_Impl>()->cieSkyModel();
184 }
185
186 ✗ int LightingDesignDay::snowIndicator() const {
187 ✗ return getImpl<detail::LightingDesignDay_Impl>()->snowIndicator();
188 }
189
190 ✗ bool LightingDesignDay::isSnowIndicatorDefaulted() const {
191 ✗ return getImpl<detail::LightingDesignDay_Impl>()->isSnowIndicatorDefaulted();
192 }
193
194 1 bool LightingDesignDay::setCIESkyModel(const std::string& cIESkyModel) {
195
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::LightingDesignDay_Impl>()->setCIESkyModel(cIESkyModel);
196 }
197
198 ✗ bool LightingDesignDay::setSnowIndicator(int snowIndicator) {
199 ✗ return getImpl<detail::LightingDesignDay_Impl>()->setSnowIndicator(snowIndicator);
200 }
201
202 ✗ void LightingDesignDay::resetSnowIndicator() {
203 ✗ getImpl<detail::LightingDesignDay_Impl>()->resetSnowIndicator();
204 ✗ }
205
206 1 openstudio::Date LightingDesignDay::date() const {
207
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::LightingDesignDay_Impl>()->date();
208 }
209
210 1 bool LightingDesignDay::setDate(const openstudio::Date& date) {
211
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::LightingDesignDay_Impl>()->setDate(date);
212 }
213
214 3 std::vector<openstudio::Time> LightingDesignDay::simulationTimes() const {
215
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::LightingDesignDay_Impl>()->simulationTimes();
216 }
217
218 1 std::vector<openstudio::DateTime> LightingDesignDay::simulationDateTimes() const {
219
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::LightingDesignDay_Impl>()->simulationDateTimes();
220 }
221
222 5 bool LightingDesignDay::addSimulationTime(const openstudio::Time& time) {
223
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::LightingDesignDay_Impl>()->addSimulationTime(time);
224 }
225
226 ✗ void LightingDesignDay::clearSimulationTimes() {
227 ✗ return getImpl<detail::LightingDesignDay_Impl>()->clearSimulationTimes();
228 }
229
230 ✗ void LightingDesignDay::ensureNoLeapDays() {
231 ✗ getImpl<detail::LightingDesignDay_Impl>()->ensureNoLeapDays();
232 ✗ }
233
234 /// @cond
235 ✗ LightingDesignDay::LightingDesignDay(std::shared_ptr<detail::LightingDesignDay_Impl> impl) : ModelObject(std::move(impl)) {}
236 /// @endcond
237
238 } // namespace model
239 } // namespace openstudio
240