@@ -96,6 +96,10 @@ void MeasureManager::setUrl(const QUrl& url) {
96
96
m_url = url;
97
97
}
98
98
99
+ void MeasureManager::setResourcesPath (const openstudio::path& resourcesPath) {
100
+ m_resourcesPath = resourcesPath;
101
+ }
102
+
99
103
bool MeasureManager::waitForStarted (int msec) {
100
104
if (m_started) {
101
105
return true ;
@@ -199,6 +203,13 @@ void MeasureManager::saveTempModel(const path& tempDir) {
199
203
m_measureArguments.clear ();
200
204
}
201
205
206
+
207
+ boost::optional<BCLMeasure> MeasureManager::standardReportMeasure () const {
208
+ // DLM: Breaking changes in openstudio_results measures prevent us from being able to ensure
209
+ // that measure in users local BCL or remote BCL will work, just use measure in installer
210
+ return BCLMeasure::load (m_resourcesPath / toPath (" openstudio_results" ));
211
+ }
212
+
202
213
std::vector<BCLMeasure> MeasureManager::bclMeasures () const {
203
214
std::vector<BCLMeasure> result;
204
215
result.reserve (m_bclMeasures.size ());
@@ -224,6 +235,7 @@ std::vector<BCLMeasure> MeasureManager::combinedMeasures() const {
224
235
result.reserve (m_myMeasures.size () + m_bclMeasures.size ());
225
236
226
237
std::set<UUID> resultUUIDs;
238
+
227
239
// insert my measures
228
240
for (auto it = m_myMeasures.begin (), itend = m_myMeasures.end (); it != itend; ++it) {
229
241
if (resultUUIDs.find (it->first ) == resultUUIDs.end ()) {
@@ -958,11 +970,25 @@ bool MeasureManager::checkForUpdates(const openstudio::path& measureDir, bool fo
958
970
959
971
void MeasureManager::checkForRemoteBCLUpdates () {
960
972
RemoteBCL remoteBCL;
961
- int numUpdates = remoteBCL.checkForMeasureUpdates ();
973
+ remoteBCL.checkForMeasureUpdates ();
974
+ std::vector<BCLSearchResult> updates = remoteBCL.measuresWithUpdates ();
975
+
976
+ // remove false updates (e.g. measure was updated after downloading from bcl due to incorrect sha)
977
+ updates.erase (std::remove_if (updates.begin (), updates.end (), [this ](const BCLSearchResult& update) {
978
+ auto current = m_bclMeasures.find (toUUID (update.uid ()));
979
+ if (current != m_bclMeasures.end ()) {
980
+ if (update.versionModified () && current->second .versionModified ()) {
981
+ return update.versionModified ().get () < current->second .versionModified ().get ();
982
+ }
983
+ }
984
+ return false ;
985
+ }), updates.end ());
986
+
987
+ int numUpdates = updates.size ();
988
+
962
989
if (numUpdates == 0 ) {
963
990
QMessageBox::information (m_app->mainWidget (), tr (" Measures Updated" ), tr (" All measures are up-to-date." ));
964
- } else {
965
- std::vector<BCLSearchResult> updates = remoteBCL.measuresWithUpdates ();
991
+ } else {
966
992
967
993
QString text (QString::number (numUpdates) + tr (" measures have been updated on BCL compared to your local BCL directory.\n " )
968
994
+ tr (" Would you like update them?" ));
@@ -997,50 +1023,6 @@ void MeasureManager::checkForRemoteBCLUpdates() {
997
1023
}
998
1024
}
999
1025
1000
- void MeasureManager::downloadBCLMeasures () {
1001
- RemoteBCL remoteBCL;
1002
- int numUpdates = remoteBCL.checkForMeasureUpdates ();
1003
- if (numUpdates == 0 ) {
1004
- QMessageBox::information (m_app->mainWidget (), " Measures Updated" , " All measures are up-to-date." );
1005
- } else {
1006
- std::vector<BCLSearchResult> updates = remoteBCL.measuresWithUpdates ();
1007
-
1008
- QString detailedText;
1009
- for (const BCLSearchResult& update : updates) {
1010
- detailedText += toQString (" * name: " + update.name () + " \n " );
1011
- detailedText += toQString (" - uid: " + update.uid () + " \n " );
1012
- auto current = m_bclMeasures.find (toUUID (update.uid ()));
1013
- if (current != m_bclMeasures.end ()) {
1014
- detailedText += toQString (" - old versionId: " + current->second .versionId () + " \n " );
1015
- }
1016
- detailedText += toQString (" - new versionId: " + update.versionId () + " \n\n " );
1017
- }
1018
-
1019
- remoteBCL.updateMeasures ();
1020
-
1021
- // remoteBCL.updateMeasures should remove outdated measures, but won't work correctly until https://github.com/NREL/OpenStudio/pull/5129
1022
- // if we have the new measure, delete outdated ones
1023
- for (const BCLSearchResult& update : updates) {
1024
- if (OSAppBase::instance ()->currentDocument ()->getLocalMeasure (update.uid (), update.versionId ())) {
1025
- OSAppBase::instance ()->currentDocument ()->removeOutdatedLocalMeasures (update.uid (), update.versionId ());
1026
- }
1027
- }
1028
-
1029
- updateMeasuresLists (false );
1030
-
1031
- QMessageBox msg (m_app->mainWidget ());
1032
- msg.setIcon (QMessageBox::Information);
1033
- msg.setWindowTitle (" Measures Updated" );
1034
- if (numUpdates == 1 ) {
1035
- msg.setText (" 1 measure has been updated." );
1036
- } else {
1037
- msg.setText (QString::number (numUpdates) + " measures have been updated." );
1038
- }
1039
- msg.setDetailedText (detailedText);
1040
- msg.exec ();
1041
- }
1042
- }
1043
-
1044
1026
void MeasureManager::addMeasure () {
1045
1027
// open modal dialog
1046
1028
// QSharedPointer<BCLMeasureDialog> dialog(new BCLMeasureDialog(this->mainWindow));
0 commit comments