src/model/EnergyManagementSystemSubroutine.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 "EnergyManagementSystemSubroutine.hpp" | ||
| 7 | #include "EnergyManagementSystemSubroutine_Impl.hpp" | ||
| 8 | |||
| 9 | #include "EnergyManagementSystemMeteredOutputVariable.hpp" | ||
| 10 | #include "EnergyManagementSystemMeteredOutputVariable_Impl.hpp" | ||
| 11 | |||
| 12 | #include <utilities/idd/IddEnums.hxx> | ||
| 13 | #include <utilities/idd/OS_EnergyManagementSystem_Subroutine_FieldEnums.hxx> | ||
| 14 | |||
| 15 | #include "../utilities/core/Assert.hpp" | ||
| 16 | |||
| 17 | #include "ModelExtensibleGroup.hpp" | ||
| 18 | #include "Model.hpp" | ||
| 19 | |||
| 20 | #include "../utilities/core/String.hpp" | ||
| 21 | #include "../utilities/core/StringHelpers.hpp" | ||
| 22 | #include "../utilities/core/UUID.hpp" | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | namespace model { | ||
| 26 | |||
| 27 | namespace detail { | ||
| 28 | |||
| 29 | 13 | EnergyManagementSystemSubroutine_Impl::EnergyManagementSystemSubroutine_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 30 | 13 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 31 |
4/6✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 13 times.
✗ Branch 13 not taken.
|
13 | OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemSubroutine::iddObjectType()); |
| 32 | 13 | } | |
| 33 | |||
| 34 | ✗ | EnergyManagementSystemSubroutine_Impl::EnergyManagementSystemSubroutine_Impl(const openstudio::detail::WorkspaceObject_Impl& other, | |
| 35 | ✗ | Model_Impl* model, bool keepHandle) | |
| 36 | ✗ | : ModelObject_Impl(other, model, keepHandle) { | |
| 37 | ✗ | OS_ASSERT(other.iddObject().type() == EnergyManagementSystemSubroutine::iddObjectType()); | |
| 38 | ✗ | } | |
| 39 | |||
| 40 | 5 | EnergyManagementSystemSubroutine_Impl::EnergyManagementSystemSubroutine_Impl(const EnergyManagementSystemSubroutine_Impl& other, | |
| 41 | 5 | Model_Impl* model, bool keepHandle) | |
| 42 | 5 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 43 | |||
| 44 | ✗ | const std::vector<std::string>& EnergyManagementSystemSubroutine_Impl::outputVariableNames() const { | |
| 45 | ✗ | static const std::vector<std::string> result; | |
| 46 | ✗ | return result; | |
| 47 | } | ||
| 48 | |||
| 49 | 7 | IddObjectType EnergyManagementSystemSubroutine_Impl::iddObjectType() const { | |
| 50 | 7 | return EnergyManagementSystemSubroutine::iddObjectType(); | |
| 51 | } | ||
| 52 | |||
| 53 | 6 | std::string EnergyManagementSystemSubroutine_Impl::body() const { | |
| 54 | //return program body as string | ||
| 55 | |||
| 56 | // loop through extensible groups and add ProgramLine to body string. | ||
| 57 | 6 | std::string body; | |
| 58 | 6 | boost::optional<std::string> comment; | |
| 59 | |||
| 60 |
1/1✓ Branch 1 taken 6 times.
|
6 | auto groups = extensibleGroups(); |
| 61 |
2/2✓ Branch 4 taken 14 times.
✓ Branch 5 taken 6 times.
|
20 | for (auto group = groups.begin(); group != groups.end(); ++group) { |
| 62 | //get program line content | ||
| 63 |
1/1✓ Branch 2 taken 14 times.
|
14 | const auto& line = group->getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, true); |
| 64 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 4 not taken.
|
14 | OS_ASSERT(line); |
| 65 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
|
14 | body += line.get(); |
| 66 | //get non-default comments if they exist | ||
| 67 |
1/1✓ Branch 2 taken 14 times.
|
14 | comment = group->fieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, false); |
| 68 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | if (comment.is_initialized()) { |
| 69 | //remove space after ! | ||
| 70 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
|
14 | boost::erase_first(comment.get(), " "); |
| 71 | //add space between end of program line and comment | ||
| 72 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 2 times.
|
14 | if (!comment.get().empty()) { |
| 73 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | body += " " + comment.get(); |
| 74 | } | ||
| 75 | } | ||
| 76 | //add newline character | ||
| 77 |
1/1✓ Branch 1 taken 14 times.
|
14 | body += '\n'; |
| 78 | 14 | } | |
| 79 | 12 | return body; | |
| 80 | 6 | } | |
| 81 | |||
| 82 | 3 | bool EnergyManagementSystemSubroutine_Impl::setBody(const std::string& body) { | |
| 83 | //set body of program to input string | ||
| 84 | 3 | bool result = false; | |
| 85 | // TODO: JM 2019-01-03: This is unused | ||
| 86 | 3 | [[maybe_unused]] bool comment_result = false; | |
| 87 | //if body string empty then return false | ||
| 88 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (body.empty()) { |
| 89 | ✗ | return false; | |
| 90 | }; | ||
| 91 | |||
| 92 | //clobber existing body | ||
| 93 |
1/1✓ Branch 1 taken 3 times.
|
3 | this->resetBody(); |
| 94 | |||
| 95 | // remove '\r' from the body string | ||
| 96 |
1/1✓ Branch 1 taken 3 times.
|
3 | std::string body_minus_r = body; |
| 97 | 3 | std::string::size_type pos = 0; // Must initialize | |
| 98 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
|
6 | while ((pos = body_minus_r.find("\r", pos)) != std::string::npos) { |
| 99 |
1/1✓ Branch 1 taken 3 times.
|
3 | body_minus_r.erase(pos, 1); |
| 100 | } | ||
| 101 | |||
| 102 | //split the body string on newline characters and insert program line for each string line | ||
| 103 |
1/1✓ Branch 1 taken 3 times.
|
3 | std::vector<std::string> body_minus_nl = splitString(body_minus_r, '\n'); |
| 104 | 3 | std::string body_minus_comment; | |
| 105 | 3 | std::vector<std::string> comments; | |
| 106 | 3 | std::string comment; | |
| 107 | |||
| 108 | //add program lines to body | ||
| 109 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 2 taken 3 times.
|
13 | for (size_t i = 0; i < body_minus_nl.size(); i++) { |
| 110 | //split string on comment character ! | ||
| 111 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
10 | comments = splitString(body_minus_nl.at(i), '!'); |
| 112 | //get extensibleGroup object | ||
| 113 |
3/3✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
|
10 | auto group = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>(); |
| 114 | //make sure program line exists and insert | ||
| 115 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | if (!comments.empty()) { |
| 116 | //remove whitespace at end of comments[0] | ||
| 117 |
1/1✓ Branch 3 taken 10 times.
|
10 | boost::trim_right(comments[0]); |
| 118 | //remove whitespace at beginning of comments[0] | ||
| 119 |
1/1✓ Branch 3 taken 10 times.
|
10 | boost::trim_left(comments[0]); |
| 120 | //remove , | ||
| 121 | 10 | pos = 0; | |
| 122 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
|
10 | while ((pos = comments[0].find(",", pos)) != std::string::npos) { |
| 123 | ✗ | comments[0].erase(pos, 1); | |
| 124 | } | ||
| 125 | //insert program line | ||
| 126 |
1/1✓ Branch 2 taken 10 times.
|
10 | result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); |
| 127 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | if (!result) { |
| 128 | ✗ | return result; | |
| 129 | } | ||
| 130 | //check if comments exist | ||
| 131 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
|
10 | if (comments.size() > 1) { |
| 132 | //clear out the old comment | ||
| 133 | 8 | comment.clear(); | |
| 134 | //add comment to comment vector | ||
| 135 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | comment.append(comments.at(1)); |
| 136 | //combine any remaining comments for this line into one comment | ||
| 137 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
|
8 | if (comments.size() > 2) { |
| 138 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
|
8 | for (size_t j = 2; j < comments.size(); j++) { |
| 139 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | comment.append("!" + comments.at(j)); |
| 140 | } | ||
| 141 | } | ||
| 142 |
1/1✓ Branch 1 taken 8 times.
|
8 | comment_result = group.setFieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comment); |
| 143 | } | ||
| 144 | } else { | ||
| 145 | ✗ | result = false; | |
| 146 | } | ||
| 147 | 10 | } | |
| 148 | 3 | return result; | |
| 149 | 3 | } | |
| 150 | |||
| 151 | 5 | bool EnergyManagementSystemSubroutine_Impl::resetBody() { | |
| 152 | //erase body of program | ||
| 153 | 5 | bool results = false; | |
| 154 | 5 | std::vector<std::vector<std::string>> result; | |
| 155 |
1/1✓ Branch 1 taken 5 times.
|
5 | result = clearExtensibleGroups(); |
| 156 | // if result is not empty, then the group was cleared out since the old values were returned | ||
| 157 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 4 times.
|
5 | if (!result.empty()) { |
| 158 | 1 | results = true; | |
| 159 | }; | ||
| 160 | 5 | return results; | |
| 161 | 5 | } | |
| 162 | |||
| 163 | 11 | bool EnergyManagementSystemSubroutine_Impl::addLine(const std::string& line) { | |
| 164 | //add line to end of program body | ||
| 165 | 11 | bool result = true; | |
| 166 | // TODO: JM 2019-01-03: This is unused | ||
| 167 | 11 | [[maybe_unused]] bool comment_result = false; | |
| 168 | 11 | std::string comment; | |
| 169 | |||
| 170 | // remove '\r' from the line string | ||
| 171 |
1/1✓ Branch 1 taken 11 times.
|
11 | std::string line_rn = line; |
| 172 | 11 | std::string::size_type pos = 0; // Must initialize | |
| 173 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 11 times.
|
16 | while ((pos = line_rn.find("\r", pos)) != std::string::npos) { |
| 174 |
1/1✓ Branch 1 taken 5 times.
|
5 | line_rn.erase(pos, 1); |
| 175 | } | ||
| 176 | // remove '\n' | ||
| 177 | 11 | pos = 0; | |
| 178 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 11 times.
|
16 | while ((pos = line_rn.find("\n", pos)) != std::string::npos) { |
| 179 |
1/1✓ Branch 1 taken 5 times.
|
5 | line_rn.erase(pos, 1); |
| 180 | } | ||
| 181 | //get extensibleGroup object | ||
| 182 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | auto group = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>(); |
| 183 | //split string on comment character ! | ||
| 184 |
1/1✓ Branch 1 taken 11 times.
|
11 | std::vector<std::string> comments = splitString(line_rn, '!'); |
| 185 | //make sure program line exists and insert | ||
| 186 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | if (!comments.empty()) { |
| 187 | //remove whitespace at end of comments[0] | ||
| 188 |
1/1✓ Branch 3 taken 11 times.
|
11 | boost::trim_right(comments[0]); |
| 189 | //remove whitespace at beginning of comments[0] | ||
| 190 |
1/1✓ Branch 3 taken 11 times.
|
11 | boost::trim_left(comments[0]); |
| 191 | //remove , | ||
| 192 | 11 | pos = 0; | |
| 193 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
|
11 | while ((pos = comments[0].find(",", pos)) != std::string::npos) { |
| 194 | ✗ | comments[0].erase(pos, 1); | |
| 195 | } | ||
| 196 | //insert program line | ||
| 197 |
1/1✓ Branch 2 taken 11 times.
|
11 | result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); |
| 198 | //check if comments exist | ||
| 199 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 6 times.
|
11 | if (comments.size() > 1) { |
| 200 | //clear out the old comment | ||
| 201 | 5 | comment.clear(); | |
| 202 | //add comment to comment vector | ||
| 203 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | comment.append(comments.at(1)); |
| 204 | //combine any remaining comments for this line into one comment | ||
| 205 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (comments.size() > 2) { |
| 206 | ✗ | for (size_t j = 2; j < comments.size(); j++) { | |
| 207 | ✗ | comment.append(", " + comments.at(j)); | |
| 208 | } | ||
| 209 | } | ||
| 210 |
1/1✓ Branch 1 taken 5 times.
|
5 | comment_result = group.setFieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comment); |
| 211 | } | ||
| 212 | } else { | ||
| 213 | ✗ | result = false; | |
| 214 | } | ||
| 215 | 11 | return result; | |
| 216 | 11 | } | |
| 217 | |||
| 218 | 28 | std::vector<std::string> EnergyManagementSystemSubroutine_Impl::lines() const { | |
| 219 | //return vector of lines from body | ||
| 220 | 28 | std::vector<std::string> result; | |
| 221 | 28 | boost::optional<std::string> comment; | |
| 222 | 28 | std::string whole_line; | |
| 223 | |||
| 224 | // loop through extensible groups and add ProgramLine to vector result. | ||
| 225 |
1/1✓ Branch 1 taken 28 times.
|
28 | auto groups = extensibleGroups(); |
| 226 | |||
| 227 |
2/2✓ Branch 4 taken 61 times.
✓ Branch 5 taken 28 times.
|
89 | for (auto group = groups.begin(); group != groups.end(); ++group) { |
| 228 | //clear out whole_line | ||
| 229 | 61 | whole_line.clear(); | |
| 230 | //get program line content | ||
| 231 |
1/1✓ Branch 2 taken 61 times.
|
61 | const auto& line = group->getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, true); |
| 232 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 4 not taken.
|
61 | OS_ASSERT(line); |
| 233 | //add programLine to whole_line | ||
| 234 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | whole_line += line.get(); |
| 235 | //get non-default comments if they exist | ||
| 236 |
1/1✓ Branch 2 taken 61 times.
|
61 | comment = group->fieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, false); |
| 237 |
1/2✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
|
61 | if (comment.is_initialized()) { |
| 238 | //remove space after ! | ||
| 239 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | boost::erase_first(comment.get(), " "); |
| 240 | //add space between end of program line and comment | ||
| 241 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 6 times.
|
61 | if (!comment.get().empty()) { |
| 242 |
3/3✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 7 taken 55 times.
|
55 | whole_line += " " + comment.get(); |
| 243 | } | ||
| 244 | } | ||
| 245 | //add newline character | ||
| 246 |
1/1✓ Branch 1 taken 61 times.
|
61 | whole_line += '\n'; |
| 247 | //add whole_line to vector | ||
| 248 |
1/1✓ Branch 1 taken 61 times.
|
61 | result.push_back(whole_line); |
| 249 | 61 | } | |
| 250 | 56 | return result; | |
| 251 | 28 | } | |
| 252 | |||
| 253 | 1 | bool EnergyManagementSystemSubroutine_Impl::setLines(const std::vector<std::string>& lines) { | |
| 254 | //set body of program to input vector of strings | ||
| 255 | 1 | bool result = false; | |
| 256 | 1 | std::string temp; | |
| 257 | |||
| 258 | //if body string empty then return false | ||
| 259 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (lines.empty()) { |
| 260 | ✗ | return false; | |
| 261 | }; | ||
| 262 | |||
| 263 | //clobber existing body | ||
| 264 |
1/1✓ Branch 1 taken 1 time.
|
1 | this->resetBody(); |
| 265 | |||
| 266 | //add program lines to body | ||
| 267 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
|
3 | for (size_t i = 0; i < lines.size(); i++) { |
| 268 | //use method addLine to add each line | ||
| 269 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | result = addLine(lines.at(i)); |
| 270 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (!result) { |
| 271 | ✗ | return result; | |
| 272 | } | ||
| 273 | } | ||
| 274 | 1 | return result; | |
| 275 | 1 | } | |
| 276 | |||
| 277 | 13 | std::vector<ModelObject> EnergyManagementSystemSubroutine_Impl::referencedObjects() const { | |
| 278 | //return vector of model objects that are referenced in program | ||
| 279 | 13 | std::vector<ModelObject> result; | |
| 280 | 13 | const int subs[] = {1}; | |
| 281 | 13 | std::string possible_uid; | |
| 282 | |||
| 283 |
1/1✓ Branch 1 taken 13 times.
|
13 | const Model m = this->model(); |
| 284 | 13 | boost::optional<ModelObject> modelObject; | |
| 285 | |||
| 286 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
13 | boost::optional<std::vector<std::string>> body = this->lines(); |
| 287 |
1/2✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
|
13 | if (body.is_initialized()) { |
| 288 | //assume body is a vector of strings | ||
| 289 |
3/3✓ Branch 1 taken 39 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 13 times.
|
39 | for (size_t i = 0; i < body.get().size(); i++) { |
| 290 | //find uids | ||
| 291 |
6/6✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 7 taken 26 times.
✓ Branch 12 taken 26 times.
✓ Branch 15 taken 26 times.
✓ Branch 20 taken 26 times.
|
26 | boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); |
| 292 | |||
| 293 |
3/3✓ Branch 2 taken 53 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 26 times.
|
53 | while (j != boost::sregex_token_iterator()) { |
| 294 |
3/3✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 7 taken 27 times.
|
27 | possible_uid = *j++; |
| 295 | //look to see if uid is in the model and return the object | ||
| 296 |
1/1✓ Branch 1 taken 27 times.
|
27 | UUID uid = toUUID(possible_uid); |
| 297 |
1/1✓ Branch 1 taken 27 times.
|
27 | modelObject = m.getModelObject<model::ModelObject>(uid); |
| 298 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | if (modelObject) { |
| 299 |
2/2✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
|
27 | result.push_back(modelObject.get()); |
| 300 | } | ||
| 301 | } | ||
| 302 | 26 | } | |
| 303 | } | ||
| 304 | 26 | return result; | |
| 305 | 13 | } | |
| 306 | |||
| 307 | 7 | std::vector<std::string> EnergyManagementSystemSubroutine_Impl::invalidReferencedObjects() const { | |
| 308 | //return vector of body lines that contain missing uid strings for invalid referenced objects | ||
| 309 | 7 | std::vector<std::string> result; | |
| 310 | 7 | const int subs[] = {1}; | |
| 311 | 7 | std::string possible_uid; | |
| 312 | |||
| 313 |
1/1✓ Branch 1 taken 7 times.
|
7 | const Model m = this->model(); |
| 314 | 7 | boost::optional<ModelObject> modelObject; | |
| 315 | |||
| 316 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | boost::optional<std::vector<std::string>> body = this->lines(); |
| 317 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | if (body.is_initialized()) { |
| 318 | //assume body is a vector of strings | ||
| 319 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 7 times.
|
21 | for (size_t i = 0; i < body.get().size(); i++) { |
| 320 | 14 | int found = 0; | |
| 321 | //find uids | ||
| 322 |
6/6✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✓ Branch 12 taken 14 times.
✓ Branch 15 taken 14 times.
✓ Branch 20 taken 14 times.
|
14 | boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); |
| 323 | |||
| 324 |
3/3✓ Branch 2 taken 28 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 14 times.
|
28 | while (j != boost::sregex_token_iterator()) { |
| 325 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
14 | possible_uid = *j++; |
| 326 | 14 | found = 1; | |
| 327 | //look to see if uid is in the model and return the object | ||
| 328 |
1/1✓ Branch 1 taken 14 times.
|
14 | UUID uid = toUUID(possible_uid); |
| 329 |
1/1✓ Branch 1 taken 14 times.
|
14 | modelObject = m.getModelObject<model::ModelObject>(uid); |
| 330 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
|
14 | if (modelObject) { |
| 331 | 9 | found++; | |
| 332 | } | ||
| 333 | } | ||
| 334 | //possible uid NOT found in model | ||
| 335 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9 times.
|
14 | if (found == 1) { |
| 336 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | result.push_back(body.get().at(i)); |
| 337 | }; | ||
| 338 | 14 | } | |
| 339 | } | ||
| 340 | 14 | return result; | |
| 341 | 7 | } | |
| 342 | |||
| 343 | std::vector<EnergyManagementSystemMeteredOutputVariable> | ||
| 344 | 3 | EnergyManagementSystemSubroutine_Impl::energyManagementSystemMeteredOutputVariables() const { | |
| 345 |
1/1✓ Branch 1 taken 3 times.
|
6 | return getObject<ModelObject>().getModelObjectSources<EnergyManagementSystemMeteredOutputVariable>( |
| 346 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | EnergyManagementSystemMeteredOutputVariable::iddObjectType()); |
| 347 | } | ||
| 348 | } // namespace detail | ||
| 349 | |||
| 350 | 13 | EnergyManagementSystemSubroutine::EnergyManagementSystemSubroutine(const Model& model) | |
| 351 | 13 | : ModelObject(EnergyManagementSystemSubroutine::iddObjectType(), model) { | |
| 352 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 5 not taken.
|
13 | OS_ASSERT(getImpl<detail::EnergyManagementSystemSubroutine_Impl>()); |
| 353 | 13 | } | |
| 354 | |||
| 355 | 7762 | IddObjectType EnergyManagementSystemSubroutine::iddObjectType() { | |
| 356 |
1/1✓ Branch 1 taken 7762 times.
|
7762 | return {IddObjectType::OS_EnergyManagementSystem_Subroutine}; |
| 357 | } | ||
| 358 | |||
| 359 | 6 | std::string EnergyManagementSystemSubroutine::body() const { | |
| 360 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->body(); |
| 361 | } | ||
| 362 | |||
| 363 | 3 | bool EnergyManagementSystemSubroutine::setBody(const std::string& body) { | |
| 364 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->setBody(body); |
| 365 | } | ||
| 366 | |||
| 367 | 1 | bool EnergyManagementSystemSubroutine::resetBody() { | |
| 368 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->resetBody(); |
| 369 | } | ||
| 370 | |||
| 371 | 9 | bool EnergyManagementSystemSubroutine::addLine(const std::string& line) { | |
| 372 |
1/1✓ Branch 3 taken 9 times.
|
9 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->addLine(line); |
| 373 | } | ||
| 374 | |||
| 375 | 8 | std::vector<std::string> EnergyManagementSystemSubroutine::lines() const { | |
| 376 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->lines(); |
| 377 | } | ||
| 378 | |||
| 379 | 1 | bool EnergyManagementSystemSubroutine::setLines(const std::vector<std::string>& lines) { | |
| 380 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->setLines(lines); |
| 381 | } | ||
| 382 | |||
| 383 | 13 | std::vector<ModelObject> EnergyManagementSystemSubroutine::referencedObjects() const { | |
| 384 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->referencedObjects(); |
| 385 | } | ||
| 386 | |||
| 387 | 7 | std::vector<std::string> EnergyManagementSystemSubroutine::invalidReferencedObjects() const { | |
| 388 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->invalidReferencedObjects(); |
| 389 | } | ||
| 390 | |||
| 391 | 3 | std::vector<EnergyManagementSystemMeteredOutputVariable> EnergyManagementSystemSubroutine::energyManagementSystemMeteredOutputVariables() const { | |
| 392 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::EnergyManagementSystemSubroutine_Impl>()->energyManagementSystemMeteredOutputVariables(); |
| 393 | } | ||
| 394 | |||
| 395 | /// @cond | ||
| 396 | 8 | EnergyManagementSystemSubroutine::EnergyManagementSystemSubroutine(std::shared_ptr<detail::EnergyManagementSystemSubroutine_Impl> impl) | |
| 397 |
1/1✓ Branch 3 taken 8 times.
|
8 | : ModelObject(std::move(impl)) {} |
| 398 | /// @endcond | ||
| 399 | |||
| 400 | } // namespace model | ||
| 401 | } // namespace openstudio | ||
| 402 |