mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add cancellation of well path collection loading.
This commit is contained in:
@@ -762,6 +762,9 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da
|
||||
RiaLogging::info( "Requesting download of parquet from: " + url );
|
||||
|
||||
auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaCloudDefines::contentTypeParquet() );
|
||||
m_repliesMutex.lock();
|
||||
m_replies[id] = reply;
|
||||
m_repliesMutex.unlock();
|
||||
|
||||
connect( reply,
|
||||
&QNetworkReply::finished,
|
||||
@@ -792,3 +795,19 @@ void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, cons
|
||||
m_parquetData[id] = contents;
|
||||
m_parquetErrors[id] = errorMessage;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::cancelRequestForId( const QString& id )
|
||||
{
|
||||
QMutexLocker lock( &m_repliesMutex );
|
||||
auto it = m_replies.find( id );
|
||||
if ( it != m_replies.end() )
|
||||
{
|
||||
if ( !it->second.isNull() )
|
||||
{
|
||||
it->second->abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ public:
|
||||
|
||||
QString wellIdForWellboreId( const QString& wellboreId ) const;
|
||||
|
||||
void cancelRequestForId( const QString& id );
|
||||
|
||||
void clearCachedData();
|
||||
|
||||
QString dataPartition() const;
|
||||
@@ -173,6 +175,7 @@ private:
|
||||
const QString m_dataPartitionId;
|
||||
|
||||
mutable QMutex m_mutex;
|
||||
mutable QMutex m_repliesMutex;
|
||||
std::vector<OsduField> m_fields;
|
||||
std::vector<OsduWell> m_wells;
|
||||
std::map<QString, std::vector<OsduWellbore>> m_wellbores;
|
||||
@@ -180,4 +183,5 @@ private:
|
||||
std::map<QString, std::vector<OsduWellLog>> m_wellLogs;
|
||||
std::map<QString, QByteArray> m_parquetData;
|
||||
std::map<QString, QString> m_parquetErrors;
|
||||
std::map<QString, QPointer<QNetworkReply>> m_replies;
|
||||
};
|
||||
|
||||
@@ -79,6 +79,20 @@ bool RimOsduWellPathDataLoader::isRunnable() const
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimOsduWellPathDataLoader::cancel()
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
RiaOsduConnector* osduConnector = app->makeOsduConnector();
|
||||
|
||||
for ( auto& [trajectoryId, taskId] : m_taskIds )
|
||||
{
|
||||
osduConnector->cancelRequestForId( trajectoryId );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
RimOsduWellPathDataLoader();
|
||||
void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override;
|
||||
bool isRunnable() const override;
|
||||
void cancel() override;
|
||||
|
||||
private slots:
|
||||
void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id );
|
||||
|
||||
@@ -151,10 +151,6 @@ void RimWellPathCollection::fieldChangedByUi( const caf::PdmFieldHandle* changed
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::loadDataAndUpdate()
|
||||
{
|
||||
caf::ProgressInfo progress( 3, "Reading well paths from file" );
|
||||
|
||||
readWellPathFormationFiles();
|
||||
|
||||
auto hasOsduData = []( const std::vector<RimWellPath*>& wellPaths ) -> bool
|
||||
{
|
||||
for ( RimWellPath* wellPath : wellPaths )
|
||||
@@ -168,6 +164,22 @@ void RimWellPathCollection::loadDataAndUpdate()
|
||||
return false;
|
||||
};
|
||||
|
||||
auto countWellLogs = []( const std::vector<RimWellPath*>& wellPaths ) -> bool
|
||||
{
|
||||
size_t count = 0;
|
||||
for ( RimWellPath* wellPath : wellPaths )
|
||||
{
|
||||
count += wellPath->wellLogs().size();
|
||||
}
|
||||
return count;
|
||||
};
|
||||
|
||||
caf::ProgressInfo progress( allWellPaths().size() + countWellLogs( allWellPaths() ) + 2, "Reading well paths from file", false, true );
|
||||
|
||||
readWellPathFormationFiles();
|
||||
|
||||
progress.incrementProgress();
|
||||
|
||||
if ( hasOsduData( allWellPaths() ) )
|
||||
{
|
||||
auto osduConnector = RiaApplication::instance()->makeOsduConnector();
|
||||
@@ -185,7 +197,11 @@ void RimWellPathCollection::loadDataAndUpdate()
|
||||
dataLoadController->loadData( *wellPath, wellPathGeometryKeyword, progress );
|
||||
}
|
||||
dataLoadController->blockUntilDone( wellPathGeometryKeyword );
|
||||
progress.incrementProgress();
|
||||
|
||||
if ( progress.isCancelled() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
progress.setProgressDescription( QString( "Reading well logs." ) );
|
||||
for ( RimWellPath* wellPath : allWellPaths() )
|
||||
@@ -196,7 +212,6 @@ void RimWellPathCollection::loadDataAndUpdate()
|
||||
}
|
||||
}
|
||||
dataLoadController->blockUntilDone( wellLogKeyword );
|
||||
progress.incrementProgress();
|
||||
|
||||
progress.setProgressDescription( QString( "Reading additional data." ) );
|
||||
for ( RimWellPath* wellPath : allWellPaths() )
|
||||
@@ -692,15 +707,15 @@ void RimWellPathCollection::readWellPathFormationFiles()
|
||||
{
|
||||
caf::ProgressInfo progress( m_wellPaths.size(), "Reading well picks from file" );
|
||||
|
||||
for ( size_t wpIdx = 0; wpIdx < m_wellPaths.size(); wpIdx++ )
|
||||
for ( const auto& wellPath : m_wellPaths )
|
||||
{
|
||||
QString errorMessage;
|
||||
if ( !m_wellPaths[wpIdx]->readWellPathFormationsFile( &errorMessage, m_wellPathFormationsImporter.get() ) )
|
||||
if ( !wellPath->readWellPathFormationsFile( &errorMessage, m_wellPathFormationsImporter.get() ) )
|
||||
{
|
||||
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage );
|
||||
}
|
||||
|
||||
progress.setProgressDescription( QString( "Reading formation file %1" ).arg( wpIdx ) );
|
||||
progress.setProgressDescription( QString( "Reading formation file for %1" ).arg( wellPath->name() ) );
|
||||
progress.incrementProgress();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user