GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 78.0% 96 / 0 / 123
Functions: 88.6% 31 / 0 / 35
Branches: 29.4% 58 / 0 / 197

src/model/ExternalInterfaceActuator.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 "ExternalInterfaceActuator.hpp"
7 #include "ExternalInterfaceActuator_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "Model_Impl.hpp"
11
12 #include <utilities/idd/IddEnums.hxx>
13 #include <utilities/idd/OS_ExternalInterface_Actuator_FieldEnums.hxx>
14
15 #include "../utilities/units/Unit.hpp"
16
17 #include "../utilities/core/Assert.hpp"
18
19 namespace openstudio {
20 namespace model {
21
22 namespace detail {
23
24 3 ExternalInterfaceActuator_Impl::ExternalInterfaceActuator_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
25 3 : ModelObject_Impl(idfObject, model, keepHandle) {
26
4/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 13 not taken.
3 OS_ASSERT(idfObject.iddObject().type() == ExternalInterfaceActuator::iddObjectType());
27 3 }
28
29 ✗ ExternalInterfaceActuator_Impl::ExternalInterfaceActuator_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
30 ✗ bool keepHandle)
31 ✗ : ModelObject_Impl(other, model, keepHandle) {
32 ✗ OS_ASSERT(other.iddObject().type() == ExternalInterfaceActuator::iddObjectType());
33 ✗ }
34
35 1 ExternalInterfaceActuator_Impl::ExternalInterfaceActuator_Impl(const ExternalInterfaceActuator_Impl& other, Model_Impl* model, bool keepHandle)
36 1 : ModelObject_Impl(other, model, keepHandle) {}
37
38 ✗ const std::vector<std::string>& ExternalInterfaceActuator_Impl::outputVariableNames() const {
39 ✗ static const std::vector<std::string> result;
40 ✗ return result;
41 }
42
43 ✗ IddObjectType ExternalInterfaceActuator_Impl::iddObjectType() const {
44 ✗ return ExternalInterfaceActuator::iddObjectType();
45 }
46
47 4 ModelObject ExternalInterfaceActuator_Impl::actuatedComponentUnique() const {
48
49
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 return this->getTarget(OS_ExternalInterface_ActuatorFields::ActuatedComponentUniqueName)->cast<ModelObject>();
50 }
51
52 5 std::string ExternalInterfaceActuator_Impl::actuatedComponentType() const {
53
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<std::string> value = getString(OS_ExternalInterface_ActuatorFields::ActuatedComponentType, true);
54
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (value) {
55
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 return value.get();
56 } else {
57 ✗ return "";
58 }
59 5 }
60
61 5 std::string ExternalInterfaceActuator_Impl::actuatedComponentControlType() const {
62
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<std::string> value = getString(OS_ExternalInterface_ActuatorFields::ActuatedComponentControlType, true);
63
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (value) {
64
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 return value.get();
65 } else {
66 ✗ return "";
67 }
68 5 }
69
70 4 boost::optional<double> ExternalInterfaceActuator_Impl::optionalInitialValue() const {
71 4 return getDouble(OS_ExternalInterface_ActuatorFields::OptionalInitialValue, true);
72 }
73
74 4 bool ExternalInterfaceActuator_Impl::setActuatedComponentUnique(const ModelObject& modelObject) {
75
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 bool result = setPointer(OS_ExternalInterface_ActuatorFields::ActuatedComponentUniqueName, modelObject.handle());
76 4 return result;
77 }
78
79 5 bool ExternalInterfaceActuator_Impl::setActuatedComponentType(const std::string& actuatedComponentType) {
80 5 bool result = setString(OS_ExternalInterface_ActuatorFields::ActuatedComponentType, actuatedComponentType);
81 5 return result;
82 }
83
84 5 bool ExternalInterfaceActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) {
85 5 bool result = setString(OS_ExternalInterface_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType);
86 5 return result;
87 }
88
89 2 bool ExternalInterfaceActuator_Impl::setOptionalInitialValue(double optionalInitialValue) {
90 2 bool result = setDouble(OS_ExternalInterface_ActuatorFields::OptionalInitialValue, optionalInitialValue);
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
92 2 return result;
93 }
94
95 1 void ExternalInterfaceActuator_Impl::resetOptionalInitialValue() {
96
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ExternalInterface_ActuatorFields::OptionalInitialValue, "");
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
98 1 }
99
100 3 bool ExternalInterfaceActuator_Impl::exportToBCVTB() const {
101
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_ExternalInterface_ActuatorFields::ExportToBCVTB, true);
102
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(value);
103
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 return openstudio::istringEqual(value.get(), "True");
104 3 }
105
106 1 bool ExternalInterfaceActuator_Impl::isExportToBCVTBDefaulted() const {
107 1 return isEmpty(OS_ExternalInterface_ActuatorFields::ExportToBCVTB);
108 }
109
110 1 bool ExternalInterfaceActuator_Impl::setExportToBCVTB(bool exportToBCVTB) {
111 1 bool result = false;
112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (exportToBCVTB) {
113 ✗ result = setString(OS_ExternalInterface_ActuatorFields::ExportToBCVTB, "True");
114 } else {
115
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
3 result = setString(OS_ExternalInterface_ActuatorFields::ExportToBCVTB, "False");
116 }
117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
118 1 return result;
119 }
120
121 1 void ExternalInterfaceActuator_Impl::resetExportToBCVTB() {
122
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ExternalInterface_ActuatorFields::ExportToBCVTB, "");
123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
124 1 }
125
126 } // namespace detail
127
128 3 ExternalInterfaceActuator::ExternalInterfaceActuator(const ModelObject& modelObject, const std::string actuatedComponentType,
129 3 const std::string actuatedComponentControlType)
130
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 : ModelObject(ExternalInterfaceActuator::iddObjectType(), modelObject.model()) {
131
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 5 not taken.
3 OS_ASSERT(getImpl<detail::ExternalInterfaceActuator_Impl>());
132
133
1/1
✓ Branch 1 taken 3 times.
3 bool ok = setActuatedComponentUnique(modelObject);
134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!ok) {
135 ✗ remove();
136 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s setActuatedComponentUnique to " << modelObject.briefDescription() << ".");
137 }
138
1/1
✓ Branch 1 taken 3 times.
3 ok = setActuatedComponentType(actuatedComponentType);
139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!ok) {
140 ✗ remove();
141 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s actuatedComponentType to " << actuatedComponentType << ".");
142 }
143
1/1
✓ Branch 1 taken 3 times.
3 ok = setActuatedComponentControlType(actuatedComponentControlType);
144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!ok) {
145 ✗ remove();
146 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s actuatedComponentControlType to " << actuatedComponentControlType << ".");
147 }
148 3 }
149
150 ✗ ExternalInterfaceActuator::ExternalInterfaceActuator(const ModelObject& modelObject)
151 ✗ : ModelObject(ExternalInterfaceActuator::iddObjectType(), modelObject.model()) {
152 ✗ OS_ASSERT(getImpl<detail::ExternalInterfaceActuator_Impl>());
153
154 ✗ bool ok = setActuatedComponentUnique(modelObject);
155 ✗ if (!ok) {
156 ✗ remove();
157 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s setActuatedComponentUnique to " << modelObject.briefDescription() << ".");
158 }
159 //TODO set below to some appropriate default that depends on the modelObject::IddType
160 // setActuatedComponentType();
161 // setActuatedComponentControlType();
162 ✗ }
163
164 7604 IddObjectType ExternalInterfaceActuator::iddObjectType() {
165
1/1
✓ Branch 1 taken 7604 times.
7604 return {IddObjectType::OS_ExternalInterface_Actuator};
166 }
167
168 4 ModelObject ExternalInterfaceActuator::actuatedComponentUnique() const {
169
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ExternalInterfaceActuator_Impl>()->actuatedComponentUnique();
170 }
171
172 5 std::string ExternalInterfaceActuator::actuatedComponentType() const {
173
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ExternalInterfaceActuator_Impl>()->actuatedComponentType();
174 }
175
176 5 std::string ExternalInterfaceActuator::actuatedComponentControlType() const {
177
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ExternalInterfaceActuator_Impl>()->actuatedComponentControlType();
178 }
179
180 4 boost::optional<double> ExternalInterfaceActuator::optionalInitialValue() const {
181
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ExternalInterfaceActuator_Impl>()->optionalInitialValue();
182 }
183
184 4 bool ExternalInterfaceActuator::setActuatedComponentUnique(const ModelObject& modelObject) {
185
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ExternalInterfaceActuator_Impl>()->setActuatedComponentUnique(modelObject);
186 }
187
188 5 bool ExternalInterfaceActuator::setActuatedComponentType(const std::string& actuatedComponentType) {
189
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ExternalInterfaceActuator_Impl>()->setActuatedComponentType(actuatedComponentType);
190 }
191
192 5 bool ExternalInterfaceActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) {
193
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ExternalInterfaceActuator_Impl>()->setActuatedComponentControlType(actuatedComponentControlType);
194 }
195
196 2 bool ExternalInterfaceActuator::setOptionalInitialValue(double optionalInitialValue) {
197
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ExternalInterfaceActuator_Impl>()->setOptionalInitialValue(optionalInitialValue);
198 }
199
200 1 void ExternalInterfaceActuator::resetOptionalInitialValue() {
201
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ExternalInterfaceActuator_Impl>()->resetOptionalInitialValue();
202 1 }
203
204 3 bool ExternalInterfaceActuator::exportToBCVTB() const {
205
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ExternalInterfaceActuator_Impl>()->exportToBCVTB();
206 }
207
208 1 bool ExternalInterfaceActuator::isExportToBCVTBDefaulted() const {
209
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ExternalInterfaceActuator_Impl>()->isExportToBCVTBDefaulted();
210 }
211
212 1 bool ExternalInterfaceActuator::setExportToBCVTB(bool exportToBCVTB) {
213
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ExternalInterfaceActuator_Impl>()->setExportToBCVTB(exportToBCVTB);
214 }
215
216 1 void ExternalInterfaceActuator::resetExportToBCVTB() {
217
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ExternalInterfaceActuator_Impl>()->resetExportToBCVTB();
218 1 }
219
220 /// @cond
221
1/1
✓ Branch 2 taken 1 time.
1 ExternalInterfaceActuator::ExternalInterfaceActuator(std::shared_ptr<detail::ExternalInterfaceActuator_Impl> impl) : ModelObject(impl) {}
222 /// @endcond
223
224 } // namespace model
225 } // namespace openstudio
226