Skip to content

Commit 55f5cc3

Browse files
authored
Merge pull request #720 from openstudiocoalition/measure_fixes
Fix issues with MeasureManager
2 parents 2fd41ec + da2d1ed commit 55f5cc3

File tree

175 files changed

+2076
-14496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+2076
-14496
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ endif()
272272

273273
# TODO: Modify the more specific variables as needed to indicate prerelease, etc
274274
# Keep in beta in-between release cycles. Set to empty string (or comment out) for official)
275-
set(PROJECT_VERSION_PRERELEASE "")
275+
set(PROJECT_VERSION_PRERELEASE "rc1")
276276

277277
# OpenStudio version: Only include Major.Minor.Patch, eg "3.0.0", even if you have a prerelease tag
278278
set(OPENSTUDIOAPPLICATION_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
@@ -645,6 +645,16 @@ endif()
645645

646646
set(CMAKE_AUTOMOC OFF)
647647

648+
include(FetchContent)
649+
650+
FetchContent_Declare(
651+
openstudio-coalition-measures
652+
GIT_REPOSITORY https://github.com/openstudiocoalition/openstudio-coalition-measures.git
653+
GIT_TAG da6832b3eec8e3ecccaadd39142e7c3d9c2da10f # release-1.8.0
654+
)
655+
656+
FetchContent_MakeAvailable(openstudio-coalition-measures)
657+
648658
###############################################################################
649659
# I N C L U D E P A T H S #
650660
###############################################################################
@@ -776,7 +786,7 @@ install(IMPORTED_RUNTIME_ARTIFACTS openstudio::pythonengine DESTINATION ${LIB_DE
776786

777787
# TODO: we should probably just install the **entire** OS SDK bin/ directory...
778788
if(WIN32)
779-
install(PROGRAMS "${openstudio_ROOT_DIR}/bin/python38.dll" DESTINATION bin COMPONENT "CLI")
789+
install(PROGRAMS $<$<CONFIG:Debug>:${openstudio_ROOT_DIR}/bin/python38_d.dll>$<$<CONFIG:Release>:${openstudio_ROOT_DIR}/bin/python38.dll>$<$<CONFIG:RelWithDebInfo>:${openstudio_ROOT_DIR}/bin/python38.dll>$<$<CONFIG:MinSizeRel>:${openstudio_ROOT_DIR}/bin/python38.dll> DESTINATION bin COMPONENT "CLI")
780790
endif()
781791

782792
# install(PROGRAMS ${OS_CLI_IMPORTED_PATH} DESTINATION bin COMPONENT "CLI" RENAME "${OS_CLI_IMPORTED_NAME}")

src/openstudio_app/CMakeLists.txt

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,23 +337,35 @@ get_target_property(os_lib_location openstudio::openstudiolib LOCATION)
337337
get_filename_component(os_lib_dir ${os_lib_location} DIRECTORY)
338338
set(DIRS "${QT_INSTALL_DIR}/bin" "${QT_INSTALL_DIR}/lib" "${os_lib_dir}")
339339

340-
if(APPLE)
341-
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/openstudio_app/Resources/
342-
DESTINATION OpenStudioApp.app/Contents/Resources
343-
COMPONENT "Resources"
344-
)
345-
elseif(WIN32)
346-
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/openstudio_app/Resources/
347-
DESTINATION Resources
348-
COMPONENT "Resources"
349-
)
340+
# install resources directory
341+
if( APPLE )
342+
set(RESOURCES_DEST "OpenStudioApp.app/Contents/Resources")
350343
else()
351-
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/openstudio_app/Resources/
352-
DESTINATION Resources
353-
COMPONENT "Resources"
354-
)
344+
set(RESOURCES_DEST "Resources")
355345
endif()
356346

347+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/openstudio_app/Resources/
348+
DESTINATION ${RESOURCES_DEST}
349+
COMPONENT "Resources"
350+
)
351+
352+
# install measures/models from openstudio-coalition-measures
353+
354+
install(FILES ${openstudio-coalition-measures_SOURCE_DIR}/models/ShoeboxExample.osm
355+
DESTINATION ${RESOURCES_DEST}/ShoeboxModel
356+
COMPONENT "Resources"
357+
)
358+
359+
install(DIRECTORY ${openstudio-coalition-measures_SOURCE_DIR}/models/ShoeboxExample
360+
DESTINATION ${RESOURCES_DEST}/ShoeboxModel
361+
COMPONENT "Resources"
362+
)
363+
364+
install(DIRECTORY ${openstudio-coalition-measures_SOURCE_DIR}/models/ShoeboxExample/measures/openstudio_results
365+
DESTINATION ${RESOURCES_DEST}/openstudio_results
366+
COMPONENT "Resources"
367+
)
368+
357369
# since on apple the whole app bundle is installed (including these webkit components) we can exclude apple
358370
if( NOT APPLE )
359371

src/openstudio_app/OpenStudioApp.cpp

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ OpenStudioApp::OpenStudioApp(int& argc, char** argv)
221221
waitDialog->show();
222222
emit resetWaitDialog();
223223

224+
measureManager().setResourcesPath(resourcesPath());
225+
224226
// Non blocking
225227
startMeasureManagerProcess();
226228

@@ -266,14 +268,11 @@ void OpenStudioApp::onMeasureManagerAndLibraryReady() {
266268
msgBox.setText(tr("Failed to start the Measure Manager. Would you like to keep waiting?"));
267269
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
268270
if (msgBox.exec() == QMessageBox::Close) {
269-
// this is a fatal error, application will close
270-
showFailedMeasureManagerDialog();
271-
QCoreApplication::exit();
272-
return;
273-
} else {
274-
measureManager().waitForStarted(10000);
275-
++currentTry;
271+
// user can cancel out of this quit, turns into retry
272+
quit();
276273
}
274+
measureManager().waitForStarted(10000);
275+
++currentTry;
277276
}
278277
LOG(Info, "Recovered from Measure Manager problem, managed to start it on try " << currentTry
279278
<< " at: " << toString(measureManager().url().toString()));
@@ -1174,8 +1173,9 @@ void OpenStudioApp::readSettings() {
11741173
setLastPath(settings.value("lastPath", QDir::homePath()).toString());
11751174
setDviewPath(openstudio::toPath(settings.value("dviewPath", "").toString()));
11761175
m_currLang = settings.value("language", "en").toString();
1177-
m_useClassicCLI = settings.value("useClassicCLI", false).toBool();
1178-
LOG_FREE(Debug, "OpenStudioApp", "\n\n\nm_currLang=[" << m_currLang.toStdString() << "], m_useClassicCLI=" << m_useClassicCLI << "\n\n\n");
1176+
LOG_FREE(Debug, "OpenStudioApp",
1177+
"\n\n\nm_currLang=[" << m_currLang.toStdString() << "]"
1178+
<< "\n\n\n");
11791179
if (m_currLang.isEmpty()) {
11801180
m_currLang = "en";
11811181
}
@@ -1246,6 +1246,7 @@ void OpenStudioApp::connectOSDocumentSignals() {
12461246
connect(m_osDocument.get(), &OSDocument::changeLanguageClicked, this, &OpenStudioApp::changeLanguage);
12471247
connect(m_osDocument.get(), &OSDocument::loadLibraryClicked, this, &OpenStudioApp::loadLibrary);
12481248
connect(m_osDocument.get(), &OSDocument::loadExampleModelClicked, this, &OpenStudioApp::loadExampleModel);
1249+
connect(m_osDocument.get(), &OSDocument::loadShoeboxModelClicked, this, &OpenStudioApp::loadShoeboxModel);
12491250
connect(m_osDocument.get(), &OSDocument::newClicked, this, &OpenStudioApp::newModel);
12501251
connect(m_osDocument.get(), &OSDocument::helpClicked, this, &OpenStudioApp::showHelp);
12511252
connect(m_osDocument.get(), &OSDocument::checkForUpdateClicked, this, &OpenStudioApp::checkForUpdate);
@@ -1267,6 +1268,7 @@ void OpenStudioApp::disconnectOSDocumentSignals() {
12671268
disconnect(m_osDocument.get(), &OSDocument::configureExternalToolsClicked, this, &OpenStudioApp::configureExternalTools);
12681269
disconnect(m_osDocument.get(), &OSDocument::loadLibraryClicked, this, &OpenStudioApp::loadLibrary);
12691270
disconnect(m_osDocument.get(), &OSDocument::loadExampleModelClicked, this, &OpenStudioApp::loadExampleModel);
1271+
disconnect(m_osDocument.get(), &OSDocument::loadShoeboxModelClicked, this, &OpenStudioApp::loadShoeboxModel);
12701272
disconnect(m_osDocument.get(), &OSDocument::newClicked, this, &OpenStudioApp::newModel);
12711273
disconnect(m_osDocument.get(), &OSDocument::helpClicked, this, &OpenStudioApp::showHelp);
12721274
disconnect(m_osDocument.get(), &OSDocument::checkForUpdateClicked, this, &OpenStudioApp::checkForUpdate);
@@ -1286,19 +1288,18 @@ void OpenStudioApp::measureManagerProcessFinished() {
12861288
QByteArray stdErr = m_measureManagerProcess->readAllStandardError();
12871289
QByteArray stdOut = m_measureManagerProcess->readAllStandardOutput();
12881290

1289-
QString text = tr("Measure Manager has crashed, attempting to restart. Do you want to reset Measure Manager settings?");
1291+
QString text = tr("Measure Manager has crashed. Do you want to retry?");
12901292
QString detailedText;
12911293
detailedText += stdErr;
12921294
detailedText += stdOut;
12931295

1294-
QMessageBox messageBox(QMessageBox::Warning, tr("Measure Manager Crashed"), text, QMessageBox::RestoreDefaults | QMessageBox::Close, mainWidget(),
1296+
QMessageBox messageBox(QMessageBox::Critical, tr("Measure Manager Crashed"), text, QMessageBox::Retry | QMessageBox::Close, mainWidget(),
12951297
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
12961298
messageBox.setDetailedText(detailedText);
12971299

1298-
if (messageBox.exec() == QMessageBox::RestoreDefaults) {
1299-
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
1300-
settings.setValue("useClassicCLI", true);
1301-
m_useClassicCLI = true;
1300+
if (messageBox.exec() == QMessageBox::Close) {
1301+
// user can cancel out of quit, turns into retry
1302+
quit();
13021303
}
13031304

13041305
startMeasureManagerProcess();
@@ -1351,9 +1352,7 @@ void OpenStudioApp::startMeasureManagerProcess() {
13511352
const QString program = toQString(openstudioCLIPath());
13521353
QStringList arguments;
13531354

1354-
if (m_useClassicCLI) {
1355-
arguments << "classic";
1356-
}
1355+
// MeasureManager does not work in classic CLI https://github.com/NREL/OpenStudio/issues/5212
13571356
arguments << "measure";
13581357
arguments << "-s";
13591358
arguments << portString;
@@ -1561,6 +1560,42 @@ void OpenStudioApp::loadExampleModel() {
15611560
OpenStudioApp::setQuitOnLastWindowClosed(wasQuitOnLastWindowClosed);
15621561
}
15631562

1563+
void OpenStudioApp::loadShoeboxModel() {
1564+
1565+
bool wasQuitOnLastWindowClosed = OpenStudioApp::quitOnLastWindowClosed();
1566+
OpenStudioApp::setQuitOnLastWindowClosed(false);
1567+
1568+
if (m_osDocument) {
1569+
if (!closeDocument()) {
1570+
OpenStudioApp::setQuitOnLastWindowClosed(wasQuitOnLastWindowClosed);
1571+
return;
1572+
}
1573+
processEvents();
1574+
}
1575+
1576+
osversion::VersionTranslator versionTranslator;
1577+
versionTranslator.setAllowNewerVersions(false);
1578+
1579+
auto filePath = resourcesPath() / toPath("ShoeboxModel/ShoeboxExample.osm");
1580+
boost::optional<openstudio::model::Model> model = versionTranslator.loadModel(filePath);
1581+
if (!model && isOpenStudioApplicationRunningFromBuildDirectory()) {
1582+
filePath = getOpenStudioCoalitionMeasuresSourceDirectory() / toPath("models/ShoeboxExample.osm");
1583+
model = versionTranslator.loadModel(filePath);
1584+
}
1585+
1586+
if (model) {
1587+
m_osDocument = std::make_shared<OSDocument>(componentLibrary(), resourcesPath(), model, toQString(filePath), false, startTabIndex());
1588+
m_osDocument->setSavePath("");
1589+
connectOSDocumentSignals();
1590+
1591+
QTimer::singleShot(0, m_osDocument.get(), &OSDocument::markAsModified);
1592+
}
1593+
1594+
waitDialog()->hide();
1595+
1596+
OpenStudioApp::setQuitOnLastWindowClosed(wasQuitOnLastWindowClosed);
1597+
}
1598+
15641599
void OpenStudioApp::changeDefaultLibraries() {
15651600
auto defaultPaths = defaultLibraryPaths();
15661601
auto paths = libraryPaths();
@@ -1590,18 +1625,6 @@ void OpenStudioApp::removeLibraryFromsSettings(const openstudio::path& path) {
15901625
writeLibraryPaths(paths);
15911626
}
15921627

1593-
void OpenStudioApp::showFailedMeasureManagerDialog() {
1594-
1595-
QString text = tr("The OpenStudio Application must close. Do you want to reset Measure Manager settings?\n\n");
1596-
QMessageBox::StandardButton reply = QMessageBox::critical(mainWidget(), QString("Failed to connect to Measure Manager"), text,
1597-
QMessageBox::RestoreDefaults | QMessageBox::Close, QMessageBox::RestoreDefaults);
1598-
if (reply == QMessageBox::RestoreDefaults) {
1599-
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
1600-
settings.setValue("useClassicCLI", true);
1601-
settings.sync();
1602-
}
1603-
}
1604-
16051628
void OpenStudioApp::showFailedLibraryDialog(const std::vector<std::string>& failedPaths) {
16061629
if (!failedPaths.empty()) {
16071630
QString text = tr("Failed to load the following libraries...\n\n");

src/openstudio_app/OpenStudioApp.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ class OpenStudioApp : public OSAppBase
169169
// Loads the result of openstudio::model::exampleModel()
170170
void loadExampleModel();
171171

172+
// Creates a skeleton measure based model
173+
void loadShoeboxModel();
174+
172175
// Checks what happened in the LibraryDialog preference panes, and calls writeLibraryPaths to set the user settings
173176
void changeDefaultLibraries();
174177

@@ -225,8 +228,6 @@ class OpenStudioApp : public OSAppBase
225228
GBXML
226229
};
227230

228-
void showFailedMeasureManagerDialog();
229-
230231
void showFailedLibraryDialog(const std::vector<std::string>& failedPaths);
231232

232233
void import(fileType type);
@@ -275,7 +276,6 @@ class OpenStudioApp : public OSAppBase
275276
QTranslator m_qtTranslator;
276277
QTranslator m_qtBaseTranslator;
277278
QString m_currLang;
278-
bool m_useClassicCLI;
279279

280280
// Try to find DView (or DView.exe) inside the PATH env variable. Will return an *empty* path if couldn't infer it
281281
openstudio::path inferredDViewPath() const;

src/openstudio_app/Resources/openstudio_results/LICENSE.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)