| 864 | } |
| 865 | |
| 866 | Json::Value OSRunner::getPastStepValuesForName(const std::string& stepName) const { |
| 867 | // This function aims to replace OsLib_HelperMethods.check_upstream_measure_for_arg |
| 868 | Json::Value step_values(Json::objectValue); |
| 869 | for (const MeasureStep& step : subsetCastVector<MeasureStep>(m_workflow.workflowSteps())) { |
| 870 | boost::optional<WorkflowStepResult> stepResult_ = step.result(); |
| 871 | if (!stepResult_ || !stepResult_->stepResult() || stepResult_->stepResult().get() != StepResult::Success) { |
| 872 | continue; |
| 873 | } |
| 874 | |
| 875 | std::string measure_name = step.measureDirName(); // The directory name, eg `IncreaseWallRValue` |
| 876 | if (auto s_ = step.name()) { // An optional, abritrary one |
| 877 | measure_name = std::move(*s_); |
| 878 | } |
| 879 | // if (auto s_ = stepResult_->measureName()) { // The xml one, eg `increase_insulation_r_value_for_exterior_walls_by_percentage` |
| 880 | // measure_name = std::move(*s_); |
| 881 | // } |
| 882 | |
| 883 | for (const WorkflowStepValue& stepValue : stepResult_->stepValues()) { |
| 884 | if (istringEqual(stepName, stepValue.name())) { |
| 885 | Json::Value root = stepValue.toJSON(); |
| 886 | if (auto value = root["value"]) { |
| 887 | step_values[measure_name] = value; |
| 888 | // TODO: check_upstream_measure_for_arg was breaking early, and returning a {:value => value, :measure_name => measure_name} format |
| 889 | } |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | return step_values; |
| 894 | } |
| 895 | |
| 896 | void OSRunner::setLastOpenStudioModel(const openstudio::model::Model& lastOpenStudioModel) { |
| 897 | m_lastOpenStudioModel = lastOpenStudioModel; |