| 239 | } |
| 240 | |
| 241 | boost::optional<IDFInfo> MeasureManager::getIdf(const openstudio::path& idfPath, bool force_reload) { |
| 242 | |
| 243 | if (!openstudio::filesystem::is_regular_file(idfPath)) { |
| 244 | fmt::print("Idf '{}' does not exist\n", idfPath.generic_string()); |
| 245 | m_idfs.erase(idfPath); |
| 246 | clearMeasureInfoForOsmorIdfPath(idfPath); |
| 247 | return boost::none; |
| 248 | } |
| 249 | |
| 250 | IDFInfo current; |
| 251 | current.checksum = openstudio::checksum(idfPath); |
| 252 | |
| 253 | if (!force_reload) { |
| 254 | auto it = m_idfs.find(idfPath); |
| 255 | if (it != m_idfs.end()) { |
| 256 | auto& cached = it->second; |
| 257 | if (current.checksum == cached.checksum) { |
| 258 | fmt::print("Using cached workspace {}\n", idfPath.generic_string()); |
| 259 | return cached; |
| 260 | } else { |
| 261 | fmt::print("Checksum of cached workspace does not match current checksum for '{}'\n", idfPath.generic_string()); |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | clearMeasureInfoForOsmorIdfPath(idfPath); |
| 267 | |
| 268 | fmt::print("Attempting to load idf '{}'\n", idfPath.generic_string()); |
| 269 | if (auto workspace_ = openstudio::Workspace::load(idfPath, openstudio::IddFileType::EnergyPlus)) { |
| 270 | fmt::print("Successfully loaded idf '{}'\n", idfPath.generic_string()); |
| 271 | |
| 272 | if (workspace_->isValid(openstudio::StrictnessLevel::Draft)) { |
| 273 | current.workspace = std::move(*workspace_); |
| 274 | auto [it, ok] = m_idfs.insert_or_assign(idfPath, std::move(current)); |
| 275 | return it->second; |
| 276 | } else { |
| 277 | fmt::print("Workspace loaded from '{}' is not valid to Draft StrictnessLevel\n", idfPath.generic_string()); |
| 278 | } |
| 279 | } else { |
| 280 | fmt::print("Failed to load idf '{}'\n", idfPath.generic_string()); |
| 281 | } |
| 282 | |
| 283 | m_idfs.erase(idfPath); |
| 284 | |
| 285 | return boost::none; |
| 286 | } |
| 287 | |
| 288 | boost::optional<BCLMeasure> MeasureManager::getMeasure(const openstudio::path& measureDirPath, bool force_reload) { |
| 289 | |