src/utilities/filetypes/WorkflowJSON.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 "WorkflowJSON.hpp" | ||
| 7 | #include "WorkflowJSON_Impl.hpp" | ||
| 8 | |||
| 9 | #include "WorkflowStep_Impl.hpp" | ||
| 10 | #include "RunOptions_Impl.hpp" | ||
| 11 | |||
| 12 | #include "../core/Assert.hpp" | ||
| 13 | #include "../core/PathHelpers.hpp" | ||
| 14 | #include "../core/Checksum.hpp" | ||
| 15 | #include "../time/DateTime.hpp" | ||
| 16 | |||
| 17 | namespace openstudio { | ||
| 18 | namespace detail { | ||
| 19 | |||
| 20 | const int NO_MEASURE_TYPE = -1; | ||
| 21 | |||
| 22 | 6864 | path canonicalOrAbsolute(const path& p, const path& base = boost::filesystem::current_path()) { | |
| 23 | 6864 | path result; | |
| 24 |
3/3✓ Branch 1 taken 6864 times.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 6252 times.
|
6864 | if (p.is_absolute()) { |
| 25 |
1/1✓ Branch 1 taken 612 times.
|
612 | result = p; |
| 26 | } else { | ||
| 27 |
1/1✓ Branch 1 taken 6252 times.
|
6252 | result = boost::filesystem::absolute(p, base); |
| 28 | } | ||
| 29 | |||
| 30 |
3/3✓ Branch 1 taken 6864 times.
✓ Branch 3 taken 5419 times.
✓ Branch 4 taken 1445 times.
|
6864 | if (exists(result)) { |
| 31 |
2/2✓ Branch 1 taken 5419 times.
✓ Branch 4 taken 5419 times.
|
5419 | result = boost::filesystem::canonical(result); |
| 32 | } else { | ||
| 33 |
2/2✓ Branch 1 taken 1445 times.
✓ Branch 4 taken 1445 times.
|
1445 | result = boost::filesystem::weakly_canonical(result); |
| 34 | } | ||
| 35 | |||
| 36 | 6864 | return result; | |
| 37 | ✗ | } | |
| 38 | |||
| 39 |
1/1✓ Branch 4 taken 5281 times.
|
5281 | WorkflowJSON_Impl::WorkflowJSON_Impl() { |
| 40 |
4/4✓ Branch 1 taken 5281 times.
✓ Branch 4 taken 5281 times.
✓ Branch 7 taken 5281 times.
✓ Branch 10 taken 5281 times.
|
5281 | m_value["created_at"] = DateTime::nowUTC().toISO8601(); |
| 41 |
2/2✓ Branch 1 taken 5281 times.
✓ Branch 4 taken 5281 times.
|
5281 | m_value["steps"] = Json::Value(Json::arrayValue); |
| 42 | 5281 | } | |
| 43 | |||
| 44 |
1/1✓ Branch 4 taken 55 times.
|
55 | WorkflowJSON_Impl::WorkflowJSON_Impl(const std::string& s) { |
| 45 | |||
| 46 |
1/1✓ Branch 1 taken 55 times.
|
55 | Json::CharReaderBuilder rbuilder; |
| 47 |
1/1✓ Branch 1 taken 55 times.
|
55 | std::istringstream ss(s); |
| 48 | 55 | std::string formattedErrors; | |
| 49 |
1/1✓ Branch 1 taken 55 times.
|
55 | bool parsingSuccessful = Json::parseFromStream(rbuilder, ss, &m_value, &formattedErrors); |
| 50 | |||
| 51 | 55 | openstudio::path p; | |
| 52 | |||
| 53 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 52 times.
|
55 | if (!parsingSuccessful) { |
| 54 | |||
| 55 | // see if this is a path | ||
| 56 |
1/1✓ Branch 1 taken 3 times.
|
3 | p = toPath(s); |
| 57 |
7/8✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 2 times.
|
3 | if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) { |
| 58 | // open file | ||
| 59 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::ifstream ifs(openstudio::toSystemFilename(p)); |
| 60 |
1/1✓ Branch 1 taken 1 time.
|
1 | m_value.clear(); |
| 61 | 1 | formattedErrors.clear(); | |
| 62 |
1/1✓ Branch 1 taken 1 time.
|
1 | parsingSuccessful = Json::parseFromStream(rbuilder, ifs, &m_value, &formattedErrors); |
| 63 | 1 | } | |
| 64 | |||
| 65 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
|
3 | if (!parsingSuccessful) { |
| 66 |
15/15✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 37 taken 2 times.
✓ Branch 40 taken 2 times.
✓ Branch 44 taken 2 times.
✓ Branch 47 taken 2 times.
|
2 | LOG_AND_THROW("WorkflowJSON cannot be processed, " << formattedErrors); |
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 |
1/1✓ Branch 1 taken 53 times.
|
53 | parseSteps(); |
| 71 |
1/1✓ Branch 1 taken 53 times.
|
53 | parseRunOptions(); |
| 72 | |||
| 73 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 52 times.
|
53 | if (!p.empty()) { |
| 74 |
1/1✓ Branch 1 taken 1 time.
|
1 | setOswPath(p, false); |
| 75 | } | ||
| 76 | 75 | } | |
| 77 | |||
| 78 |
1/1✓ Branch 4 taken 51 times.
|
51 | WorkflowJSON_Impl::WorkflowJSON_Impl(const openstudio::path& p) { |
| 79 |
7/8✓ Branch 1 taken 51 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 49 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 49 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 49 times.
|
51 | if (!boost::filesystem::exists(p) || !boost::filesystem::is_regular_file(p)) { |
| 80 |
17/17✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 37 taken 2 times.
✓ Branch 40 taken 2 times.
✓ Branch 43 taken 2 times.
✓ Branch 46 taken 2 times.
✓ Branch 50 taken 2 times.
✓ Branch 53 taken 2 times.
|
2 | LOG_AND_THROW("Path '" << p << "' is not a WorkflowJSON file"); |
| 81 | } | ||
| 82 | |||
| 83 | // open file | ||
| 84 |
2/2✓ Branch 1 taken 49 times.
✓ Branch 4 taken 49 times.
|
49 | std::ifstream ifs(openstudio::toSystemFilename(p)); |
| 85 | |||
| 86 |
1/1✓ Branch 1 taken 49 times.
|
49 | Json::CharReaderBuilder rbuilder; |
| 87 | 49 | std::string formattedErrors; | |
| 88 |
1/1✓ Branch 1 taken 49 times.
|
49 | bool parsingSuccessful = Json::parseFromStream(rbuilder, ifs, &m_value, &formattedErrors); |
| 89 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 47 times.
|
49 | if (!parsingSuccessful) { |
| 90 |
21/21✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 20 taken 2 times.
✓ Branch 23 taken 2 times.
✓ Branch 26 taken 2 times.
✓ Branch 32 taken 2 times.
✓ Branch 35 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 2 times.
✓ Branch 44 taken 2 times.
✓ Branch 47 taken 2 times.
✓ Branch 50 taken 2 times.
✓ Branch 53 taken 2 times.
✓ Branch 56 taken 2 times.
✓ Branch 59 taken 2 times.
✓ Branch 64 taken 2 times.
✓ Branch 67 taken 2 times.
|
2 | LOG_AND_THROW("WorkflowJSON '" << toString(p) << "' cannot be processed, " << formattedErrors); |
| 91 | } | ||
| 92 | |||
| 93 |
1/1✓ Branch 1 taken 47 times.
|
47 | parseSteps(); |
| 94 |
1/1✓ Branch 1 taken 47 times.
|
47 | parseRunOptions(); |
| 95 | |||
| 96 |
1/1✓ Branch 1 taken 47 times.
|
47 | setOswPath(p, false); |
| 97 | 81 | } | |
| 98 | |||
| 99 | 30 | WorkflowJSON WorkflowJSON_Impl::clone() const { | |
| 100 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
|
30 | WorkflowJSON result(this->string(true)); |
| 101 | |||
| 102 |
1/1✓ Branch 1 taken 30 times.
|
30 | boost::optional<openstudio::path> oswPath = this->oswPath(); |
| 103 |
2/2✓ Branch 0 taken 19 times.
✓ Branch 1 taken 11 times.
|
30 | if (oswPath) { |
| 104 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | result.setOswPath(*oswPath); |
| 105 | } else { | ||
| 106 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | result.setOswDir(this->oswDir()); |
| 107 | } | ||
| 108 | |||
| 109 | 60 | return result; | |
| 110 | 30 | } | |
| 111 | |||
| 112 | 209 | Json::Value WorkflowJSON_Impl::toJSON(bool includeHash) const { | |
| 113 | |||
| 114 |
1/1✓ Branch 1 taken 209 times.
|
209 | Json::Value clone(m_value); |
| 115 |
2/2✓ Branch 0 taken 108 times.
✓ Branch 1 taken 101 times.
|
209 | if (!includeHash) { |
| 116 |
1/1✓ Branch 1 taken 108 times.
|
108 | clone.removeMember("hash"); |
| 117 | } | ||
| 118 | |||
| 119 |
1/1✓ Branch 1 taken 209 times.
|
209 | Json::Value steps(Json::arrayValue); |
| 120 |
2/2✓ Branch 4 taken 437 times.
✓ Branch 5 taken 209 times.
|
646 | for (const auto& step : m_steps) { |
| 121 |
2/2✓ Branch 1 taken 437 times.
✓ Branch 4 taken 437 times.
|
437 | steps.append(step.toJSON()); |
| 122 | } | ||
| 123 |
1/1✓ Branch 2 taken 209 times.
|
209 | clone["steps"] = std::move(steps); |
| 124 | |||
| 125 |
2/2✓ Branch 1 taken 101 times.
✓ Branch 2 taken 108 times.
|
418 | if (m_runOptions) { |
| 126 |
3/3✓ Branch 1 taken 101 times.
✓ Branch 4 taken 101 times.
✓ Branch 7 taken 101 times.
|
101 | clone["run_options"] = m_runOptions->toJSON(); |
| 127 | } | ||
| 128 | |||
| 129 | 418 | return clone; | |
| 130 | 209 | } | |
| 131 | |||
| 132 | 209 | std::string WorkflowJSON_Impl::string(bool includeHash) const { | |
| 133 |
1/1✓ Branch 1 taken 209 times.
|
209 | Json::StreamWriterBuilder wbuilder; |
| 134 | // mimic the old StyledWriter behavior: | ||
| 135 |
3/3✓ Branch 1 taken 209 times.
✓ Branch 4 taken 209 times.
✓ Branch 7 taken 209 times.
|
627 | wbuilder["indentation"] = " "; |
| 136 |
2/2✓ Branch 1 taken 209 times.
✓ Branch 4 taken 209 times.
|
209 | std::string result = Json::writeString(wbuilder, toJSON(includeHash)); |
| 137 | |||
| 138 | 418 | return result; | |
| 139 | 209 | } | |
| 140 | |||
| 141 | 60 | std::string WorkflowJSON_Impl::hash() const { | |
| 142 |
1/1✓ Branch 1 taken 60 times.
|
60 | Json::Value defaultValue(""); |
| 143 |
1/1✓ Branch 1 taken 60 times.
|
60 | Json::Value h = m_value.get("hash", defaultValue); |
| 144 | |||
| 145 |
1/1✓ Branch 1 taken 60 times.
|
120 | return h.asString(); |
| 146 | 60 | } | |
| 147 | |||
| 148 | 104 | std::string WorkflowJSON_Impl::computeHash() const { | |
| 149 |
2/2✓ Branch 1 taken 104 times.
✓ Branch 4 taken 104 times.
|
104 | return checksum(string(false)); |
| 150 | } | ||
| 151 | |||
| 152 | 56 | bool WorkflowJSON_Impl::checkForUpdates() { | |
| 153 |
1/1✓ Branch 1 taken 56 times.
|
56 | std::string h1 = hash(); |
| 154 |
1/1✓ Branch 1 taken 56 times.
|
56 | std::string h2 = computeHash(); |
| 155 | 56 | bool result = (h1 != h2); | |
| 156 |
2/2✓ Branch 0 taken 44 times.
✓ Branch 1 taken 12 times.
|
56 | if (result) { |
| 157 |
1/1✓ Branch 1 taken 44 times.
|
44 | onUpdate(); |
| 158 |
1/1✓ Branch 1 taken 44 times.
|
44 | h2 = computeHash(); // recompute hash after updating timestamps in onUpdate |
| 159 |
2/2✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 | m_value["hash"] = h2; |
| 160 | } | ||
| 161 | 56 | return result; | |
| 162 | 56 | } | |
| 163 | |||
| 164 | 43 | bool WorkflowJSON_Impl::save() const { | |
| 165 |
1/1✓ Branch 1 taken 43 times.
|
43 | boost::optional<openstudio::path> p = oswPath(); |
| 166 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
|
43 | if (!p) { |
| 167 | ✗ | return false; | |
| 168 | } | ||
| 169 | |||
| 170 |
3/4✓ Branch 2 taken 43 times.
✓ Branch 5 taken 43 times.
✓ Branch 8 taken 43 times.
✗ Branch 9 not taken.
|
43 | if (makeParentFolder(*p)) { |
| 171 |
3/3✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
✓ Branch 7 taken 43 times.
|
43 | std::ofstream outFile(openstudio::toSystemFilename(*p)); |
| 172 | |||
| 173 |
2/3✓ Branch 1 taken 43 times.
✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
|
43 | if (outFile) { |
| 174 | try { | ||
| 175 |
2/2✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
|
43 | outFile << string(); |
| 176 |
1/1✓ Branch 1 taken 43 times.
|
43 | outFile.close(); |
| 177 | 43 | return true; | |
| 178 | ✗ | } catch (...) { | |
| 179 | ✗ | LOG(Error, "Unable to write file to path '" << toString(*p) << "'."); | |
| 180 | ✗ | return false; | |
| 181 | ✗ | } | |
| 182 | } | ||
| 183 | 43 | } | |
| 184 | |||
| 185 | ✗ | LOG(Error, "Unable to write file to path '" << toString(*p) << "', because parent directory " << "could not be created."); | |
| 186 | |||
| 187 | ✗ | return false; | |
| 188 | 43 | } | |
| 189 | |||
| 190 | 42 | bool WorkflowJSON_Impl::saveAs(const openstudio::path& p) { | |
| 191 | // cppcheck-suppress knownConditionTrueFalse | ||
| 192 |
1/2✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
|
42 | if (setOswPath(p, true)) { |
| 193 | 42 | checkForUpdates(); | |
| 194 | 42 | return save(); | |
| 195 | } | ||
| 196 | ✗ | return false; | |
| 197 | } | ||
| 198 | |||
| 199 | 7 | void WorkflowJSON_Impl::reset() { | |
| 200 | 7 | m_value.removeMember("started_at"); | |
| 201 | 7 | m_value.removeMember("completed_at"); | |
| 202 | 7 | m_value.removeMember("completed_status"); | |
| 203 | 7 | m_value.removeMember("current_step"); | |
| 204 | 7 | onUpdate(); | |
| 205 | 7 | } | |
| 206 | |||
| 207 | 28 | void WorkflowJSON_Impl::start() { | |
| 208 |
4/4✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
|
28 | m_value["started_at"] = DateTime::nowUTC().toISO8601(); |
| 209 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | m_value["current_step"] = 0; |
| 210 |
3/3✓ Branch 1 taken 28 times.
✓ Branch 8 taken 56 times.
✓ Branch 9 taken 28 times.
|
84 | for (auto& step : workflowSteps()) { |
| 211 |
1/1✓ Branch 1 taken 56 times.
|
56 | step.resetResult(); |
| 212 | 28 | } | |
| 213 | 28 | onUpdate(); | |
| 214 | 28 | } | |
| 215 | |||
| 216 | 281 | unsigned WorkflowJSON_Impl::currentStepIndex() const { | |
| 217 |
1/1✓ Branch 1 taken 281 times.
|
281 | Json::Value defaultValue(0); |
| 218 |
1/1✓ Branch 1 taken 281 times.
|
281 | Json::Value index = m_value.get("current_step", defaultValue); |
| 219 |
1/1✓ Branch 1 taken 281 times.
|
562 | return index.asUInt(); |
| 220 | 281 | } | |
| 221 | |||
| 222 | 183 | boost::optional<WorkflowStep> WorkflowJSON_Impl::currentStep() const { | |
| 223 |
1/1✓ Branch 1 taken 183 times.
|
183 | unsigned index = currentStepIndex(); |
| 224 |
1/1✓ Branch 1 taken 183 times.
|
183 | std::vector<WorkflowStep> steps = this->workflowSteps(); |
| 225 | |||
| 226 |
2/2✓ Branch 1 taken 31 times.
✓ Branch 2 taken 152 times.
|
183 | if (index >= steps.size()) { |
| 227 | 31 | return boost::none; | |
| 228 | } | ||
| 229 | |||
| 230 |
1/1✓ Branch 2 taken 152 times.
|
152 | return steps[index]; |
| 231 | 183 | } | |
| 232 | |||
| 233 | 55 | bool WorkflowJSON_Impl::incrementStep() { | |
| 234 | 55 | unsigned index = currentStepIndex(); | |
| 235 |
2/2✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
|
55 | m_value["current_step"] = index + 1; |
| 236 | 55 | onUpdate(); | |
| 237 |
1/1✓ Branch 1 taken 55 times.
|
55 | return currentStep().is_initialized(); |
| 238 | } | ||
| 239 | |||
| 240 | 26 | boost::optional<std::string> WorkflowJSON_Impl::completedStatus() const { | |
| 241 |
1/1✓ Branch 1 taken 26 times.
|
26 | Json::Value defaultValue(""); |
| 242 |
1/1✓ Branch 1 taken 26 times.
|
26 | Json::Value status = m_value.get("completed_status", defaultValue); |
| 243 |
1/1✓ Branch 1 taken 26 times.
|
26 | std::string result = status.asString(); |
| 244 |
1/2✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
|
26 | if (result.empty()) { |
| 245 | 26 | return boost::none; | |
| 246 | } | ||
| 247 | ✗ | return result; | |
| 248 | 26 | } | |
| 249 | |||
| 250 | 31 | void WorkflowJSON_Impl::setCompletedStatus(const std::string& status) { | |
| 251 |
2/2✓ Branch 1 taken 31 times.
✓ Branch 4 taken 31 times.
|
31 | m_value["completed_status"] = status; |
| 252 |
4/4✓ Branch 1 taken 31 times.
✓ Branch 4 taken 31 times.
✓ Branch 7 taken 31 times.
✓ Branch 10 taken 31 times.
|
31 | m_value["completed_at"] = DateTime::nowUTC().toISO8601(); |
| 253 | 31 | onUpdate(); | |
| 254 | 31 | } | |
| 255 | |||
| 256 | ✗ | boost::optional<DateTime> WorkflowJSON_Impl::createdAt() const { | |
| 257 | ✗ | Json::Value defaultValue(""); | |
| 258 | ✗ | Json::Value value = m_value.get("created_at", defaultValue); | |
| 259 | ✗ | std::string str = value.asString(); | |
| 260 | ✗ | if (str.empty()) { | |
| 261 | ✗ | return boost::none; | |
| 262 | } | ||
| 263 | ✗ | return DateTime::fromISO8601(str); | |
| 264 | ✗ | } | |
| 265 | |||
| 266 | ✗ | boost::optional<DateTime> WorkflowJSON_Impl::startedAt() const { | |
| 267 | ✗ | Json::Value defaultValue(""); | |
| 268 | ✗ | Json::Value value = m_value.get("started_at", defaultValue); | |
| 269 | ✗ | std::string str = value.asString(); | |
| 270 | ✗ | if (str.empty()) { | |
| 271 | ✗ | return boost::none; | |
| 272 | } | ||
| 273 | ✗ | return DateTime::fromISO8601(str); | |
| 274 | ✗ | } | |
| 275 | |||
| 276 | 2 | boost::optional<DateTime> WorkflowJSON_Impl::updatedAt() const { | |
| 277 |
1/1✓ Branch 1 taken 2 times.
|
2 | Json::Value defaultValue(""); |
| 278 |
1/1✓ Branch 1 taken 2 times.
|
2 | Json::Value value = m_value.get("updated_at", defaultValue); |
| 279 |
1/1✓ Branch 1 taken 2 times.
|
2 | std::string str = value.asString(); |
| 280 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (str.empty()) { |
| 281 | ✗ | return boost::none; | |
| 282 | } | ||
| 283 |
1/1✓ Branch 1 taken 2 times.
|
2 | return DateTime::fromISO8601(str); |
| 284 | 2 | } | |
| 285 | |||
| 286 | ✗ | boost::optional<DateTime> WorkflowJSON_Impl::completedAt() const { | |
| 287 | ✗ | Json::Value defaultValue(""); | |
| 288 | ✗ | Json::Value value = m_value.get("completed_at", defaultValue); | |
| 289 | ✗ | std::string str = value.asString(); | |
| 290 | ✗ | if (str.empty()) { | |
| 291 | ✗ | return boost::none; | |
| 292 | } | ||
| 293 | ✗ | return DateTime::fromISO8601(str); | |
| 294 | ✗ | } | |
| 295 | |||
| 296 | ✗ | boost::optional<std::string> WorkflowJSON_Impl::eplusoutErr() const { | |
| 297 | ✗ | Json::Value defaultValue(""); | |
| 298 | ✗ | Json::Value value = m_value.get("eplusout_err", defaultValue); | |
| 299 | ✗ | std::string str = value.asString(); | |
| 300 | ✗ | if (str.empty()) { | |
| 301 | ✗ | return boost::none; | |
| 302 | } | ||
| 303 | ✗ | return str; | |
| 304 | ✗ | } | |
| 305 | |||
| 306 | 15 | void WorkflowJSON_Impl::setEplusoutErr(const std::string& eplusoutErr) { | |
| 307 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | m_value["eplusout_err"] = eplusoutErr; |
| 308 | 15 | onUpdate(); | |
| 309 | 15 | } | |
| 310 | |||
| 311 | 97 | boost::optional<openstudio::path> WorkflowJSON_Impl::oswPath() const { | |
| 312 |
5/6✓ Branch 1 taken 86 times.
✓ Branch 2 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 86 times.
|
97 | if (m_oswFilename.empty() || m_oswDir.empty()) { |
| 313 | 11 | return boost::none; | |
| 314 | } | ||
| 315 |
2/2✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
|
258 | return m_oswDir / m_oswFilename; |
| 316 | } | ||
| 317 | |||
| 318 | 110 | bool WorkflowJSON_Impl::setOswPath(const openstudio::path& path, bool emitChange) { | |
| 319 |
3/3✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
✓ Branch 8 taken 110 times.
|
110 | openstudio::path p = canonicalOrAbsolute(path); |
| 320 | |||
| 321 | 110 | m_oswFilename = p.filename(); | |
| 322 |
1/1✓ Branch 1 taken 110 times.
|
110 | m_oswDir = p.parent_path(); |
| 323 |
1/1✓ Branch 1 taken 110 times.
|
110 | setMeasureTypes(); |
| 324 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 48 times.
|
110 | if (emitChange) { |
| 325 |
1/1✓ Branch 1 taken 62 times.
|
62 | onUpdate(); // onUpdate does not happen in setMeasureTypes |
| 326 | } | ||
| 327 | 110 | return true; | |
| 328 | 110 | } | |
| 329 | |||
| 330 | 3245 | openstudio::path WorkflowJSON_Impl::oswDir() const { | |
| 331 |
2/2✓ Branch 1 taken 572 times.
✓ Branch 2 taken 2673 times.
|
3245 | if (m_oswDir.empty()) { |
| 332 | 572 | return boost::filesystem::current_path(); | |
| 333 | } | ||
| 334 | 2673 | return m_oswDir; | |
| 335 | } | ||
| 336 | |||
| 337 | 29 | bool WorkflowJSON_Impl::setOswDir(const openstudio::path& path) { | |
| 338 |
2/2✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
|
29 | m_oswDir = canonicalOrAbsolute(path); |
| 339 | 29 | setMeasureTypes(); | |
| 340 | 29 | onUpdate(); // onUpdate does not happen in setMeasureTypes | |
| 341 | 29 | return true; | |
| 342 | } | ||
| 343 | |||
| 344 | 3182 | openstudio::path WorkflowJSON_Impl::rootDir() const { | |
| 345 |
1/1✓ Branch 1 taken 3182 times.
|
3182 | Json::Value defaultValue("."); |
| 346 |
1/1✓ Branch 1 taken 3182 times.
|
3182 | Json::Value root = m_value.get("root", defaultValue); |
| 347 |
4/4✓ Branch 1 taken 3182 times.
✓ Branch 4 taken 3182 times.
✓ Branch 7 taken 3182 times.
✓ Branch 10 taken 3182 times.
|
6364 | return toPath(root.asString()).remove_trailing_separator(); |
| 348 | 3182 | } | |
| 349 | |||
| 350 | 3171 | openstudio::path WorkflowJSON_Impl::absoluteRootDir() const { | |
| 351 |
1/1✓ Branch 1 taken 3171 times.
|
3171 | openstudio::path result = rootDir(); |
| 352 |
2/3✓ Branch 1 taken 3171 times.
✓ Branch 3 taken 3171 times.
✗ Branch 4 not taken.
|
3171 | if (result.is_relative()) { |
| 353 |
2/2✓ Branch 1 taken 3171 times.
✓ Branch 4 taken 3171 times.
|
3171 | return canonicalOrAbsolute(result, oswDir()); |
| 354 | } | ||
| 355 | ✗ | return result; | |
| 356 | 3171 | } | |
| 357 | |||
| 358 | 1 | bool WorkflowJSON_Impl::setRootDir(const openstudio::path& path) { | |
| 359 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (path.is_relative()) { |
| 360 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto canonical_path = canonicalOrAbsolute(path); |
| 361 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | if (!pathBeginsWith(m_oswDir, canonical_path)) { |
| 362 |
9/9✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
|
1 | LOG(Warn, "Resulting rootDir '" << canonical_path << "' is not a descendant of oswDir: '" << m_oswDir << "'"); |
| 363 | } | ||
| 364 | 1 | } | |
| 365 | |||
| 366 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | m_value["root"] = toString(path); |
| 367 | 1 | onUpdate(); | |
| 368 | 1 | return true; | |
| 369 | } | ||
| 370 | |||
| 371 | 306 | openstudio::path WorkflowJSON_Impl::runDir() const { | |
| 372 |
1/1✓ Branch 1 taken 306 times.
|
306 | Json::Value defaultValue("./run"); |
| 373 |
1/1✓ Branch 1 taken 306 times.
|
306 | Json::Value runDirectory = m_value.get("run_directory", defaultValue); |
| 374 |
4/4✓ Branch 1 taken 306 times.
✓ Branch 4 taken 306 times.
✓ Branch 7 taken 306 times.
✓ Branch 10 taken 306 times.
|
612 | return toPath(runDirectory.asString()).remove_trailing_separator(); |
| 375 | 306 | } | |
| 376 | |||
| 377 | 303 | openstudio::path WorkflowJSON_Impl::absoluteRunDir() const { | |
| 378 |
1/1✓ Branch 1 taken 303 times.
|
303 | openstudio::path result = runDir(); |
| 379 |
3/3✓ Branch 1 taken 303 times.
✓ Branch 3 taken 196 times.
✓ Branch 4 taken 107 times.
|
303 | if (result.is_relative()) { |
| 380 |
2/2✓ Branch 1 taken 196 times.
✓ Branch 4 taken 196 times.
|
196 | return canonicalOrAbsolute(result, absoluteRootDir()); |
| 381 | } | ||
| 382 | 107 | return result; | |
| 383 | 303 | } | |
| 384 | |||
| 385 | 1 | bool WorkflowJSON_Impl::setRunDir(const openstudio::path& path) { | |
| 386 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (path.is_relative()) { |
| 387 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto canonical_path = canonicalOrAbsolute(path); |
| 388 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | if (!pathBeginsWith(m_oswDir, canonical_path)) { |
| 389 |
9/9✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
|
1 | LOG(Warn, "Resulting runDir '" << canonical_path << "' is not a descendant of oswDir: '" << m_oswDir << "'"); |
| 390 | } | ||
| 391 | 1 | } | |
| 392 | |||
| 393 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | m_value["run_directory"] = toString(path); |
| 394 | 1 | onUpdate(); | |
| 395 | 1 | return true; | |
| 396 | } | ||
| 397 | |||
| 398 | 34 | openstudio::path WorkflowJSON_Impl::outPath() const { | |
| 399 |
1/1✓ Branch 1 taken 34 times.
|
34 | Json::Value defaultValue("out.osw"); |
| 400 |
1/1✓ Branch 1 taken 34 times.
|
34 | Json::Value path = m_value.get("out_name", defaultValue); |
| 401 |
2/2✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
|
68 | return toPath(path.asString()); |
| 402 | 34 | } | |
| 403 | |||
| 404 | 34 | openstudio::path WorkflowJSON_Impl::absoluteOutPath() const { | |
| 405 |
1/1✓ Branch 1 taken 34 times.
|
34 | openstudio::path result = outPath(); |
| 406 |
2/3✓ Branch 1 taken 34 times.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
|
34 | if (result.is_relative()) { |
| 407 |
2/2✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
|
34 | return canonicalOrAbsolute(result, oswDir()); |
| 408 | } | ||
| 409 | ✗ | return result; | |
| 410 | 34 | } | |
| 411 | |||
| 412 | 188 | std::vector<openstudio::path> WorkflowJSON_Impl::filePaths() const { | |
| 413 | 188 | std::vector<openstudio::path> result; | |
| 414 | |||
| 415 |
1/1✓ Branch 1 taken 188 times.
|
188 | Json::Value defaultValue(Json::arrayValue); |
| 416 | |||
| 417 |
1/1✓ Branch 1 taken 188 times.
|
188 | Json::Value paths = m_value.get("file_paths", defaultValue); |
| 418 |
2/2✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
|
188 | paths.append("./files"); |
| 419 |
2/2✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
|
188 | paths.append("./weather"); |
| 420 |
2/2✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
|
188 | paths.append("../../files"); |
| 421 |
2/2✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
|
188 | paths.append("../../weather"); |
| 422 |
2/2✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
|
188 | paths.append("./"); |
| 423 | |||
| 424 |
1/1✓ Branch 1 taken 188 times.
|
188 | Json::ArrayIndex n = paths.size(); |
| 425 |
2/2✓ Branch 0 taken 1252 times.
✓ Branch 1 taken 188 times.
|
1440 | for (Json::ArrayIndex i = 0; i < n; ++i) { |
| 426 |
4/4✓ Branch 1 taken 1252 times.
✓ Branch 4 taken 1252 times.
✓ Branch 7 taken 1252 times.
✓ Branch 10 taken 1252 times.
|
1252 | result.push_back(toPath(paths[i].asString())); |
| 427 | } | ||
| 428 | |||
| 429 | 376 | return result; | |
| 430 | 188 | } | |
| 431 | |||
| 432 | 157 | std::vector<openstudio::path> WorkflowJSON_Impl::absoluteFilePaths() const { | |
| 433 | 157 | std::vector<openstudio::path> result; | |
| 434 |
3/3✓ Branch 1 taken 157 times.
✓ Branch 8 taken 1097 times.
✓ Branch 9 taken 157 times.
|
1254 | for (const auto& path : filePaths()) { |
| 435 |
3/3✓ Branch 1 taken 1097 times.
✓ Branch 3 taken 69 times.
✓ Branch 4 taken 1028 times.
|
1097 | if (path.is_absolute()) { |
| 436 |
1/1✓ Branch 1 taken 69 times.
|
69 | result.push_back(path); |
| 437 | } else { | ||
| 438 |
3/3✓ Branch 1 taken 1028 times.
✓ Branch 4 taken 1028 times.
✓ Branch 7 taken 1028 times.
|
1028 | result.push_back(canonicalOrAbsolute(path, absoluteRootDir())); |
| 439 | } | ||
| 440 | 157 | } | |
| 441 | 157 | return result; | |
| 442 | ✗ | } | |
| 443 | |||
| 444 | 190 | bool WorkflowJSON_Impl::addFilePath(const openstudio::path& path) { | |
| 445 |
5/6✓ Branch 1 taken 186 times.
✓ Branch 2 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 186 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 186 times.
|
190 | if (!m_value.isMember("file_paths") || !m_value["file_paths"].isArray()) { |
| 446 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | m_value["file_paths"] = Json::Value(Json::arrayValue); |
| 447 | } | ||
| 448 |
3/3✓ Branch 2 taken 190 times.
✓ Branch 5 taken 190 times.
✓ Branch 8 taken 190 times.
|
190 | m_value["file_paths"].append(toString(path)); |
| 449 | 190 | onUpdate(); | |
| 450 | 190 | return true; | |
| 451 | } | ||
| 452 | |||
| 453 | 31 | void WorkflowJSON_Impl::resetFilePaths() { | |
| 454 |
2/2✓ Branch 1 taken 31 times.
✓ Branch 4 taken 31 times.
|
31 | m_value["file_paths"] = Json::Value(Json::arrayValue); |
| 455 | 31 | onUpdate(); | |
| 456 | 31 | } | |
| 457 | |||
| 458 | 113 | boost::optional<openstudio::path> WorkflowJSON_Impl::findFile(const openstudio::path& file) const { | |
| 459 | // if absolute check if exists | ||
| 460 |
3/3✓ Branch 1 taken 113 times.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 43 times.
|
113 | if (file.is_absolute()) { |
| 461 |
2/3✓ Branch 1 taken 70 times.
✓ Branch 3 taken 70 times.
✗ Branch 4 not taken.
|
70 | if (boost::filesystem::exists(file)) { |
| 462 |
1/1✓ Branch 1 taken 70 times.
|
70 | return file; |
| 463 | } | ||
| 464 | |||
| 465 | // absolute path does not exist | ||
| 466 | ✗ | return boost::none; | |
| 467 | } | ||
| 468 | |||
| 469 |
3/3✓ Branch 1 taken 43 times.
✓ Branch 8 taken 157 times.
✓ Branch 9 taken 3 times.
|
160 | for (const auto& path : absoluteFilePaths()) { |
| 470 |
1/1✓ Branch 1 taken 157 times.
|
314 | openstudio::path p = path / file; |
| 471 |
7/8✓ Branch 1 taken 157 times.
✓ Branch 3 taken 40 times.
✓ Branch 4 taken 117 times.
✓ Branch 6 taken 40 times.
✓ Branch 8 taken 40 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 40 times.
✓ Branch 11 taken 117 times.
|
157 | if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) { |
| 472 |
3/3✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
|
40 | return canonicalOrAbsolute(p); |
| 473 | } | ||
| 474 | 200 | } | |
| 475 | |||
| 476 | // Extra check: if it starts with file:// | ||
| 477 |
1/1✓ Branch 1 taken 3 times.
|
3 | std::string fileName = toString(file); |
| 478 |
2/3✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | if (fileName.rfind("file://", 0) == 0) { |
| 479 | // We strip it, and try again | ||
| 480 | ✗ | return findFile(toPath(fileName.substr(7))); | |
| 481 | |||
| 482 | // if it starts with 'file:' (some test files - at least seb.osm - on OpenStudio-workflow-gem have that...) | ||
| 483 | // eg: 'file:files/USA_CO_Golden-NREL.724666_TMY3.epw' | ||
| 484 |
2/3✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | } else if (fileName.rfind("file:", 0) == 0) { |
| 485 | // We strip it, and try again | ||
| 486 | ✗ | return findFile(toPath(fileName.substr(5))); | |
| 487 | } | ||
| 488 | 3 | return boost::none; | |
| 489 | 3 | } | |
| 490 | |||
| 491 | 3 | boost::optional<openstudio::path> WorkflowJSON_Impl::findFile(const std::string& fileName) const { | |
| 492 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | return findFile(toPath(fileName)); |
| 493 | } | ||
| 494 | |||
| 495 | 542 | std::vector<openstudio::path> WorkflowJSON_Impl::measurePaths() const { | |
| 496 | 542 | std::vector<openstudio::path> result; | |
| 497 | |||
| 498 |
1/1✓ Branch 1 taken 542 times.
|
542 | Json::Value defaultValue(Json::arrayValue); |
| 499 | |||
| 500 |
1/1✓ Branch 1 taken 542 times.
|
542 | Json::Value paths = m_value.get("measure_paths", defaultValue); |
| 501 |
2/2✓ Branch 1 taken 542 times.
✓ Branch 4 taken 542 times.
|
542 | paths.append("./measures"); |
| 502 |
2/2✓ Branch 1 taken 542 times.
✓ Branch 4 taken 542 times.
|
542 | paths.append("../../measures"); |
| 503 |
2/2✓ Branch 1 taken 542 times.
✓ Branch 4 taken 542 times.
|
542 | paths.append("./"); |
| 504 | |||
| 505 |
1/1✓ Branch 1 taken 542 times.
|
542 | Json::ArrayIndex n = paths.size(); |
| 506 |
2/2✓ Branch 0 taken 1808 times.
✓ Branch 1 taken 542 times.
|
2350 | for (Json::ArrayIndex i = 0; i < n; ++i) { |
| 507 |
5/5✓ Branch 1 taken 1808 times.
✓ Branch 4 taken 1808 times.
✓ Branch 7 taken 1808 times.
✓ Branch 10 taken 1808 times.
✓ Branch 13 taken 1808 times.
|
1808 | result.push_back(toPath(paths[i].asString()).remove_trailing_separator()); |
| 508 | } | ||
| 509 | |||
| 510 | 1084 | return result; | |
| 511 | 542 | } | |
| 512 | |||
| 513 | 542 | std::vector<openstudio::path> WorkflowJSON_Impl::absoluteMeasurePaths() const { | |
| 514 | 542 | std::vector<openstudio::path> result; | |
| 515 |
3/3✓ Branch 1 taken 542 times.
✓ Branch 8 taken 1808 times.
✓ Branch 9 taken 542 times.
|
2350 | for (const auto& path : measurePaths()) { |
| 516 |
2/3✓ Branch 1 taken 1808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1808 times.
|
1808 | if (path.is_absolute()) { |
| 517 | ✗ | result.push_back(path); | |
| 518 | } else { | ||
| 519 |
3/3✓ Branch 1 taken 1808 times.
✓ Branch 4 taken 1808 times.
✓ Branch 7 taken 1808 times.
|
1808 | result.push_back(canonicalOrAbsolute(path, absoluteRootDir())); |
| 520 | } | ||
| 521 | 542 | } | |
| 522 | 542 | return result; | |
| 523 | ✗ | } | |
| 524 | |||
| 525 | ✗ | bool WorkflowJSON_Impl::addMeasurePath(const openstudio::path& path) { | |
| 526 | ✗ | if (!m_value.isMember("measure_paths") || !m_value["measure_paths"].isArray()) { | |
| 527 | ✗ | m_value["measure_paths"] = Json::Value(Json::arrayValue); | |
| 528 | } | ||
| 529 | ✗ | m_value["measure_paths"].append(toString(path)); | |
| 530 | ✗ | onUpdate(); | |
| 531 | ✗ | return true; | |
| 532 | } | ||
| 533 | |||
| 534 | ✗ | void WorkflowJSON_Impl::resetMeasurePaths() { | |
| 535 | ✗ | m_value["measure_paths"] = Json::Value(Json::arrayValue); | |
| 536 | ✗ | onUpdate(); | |
| 537 | ✗ | } | |
| 538 | |||
| 539 | 542 | boost::optional<openstudio::path> WorkflowJSON_Impl::findMeasure(const openstudio::path& measureDir) const { | |
| 540 | // if absolute check if exists | ||
| 541 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 542 times.
|
542 | if (measureDir.is_absolute()) { |
| 542 | ✗ | if (boost::filesystem::exists(measureDir)) { | |
| 543 | ✗ | return measureDir; | |
| 544 | } | ||
| 545 | |||
| 546 | // absolute path does not exist | ||
| 547 | ✗ | return boost::none; | |
| 548 | } | ||
| 549 | |||
| 550 |
3/3✓ Branch 1 taken 542 times.
✓ Branch 8 taken 769 times.
✓ Branch 9 taken 96 times.
|
865 | for (const auto& path : absoluteMeasurePaths()) { |
| 551 |
1/1✓ Branch 1 taken 769 times.
|
1538 | openstudio::path p = path / measureDir; |
| 552 |
7/8✓ Branch 1 taken 769 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 323 times.
✓ Branch 6 taken 446 times.
✓ Branch 8 taken 446 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 446 times.
✓ Branch 11 taken 323 times.
|
769 | if (boost::filesystem::exists(p) && boost::filesystem::is_directory(p)) { |
| 553 |
3/3✓ Branch 1 taken 446 times.
✓ Branch 4 taken 446 times.
✓ Branch 7 taken 446 times.
|
446 | return canonicalOrAbsolute(p); |
| 554 | } | ||
| 555 | 1311 | } | |
| 556 | 96 | return boost::none; | |
| 557 | } | ||
| 558 | |||
| 559 | 540 | boost::optional<openstudio::path> WorkflowJSON_Impl::findMeasure(const std::string& measureDirName) const { | |
| 560 |
2/2✓ Branch 1 taken 540 times.
✓ Branch 4 taken 540 times.
|
540 | return findMeasure(toPath(measureDirName)); |
| 561 | } | ||
| 562 | |||
| 563 | 48 | boost::optional<openstudio::path> WorkflowJSON_Impl::seedFile() const { | |
| 564 |
1/1✓ Branch 1 taken 48 times.
|
48 | Json::Value defaultValue(""); |
| 565 |
1/1✓ Branch 1 taken 48 times.
|
48 | Json::Value seed = m_value.get("seed_file", defaultValue); |
| 566 |
1/1✓ Branch 1 taken 48 times.
|
48 | std::string result = seed.asString(); |
| 567 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 2 taken 32 times.
|
48 | if (result.empty()) { |
| 568 | 16 | return boost::none; | |
| 569 | } | ||
| 570 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
32 | return toPath(result); |
| 571 | 48 | } | |
| 572 | |||
| 573 | 4 | bool WorkflowJSON_Impl::setSeedFile(const openstudio::path& seedFile) { | |
| 574 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | m_value["seed_file"] = toString(seedFile); |
| 575 | 4 | onUpdate(); | |
| 576 | 4 | return true; | |
| 577 | } | ||
| 578 | |||
| 579 | 1 | void WorkflowJSON_Impl::resetSeedFile() { | |
| 580 | 1 | m_value.removeMember("seed_file"); | |
| 581 | 1 | onUpdate(); | |
| 582 | 1 | } | |
| 583 | |||
| 584 | 19 | boost::optional<openstudio::path> WorkflowJSON_Impl::seedModelicaFile() const { | |
| 585 |
1/1✓ Branch 1 taken 19 times.
|
19 | Json::Value defaultValue(""); |
| 586 |
1/1✓ Branch 1 taken 19 times.
|
19 | Json::Value seed = m_value.get("seed_modelica_file", defaultValue); |
| 587 |
1/1✓ Branch 1 taken 19 times.
|
19 | std::string result = seed.asString(); |
| 588 |
1/2✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
|
19 | if (result.empty()) { |
| 589 | 19 | return boost::none; | |
| 590 | } | ||
| 591 | ✗ | return toPath(result); | |
| 592 | 19 | } | |
| 593 | |||
| 594 | 22 | boost::optional<std::string> WorkflowJSON_Impl::seedModelicaModel() const { | |
| 595 |
1/1✓ Branch 1 taken 22 times.
|
22 | Json::Value defaultValue(""); |
| 596 |
1/1✓ Branch 1 taken 22 times.
|
22 | Json::Value seed = m_value.get("seed_modelica_model", defaultValue); |
| 597 |
1/1✓ Branch 1 taken 22 times.
|
22 | std::string result = seed.asString(); |
| 598 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | if (result.empty()) { |
| 599 | 22 | return boost::none; | |
| 600 | } | ||
| 601 | ✗ | return result; | |
| 602 | 22 | } | |
| 603 | |||
| 604 | ✗ | bool WorkflowJSON_Impl::setSeedModelicaFile(const openstudio::path& modelicaSeedFile) { | |
| 605 | ✗ | m_value["seed_modelica_file"] = toString(modelicaSeedFile); | |
| 606 | ✗ | onUpdate(); | |
| 607 | ✗ | return true; | |
| 608 | } | ||
| 609 | |||
| 610 | ✗ | void WorkflowJSON_Impl::resetSeedModelicaFile() { | |
| 611 | ✗ | m_value.removeMember("seed_modelica_file"); | |
| 612 | ✗ | onUpdate(); | |
| 613 | ✗ | } | |
| 614 | |||
| 615 | ✗ | std::vector<openstudio::path> WorkflowJSON_Impl::modelicaPackages() const { | |
| 616 | ✗ | std::vector<openstudio::path> result; | |
| 617 | ✗ | const Json::Value& packages = m_value.get("modelica_packages", Json::Value()); | |
| 618 | |||
| 619 | ✗ | auto appendIfValid = [&result](const Json::Value& value) { | |
| 620 | ✗ | if (value.isString()) { | |
| 621 | ✗ | const std::string str = value.asString(); | |
| 622 | ✗ | if (!str.empty()) { | |
| 623 | ✗ | result.push_back(toPath(str)); | |
| 624 | } | ||
| 625 | ✗ | } | |
| 626 | ✗ | }; | |
| 627 | |||
| 628 | ✗ | if (packages.isArray()) { | |
| 629 | ✗ | for (const auto& entry : packages) { | |
| 630 | ✗ | appendIfValid(entry); | |
| 631 | } | ||
| 632 | } else { | ||
| 633 | ✗ | appendIfValid(packages); | |
| 634 | } | ||
| 635 | |||
| 636 | ✗ | return result; | |
| 637 | ✗ | } | |
| 638 | |||
| 639 | ✗ | bool WorkflowJSON_Impl::setModelicaPackages(const std::vector<openstudio::path>& packages) { | |
| 640 | ✗ | if (packages.empty()) { | |
| 641 | ✗ | resetModelicaPackages(); | |
| 642 | ✗ | return true; | |
| 643 | } | ||
| 644 | |||
| 645 | ✗ | Json::Value packageArray(Json::arrayValue); | |
| 646 | ✗ | for (const auto& package : packages) { | |
| 647 | ✗ | packageArray.append(toString(package)); | |
| 648 | } | ||
| 649 | |||
| 650 | ✗ | m_value["modelica_packages"] = std::move(packageArray); | |
| 651 | ✗ | onUpdate(); | |
| 652 | ✗ | return true; | |
| 653 | ✗ | } | |
| 654 | |||
| 655 | ✗ | void WorkflowJSON_Impl::resetModelicaPackages() { | |
| 656 | ✗ | m_value.removeMember("modelica_packages"); | |
| 657 | ✗ | onUpdate(); | |
| 658 | ✗ | } | |
| 659 | |||
| 660 | 60 | boost::optional<openstudio::path> WorkflowJSON_Impl::weatherFile() const { | |
| 661 |
1/1✓ Branch 1 taken 60 times.
|
60 | Json::Value defaultValue(""); |
| 662 |
1/1✓ Branch 1 taken 60 times.
|
60 | Json::Value weather = m_value.get("weather_file", defaultValue); |
| 663 |
1/1✓ Branch 1 taken 60 times.
|
60 | std::string result = weather.asString(); |
| 664 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 2 taken 40 times.
|
60 | if (result.empty()) { |
| 665 | 20 | return boost::none; | |
| 666 | } | ||
| 667 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
40 | return toPath(result); |
| 668 | 60 | } | |
| 669 | |||
| 670 | 3 | bool WorkflowJSON_Impl::setWeatherFile(const openstudio::path& weatherFile) { | |
| 671 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | m_value["weather_file"] = toString(weatherFile); |
| 672 | 3 | onUpdate(); | |
| 673 | 3 | return true; | |
| 674 | } | ||
| 675 | |||
| 676 | 1 | void WorkflowJSON_Impl::resetWeatherFile() { | |
| 677 | 1 | m_value.removeMember("weather_file"); | |
| 678 | 1 | onUpdate(); | |
| 679 | 1 | } | |
| 680 | |||
| 681 | 264 | std::vector<WorkflowStep> WorkflowJSON_Impl::workflowSteps() const { | |
| 682 | 264 | return m_steps; | |
| 683 | } | ||
| 684 | |||
| 685 | 14 | bool WorkflowJSON_Impl::setWorkflowSteps(const std::vector<WorkflowStep>& workflowSteps) { | |
| 686 | 14 | disconnectSteps(); | |
| 687 | 14 | m_steps = workflowSteps; | |
| 688 | 14 | setMeasureTypes(); | |
| 689 | 14 | connectSteps(); | |
| 690 | 14 | onUpdate(); // onUpdate does not happen in setMeasureTypes | |
| 691 | 14 | return true; | |
| 692 | } | ||
| 693 | |||
| 694 | 1 | void WorkflowJSON_Impl::resetWorkflowSteps() { | |
| 695 |
1/1✓ Branch 2 taken 1 time.
|
1 | bool test = setWorkflowSteps(std::vector<WorkflowStep>()); // will hit onUpdate in setWorkflowSteps |
| 696 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(test); |
| 697 | 1 | } | |
| 698 | |||
| 699 | ✗ | std::vector<MeasureStep> WorkflowJSON_Impl::getMeasureSteps(const MeasureType& measureType) const { | |
| 700 | ✗ | std::vector<MeasureStep> result; | |
| 701 | ✗ | size_t n = m_steps.size(); | |
| 702 | ✗ | OS_ASSERT(m_measureTypes.size() == n); | |
| 703 | ✗ | for (size_t i = 0; i < n; ++i) { | |
| 704 | ✗ | if (m_steps[i].optionalCast<MeasureStep>()) { | |
| 705 | ✗ | if (m_measureTypes[i] == measureType.value()) { | |
| 706 | ✗ | result.push_back(m_steps[i].cast<MeasureStep>()); | |
| 707 | } | ||
| 708 | } | ||
| 709 | } | ||
| 710 | ✗ | return result; | |
| 711 | ✗ | } | |
| 712 | |||
| 713 | 66 | std::vector<std::pair<unsigned, MeasureStep>> WorkflowJSON_Impl::getMeasureStepsWithIndex(const MeasureType& measureType) const { | |
| 714 | 66 | std::vector<std::pair<unsigned, MeasureStep>> result; | |
| 715 | 66 | size_t n = m_steps.size(); | |
| 716 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 4 not taken.
|
66 | OS_ASSERT(m_measureTypes.size() == n); |
| 717 |
2/2✓ Branch 0 taken 145 times.
✓ Branch 1 taken 66 times.
|
211 | for (size_t i = 0; i < n; ++i) { |
| 718 |
2/3✓ Branch 2 taken 145 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
|
290 | if (m_steps[i].optionalCast<MeasureStep>()) { |
| 719 |
3/3✓ Branch 2 taken 145 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 93 times.
|
145 | if (m_measureTypes[i] == measureType.value()) { |
| 720 |
2/2✓ Branch 2 taken 52 times.
✓ Branch 5 taken 52 times.
|
52 | result.emplace_back(i, m_steps[i].cast<MeasureStep>()); |
| 721 | } | ||
| 722 | } | ||
| 723 | } | ||
| 724 | 66 | return result; | |
| 725 | ✗ | } | |
| 726 | |||
| 727 | ✗ | bool WorkflowJSON_Impl::setMeasureSteps(const MeasureType& measureType, const std::vector<MeasureStep>& steps) { | |
| 728 | |||
| 729 | // verify steps | ||
| 730 | ✗ | for (const auto& step : steps) { | |
| 731 | ✗ | boost::optional<BCLMeasure> bclMeasure = getBCLMeasure(step); | |
| 732 | ✗ | if (!bclMeasure) { | |
| 733 | ✗ | return false; | |
| 734 | } | ||
| 735 | ✗ | if (bclMeasure->measureType() != measureType) { | |
| 736 | ✗ | return false; | |
| 737 | } | ||
| 738 | ✗ | } | |
| 739 | |||
| 740 | // DLM: this implementation may evolve | ||
| 741 | ✗ | std::vector<WorkflowStep> newSteps; | |
| 742 | |||
| 743 | ✗ | if (measureType == MeasureType::ModelMeasure) { | |
| 744 | ✗ | newSteps.insert(newSteps.end(), steps.begin(), steps.end()); | |
| 745 | } else { | ||
| 746 | ✗ | std::vector<MeasureStep> oldSteps = getMeasureSteps(MeasureType::ModelMeasure); | |
| 747 | ✗ | newSteps.insert(newSteps.end(), oldSteps.begin(), oldSteps.end()); | |
| 748 | ✗ | } | |
| 749 | |||
| 750 | ✗ | if (measureType == MeasureType::EnergyPlusMeasure) { | |
| 751 | ✗ | newSteps.insert(newSteps.end(), steps.begin(), steps.end()); | |
| 752 | } else { | ||
| 753 | ✗ | std::vector<MeasureStep> oldSteps = getMeasureSteps(MeasureType::EnergyPlusMeasure); | |
| 754 | ✗ | newSteps.insert(newSteps.end(), oldSteps.begin(), oldSteps.end()); | |
| 755 | ✗ | } | |
| 756 | |||
| 757 | ✗ | if (measureType == MeasureType::ReportingMeasure) { | |
| 758 | ✗ | newSteps.insert(newSteps.end(), steps.begin(), steps.end()); | |
| 759 | } else { | ||
| 760 | ✗ | std::vector<MeasureStep> oldSteps = getMeasureSteps(MeasureType::ReportingMeasure); | |
| 761 | ✗ | newSteps.insert(newSteps.end(), oldSteps.begin(), oldSteps.end()); | |
| 762 | ✗ | } | |
| 763 | |||
| 764 | ✗ | return setWorkflowSteps(newSteps); // onUpdate in setWorkflowSteps | |
| 765 | ✗ | } | |
| 766 | |||
| 767 | 329 | boost::optional<BCLMeasure> WorkflowJSON_Impl::getBCLMeasure(const MeasureStep& step) const { | |
| 768 |
2/2✓ Branch 1 taken 329 times.
✓ Branch 4 taken 329 times.
|
329 | boost::optional<openstudio::path> path = findMeasure(step.measureDirName()); |
| 769 |
2/2✓ Branch 0 taken 235 times.
✓ Branch 1 taken 94 times.
|
329 | if (path) { |
| 770 |
2/2✓ Branch 1 taken 235 times.
✓ Branch 4 taken 235 times.
|
235 | return BCLMeasure::load(*path); |
| 771 | } | ||
| 772 | 94 | return boost::none; | |
| 773 | 329 | } | |
| 774 | |||
| 775 | ✗ | boost::optional<BCLMeasure> WorkflowJSON_Impl::getBCLMeasureByUUID(const UUID& id) const { | |
| 776 | ✗ | for (const auto& step : m_steps) { | |
| 777 | ✗ | if (step.optionalCast<MeasureStep>()) { | |
| 778 | ✗ | boost::optional<BCLMeasure> bclMeasure = getBCLMeasure(step.cast<MeasureStep>()); | |
| 779 | ✗ | if (bclMeasure && (bclMeasure->uuid() == id)) { | |
| 780 | ✗ | return bclMeasure; | |
| 781 | } | ||
| 782 | ✗ | } | |
| 783 | } | ||
| 784 | ✗ | return boost::none; | |
| 785 | } | ||
| 786 | |||
| 787 | ✗ | boost::optional<BCLMeasure> WorkflowJSON_Impl::addMeasure(const BCLMeasure& bclMeasure) { | |
| 788 | ✗ | boost::optional<BCLMeasure> existingMeasure = getBCLMeasureByUUID(bclMeasure.uuid()); | |
| 789 | ✗ | boost::optional<openstudio::path> existingMeasureDirName; | |
| 790 | ✗ | if (existingMeasure) { | |
| 791 | // TODO: check that measure type has not changed? | ||
| 792 | |||
| 793 | ✗ | existingMeasureDirName = existingMeasure->directory(); | |
| 794 | ✗ | boost::filesystem::remove_all(*existingMeasureDirName); | |
| 795 | } | ||
| 796 | |||
| 797 | ✗ | std::vector<openstudio::path> paths = absoluteMeasurePaths(); | |
| 798 | ✗ | OS_ASSERT(!paths.empty()); | |
| 799 | |||
| 800 | // Get the name of the directory (=last level directory name), eg: /path/to/measure_folder => measure_folder | ||
| 801 | ✗ | openstudio::path lastLevelDirectoryName = getLastLevelDirectoryName(bclMeasure.directory()); | |
| 802 | ✗ | if (!toUUID(toString(lastLevelDirectoryName)).isNull()) { | |
| 803 | // directory name is convertible to uuid, use the class name | ||
| 804 | ✗ | lastLevelDirectoryName = toPath(bclMeasure.className()); | |
| 805 | } | ||
| 806 | |||
| 807 | ✗ | int i = 1; | |
| 808 | ✗ | while (boost::filesystem::exists(paths[0] / lastLevelDirectoryName)) { | |
| 809 | ✗ | std::stringstream ss; | |
| 810 | ✗ | ss << toString(lastLevelDirectoryName) << " " << i; | |
| 811 | ✗ | lastLevelDirectoryName = toPath(ss.str()); | |
| 812 | ✗ | } | |
| 813 | ✗ | openstudio::path newMeasureDirName = paths[0] / lastLevelDirectoryName; | |
| 814 | |||
| 815 | // If we have an existing measure | ||
| 816 | ✗ | if (existingMeasureDirName) { | |
| 817 | ✗ | openstudio::path lastLevelExistingDirectoryName = getLastLevelDirectoryName(*existingMeasureDirName); | |
| 818 | // And the previous directory name isn't the same as the new one | ||
| 819 | ✗ | if (lastLevelExistingDirectoryName != lastLevelDirectoryName) { | |
| 820 | // update steps | ||
| 821 | ✗ | for (auto& step : m_steps) { | |
| 822 | ✗ | if (auto measureStep = step.optionalCast<MeasureStep>()) { | |
| 823 | ✗ | if (measureStep->measureDirName() == toString(lastLevelExistingDirectoryName)) { | |
| 824 | ✗ | measureStep->setMeasureDirName(toString(lastLevelDirectoryName)); | |
| 825 | } | ||
| 826 | ✗ | } | |
| 827 | } | ||
| 828 | } | ||
| 829 | ✗ | } | |
| 830 | |||
| 831 | ✗ | onUpdate(); | |
| 832 | |||
| 833 | ✗ | return bclMeasure.clone(newMeasureDirName); | |
| 834 | ✗ | } | |
| 835 | |||
| 836 | 449 | boost::optional<RunOptions> WorkflowJSON_Impl::runOptions() const { | |
| 837 | 449 | return m_runOptions; | |
| 838 | } | ||
| 839 | |||
| 840 | 24 | bool WorkflowJSON_Impl::setRunOptions(const RunOptions& options) { | |
| 841 | 24 | disconnectRunOptions(); | |
| 842 | 24 | m_runOptions = options; | |
| 843 | 24 | connectRunOptions(); | |
| 844 | 24 | onUpdate(); | |
| 845 | 24 | return true; | |
| 846 | } | ||
| 847 | |||
| 848 | ✗ | void WorkflowJSON_Impl::resetRunOptions() { | |
| 849 | ✗ | disconnectRunOptions(); | |
| 850 | ✗ | m_runOptions.reset(); | |
| 851 | ✗ | onUpdate(); | |
| 852 | ✗ | } | |
| 853 | |||
| 854 | 669 | void WorkflowJSON_Impl::onUpdate() { | |
| 855 |
4/4✓ Branch 1 taken 669 times.
✓ Branch 4 taken 669 times.
✓ Branch 7 taken 669 times.
✓ Branch 10 taken 669 times.
|
669 | m_value["updated_at"] = DateTime::nowUTC().toISO8601(); |
| 856 | 669 | this->onChange.nano_emit(); | |
| 857 | 669 | } | |
| 858 | |||
| 859 | 100 | void WorkflowJSON_Impl::parseSteps() { | |
| 860 |
1/1✓ Branch 1 taken 100 times.
|
100 | disconnectSteps(); |
| 861 | 100 | m_steps.clear(); | |
| 862 | |||
| 863 |
1/1✓ Branch 1 taken 100 times.
|
100 | Json::Value defaultValue(Json::arrayValue); |
| 864 |
1/1✓ Branch 1 taken 100 times.
|
100 | Json::Value steps = m_value.get("steps", defaultValue); |
| 865 | |||
| 866 |
1/1✓ Branch 1 taken 100 times.
|
100 | Json::ArrayIndex n = steps.size(); |
| 867 | |||
| 868 |
2/2✓ Branch 0 taken 92 times.
✓ Branch 1 taken 8 times.
|
100 | if (n > 0) { |
| 869 |
1/1✓ Branch 1 taken 92 times.
|
92 | Json::StreamWriterBuilder wbuilder; |
| 870 | |||
| 871 | // mimic the old FastWriter behavior: | ||
| 872 |
3/3✓ Branch 1 taken 92 times.
✓ Branch 4 taken 92 times.
✓ Branch 7 taken 92 times.
|
276 | wbuilder["commentStyle"] = "None"; |
| 873 |
3/3✓ Branch 1 taken 92 times.
✓ Branch 4 taken 92 times.
✓ Branch 7 taken 92 times.
|
276 | wbuilder["indentation"] = ""; |
| 874 | |||
| 875 |
2/2✓ Branch 0 taken 217 times.
✓ Branch 1 taken 92 times.
|
309 | for (Json::ArrayIndex i = 0; i < n; ++i) { |
| 876 |
2/2✓ Branch 1 taken 217 times.
✓ Branch 4 taken 217 times.
|
217 | Json::Value step = steps[i]; |
| 877 | |||
| 878 |
1/1✓ Branch 1 taken 217 times.
|
217 | std::string s = Json::writeString(wbuilder, step); |
| 879 | |||
| 880 |
1/1✓ Branch 1 taken 217 times.
|
217 | boost::optional<WorkflowStep> workflowStep = WorkflowStep::fromString(s); |
| 881 |
1/2✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
|
217 | if (workflowStep) { |
| 882 |
2/2✓ Branch 1 taken 217 times.
✓ Branch 4 taken 217 times.
|
217 | m_steps.push_back(*workflowStep); |
| 883 | } else { | ||
| 884 | ✗ | LOG_AND_THROW("Step " << i << " cannot be processed"); | |
| 885 | } | ||
| 886 | 217 | } | |
| 887 | 92 | } | |
| 888 | |||
| 889 |
1/1✓ Branch 1 taken 100 times.
|
100 | connectSteps(); |
| 890 | |||
| 891 |
1/1✓ Branch 1 taken 100 times.
|
100 | m_value.removeMember("steps"); |
| 892 | 100 | } | |
| 893 | |||
| 894 | 114 | void WorkflowJSON_Impl::disconnectSteps() { | |
| 895 |
2/2✓ Branch 4 taken 3 times.
✓ Branch 5 taken 114 times.
|
117 | for (const auto& step : m_steps) { |
| 896 |
1/1✓ Branch 3 taken 3 times.
|
3 | step.getImpl<detail::WorkflowStep_Impl>().get()->WorkflowStep_Impl::onChange.disconnect<WorkflowJSON_Impl, &WorkflowJSON_Impl::onUpdate>(this); |
| 897 | } | ||
| 898 | 114 | } | |
| 899 | |||
| 900 | 114 | void WorkflowJSON_Impl::connectSteps() { | |
| 901 |
2/2✓ Branch 4 taken 233 times.
✓ Branch 5 taken 114 times.
|
347 | for (const auto& step : m_steps) { |
| 902 |
1/1✓ Branch 3 taken 233 times.
|
233 | step.getImpl<detail::WorkflowStep_Impl>().get()->WorkflowStep_Impl::onChange.connect<WorkflowJSON_Impl, &WorkflowJSON_Impl::onUpdate>(this); |
| 903 | } | ||
| 904 | 114 | } | |
| 905 | |||
| 906 | 100 | void WorkflowJSON_Impl::parseRunOptions() { | |
| 907 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
|
200 | if (m_runOptions) { |
| 908 | ✗ | disconnectRunOptions(); | |
| 909 | ✗ | m_runOptions.reset(); | |
| 910 | } | ||
| 911 | |||
| 912 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 2 taken 79 times.
|
100 | if (m_value.isMember("run_options")) { |
| 913 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | Json::Value options = m_value["run_options"]; |
| 914 | |||
| 915 |
1/1✓ Branch 1 taken 21 times.
|
21 | Json::StreamWriterBuilder wbuilder; |
| 916 | // mimic the old FastWriter behavior: | ||
| 917 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
63 | wbuilder["commentStyle"] = "None"; |
| 918 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
63 | wbuilder["indentation"] = ""; |
| 919 | |||
| 920 |
1/1✓ Branch 1 taken 21 times.
|
21 | std::string s = Json::writeString(wbuilder, options); |
| 921 | |||
| 922 |
1/1✓ Branch 1 taken 21 times.
|
21 | m_runOptions = RunOptions::fromString(s); |
| 923 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
|
21 | if (!m_runOptions) { |
| 924 | ✗ | LOG_AND_THROW("Run options cannot be processed"); | |
| 925 | } | ||
| 926 | |||
| 927 |
1/1✓ Branch 1 taken 21 times.
|
21 | connectRunOptions(); |
| 928 |
1/1✓ Branch 1 taken 21 times.
|
21 | m_value.removeMember("run_options"); |
| 929 | 21 | } | |
| 930 | 100 | } | |
| 931 | |||
| 932 | 24 | void WorkflowJSON_Impl::disconnectRunOptions() { | |
| 933 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
|
48 | if (m_runOptions) { |
| 934 | ✗ | m_runOptions->getImpl<detail::RunOptions_Impl>().get()->RunOptions_Impl::onChange.disconnect<WorkflowJSON_Impl, &WorkflowJSON_Impl::onUpdate>( | |
| 935 | this); | ||
| 936 | } | ||
| 937 | 24 | } | |
| 938 | |||
| 939 | 45 | void WorkflowJSON_Impl::connectRunOptions() { | |
| 940 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
90 | if (m_runOptions) { |
| 941 |
2/2✓ Branch 1 taken 45 times.
✓ Branch 6 taken 45 times.
|
45 | m_runOptions->getImpl<detail::RunOptions_Impl>().get()->RunOptions_Impl::onChange.connect<WorkflowJSON_Impl, &WorkflowJSON_Impl::onUpdate>( |
| 942 | this); | ||
| 943 | } | ||
| 944 | 45 | } | |
| 945 | |||
| 946 | 153 | void WorkflowJSON_Impl::setMeasureTypes() { | |
| 947 | 153 | m_measureTypes.clear(); | |
| 948 | 153 | m_measureTypes.reserve(m_steps.size()); | |
| 949 |
2/2✓ Branch 5 taken 323 times.
✓ Branch 6 taken 153 times.
|
476 | for (const auto& step : m_steps) { |
| 950 |
2/3✓ Branch 1 taken 323 times.
✓ Branch 4 taken 323 times.
✗ Branch 5 not taken.
|
646 | if (step.optionalCast<MeasureStep>()) { |
| 951 |
2/2✓ Branch 1 taken 323 times.
✓ Branch 4 taken 323 times.
|
323 | boost::optional<BCLMeasure> bclMeasure = getBCLMeasure(step.cast<MeasureStep>()); |
| 952 |
2/2✓ Branch 0 taken 226 times.
✓ Branch 1 taken 97 times.
|
323 | if (bclMeasure) { |
| 953 |
4/4✓ Branch 1 taken 226 times.
✓ Branch 4 taken 226 times.
✓ Branch 7 taken 226 times.
✓ Branch 10 taken 226 times.
|
226 | m_measureTypes.push_back(bclMeasure->measureType().value()); |
| 954 | } else { | ||
| 955 |
1/1✓ Branch 1 taken 97 times.
|
97 | m_measureTypes.push_back(NO_MEASURE_TYPE); |
| 956 | } | ||
| 957 | 323 | } else { | |
| 958 | ✗ | m_measureTypes.push_back(NO_MEASURE_TYPE); | |
| 959 | } | ||
| 960 | } | ||
| 961 | 153 | } | |
| 962 | |||
| 963 | 26 | bool WorkflowJSON_Impl::validateMeasures() const { | |
| 964 | // TODO: should we exit early, or return all problems found? | ||
| 965 | |||
| 966 | 26 | bool result = true; | |
| 967 |
1/1✓ Branch 1 taken 26 times.
|
26 | MeasureType state = MeasureType::ModelMeasure; |
| 968 | |||
| 969 |
2/2✓ Branch 5 taken 56 times.
✓ Branch 6 taken 26 times.
|
82 | for (size_t i = 0; const auto& step : m_steps) { |
| 970 |
6/6✓ Branch 1 taken 56 times.
✓ Branch 4 taken 56 times.
✓ Branch 7 taken 56 times.
✓ Branch 10 taken 56 times.
✓ Branch 13 taken 56 times.
✓ Branch 16 taken 56 times.
|
56 | LOG(Debug, "Validating step " << i); |
| 971 |
2/3✓ Branch 1 taken 56 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
|
112 | if (auto step_ = step.optionalCast<MeasureStep>()) { |
| 972 | // Not calling getBCLMeasure because I want to mimic workflow-gem and be as explicit as possible about what went wrong | ||
| 973 |
2/2✓ Branch 1 taken 56 times.
✓ Branch 4 taken 56 times.
|
56 | const auto measureDirName = step_->measureDirName(); |
| 974 |
1/1✓ Branch 1 taken 56 times.
|
56 | auto measurePath_ = findMeasure(measureDirName); |
| 975 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 54 times.
|
56 | if (!measurePath_) { |
| 976 |
7/7✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
|
2 | LOG(Error, "Cannot find measure '" << measureDirName << "'"); |
| 977 | 2 | result = false; | |
| 978 | 2 | continue; | |
| 979 | 2 | } | |
| 980 |
2/2✓ Branch 1 taken 54 times.
✓ Branch 4 taken 54 times.
|
54 | auto bclMeasure_ = BCLMeasure::load(*measurePath_); |
| 981 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 52 times.
|
54 | if (!bclMeasure_) { |
| 982 |
10/10✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
|
2 | LOG(Error, "Cannot load measure '" << measureDirName << "' at '" << *measurePath_ << "'"); |
| 983 | 2 | result = false; | |
| 984 | 2 | continue; | |
| 985 | 2 | } | |
| 986 | |||
| 987 | // Ensure that measures are in order, i.e. no OS after E+, E+ or OS after Reporting | ||
| 988 |
2/2✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
|
52 | const auto measureType = bclMeasure_->measureType(); |
| 989 | |||
| 990 |
3/3✓ Branch 1 taken 52 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 30 times.
|
52 | if (measureType == MeasureType::ModelMeasure) { |
| 991 |
2/3✓ Branch 1 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
|
22 | if (state == MeasureType::EnergyPlusMeasure) { |
| 992 | ✗ | LOG(Error, "OpenStudio measure '" << measureDirName << "' called after transition to EnergyPlus."); | |
| 993 | ✗ | result = false; | |
| 994 | } | ||
| 995 |
2/3✓ Branch 1 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
|
22 | if (state == MeasureType::ModelicaMeasure) { |
| 996 | ✗ | LOG(Error, "OpenStudio measure '" << measureDirName << "' called after Modelica measure."); | |
| 997 | ✗ | result = false; | |
| 998 | } | ||
| 999 |
3/3✓ Branch 1 taken 22 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 20 times.
|
22 | if (state == MeasureType::ReportingMeasure) { |
| 1000 |
7/7✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
|
2 | LOG(Error, "OpenStudio measure '" << measureDirName << "' called after Energyplus simulation."); |
| 1001 | 2 | result = false; | |
| 1002 | } | ||
| 1003 |
3/3✓ Branch 1 taken 30 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 22 times.
|
30 | } else if (measureType == MeasureType::EnergyPlusMeasure) { |
| 1004 |
2/3✓ Branch 1 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
|
8 | if (state == MeasureType::ModelicaMeasure) { |
| 1005 | ✗ | LOG(Error, "EnergyPlus measure '" << measureDirName << "' called after Modelica measure."); | |
| 1006 | ✗ | result = false; | |
| 1007 | } | ||
| 1008 |
2/3✓ Branch 1 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
|
8 | if (state == MeasureType::ReportingMeasure) { |
| 1009 | ✗ | LOG(Error, "EnergyPlus measure '" << measureDirName << "' called after Energyplus simulation."); | |
| 1010 | ✗ | result = false; | |
| 1011 | } | ||
| 1012 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 1 time.
|
8 | if (state == MeasureType::ModelMeasure) { |
| 1013 |
1/1✓ Branch 1 taken 7 times.
|
7 | state = MeasureType::EnergyPlusMeasure; |
| 1014 | } | ||
| 1015 |
2/3✓ Branch 1 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
|
22 | } else if (measureType == MeasureType::ModelicaMeasure) { |
| 1016 | ✗ | if (state == MeasureType::ReportingMeasure) { | |
| 1017 | ✗ | LOG(Error, "Modelica measure '" << measureDirName << "' called after Energyplus simulation."); | |
| 1018 | ✗ | result = false; | |
| 1019 | } | ||
| 1020 | ✗ | if (state == MeasureType::EnergyPlusMeasure) { | |
| 1021 | ✗ | state = MeasureType::ModelicaMeasure; | |
| 1022 | } | ||
| 1023 |
2/3✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
22 | } else if (measureType == MeasureType::ReportingMeasure) { |
| 1024 |
1/1✓ Branch 1 taken 22 times.
|
22 | state = MeasureType::ReportingMeasure; |
| 1025 | } else { | ||
| 1026 | ✗ | LOG(Error, "MeasureType " << measureType.valueName() << " of measure '" << measureDirName << "' is not supported"); | |
| 1027 | ✗ | result = false; | |
| 1028 | } | ||
| 1029 | 118 | } | |
| 1030 | 52 | ++i; | |
| 1031 | } | ||
| 1032 | |||
| 1033 | 26 | return result; | |
| 1034 | } | ||
| 1035 | } // namespace detail | ||
| 1036 | |||
| 1037 |
2/4✓ Branch 2 taken 5281 times.
✓ Branch 5 taken 5281 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
5281 | WorkflowJSON::WorkflowJSON() : m_impl(std::shared_ptr<detail::WorkflowJSON_Impl>(new detail::WorkflowJSON_Impl())) {} |
| 1038 | |||
| 1039 |
3/4✓ Branch 2 taken 53 times.
✓ Branch 5 taken 53 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
55 | WorkflowJSON::WorkflowJSON(const std::string& s) : m_impl(std::shared_ptr<detail::WorkflowJSON_Impl>(new detail::WorkflowJSON_Impl(s))) {} |
| 1040 | |||
| 1041 |
3/4✓ Branch 2 taken 47 times.
✓ Branch 5 taken 47 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
51 | WorkflowJSON::WorkflowJSON(const openstudio::path& p) : m_impl(std::shared_ptr<detail::WorkflowJSON_Impl>(new detail::WorkflowJSON_Impl(p))) {} |
| 1042 | |||
| 1043 | ✗ | WorkflowJSON::WorkflowJSON(std::shared_ptr<detail::WorkflowJSON_Impl> impl) : m_impl(impl) {} | |
| 1044 | |||
| 1045 | 30 | WorkflowJSON WorkflowJSON::clone() const { | |
| 1046 |
1/1✓ Branch 3 taken 30 times.
|
30 | return getImpl<detail::WorkflowJSON_Impl>()->clone(); |
| 1047 | } | ||
| 1048 | |||
| 1049 | 6 | boost::optional<WorkflowJSON> WorkflowJSON::load(const std::string& s) { | |
| 1050 | 6 | boost::optional<WorkflowJSON> result; | |
| 1051 | try { | ||
| 1052 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
6 | result = WorkflowJSON(s); |
| 1053 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | } catch (const std::exception&) { |
| 1054 | 2 | } | |
| 1055 | 6 | return result; | |
| 1056 | ✗ | } | |
| 1057 | |||
| 1058 | 12 | boost::optional<WorkflowJSON> WorkflowJSON::load(const openstudio::path& p) { | |
| 1059 | 12 | boost::optional<WorkflowJSON> result; | |
| 1060 | try { | ||
| 1061 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
12 | result = WorkflowJSON(p); |
| 1062 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | } catch (const std::exception&) { |
| 1063 | 2 | } | |
| 1064 | 12 | return result; | |
| 1065 | ✗ | } | |
| 1066 | |||
| 1067 | ✗ | Json::Value WorkflowJSON::toJSON(bool includeHash) const { | |
| 1068 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->toJSON(includeHash); | |
| 1069 | } | ||
| 1070 | |||
| 1071 | 32 | std::string WorkflowJSON::string(bool includeHash) const { | |
| 1072 |
1/1✓ Branch 3 taken 32 times.
|
32 | return getImpl<detail::WorkflowJSON_Impl>()->string(includeHash); |
| 1073 | } | ||
| 1074 | |||
| 1075 | 4 | std::string WorkflowJSON::hash() const { | |
| 1076 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::WorkflowJSON_Impl>()->hash(); |
| 1077 | } | ||
| 1078 | |||
| 1079 | 4 | std::string WorkflowJSON::computeHash() const { | |
| 1080 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::WorkflowJSON_Impl>()->computeHash(); |
| 1081 | } | ||
| 1082 | |||
| 1083 | 14 | bool WorkflowJSON::checkForUpdates() const { | |
| 1084 |
1/1✓ Branch 3 taken 14 times.
|
14 | return getImpl<detail::WorkflowJSON_Impl>()->checkForUpdates(); |
| 1085 | } | ||
| 1086 | |||
| 1087 | 1 | bool WorkflowJSON::save() const { | |
| 1088 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::WorkflowJSON_Impl>()->save(); |
| 1089 | } | ||
| 1090 | |||
| 1091 | 42 | bool WorkflowJSON::saveAs(const openstudio::path& p) const { | |
| 1092 |
1/1✓ Branch 3 taken 42 times.
|
42 | return getImpl<detail::WorkflowJSON_Impl>()->saveAs(p); |
| 1093 | } | ||
| 1094 | |||
| 1095 | 7 | void WorkflowJSON::reset() const { | |
| 1096 |
1/1✓ Branch 3 taken 7 times.
|
7 | getImpl<detail::WorkflowJSON_Impl>()->reset(); |
| 1097 | 7 | } | |
| 1098 | |||
| 1099 | 28 | void WorkflowJSON::start() const { | |
| 1100 |
1/1✓ Branch 3 taken 28 times.
|
28 | getImpl<detail::WorkflowJSON_Impl>()->start(); |
| 1101 | 28 | } | |
| 1102 | |||
| 1103 | 43 | unsigned WorkflowJSON::currentStepIndex() const { | |
| 1104 |
1/1✓ Branch 3 taken 43 times.
|
43 | return getImpl<detail::WorkflowJSON_Impl>()->currentStepIndex(); |
| 1105 | } | ||
| 1106 | |||
| 1107 | 128 | boost::optional<WorkflowStep> WorkflowJSON::currentStep() const { | |
| 1108 |
1/1✓ Branch 3 taken 128 times.
|
128 | return getImpl<detail::WorkflowJSON_Impl>()->currentStep(); |
| 1109 | } | ||
| 1110 | |||
| 1111 | 55 | bool WorkflowJSON::incrementStep() const { | |
| 1112 |
1/1✓ Branch 3 taken 55 times.
|
55 | return getImpl<detail::WorkflowJSON_Impl>()->incrementStep(); |
| 1113 | } | ||
| 1114 | |||
| 1115 | 26 | boost::optional<std::string> WorkflowJSON::completedStatus() const { | |
| 1116 |
1/1✓ Branch 3 taken 26 times.
|
26 | return getImpl<detail::WorkflowJSON_Impl>()->completedStatus(); |
| 1117 | } | ||
| 1118 | |||
| 1119 | 31 | void WorkflowJSON::setCompletedStatus(const std::string& status) const { | |
| 1120 |
1/1✓ Branch 3 taken 31 times.
|
31 | return getImpl<detail::WorkflowJSON_Impl>()->setCompletedStatus(status); |
| 1121 | } | ||
| 1122 | |||
| 1123 | ✗ | boost::optional<DateTime> WorkflowJSON::createdAt() const { | |
| 1124 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->createdAt(); | |
| 1125 | } | ||
| 1126 | |||
| 1127 | ✗ | boost::optional<DateTime> WorkflowJSON::startedAt() const { | |
| 1128 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->startedAt(); | |
| 1129 | } | ||
| 1130 | |||
| 1131 | 2 | boost::optional<DateTime> WorkflowJSON::updatedAt() const { | |
| 1132 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::WorkflowJSON_Impl>()->updatedAt(); |
| 1133 | } | ||
| 1134 | |||
| 1135 | ✗ | boost::optional<DateTime> WorkflowJSON::completedAt() const { | |
| 1136 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->completedAt(); | |
| 1137 | } | ||
| 1138 | |||
| 1139 | ✗ | boost::optional<std::string> WorkflowJSON::eplusoutErr() const { | |
| 1140 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->eplusoutErr(); | |
| 1141 | } | ||
| 1142 | |||
| 1143 | 15 | void WorkflowJSON::setEplusoutErr(const std::string& eplusoutErr) const { | |
| 1144 |
1/1✓ Branch 3 taken 15 times.
|
15 | getImpl<detail::WorkflowJSON_Impl>()->setEplusoutErr(eplusoutErr); |
| 1145 | 15 | } | |
| 1146 | |||
| 1147 | 24 | boost::optional<openstudio::path> WorkflowJSON::oswPath() const { | |
| 1148 |
1/1✓ Branch 3 taken 24 times.
|
24 | return getImpl<detail::WorkflowJSON_Impl>()->oswPath(); |
| 1149 | } | ||
| 1150 | |||
| 1151 | 20 | bool WorkflowJSON::setOswPath(const openstudio::path& path) const { | |
| 1152 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::WorkflowJSON_Impl>()->setOswPath(path, true); |
| 1153 | } | ||
| 1154 | |||
| 1155 | 29 | openstudio::path WorkflowJSON::oswDir() const { | |
| 1156 |
1/1✓ Branch 3 taken 29 times.
|
29 | return getImpl<detail::WorkflowJSON_Impl>()->oswDir(); |
| 1157 | } | ||
| 1158 | |||
| 1159 | 29 | bool WorkflowJSON::setOswDir(const openstudio::path& path) const { | |
| 1160 |
1/1✓ Branch 3 taken 29 times.
|
29 | return getImpl<detail::WorkflowJSON_Impl>()->setOswDir(path); |
| 1161 | } | ||
| 1162 | |||
| 1163 | 11 | openstudio::path WorkflowJSON::rootDir() const { | |
| 1164 |
1/1✓ Branch 3 taken 11 times.
|
11 | return getImpl<detail::WorkflowJSON_Impl>()->rootDir(); |
| 1165 | } | ||
| 1166 | |||
| 1167 | 139 | openstudio::path WorkflowJSON::absoluteRootDir() const { | |
| 1168 |
1/1✓ Branch 3 taken 139 times.
|
139 | return getImpl<detail::WorkflowJSON_Impl>()->absoluteRootDir(); |
| 1169 | } | ||
| 1170 | |||
| 1171 | 1 | bool WorkflowJSON::setRootDir(const openstudio::path& path) const { | |
| 1172 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::WorkflowJSON_Impl>()->setRootDir(path); |
| 1173 | } | ||
| 1174 | |||
| 1175 | 3 | openstudio::path WorkflowJSON::runDir() const { | |
| 1176 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::WorkflowJSON_Impl>()->runDir(); |
| 1177 | } | ||
| 1178 | |||
| 1179 | 303 | openstudio::path WorkflowJSON::absoluteRunDir() const { | |
| 1180 |
1/1✓ Branch 3 taken 303 times.
|
303 | return getImpl<detail::WorkflowJSON_Impl>()->absoluteRunDir(); |
| 1181 | } | ||
| 1182 | |||
| 1183 | 1 | bool WorkflowJSON::setRunDir(const openstudio::path& path) const { | |
| 1184 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::WorkflowJSON_Impl>()->setRunDir(path); |
| 1185 | } | ||
| 1186 | |||
| 1187 | ✗ | openstudio::path WorkflowJSON::outPath() const { | |
| 1188 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->outPath(); | |
| 1189 | } | ||
| 1190 | |||
| 1191 | 34 | openstudio::path WorkflowJSON::absoluteOutPath() const { | |
| 1192 |
1/1✓ Branch 3 taken 34 times.
|
34 | return getImpl<detail::WorkflowJSON_Impl>()->absoluteOutPath(); |
| 1193 | } | ||
| 1194 | |||
| 1195 | 31 | std::vector<openstudio::path> WorkflowJSON::filePaths() const { | |
| 1196 |
1/1✓ Branch 3 taken 31 times.
|
31 | return getImpl<detail::WorkflowJSON_Impl>()->filePaths(); |
| 1197 | } | ||
| 1198 | |||
| 1199 | 114 | std::vector<openstudio::path> WorkflowJSON::absoluteFilePaths() const { | |
| 1200 |
1/1✓ Branch 3 taken 114 times.
|
114 | return getImpl<detail::WorkflowJSON_Impl>()->absoluteFilePaths(); |
| 1201 | } | ||
| 1202 | |||
| 1203 | 190 | bool WorkflowJSON::addFilePath(const openstudio::path& path) const { | |
| 1204 |
1/1✓ Branch 3 taken 190 times.
|
190 | return getImpl<detail::WorkflowJSON_Impl>()->addFilePath(path); |
| 1205 | } | ||
| 1206 | |||
| 1207 | 31 | void WorkflowJSON::resetFilePaths() const { | |
| 1208 |
1/1✓ Branch 3 taken 31 times.
|
31 | getImpl<detail::WorkflowJSON_Impl>()->resetFilePaths(); |
| 1209 | 31 | } | |
| 1210 | |||
| 1211 | 110 | boost::optional<openstudio::path> WorkflowJSON::findFile(const openstudio::path& file) const { | |
| 1212 |
1/1✓ Branch 3 taken 110 times.
|
110 | return getImpl<detail::WorkflowJSON_Impl>()->findFile(file); |
| 1213 | } | ||
| 1214 | |||
| 1215 | 3 | boost::optional<openstudio::path> WorkflowJSON::findFile(const std::string& fileName) const { | |
| 1216 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::WorkflowJSON_Impl>()->findFile(fileName); |
| 1217 | } | ||
| 1218 | |||
| 1219 | ✗ | std::vector<openstudio::path> WorkflowJSON::measurePaths() const { | |
| 1220 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->measurePaths(); | |
| 1221 | } | ||
| 1222 | |||
| 1223 | ✗ | std::vector<openstudio::path> WorkflowJSON::absoluteMeasurePaths() const { | |
| 1224 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->absoluteMeasurePaths(); | |
| 1225 | } | ||
| 1226 | |||
| 1227 | ✗ | bool WorkflowJSON::addMeasurePath(const openstudio::path& path) const { | |
| 1228 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->addMeasurePath(path); | |
| 1229 | } | ||
| 1230 | |||
| 1231 | ✗ | void WorkflowJSON::resetMeasurePaths() const { | |
| 1232 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->resetMeasurePaths(); | |
| 1233 | } | ||
| 1234 | |||
| 1235 | 2 | boost::optional<openstudio::path> WorkflowJSON::findMeasure(const openstudio::path& measureDir) const { | |
| 1236 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::WorkflowJSON_Impl>()->findMeasure(measureDir); |
| 1237 | } | ||
| 1238 | |||
| 1239 | 155 | boost::optional<openstudio::path> WorkflowJSON::findMeasure(const std::string& measureDirName) const { | |
| 1240 |
1/1✓ Branch 3 taken 155 times.
|
155 | return getImpl<detail::WorkflowJSON_Impl>()->findMeasure(measureDirName); |
| 1241 | } | ||
| 1242 | |||
| 1243 | 48 | boost::optional<openstudio::path> WorkflowJSON::seedFile() const { | |
| 1244 |
1/1✓ Branch 3 taken 48 times.
|
48 | return getImpl<detail::WorkflowJSON_Impl>()->seedFile(); |
| 1245 | } | ||
| 1246 | |||
| 1247 | 4 | bool WorkflowJSON::setSeedFile(const openstudio::path& seedFile) const { | |
| 1248 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::WorkflowJSON_Impl>()->setSeedFile(seedFile); |
| 1249 | } | ||
| 1250 | |||
| 1251 | 1 | void WorkflowJSON::resetSeedFile() const { | |
| 1252 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::WorkflowJSON_Impl>()->resetSeedFile(); |
| 1253 | 1 | } | |
| 1254 | |||
| 1255 | 19 | boost::optional<openstudio::path> WorkflowJSON::seedModelicaFile() const { | |
| 1256 |
1/1✓ Branch 3 taken 19 times.
|
19 | return getImpl<detail::WorkflowJSON_Impl>()->seedModelicaFile(); |
| 1257 | } | ||
| 1258 | |||
| 1259 | 22 | boost::optional<std::string> WorkflowJSON::seedModelicaModel() const { | |
| 1260 |
1/1✓ Branch 3 taken 22 times.
|
22 | return getImpl<detail::WorkflowJSON_Impl>()->seedModelicaModel(); |
| 1261 | } | ||
| 1262 | |||
| 1263 | ✗ | bool WorkflowJSON::setSeedModelicaFile(const openstudio::path& modelicaSeedFile) const { | |
| 1264 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->setSeedModelicaFile(modelicaSeedFile); | |
| 1265 | } | ||
| 1266 | |||
| 1267 | ✗ | void WorkflowJSON::resetSeedModelicaFile() const { | |
| 1268 | ✗ | getImpl<detail::WorkflowJSON_Impl>()->resetSeedModelicaFile(); | |
| 1269 | ✗ | } | |
| 1270 | |||
| 1271 | ✗ | std::vector<openstudio::path> WorkflowJSON::modelicaPackages() const { | |
| 1272 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->modelicaPackages(); | |
| 1273 | } | ||
| 1274 | |||
| 1275 | ✗ | bool WorkflowJSON::setModelicaPackages(const std::vector<openstudio::path>& packages) const { | |
| 1276 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->setModelicaPackages(packages); | |
| 1277 | } | ||
| 1278 | |||
| 1279 | ✗ | void WorkflowJSON::resetModelicaPackages() const { | |
| 1280 | ✗ | getImpl<detail::WorkflowJSON_Impl>()->resetModelicaPackages(); | |
| 1281 | ✗ | } | |
| 1282 | |||
| 1283 | 60 | boost::optional<openstudio::path> WorkflowJSON::weatherFile() const { | |
| 1284 |
1/1✓ Branch 3 taken 60 times.
|
60 | return getImpl<detail::WorkflowJSON_Impl>()->weatherFile(); |
| 1285 | } | ||
| 1286 | |||
| 1287 | 3 | bool WorkflowJSON::setWeatherFile(const openstudio::path& weatherFile) const { | |
| 1288 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::WorkflowJSON_Impl>()->setWeatherFile(weatherFile); |
| 1289 | } | ||
| 1290 | |||
| 1291 | 1 | void WorkflowJSON::resetWeatherFile() const { | |
| 1292 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::WorkflowJSON_Impl>()->resetWeatherFile(); |
| 1293 | } | ||
| 1294 | |||
| 1295 | 53 | std::vector<WorkflowStep> WorkflowJSON::workflowSteps() const { | |
| 1296 |
1/1✓ Branch 3 taken 53 times.
|
53 | return getImpl<detail::WorkflowJSON_Impl>()->workflowSteps(); |
| 1297 | } | ||
| 1298 | |||
| 1299 | 13 | bool WorkflowJSON::setWorkflowSteps(const std::vector<WorkflowStep>& steps) const { | |
| 1300 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::WorkflowJSON_Impl>()->setWorkflowSteps(steps); |
| 1301 | } | ||
| 1302 | |||
| 1303 | 1 | void WorkflowJSON::resetWorkflowSteps() const { | |
| 1304 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::WorkflowJSON_Impl>()->resetWorkflowSteps(); |
| 1305 | 1 | } | |
| 1306 | |||
| 1307 | ✗ | std::vector<MeasureStep> WorkflowJSON::getMeasureSteps(const MeasureType& measureType) const { | |
| 1308 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->getMeasureSteps(measureType); | |
| 1309 | } | ||
| 1310 | |||
| 1311 | 66 | std::vector<std::pair<unsigned, MeasureStep>> WorkflowJSON::getMeasureStepsWithIndex(const MeasureType& measureType) const { | |
| 1312 |
1/1✓ Branch 3 taken 66 times.
|
66 | return getImpl<detail::WorkflowJSON_Impl>()->getMeasureStepsWithIndex(measureType); |
| 1313 | } | ||
| 1314 | |||
| 1315 | ✗ | bool WorkflowJSON::setMeasureSteps(const MeasureType& measureType, const std::vector<MeasureStep>& steps) const { | |
| 1316 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->setMeasureSteps(measureType, steps); | |
| 1317 | } | ||
| 1318 | |||
| 1319 | 6 | boost::optional<BCLMeasure> WorkflowJSON::getBCLMeasure(const MeasureStep& step) const { | |
| 1320 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::WorkflowJSON_Impl>()->getBCLMeasure(step); |
| 1321 | } | ||
| 1322 | |||
| 1323 | ✗ | boost::optional<BCLMeasure> WorkflowJSON::getBCLMeasureByUUID(const UUID& id) const { | |
| 1324 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->getBCLMeasureByUUID(id); | |
| 1325 | } | ||
| 1326 | |||
| 1327 | ✗ | boost::optional<BCLMeasure> WorkflowJSON::addMeasure(const BCLMeasure& bclMeasure) const { | |
| 1328 | ✗ | return getImpl<detail::WorkflowJSON_Impl>()->addMeasure(bclMeasure); | |
| 1329 | } | ||
| 1330 | |||
| 1331 | 449 | boost::optional<RunOptions> WorkflowJSON::runOptions() const { | |
| 1332 |
1/1✓ Branch 3 taken 449 times.
|
449 | return getImpl<detail::WorkflowJSON_Impl>()->runOptions(); |
| 1333 | } | ||
| 1334 | |||
| 1335 | 24 | bool WorkflowJSON::setRunOptions(const RunOptions& options) const { | |
| 1336 |
1/1✓ Branch 3 taken 24 times.
|
24 | return getImpl<detail::WorkflowJSON_Impl>()->setRunOptions(options); |
| 1337 | } | ||
| 1338 | |||
| 1339 | ✗ | void WorkflowJSON::resetRunOptions() const { | |
| 1340 | ✗ | getImpl<detail::WorkflowJSON_Impl>()->resetRunOptions(); | |
| 1341 | ✗ | } | |
| 1342 | |||
| 1343 | 26 | bool WorkflowJSON::validateMeasures() const { | |
| 1344 |
1/1✓ Branch 3 taken 26 times.
|
26 | return getImpl<detail::WorkflowJSON_Impl>()->validateMeasures(); |
| 1345 | } | ||
| 1346 | |||
| 1347 | ✗ | std::ostream& operator<<(std::ostream& os, const WorkflowJSON& workflowJSON) { | |
| 1348 | ✗ | os << workflowJSON.string(); | |
| 1349 | ✗ | return os; | |
| 1350 | } | ||
| 1351 | |||
| 1352 | } // namespace openstudio | ||
| 1353 |