2017-09-22 14:26:54 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-09-22 14:26:54 +02:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-09-22 14:26:54 +02:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-09-22 14:26:54 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2017-09-27 15:19:04 +02:00
|
|
|
#include "RimObservedEclipseUserData.h"
|
2017-09-22 14:26:54 +02:00
|
|
|
|
2017-09-27 15:12:55 +02:00
|
|
|
#include "RiaLogging.h"
|
|
|
|
|
|
2017-09-27 10:19:24 +02:00
|
|
|
#include "RifColumnBasedUserData.h"
|
2017-09-27 15:12:55 +02:00
|
|
|
#include "RifColumnBasedUserDataParser.h"
|
|
|
|
|
#include "RifKeywordVectorParser.h"
|
|
|
|
|
#include "RifKeywordVectorUserData.h"
|
2023-03-15 13:39:57 +01:00
|
|
|
#include "RifMultipleSummaryReaders.h"
|
2017-09-25 14:37:41 +02:00
|
|
|
#include "RifSummaryReaderInterface.h"
|
2017-09-22 14:26:54 +02:00
|
|
|
|
2023-03-15 13:39:57 +01:00
|
|
|
#include "RimCalculatedSummaryCurveReader.h"
|
|
|
|
|
|
2017-09-25 14:37:41 +02:00
|
|
|
#include "cafUtils.h"
|
2017-09-22 14:26:54 +02:00
|
|
|
|
2017-09-27 15:12:55 +02:00
|
|
|
#include <QFile>
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RimObservedEclipseUserData, "RimObservedEclipseUserData" );
|
2017-09-22 14:26:54 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-22 14:26:54 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-27 15:19:04 +02:00
|
|
|
RimObservedEclipseUserData::RimObservedEclipseUserData()
|
2017-09-22 14:26:54 +02:00
|
|
|
{
|
2022-01-07 08:31:52 +01:00
|
|
|
CAF_PDM_InitObject( "Observed RSMSPEC Column Based Data File", ":/ObservedRSMDataFile16x16.png" );
|
2019-09-06 10:40:57 +02:00
|
|
|
m_summaryHeaderFilename.uiCapability()->setUiName( "File" );
|
2017-09-22 14:26:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-22 14:26:54 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-27 15:19:04 +02:00
|
|
|
void RimObservedEclipseUserData::createSummaryReaderInterface()
|
2017-09-22 14:26:54 +02:00
|
|
|
{
|
2023-03-15 13:39:57 +01:00
|
|
|
m_multiSummaryReader = nullptr;
|
2025-07-16 15:16:19 +02:00
|
|
|
|
|
|
|
|
std::unique_ptr<RifSummaryReaderInterface> myReader = nullptr;
|
2017-09-27 15:12:55 +02:00
|
|
|
|
2023-08-04 09:04:14 +02:00
|
|
|
if ( caf::Utils::fileExists( summaryHeaderFilename() ) )
|
2017-09-25 14:37:41 +02:00
|
|
|
{
|
2023-08-04 09:04:14 +02:00
|
|
|
QFile file( summaryHeaderFilename() );
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
2017-09-27 15:12:55 +02:00
|
|
|
{
|
2023-08-04 09:04:14 +02:00
|
|
|
RiaLogging::error( QString( "Failed to open %1" ).arg( summaryHeaderFilename() ) );
|
2017-09-27 15:12:55 +02:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
QTextStream in( &file );
|
|
|
|
|
QString fileContents = in.readAll();
|
|
|
|
|
fileContents.replace( "\t", " " );
|
2017-09-27 15:12:55 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( RifKeywordVectorParser::canBeParsed( fileContents ) )
|
2017-09-27 15:12:55 +02:00
|
|
|
{
|
2025-07-16 15:16:19 +02:00
|
|
|
auto candidate = std::make_unique<RifKeywordVectorUserData>();
|
|
|
|
|
if ( candidate->parse( fileContents, customWellName() ) )
|
2017-09-27 15:12:55 +02:00
|
|
|
{
|
2025-07-16 15:16:19 +02:00
|
|
|
myReader = std::move( candidate );
|
2017-09-27 15:12:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-09-25 14:37:41 +02:00
|
|
|
{
|
2025-07-16 15:16:19 +02:00
|
|
|
auto candidate = std::make_unique<RifColumnBasedUserData>();
|
|
|
|
|
if ( candidate->parse( fileContents, &m_errorText ) )
|
2017-09-27 15:12:55 +02:00
|
|
|
{
|
2025-07-16 15:16:19 +02:00
|
|
|
myReader = std::move( candidate );
|
2017-09-27 15:12:55 +02:00
|
|
|
}
|
2017-09-25 14:37:41 +02:00
|
|
|
}
|
2023-03-15 13:39:57 +01:00
|
|
|
|
2025-07-16 15:16:19 +02:00
|
|
|
if ( myReader )
|
2023-03-15 13:39:57 +01:00
|
|
|
{
|
2025-07-16 15:16:19 +02:00
|
|
|
m_multiSummaryReader = std::make_unique<RifMultipleSummaryReaders>();
|
|
|
|
|
m_multiSummaryReader->addReader( std::move( myReader ) );
|
|
|
|
|
m_multiSummaryReader->addReader( std::make_unique<RifCalculatedSummaryCurveReader>( this ) );
|
2025-07-17 16:32:25 +02:00
|
|
|
m_multiSummaryReader->createAndSetAddresses();
|
2023-03-15 13:39:57 +01:00
|
|
|
}
|
2017-09-25 14:37:41 +02:00
|
|
|
}
|
2017-09-22 14:26:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-22 14:26:54 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-27 15:19:04 +02:00
|
|
|
RifSummaryReaderInterface* RimObservedEclipseUserData::summaryReader()
|
2017-09-22 14:26:54 +02:00
|
|
|
{
|
2025-07-16 15:16:19 +02:00
|
|
|
if ( !m_multiSummaryReader )
|
2020-10-12 14:28:24 +02:00
|
|
|
{
|
|
|
|
|
createSummaryReaderInterface();
|
|
|
|
|
}
|
2025-07-16 15:16:19 +02:00
|
|
|
return m_multiSummaryReader.get();
|
2017-09-22 14:26:54 +02:00
|
|
|
}
|
2017-11-03 08:11:27 +01:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-03 08:11:27 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimObservedEclipseUserData::errorMessagesFromReader()
|
|
|
|
|
{
|
|
|
|
|
return m_errorText;
|
|
|
|
|
}
|