| 43 | } |
| 44 | |
| 45 | void OSWorkflow::applyMeasures(MeasureType measureType, ApplyMeasureType apply_measure_type) { |
| 46 | |
| 47 | if (m_add_timings && m_detailed_timings) { |
| 48 | m_timers->newTimer(fmt::format("{}:apply_measures", measureType.valueName()), 1); |
| 49 | } |
| 50 | |
| 51 | LOG(Debug, "Finding measures of type " << measureType.valueName()); |
| 52 | |
| 53 | // We actually want the order of the steps preserved, so this won't cut it |
| 54 | // const auto modelSteps = workflowJSON.getMeasureSteps(stepType); |
| 55 | |
| 56 | for (const auto& stepAndIndex : workflowJSON.getMeasureStepsWithIndex(measureType)) { |
| 57 | auto stepIndex = stepAndIndex.first; |
| 58 | auto step = stepAndIndex.second; |
| 59 | LOG(Debug, "Running step " << stepIndex); |
| 60 | |
| 61 | const auto measureDirName = step.measureDirName(); |
| 62 | |
| 63 | auto stepArgs = step.arguments(); |
| 64 | const bool skip_measure = isStepMarkedSkip(stepArgs); |
| 65 | if (skip_measure || runner.halted()) { |
| 66 | if (apply_measure_type == ApplyMeasureType::Regular) { |
| 67 | if (runner.halted()) { |
| 68 | LOG(Info, fmt::format("Skipping measure '{}' because simulation halted", measureDirName)); |
| 69 | } else { |
| 70 | LOG(Info, fmt::format("Skipping measure '{}'", measureDirName)); |
| 71 | // required to update current step |
| 72 | runner.prepareForMeasureRun(); |
| 73 | |
| 74 | WorkflowStepResult result = runner.result(); |
| 75 | runner.incrementStep(); |
| 76 | const auto measureDirPath_ = workflowJSON.findMeasure(measureDirName); |
| 77 | if (measureDirPath_) { |
| 78 | BCLMeasure bclMeasure(measureDirPath_.get()); |
| 79 | workflow::util::addResultMeasureInfo(result, bclMeasure); |
| 80 | const std::string className = bclMeasure.className(); |
| 81 | const auto measureName = step.name().value_or(className); |
| 82 | output_attributes[measureName]["applicable"] = openstudio::Variant(false); |
| 83 | } else { |
| 84 | LOG(Warn, "Could not find measure '" << measureDirName << "', but it's marked as skipped anyways so ignoring."); |
| 85 | output_attributes[step.name().value_or(measureDirName)]["applicable"] = openstudio::Variant(false); |
| 86 | } |
| 87 | result.setStepResult(StepResult::Skip); |
| 88 | } |
| 89 | } |
| 90 | continue; |
| 91 | } |
| 92 | |
| 93 | if (model.numObjects() > 0) { |
| 94 | runner.setLastOpenStudioModel(model); |
| 95 | } |
| 96 | if (workspace_) { |
| 97 | runner.setLastEnergyPlusWorkspace(workspace_.get()); |
| 98 | } |
| 99 | if (!sqlPath.empty()) { |
| 100 | runner.setLastEnergyPlusSqlFilePath(sqlPath); |
| 101 | } |
| 102 | if (m_lastModelicaResultPath) { |
nothing calls this directly
no test coverage detected