MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / initializeMap

Method initializeMap

src/osversion/VersionTranslator.cpp:367–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365 }
366
367 void VersionTranslator::initializeMap(std::istream& is) {
368 // default version is 0.7.0
369 VersionString currentVersion("0.7.0");
370
371 // load with current IDD and extract version
372 if (boost::optional<VersionString> candidate = IdfFile::loadVersionOnly(is)) {
373 currentVersion = *candidate;
374 }
375
376 // we didn't bump Version Identifier in 3.3.0's idd OS:Version object, so the following is necessary
377 if (currentVersion == VersionString("3.2.2")) {
378 currentVersion = VersionString("3.3.0");
379 }
380
381 m_originalVersion = currentVersion; // save for user
382 is.seekg(std::ios_base::beg); // prep to re-read file
383
384 // bracket allowable versions
385 LOG(Debug, "Starting translation from Version " << currentVersion.str() << ".");
386 if (currentVersion < VersionString("0.7.0")) {
387 LOG(Error, "Version translation is not provided for OpenStudio models created prior to " << "Version 0.7.0.");
388 return;
389 }
390 if (currentVersion > VersionString(openStudioVersion())) {
391 if (m_allowNewerVersions) {
392 // if currentVersion is just one ahead, may be a developer using the cloud.
393 // let it pass as if currentVersion == openStudioVersion(), with a warning
394 if (VersionString(openStudioVersion()).isNextVersion(currentVersion)) {
395 LOG(Warn, "Version extracted from file '" << currentVersion.str() << "' is one " << "increment ahead of OpenStudio Version "
396 << openStudioVersion() << ". "
397 << "Proceeding as if these versions are the same. Use with caution.");
398 currentVersion = VersionString(openStudioVersion());
399 } else {
400 // if currentVersion is farther ahead, log error and return nothing
401 LOG(Error, "Version extracted from file '" << currentVersion.str() << "' is not supported by OpenStudio Version " << openStudioVersion()
402 << ". Please check https://www.openstudio.net for updates.");
403 return;
404 }
405 } else {
406 // log error and return nothing
407 LOG(Error, "Version extracted from file '" << currentVersion.str() << "' is newer than current OpenStudio Version " << openStudioVersion()
408 << ". Please check https://www.openstudio.net for updates.");
409 return;
410 }
411 }
412
413 // load IdfFile with correct IddFile and save
414 OptionalIdfFile oIdfFile;
415 IddFileAndFactoryWrapper iddFile = getIddFile(currentVersion);
416 if (iddFile.iddFileType() == IddFileType::UserCustom) {
417 oIdfFile = IdfFile::load(is, iddFile.iddFile());
418 if (currentVersion == VersionString(1, 9, 0)) {
419 if (oIdfFile) {
420 auto sizingObjects = oIdfFile->getObjectsByType(iddFile.getObject("OS:Sizing:Zone").get());
421
422 // Figure out if the OS:Sizing:Zone object looks like it is from CBECC
423 // it will have extra fields that would were not in the "real" 1.9.0 IDD
424 bool fromCBECC = false;

Callers

nothing calls this directly

Calls 13

istringEqualFunction · 0.85
get_1_9_0_CBECC_IddFileFunction · 0.85
isNextVersionMethod · 0.80
VersionStringClass · 0.50
strMethod · 0.45
iddFileTypeMethod · 0.45
iddFileMethod · 0.45
getObjectsByTypeMethod · 0.45
getMethod · 0.45
getObjectMethod · 0.45
getStringMethod · 0.45
removeObjectsMethod · 0.45

Tested by

no test coverage detected