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