mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 15:14:07 -06:00
Octave Interface: Added riGetWellStatus
p4#: 22301
This commit is contained in:
parent
14ee999d7e
commit
cac9d9d3f9
@ -54,6 +54,7 @@ set( SOCKET_INTERFACE_FILES
|
||||
SocketInterface/RiaCaseInfoCommands.cpp
|
||||
SocketInterface/RiaGeometryCommands.cpp
|
||||
SocketInterface/RiaPropertyDataCommands.cpp
|
||||
SocketInterface/RiaWellDataCommands.cpp
|
||||
SocketInterface/RiaSocketTools.cpp
|
||||
)
|
||||
|
||||
|
230
ApplicationCode/SocketInterface/RiaWellDataCommands.cpp
Normal file
230
ApplicationCode/SocketInterface/RiaWellDataCommands.cpp
Normal file
@ -0,0 +1,230 @@
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
#include "RiaSocketCommand.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimInputCase.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetWellNames : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellNames"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
RimCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<QString> wellNames;
|
||||
|
||||
const cvf::Collection<RigSingleWellResultsData>& wells = rimCase->reservoirData()->wellResults();
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wells.size(); ++wIdx)
|
||||
{
|
||||
wellNames.push_back(wells[wIdx]->m_wellName);
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 wellCount = wellNames.size();
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wellCount; wIdx++)
|
||||
{
|
||||
byteCount += wellNames[wIdx].size() * sizeof(QChar);
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << wellCount;
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wellCount; wIdx++)
|
||||
{
|
||||
socketStream << wellNames[wIdx];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellNames_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellNames>(RiaGetWellNames::commandName());
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetWellStatus : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellStatus"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
|
||||
RimCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create a list of all the requested time steps
|
||||
|
||||
std::vector<size_t> requestedTimesteps;
|
||||
//First find the well result for the correct well
|
||||
|
||||
const cvf::Collection<RigSingleWellResultsData>& allWellRes = rimCase->reservoirData()->wellResults();
|
||||
cvf::ref<RigSingleWellResultsData> currentWellResult;
|
||||
for (size_t tsIdx = 0; tsIdx < allWellRes.size(); ++tsIdx)
|
||||
{
|
||||
if (allWellRes[tsIdx]->m_wellName == wellName)
|
||||
{
|
||||
currentWellResult = allWellRes[tsIdx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWellResult.isNull())
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(
|
||||
RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the well with name : \"%1\"").arg(wellName));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (args.size() <= 3)
|
||||
{
|
||||
// Select all timesteps.
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < currentWellResult->m_resultTimeStepIndexToWellTimeStepIndex.size(); ++tsIdx)
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 3; argIdx < args.size(); ++argIdx)
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
|
||||
if (conversionOk)
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeStepReadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetGridProperty : \n")
|
||||
+ RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<QString> wellTypes;
|
||||
std::vector<qint32> wellStatuses;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < requestedTimesteps.size(); ++tsIdx)
|
||||
{
|
||||
QString wellType = "NotDefined";
|
||||
qint32 wellStatus = 0;
|
||||
if (currentWellResult->hasWellResult(tsIdx))
|
||||
{
|
||||
switch(currentWellResult->wellResultFrame(tsIdx).m_productionType)
|
||||
{
|
||||
case RigWellResultFrame::PRODUCER:
|
||||
wellType = "Producer";
|
||||
break;
|
||||
case RigWellResultFrame::OIL_INJECTOR:
|
||||
wellType = "OilInjector";
|
||||
break;
|
||||
case RigWellResultFrame::WATER_INJECTOR:
|
||||
wellType = "WaterInjector";
|
||||
break;
|
||||
case RigWellResultFrame::GAS_INJECTOR:
|
||||
wellType = "GasInjector";
|
||||
break;
|
||||
}
|
||||
|
||||
wellStatus = currentWellResult->wellResultFrame(tsIdx).m_isOpen ? 1 : 0;
|
||||
}
|
||||
|
||||
wellTypes.push_back(wellType);
|
||||
wellStatuses.push_back(wellStatus);
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 timeStepCount = wellTypes.size();
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++)
|
||||
{
|
||||
byteCount += wellTypes[tsIdx].size() * sizeof(QChar);
|
||||
byteCount += sizeof(qint32);
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++)
|
||||
{
|
||||
socketStream << wellTypes[tsIdx];
|
||||
socketStream << wellStatuses[tsIdx];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellStatus_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellStatus>(RiaGetWellStatus::commandName());
|
@ -43,6 +43,10 @@ add_library( ${PROJECT_NAME}
|
||||
RimOilRegionEntry.cpp
|
||||
RimOilFieldEntry.h
|
||||
RimOilFieldEntry.cpp
|
||||
RimWellsEntry.h
|
||||
RimWellsEntry.cpp
|
||||
RimWellCollection.h
|
||||
RimWellCollection.cpp
|
||||
RiuWellImportWizard.h
|
||||
RiuWellImportWizard.cpp
|
||||
|
||||
|
@ -17,7 +17,13 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimOilFieldEntry.h"
|
||||
#include "RimWellPathImport.h"
|
||||
|
||||
#include "RifJsonEncodeDecode.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMap>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimOilFieldEntry, "RimOilFieldEntry");
|
||||
|
||||
@ -54,3 +60,53 @@ caf::PdmFieldHandle* RimOilFieldEntry::objectToggleField()
|
||||
return &selected;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimOilFieldEntry::parseWellsResponse(const QString& absolutePath, const QString& wsAddress)
|
||||
{
|
||||
wells.deleteAllChildObjects();
|
||||
|
||||
if (QFile::exists(wellsFilePath))
|
||||
{
|
||||
JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(wellsFilePath);
|
||||
|
||||
QMapIterator<QString, QVariant> it(jsonMap);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
|
||||
QString key = it.key();
|
||||
if (key[0].isDigit())
|
||||
{
|
||||
QMap<QString, QVariant> rootMap = it.value().toMap();
|
||||
QMap<QString, QVariant> surveyMap = rootMap["survey"].toMap();
|
||||
|
||||
{
|
||||
QString name = surveyMap["name"].toString();
|
||||
QMap<QString, QVariant> linksMap = surveyMap["links"].toMap();
|
||||
QString requestUrl = wsAddress + linksMap["entity"].toString();
|
||||
QString surveyType = surveyMap["surveyType"].toString();
|
||||
RimWellPathEntry* surveyWellPathEntry = RimWellPathEntry::createWellPathEntry(name, surveyType, requestUrl, absolutePath, RimWellPathEntry::WELL_SURVEY);
|
||||
wells.push_back(surveyWellPathEntry);
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> plansMap = rootMap["plans"].toMap();
|
||||
QMapIterator<QString, QVariant> planIt(plansMap);
|
||||
while (planIt.hasNext())
|
||||
{
|
||||
planIt.next();
|
||||
QString name = surveyMap["name"].toString();
|
||||
QMap<QString, QVariant> linksMap = surveyMap["links"].toMap();
|
||||
QString requestUrl = wsAddress + linksMap["entity"].toString();
|
||||
QString surveyType = surveyMap["surveyType"].toString();
|
||||
RimWellPathEntry* surveyWellPathEntry = RimWellPathEntry::createWellPathEntry(name, surveyType, requestUrl, absolutePath, RimWellPathEntry::WELL_PLAN);
|
||||
wells.push_back(surveyWellPathEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
|
||||
#include "RimWellsEntry.h"
|
||||
|
||||
|
||||
|
||||
@ -32,13 +32,19 @@ class RimOilFieldEntry : public caf::PdmObject
|
||||
public:
|
||||
RimOilFieldEntry();
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
void parseWellsResponse(const QString& absolutePath, const QString& wsAddress);
|
||||
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<QString> edmId;
|
||||
caf::PdmField<bool> selected;
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<QString> edmId;
|
||||
caf::PdmField<bool> selected;
|
||||
caf::PdmField<QString> wellsFilePath; // Location of the response file from request "/wells"
|
||||
|
||||
caf::PdmPointersField<RimWellPathEntry*> wells;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -38,9 +38,9 @@ public:
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<bool> selected;
|
||||
caf::PdmPointersField<RimOilFieldEntry*> fields;
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<bool> selected;
|
||||
caf::PdmPointersField<RimOilFieldEntry*> fields;
|
||||
};
|
||||
|
||||
|
||||
|
45
ApplicationCode/ssihubInterface/RimWellCollection.cpp
Normal file
45
ApplicationCode/ssihubInterface/RimWellCollection.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellCollection, "RimWellCollection");
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellCollection::RimWellCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("OilFieldEntry", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wells, "Wells", "", "", "", "");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellCollection::~RimWellCollection()
|
||||
{
|
||||
// Remove all objects in this container, but do not delete the objects
|
||||
wells.clear();
|
||||
}
|
||||
|
39
ApplicationCode/ssihubInterface/RimWellCollection.h
Normal file
39
ApplicationCode/ssihubInterface/RimWellCollection.h
Normal file
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
#include "RimWellsEntry.h"
|
||||
|
||||
|
||||
|
||||
class RimWellCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellCollection();
|
||||
~RimWellCollection();
|
||||
|
||||
caf::PdmPointersField<RimWellPathEntry*> wells;
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,7 @@ namespace caf {
|
||||
setDefault(RimWellPathImport::UTM_FILTER_PROJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
template<>
|
||||
void caf::AppEnum< RimWellPathImport::WellTypeEnum >::setUp()
|
||||
{
|
||||
@ -37,6 +38,7 @@ namespace caf {
|
||||
addItem(RimWellPathImport::WELL_PLAN, "WELL_PLAN", "Plan");
|
||||
setDefault(RimWellPathImport::WELL_ALL);
|
||||
}
|
||||
*/
|
||||
|
||||
} // End namespace caf
|
||||
|
||||
@ -52,8 +54,9 @@ RimWellPathImport::RimWellPathImport()
|
||||
{
|
||||
CAF_PDM_InitObject("RimWellPathImport", "", "", "");
|
||||
|
||||
caf::AppEnum<RimWellPathImport::WellTypeEnum> defaultWellMode = WELL_ALL;
|
||||
CAF_PDM_InitField(&wellMode, "WellMode", defaultWellMode, "Well types", "", "", "");
|
||||
CAF_PDM_InitField(&wellTypeSurvey, "WellTypeSurvey", true, "Survey", "", "", "");
|
||||
CAF_PDM_InitField(&wellTypePlans, "WellTypePlans", true, "Plans", "", "", "");
|
||||
CAF_PDM_InitField(&wellTypeAll, "WellTypeAll", true, "All", "", "", "");
|
||||
|
||||
caf::AppEnum<RimWellPathImport::UtmFilterEnum> defaultUtmMode = UTM_FILTER_OFF;
|
||||
CAF_PDM_InitField(&utmFilterMode, "UtmMode", defaultUtmMode, "Utm filter", "", "", "");
|
||||
|
@ -31,12 +31,6 @@ class RimWellPathImport : public caf::PdmObject
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum WellTypeEnum
|
||||
{
|
||||
WELL_ALL,
|
||||
WELL_SURVEY,
|
||||
WELL_PLAN
|
||||
};
|
||||
|
||||
enum UtmFilterEnum
|
||||
{
|
||||
@ -48,7 +42,9 @@ public:
|
||||
public:
|
||||
RimWellPathImport();
|
||||
|
||||
caf::PdmField< caf::AppEnum< WellTypeEnum > > wellMode;
|
||||
caf::PdmField<bool> wellTypeSurvey;
|
||||
caf::PdmField<bool> wellTypePlans;
|
||||
caf::PdmField<bool> wellTypeAll;
|
||||
|
||||
caf::PdmField< caf::AppEnum< UtmFilterEnum > > utmFilterMode;
|
||||
caf::PdmField<double> north;
|
||||
|
123
ApplicationCode/ssihubInterface/RimWellsEntry.cpp
Normal file
123
ApplicationCode/ssihubInterface/RimWellsEntry.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimWellsEntry.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace caf {
|
||||
|
||||
template<>
|
||||
void caf::AppEnum< RimWellPathEntry::WellTypeEnum >::setUp()
|
||||
{
|
||||
addItem(RimWellPathEntry::WELL_ALL, "WELL_ALL", "All");
|
||||
addItem(RimWellPathEntry::WELL_SURVEY, "WELL_SURVEY", "Survey");
|
||||
addItem(RimWellPathEntry::WELL_PLAN, "WELL_PLAN", "Plan");
|
||||
setDefault(RimWellPathEntry::WELL_ALL);
|
||||
}
|
||||
|
||||
} // End namespace caf
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellPathEntry, "RimWellPathEntry");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPathEntry::RimWellPathEntry()
|
||||
{
|
||||
CAF_PDM_InitObject("WellPathEntry", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&name, "Name", "Name", "", "", "");
|
||||
CAF_PDM_InitField(&selected, "Selected", true, "Selected", "", "", "");
|
||||
|
||||
caf::AppEnum< RimWellPathEntry::WellTypeEnum > wellType = WELL_ALL;
|
||||
CAF_PDM_InitField(&wellPathType, "WellPathType", wellType, "Well path type", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&surveyType, "surveyType", "surveyType", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&requestUrl, "requestUrl", "requestUrl", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wellPathFilePath, "wellPathFilePath", "wellPathFilePath", "", "", "");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimWellPathEntry::userDescriptionField()
|
||||
{
|
||||
return &name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimWellPathEntry::objectToggleField()
|
||||
{
|
||||
return &selected;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPathEntry* RimWellPathEntry::createWellPathEntry(const QString& name, const QString& surveyType, const QString& requestUrl, const QString& absolutePath, WellTypeEnum wellType)
|
||||
{
|
||||
RimWellPathEntry* entry = new RimWellPathEntry();
|
||||
entry->name = name;
|
||||
entry->surveyType = surveyType;
|
||||
entry->requestUrl = requestUrl;
|
||||
entry->wellPathType = wellType;
|
||||
|
||||
QString responseFilePath = undefinedWellPathLocation();
|
||||
|
||||
int strIndex = requestUrl.indexOf("edm/");
|
||||
if (strIndex >= 0)
|
||||
{
|
||||
QString lastPart = requestUrl.right(requestUrl.size() - strIndex);
|
||||
lastPart = lastPart.replace('/', '_');
|
||||
|
||||
responseFilePath = absolutePath + "/" + lastPart + ".json";
|
||||
}
|
||||
|
||||
entry->wellPathFilePath = responseFilePath;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathEntry::undefinedWellPathLocation()
|
||||
{
|
||||
return "UNDEFIED_WELLPATH_FILE";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellPathEntry::isWellPathValid()
|
||||
{
|
||||
return (wellPathFilePath().compare(undefinedWellPathLocation()) != 0);
|
||||
}
|
||||
|
64
ApplicationCode/ssihubInterface/RimWellsEntry.h
Normal file
64
ApplicationCode/ssihubInterface/RimWellsEntry.h
Normal file
@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class RimWellPathEntry : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum WellTypeEnum
|
||||
{
|
||||
WELL_SURVEY,
|
||||
WELL_PLAN,
|
||||
WELL_ALL
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
RimWellPathEntry();
|
||||
|
||||
static RimWellPathEntry* createWellPathEntry(const QString& name, const QString& surveyType, const QString& requestUrl, const QString& absolutePath, WellTypeEnum wellType);
|
||||
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<bool> selected;
|
||||
|
||||
caf::PdmField< caf::AppEnum< WellTypeEnum > > wellPathType;
|
||||
caf::PdmField<QString> surveyType;
|
||||
caf::PdmField<QString> requestUrl;
|
||||
|
||||
bool isWellPathValid();
|
||||
caf::PdmField<QString> wellPathFilePath; // Location of the well path response
|
||||
|
||||
private:
|
||||
static QString undefinedWellPathLocation();
|
||||
};
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "RifJsonEncodeDecode.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -63,11 +64,16 @@ RiuWellImportWizard::RiuWellImportWizard(const QString& webServiceAddress, const
|
||||
|
||||
addPage(new FieldSelectionPage(m_wellPathImport, NULL, m_pdmTreeView, this));
|
||||
|
||||
addPage(new WellSelectionPage(m_wellPathImport, this));
|
||||
m_wellSummaryPageId = addPage(new WellSummaryPage(m_wellPathImport, this));
|
||||
|
||||
m_statusLabel = new QLabel(tr("Status : idle"));
|
||||
m_statusLabel->setWordWrap(true);
|
||||
|
||||
m_progressDialog = new QProgressDialog(this);
|
||||
|
||||
m_wellCollection = new RimWellCollection;
|
||||
|
||||
|
||||
connect(&m_networkAccessManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
|
||||
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
|
||||
@ -120,13 +126,6 @@ QString RiuWellImportWizard::jsonWellsFilePath()
|
||||
return m_destinationFolder + "/wellpaths.json";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::downloadWellPaths()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -137,17 +136,11 @@ void RiuWellImportWizard::downloadFields()
|
||||
if (QFile::exists(wellFileName))
|
||||
{
|
||||
QFile::remove(wellFileName);
|
||||
|
||||
// m_wellPathsModel->clear();
|
||||
// m_wellPathsModel->setColumnCount(2);
|
||||
|
||||
// clear
|
||||
}
|
||||
|
||||
m_wellPathImport->regions.deleteAllChildObjects();
|
||||
m_wellPathImport->updateConnectedEditors();
|
||||
|
||||
|
||||
QString completeUrlText = m_webServiceAddress + "/resinsight/projects";
|
||||
QString destinationFileName = jsonFieldsFilePath();
|
||||
|
||||
@ -178,6 +171,7 @@ void RiuWellImportWizard::checkDownloadQueueAndIssueRequests()
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -200,7 +194,6 @@ void RiuWellImportWizard::issueHttpRequestToFile(QString completeUrlText, QStrin
|
||||
// schedule the request
|
||||
m_httpRequestAborted = false;
|
||||
startRequest(m_url);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -266,8 +259,13 @@ void RiuWellImportWizard::httpFinished()
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELL_PATH)
|
||||
{
|
||||
|
||||
qDebug() << "Downloaded " << m_file->fileName();
|
||||
|
||||
/*
|
||||
QString singleWellPathFilePath = m_file->fileName();
|
||||
|
||||
|
||||
QFile file(singleWellPathFilePath);
|
||||
if (file.open(QFile::ReadOnly))
|
||||
{
|
||||
@ -309,6 +307,7 @@ void RiuWellImportWizard::httpFinished()
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -319,16 +318,9 @@ void RiuWellImportWizard::httpFinished()
|
||||
delete m_file;
|
||||
m_file = 0;
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELLS)
|
||||
if (m_currentDownloadState == DOWNLOAD_WELLS || m_currentDownloadState == DOWNLOAD_WELL_PATH)
|
||||
{
|
||||
QStringList survey;
|
||||
QStringList plans;
|
||||
|
||||
getWellPathLinks(&survey, &plans);
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_UNDEFINED;
|
||||
|
||||
issueDownloadOfWellPaths(survey, plans);
|
||||
checkDownloadQueueAndIssueRequests_v2();
|
||||
}
|
||||
else if (m_currentDownloadState == DOWNLOAD_FIELDS)
|
||||
{
|
||||
@ -578,6 +570,172 @@ void RiuWellImportWizard::updateFieldsModel()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::downloadWells()
|
||||
{
|
||||
for (size_t rIdx = 0; rIdx < m_wellPathImport->regions.size(); rIdx++)
|
||||
{
|
||||
RimOilRegionEntry* oilRegion = m_wellPathImport->regions[rIdx];
|
||||
if (oilRegion->selected)
|
||||
{
|
||||
for (size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++)
|
||||
{
|
||||
RimOilFieldEntry* oilField = oilRegion->fields[fIdx];
|
||||
if (oilField->selected)
|
||||
{
|
||||
DownloadEntity urlToFile;
|
||||
|
||||
QString wellRequest;
|
||||
if (m_wellPathImport->utmFilterMode == RimWellPathImport::UTM_FILTER_OFF)
|
||||
{
|
||||
wellRequest = QString("/resinsight/projects/%1/wells").arg(oilField->edmId);
|
||||
}
|
||||
else
|
||||
{
|
||||
wellRequest = QString("/resinsight/projects/%1/wellsInArea?north=%2&south=%3&east=%4&west=%5&utmZone=32N")
|
||||
.arg(oilField->edmId)
|
||||
.arg(QString::number(m_wellPathImport->north, 'g', 10))
|
||||
.arg(QString::number(m_wellPathImport->south, 'g', 10))
|
||||
.arg(QString::number(m_wellPathImport->east, 'g', 10))
|
||||
.arg(QString::number(m_wellPathImport->west, 'g', 10));
|
||||
}
|
||||
|
||||
urlToFile.requestUrl = m_webServiceAddress + wellRequest;
|
||||
urlToFile.responseFilename = m_destinationFolder + QString("/wells_%1.json").arg(oilField->edmId);
|
||||
|
||||
oilField->wellsFilePath = urlToFile.responseFilename;
|
||||
|
||||
m_wellRequestQueue.push_back(urlToFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_WELLS;
|
||||
checkDownloadQueueAndIssueRequests_v2();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::downloadWellPaths()
|
||||
{
|
||||
for (size_t rIdx = 0; rIdx < m_wellPathImport->regions.size(); rIdx++)
|
||||
{
|
||||
RimOilRegionEntry* oilRegion = m_wellPathImport->regions[rIdx];
|
||||
if (oilRegion->selected)
|
||||
{
|
||||
for (size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++)
|
||||
{
|
||||
RimOilFieldEntry* oilField = oilRegion->fields[fIdx];
|
||||
if (oilField->selected)
|
||||
{
|
||||
for (size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++)
|
||||
{
|
||||
RimWellPathEntry* wellPathEntry = oilField->wells[wIdx];
|
||||
|
||||
if (!wellPathEntry->isWellPathValid())
|
||||
continue;
|
||||
|
||||
DownloadEntity urlToFile;
|
||||
|
||||
urlToFile.requestUrl = wellPathEntry->requestUrl;
|
||||
urlToFile.responseFilename = wellPathEntry->wellPathFilePath;
|
||||
|
||||
m_wellRequestQueue.push_back(urlToFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_WELL_PATH;
|
||||
|
||||
checkDownloadQueueAndIssueRequests_v2();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::checkDownloadQueueAndIssueRequests_v2()
|
||||
{
|
||||
if (m_wellRequestQueue.size() > 0)
|
||||
{
|
||||
DownloadEntity firstItem = m_wellRequestQueue[0];
|
||||
m_wellRequestQueue.pop_front();
|
||||
|
||||
QString completeUrlText = firstItem.requestUrl;
|
||||
QString absoluteFilePath = firstItem.responseFilename;
|
||||
|
||||
issueHttpRequestToFile(completeUrlText, absoluteFilePath);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELLS)
|
||||
{
|
||||
m_wellCollection->wells.clear();
|
||||
|
||||
// Update UI with downloaded wells
|
||||
|
||||
for (size_t rIdx = 0; rIdx < m_wellPathImport->regions.size(); rIdx++)
|
||||
{
|
||||
RimOilRegionEntry* oilRegion = m_wellPathImport->regions[rIdx];
|
||||
if (oilRegion->selected)
|
||||
{
|
||||
for (size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++)
|
||||
{
|
||||
RimOilFieldEntry* oilField = oilRegion->fields[fIdx];
|
||||
if (oilField->selected)
|
||||
{
|
||||
oilField->parseWellsResponse(m_destinationFolder, m_webServiceAddress);
|
||||
|
||||
for (size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++)
|
||||
{
|
||||
m_wellCollection->wells.push_back(oilField->wells[wIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_wellCollection->updateConnectedEditors();
|
||||
}
|
||||
else if (m_currentDownloadState == DOWNLOAD_WELL_PATH)
|
||||
{
|
||||
WellSummaryPage* wellSummaryPage = dynamic_cast<WellSummaryPage*>(page(m_wellSummaryPageId));
|
||||
if (wellSummaryPage)
|
||||
{
|
||||
wellSummaryPage->updateSummaryPage();
|
||||
}
|
||||
}
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_UNDEFINED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellImportWizard::~RiuWellImportWizard()
|
||||
{
|
||||
delete m_wellCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellCollection* RiuWellImportWizard::wellCollection()
|
||||
{
|
||||
return m_wellCollection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -660,102 +818,87 @@ void FieldSelectionPage::initializePage()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWizardPage* createFieldSelectionPage(RimWellPathImport* wellPathImport)
|
||||
WellSelectionPage::WellSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent /*= 0*/)
|
||||
{
|
||||
QWizardPage* page = new QWizardPage;
|
||||
page->setTitle("Field Selection");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void WellSelectionPage::initializePage()
|
||||
{
|
||||
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>(wizard());
|
||||
wiz->downloadWells();
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
page->setLayout(layout);
|
||||
setLayout(layout);
|
||||
|
||||
QLabel* label = new QLabel("Select fields");
|
||||
QLabel* label = new QLabel("Select wells");
|
||||
layout->addWidget(label);
|
||||
|
||||
// Tree view
|
||||
caf::PdmUiTreeItem* treeItemRoot = caf::UiTreeItemBuilderPdm::buildViewItems(NULL, -1, wellPathImport);
|
||||
caf::UiTreeModelPdm* treeModelPdm = new caf::UiTreeModelPdm(page);
|
||||
treeModelPdm->setTreeItemRoot(treeItemRoot);
|
||||
m_wellSelectionTreeView = new caf::PdmUiTreeView(this);
|
||||
m_wellSelectionTreeView->showTree(wiz->wellCollection());
|
||||
|
||||
QTreeView* treeView = new QTreeView(page);
|
||||
treeView->setModel(treeModelPdm);
|
||||
layout->addWidget(treeView);
|
||||
layout->addWidget(m_wellSelectionTreeView);
|
||||
|
||||
// Property view
|
||||
caf::PdmUiPropertyView* propertyView = new caf::PdmUiPropertyView(page);
|
||||
layout->addWidget(propertyView);
|
||||
|
||||
propertyView->showProperties(wellPathImport);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWizardPage* createLoginPage(const QString& webServiceAddress)
|
||||
WellSummaryPage::WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent /*= 0*/)
|
||||
{
|
||||
QWizardPage* page = new QWizardPage;
|
||||
page->setTitle("SSIHUB - Login");
|
||||
m_wellPathImportObject = wellPathImport;
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
setLayout(layout);
|
||||
|
||||
QLabel* label = new QLabel("Please enter your login information for SSIHUB at : " + webServiceAddress);
|
||||
layout->addWidget(label);
|
||||
m_textEdit = new QTextEdit(this);
|
||||
|
||||
QFormLayout* formLayout = new QFormLayout;
|
||||
layout->addLayout(formLayout);
|
||||
|
||||
QLineEdit* usernameLineEdit = new QLineEdit(page);
|
||||
QLineEdit* passwordlLineEdit = new QLineEdit(page);
|
||||
passwordlLineEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
formLayout->addRow("&Username:", usernameLineEdit);
|
||||
formLayout->addRow("&Password:", passwordlLineEdit);
|
||||
|
||||
page->setLayout(layout);
|
||||
|
||||
|
||||
return page;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWizardPage* createWellPathSelectionPage()
|
||||
{
|
||||
QWizardPage* page = new QWizardPage;
|
||||
|
||||
return page;
|
||||
layout->addWidget(m_textEdit);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RuiWellImportWizard::showImportWizard(const QString& webServiceAddress, const QString& jsonDestinationFolder)
|
||||
void WellSummaryPage::initializePage()
|
||||
{
|
||||
return;
|
||||
|
||||
|
||||
ssihub::FetchWellPathsDialog fetchWellPaths;
|
||||
fetchWellPaths.setSsiHubUrl(webServiceAddress);
|
||||
fetchWellPaths.setDestinationFolder(jsonDestinationFolder);
|
||||
//fetchWellPaths.setRegion(m_north, m_south, m_east, m_west);
|
||||
|
||||
QStringList regions, fields, edmIds;
|
||||
fetchWellPaths.requestFieldData(regions, fields, edmIds);
|
||||
|
||||
|
||||
RimWellPathImport* wellPathImport = new RimWellPathImport;
|
||||
wellPathImport->updateRegions(regions, fields, edmIds);
|
||||
|
||||
|
||||
QWizard wizard;
|
||||
wizard.addPage(createFieldSelectionPage(wellPathImport));
|
||||
wizard.addPage(createWellPathSelectionPage());
|
||||
|
||||
wizard.setField("username", "dymmy");
|
||||
wizard.setField("password", "dymmy");
|
||||
|
||||
wizard.setWindowTitle("ssihub Well Path Import Wizard");
|
||||
wizard.exec();
|
||||
RiuWellImportWizard* wiz = dynamic_cast<RiuWellImportWizard*>(wizard());
|
||||
wiz->downloadWellPaths();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void WellSummaryPage::updateSummaryPage()
|
||||
{
|
||||
m_textEdit->setText("Summary of imported wells\n\n");
|
||||
|
||||
for (size_t rIdx = 0; rIdx < m_wellPathImportObject->regions.size(); rIdx++)
|
||||
{
|
||||
RimOilRegionEntry* oilRegion = m_wellPathImportObject->regions[rIdx];
|
||||
if (oilRegion->selected)
|
||||
{
|
||||
for (size_t fIdx = 0; fIdx < oilRegion->fields.size(); fIdx++)
|
||||
{
|
||||
RimOilFieldEntry* oilField = oilRegion->fields[fIdx];
|
||||
if (oilField->selected)
|
||||
{
|
||||
QString oilFieldText = QString("\nRegion : %1 - Field : %2").arg(oilRegion->name).arg(oilField->name);
|
||||
m_textEdit->append(oilFieldText);
|
||||
|
||||
for (size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++)
|
||||
{
|
||||
RimWellPathEntry* wellPathEntry = oilField->wells[wIdx];
|
||||
QString wellStatus = QString("%1 %2").arg(oilField->wells[wIdx]->name).arg(oilField->wells[wIdx]->wellPathFilePath);
|
||||
|
||||
m_textEdit->append(wellStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,11 @@
|
||||
class QFile;
|
||||
class QProgressDialog;
|
||||
class QLabel;
|
||||
class QTextEdit;
|
||||
|
||||
|
||||
class RimWellPathImport;
|
||||
class RimWellCollection;
|
||||
|
||||
|
||||
namespace caf
|
||||
@ -63,6 +65,43 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class WellSelectionPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WellSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = 0);
|
||||
|
||||
virtual void initializePage();
|
||||
|
||||
private:
|
||||
caf::PdmUiTreeView* m_wellSelectionTreeView;
|
||||
|
||||
};
|
||||
|
||||
class WellSummaryPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent = 0);
|
||||
|
||||
virtual void initializePage();
|
||||
|
||||
void updateSummaryPage();
|
||||
|
||||
private:
|
||||
RimWellPathImport* m_wellPathImportObject;
|
||||
QTextEdit* m_textEdit;
|
||||
};
|
||||
|
||||
|
||||
class DownloadEntity
|
||||
{
|
||||
public:
|
||||
QString requestUrl;
|
||||
QString responseFilename;
|
||||
};
|
||||
|
||||
class RiuWellImportWizard : public QWizard
|
||||
{
|
||||
@ -73,11 +112,14 @@ public:
|
||||
|
||||
public:
|
||||
RiuWellImportWizard(const QString& webServiceAddress, const QString& downloadFolder, RimWellPathImport* wellPathImportObject, QWidget *parent = 0);
|
||||
~RiuWellImportWizard();
|
||||
|
||||
void setWebServiceAddress(const QString& wsAdress);
|
||||
void setJsonDestinationFolder(const QString& folder);
|
||||
void setWellPathImportObject(RimWellPathImport* wellPathImportObject);
|
||||
|
||||
RimWellCollection* wellCollection();
|
||||
|
||||
private:
|
||||
void startRequest(QUrl url);
|
||||
void setUrl(const QString& httpAddress);
|
||||
@ -97,8 +139,11 @@ private:
|
||||
|
||||
public slots:
|
||||
void downloadWellPaths();
|
||||
void downloadWells();
|
||||
void downloadFields();
|
||||
void checkDownloadQueueAndIssueRequests();
|
||||
|
||||
void checkDownloadQueueAndIssueRequests_v2();
|
||||
|
||||
void issueHttpRequestToFile( QString completeUrlText, QString destinationFileName );
|
||||
void cancelDownload();
|
||||
@ -122,9 +167,10 @@ private:
|
||||
QString m_destinationFolder;
|
||||
|
||||
RimWellPathImport* m_wellPathImport;
|
||||
// caf::UiTreeModelPdm* m_treeModelPdm;
|
||||
caf::PdmUiTreeView* m_pdmTreeView;
|
||||
|
||||
RimWellCollection* m_wellCollection;
|
||||
|
||||
QProgressDialog* m_progressDialog;
|
||||
|
||||
QUrl m_url;
|
||||
@ -134,7 +180,8 @@ private:
|
||||
bool m_httpRequestAborted;
|
||||
|
||||
|
||||
QStringList m_wellPathRequestQueue;
|
||||
QStringList m_wellPathRequestQueue;
|
||||
QList<DownloadEntity> m_wellRequestQueue;
|
||||
|
||||
DownloadState m_currentDownloadState;
|
||||
|
||||
@ -142,6 +189,8 @@ private:
|
||||
// To be deleted
|
||||
QLabel* m_statusLabel;
|
||||
|
||||
int m_wellSummaryPageId;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -152,8 +201,3 @@ private:
|
||||
|
||||
|
||||
|
||||
class RuiWellImportWizard
|
||||
{
|
||||
public:
|
||||
static void showImportWizard(const QString& webServiceAddress, const QString& jsonDestinationFolder);
|
||||
};
|
||||
|
@ -70,6 +70,7 @@ void Interface::setRegion(int north, int south, int east, int west)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList Interface::jsonWellPaths()
|
||||
{
|
||||
/*
|
||||
RuiWellImportWizard::showImportWizard(m_webServiceAddress, m_jsonDestinationFolder);
|
||||
|
||||
FetchWellPathsDialog fetchWellPaths;
|
||||
@ -84,6 +85,9 @@ QStringList Interface::jsonWellPaths()
|
||||
}
|
||||
|
||||
return importedWellPathFiles;
|
||||
*/
|
||||
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
}; // namespace ssihub
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "ssihubInterface.h"
|
||||
#include "TestTools.h"
|
||||
#include "RiuWellImportWizard.h"
|
||||
#include "RimWellPathImport.h"
|
||||
|
||||
|
||||
|
||||
@ -76,6 +77,10 @@ int main(int argc, char *argv[])
|
||||
// QStringList jsonWellPaths();
|
||||
|
||||
RimWellPathImport* wellPathImportObject = TestTools::createMockObject();
|
||||
wellPathImportObject->north = north;
|
||||
wellPathImportObject->south = south;
|
||||
wellPathImportObject->east = east;
|
||||
wellPathImportObject->west = west;
|
||||
|
||||
RiuWellImportWizard wizard(wsAddress, destinationFolder, wellPathImportObject);
|
||||
|
||||
|
@ -20,6 +20,8 @@ set(CPP_SOURCES
|
||||
riGetGridProperty.cpp
|
||||
riSetGridProperty.cpp
|
||||
riGetPropertyNames.cpp
|
||||
riGetWellNames.cpp
|
||||
riGetWellStatus.cpp
|
||||
)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
@ -129,6 +131,8 @@ else()
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riGetGridProperty.oct"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riSetGridProperty.oct"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riGetPropertyNames.oct"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellNames.oct"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellStatus.oct"
|
||||
SOURCES ${CPP_SOURCES}
|
||||
)
|
||||
|
||||
|
129
OctavePlugin/riGetWellNames.cpp
Normal file
129
OctavePlugin/riGetWellNames.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
#include <QtNetwork>
|
||||
#include <octave/oct.h>
|
||||
#include <octave/oct-map.h>
|
||||
|
||||
#include "riSettings.h"
|
||||
|
||||
void getWellNames(std::vector<QString>& wellNames, const QString &hostName, quint16 port,
|
||||
const qint64& caseId)
|
||||
{
|
||||
QString serverName = hostName;
|
||||
quint16 serverPort = port;
|
||||
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(serverName, serverPort);
|
||||
|
||||
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
|
||||
{
|
||||
error((("Connection: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
|
||||
// Create command and send it:
|
||||
|
||||
QString command;
|
||||
command += QString("GetWellNames") + " " + QString::number(caseId);
|
||||
QByteArray cmdBytes = command.toLatin1();
|
||||
|
||||
QDataStream socketStream(&socket);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
|
||||
socketStream << (qint64)(cmdBytes.size());
|
||||
socket.write(cmdBytes);
|
||||
|
||||
// Get response. First wait for the header
|
||||
|
||||
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
|
||||
{
|
||||
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
|
||||
{
|
||||
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
quint64 byteCount;
|
||||
socketStream >> byteCount;
|
||||
|
||||
// QString byteCountString = QString::number(byteCount);
|
||||
//error(byteCountString.toLatin1().data());
|
||||
|
||||
while (socket.bytesAvailable() < (int)(byteCount))
|
||||
{
|
||||
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
|
||||
{
|
||||
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
OCTAVE_QUIT;
|
||||
}
|
||||
|
||||
quint64 wellCount;
|
||||
socketStream >> wellCount;
|
||||
|
||||
QString wellName;
|
||||
|
||||
for (size_t i = 0; i < wellCount; i++)
|
||||
{
|
||||
socketStream >> wellName;
|
||||
|
||||
wellNames.push_back(wellName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DEFUN_DLD (riGetWellNames, args, nargout,
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
" riGetWellNames([CaseId]) \n"
|
||||
"\n"
|
||||
"This function returns the names of all the wells in the case as a Vector of strings.\n"
|
||||
"If the CaseId is not defined, ResInsight’s Current Case is used.\n"
|
||||
)
|
||||
{
|
||||
int nargin = args.length ();
|
||||
if (nargin > 1)
|
||||
{
|
||||
error("riGetWellNames: Too many arguments, this function takes one optional arguments.\n");
|
||||
print_usage();
|
||||
}
|
||||
else if (nargout != 1)
|
||||
{
|
||||
error("riGetWellNames: Wrong number of output arguments, this function requires one output argument.\n");
|
||||
print_usage();
|
||||
}
|
||||
else
|
||||
{
|
||||
qint64 argCaseId = -1;
|
||||
|
||||
if (nargin == 1)
|
||||
{
|
||||
argCaseId = args(0).uint_value();
|
||||
}
|
||||
|
||||
std::vector<QString> wellNames;
|
||||
|
||||
getWellNames(wellNames, "127.0.0.1", 40001, argCaseId);
|
||||
|
||||
size_t caseCount = wellNames.size();
|
||||
|
||||
// Create cells with N items for each field in the data structure
|
||||
|
||||
//charMatrix octaveWellNames;
|
||||
string_vector octaveWellNames;
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
{
|
||||
octaveWellNames.append(wellNames[i].toStdString());
|
||||
}
|
||||
|
||||
// Build a map between the field name and field cell values
|
||||
|
||||
return octave_value(octaveWellNames);
|
||||
}
|
||||
|
||||
return octave_value();
|
||||
}
|
||||
|
207
OctavePlugin/riGetWellStatus.cpp
Normal file
207
OctavePlugin/riGetWellStatus.cpp
Normal file
@ -0,0 +1,207 @@
|
||||
#include <QtNetwork>
|
||||
#include <octave/oct.h>
|
||||
#include <octave/oct-map.h>
|
||||
|
||||
#include "riSettings.h"
|
||||
|
||||
void getWellStatus(std::vector<QString>& wellTypes, std::vector<int>& wellStatuses, const QString &hostName, quint16 port,
|
||||
const qint64& caseId, const QString& wellName, const int32NDArray& requestedTimeSteps)
|
||||
{
|
||||
QString serverName = hostName;
|
||||
quint16 serverPort = port;
|
||||
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(serverName, serverPort);
|
||||
|
||||
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
|
||||
{
|
||||
error((("Connection: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
|
||||
// Create command and send it:
|
||||
|
||||
QString command;
|
||||
command += QString("GetWellStatus") + " " + QString::number(caseId) + " " + wellName;
|
||||
|
||||
for (int i = 0; i < requestedTimeSteps.length(); ++i)
|
||||
{
|
||||
if (i == 0) command += " ";
|
||||
command += QString::number(static_cast<int>(requestedTimeSteps.elem(i)) - 1); // To make the index 0-based
|
||||
if (i != requestedTimeSteps.length() -1) command += " ";
|
||||
}
|
||||
|
||||
QByteArray cmdBytes = command.toLatin1();
|
||||
|
||||
QDataStream socketStream(&socket);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
|
||||
socketStream << (qint64)(cmdBytes.size());
|
||||
socket.write(cmdBytes);
|
||||
|
||||
// Get response. First wait for the header
|
||||
|
||||
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
|
||||
{
|
||||
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
|
||||
{
|
||||
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
quint64 byteCount;
|
||||
socketStream >> byteCount;
|
||||
|
||||
while (socket.bytesAvailable() < (int)(byteCount))
|
||||
{
|
||||
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
|
||||
{
|
||||
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
OCTAVE_QUIT;
|
||||
}
|
||||
|
||||
quint64 timeStepCount;
|
||||
socketStream >> timeStepCount;
|
||||
|
||||
QString wellType;
|
||||
qint32 wellStatus;
|
||||
|
||||
for (size_t i = 0; i < timeStepCount; i++)
|
||||
{
|
||||
socketStream >> wellType;
|
||||
socketStream >> wellStatus;
|
||||
|
||||
wellTypes.push_back(wellType);
|
||||
wellStatuses.push_back(wellStatus);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DEFUN_DLD (riGetWellStatus, args, nargout,
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
" riGetWellStatus ([CaseId], WellName, [RequestedTimeSteps]) \n"
|
||||
"\n"
|
||||
"This function returns the status information for a specified well for each\n"
|
||||
"requested time step as a vector of Structures. \n"
|
||||
"The Structure is defined as:\n"
|
||||
"WellStatus { \n"
|
||||
" WellType = string # \"Producer\", \"OilInjector\", \"WaterInjector\", \"GasInjector\", \"NotDefined\" \n"
|
||||
" WellStatus = int # is either 0 or 1, meaning the well is shut or open respectively.\n"
|
||||
"}\n"
|
||||
"If the CaseId is not defined, ResInsight’s Current Case is used.\n"
|
||||
|
||||
)
|
||||
{
|
||||
if (nargout != 1)
|
||||
{
|
||||
error("riGetWellStatus: Wrong number of output arguments, this function requires one output argument.\n");
|
||||
print_usage();
|
||||
return octave_value();
|
||||
}
|
||||
|
||||
int nargin = args.length ();
|
||||
if (nargin < 1)
|
||||
{
|
||||
error("riGetWellStatus: Too few arguments, this function needs at least the well name as input.\n");
|
||||
print_usage();
|
||||
return octave_value();
|
||||
}
|
||||
|
||||
if (nargin > 3)
|
||||
{
|
||||
error("riGetWellStatus: Too many arguments, this function takes at most three arguments.\n");
|
||||
print_usage();
|
||||
return octave_value();
|
||||
}
|
||||
|
||||
std::vector<int> argIndices;
|
||||
argIndices.push_back(0); // caseId
|
||||
argIndices.push_back(1); // WellName
|
||||
argIndices.push_back(2); // TimeSteps
|
||||
|
||||
// Check if we do not have a CaseId:
|
||||
if (args(argIndices[0]).is_string()) // Check if first argument is a text. If it is, the caseId is missing
|
||||
{
|
||||
argIndices[0] = -1;
|
||||
for (size_t aIdx = 1; aIdx < argIndices.size(); ++aIdx)
|
||||
--argIndices[aIdx];
|
||||
}
|
||||
|
||||
// Check if we have a Requested TimeSteps
|
||||
int lastArgumentIndex = argIndices[2] ;
|
||||
if (!(nargin > argIndices[2] && args(argIndices[2]).is_matrix_type()))
|
||||
{
|
||||
argIndices[2] = -1;
|
||||
}
|
||||
|
||||
// Check if we have more arguments than we should
|
||||
if (nargin > lastArgumentIndex + 1)
|
||||
{
|
||||
error("riGetWellStatus: Unexpected argument at the end.\n");
|
||||
print_usage();
|
||||
return octave_value_list ();
|
||||
}
|
||||
|
||||
// Setup the argument list
|
||||
|
||||
NDArray propertyFrames;
|
||||
int caseId = -1;
|
||||
std::string wellName = "UNDEFINED";
|
||||
int32NDArray requestedTimeSteps;
|
||||
|
||||
if (argIndices[0] >= 0) caseId = args(argIndices[0]).int_value();
|
||||
if (argIndices[1] >= 0) wellName = args(argIndices[1]).char_matrix_value().row_as_string(0);
|
||||
if (argIndices[2] >= 0) requestedTimeSteps = args(argIndices[2]).int32_array_value();
|
||||
|
||||
if (wellName == "UNDEFINED")
|
||||
{
|
||||
error("riGetWellStatus: The argument must be a text containing the well name.\n");
|
||||
print_usage();
|
||||
return octave_value();
|
||||
}
|
||||
|
||||
std::vector<QString> wellType;
|
||||
std::vector<int> wellStatus;
|
||||
|
||||
getWellStatus(wellType, wellStatus, "127.0.0.1", 40001, caseId, QString::fromStdString(wellName), requestedTimeSteps);
|
||||
|
||||
size_t caseCount = wellType.size();
|
||||
|
||||
if (wellType.size() != wellStatus.size() )
|
||||
{
|
||||
error("riGetWellStatus: Inconsistent data received from ResInsight.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create cells with N items for each field in the data structure
|
||||
|
||||
Cell cellValuesB(caseCount, 1);
|
||||
Cell cellValuesC(caseCount, 1);
|
||||
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
{
|
||||
cellValuesB(i) = wellType[i].toLatin1().data();
|
||||
cellValuesC(i) = wellStatus[i];
|
||||
}
|
||||
|
||||
// Build a map between the field name and field cell values
|
||||
|
||||
Octave_map m;
|
||||
|
||||
m.assign(riOctavePlugin::wellStatus_WellType, cellValuesB);
|
||||
m.assign(riOctavePlugin::wellStatus_WellStatus, cellValuesC);
|
||||
|
||||
return octave_value(m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ namespace riOctavePlugin
|
||||
char propertyInfo_PropName[] = "PropName";
|
||||
char propertyInfo_PropType[] = "PropType";
|
||||
|
||||
// Octave data structure: WellStatus
|
||||
char wellStatus_WellType[] = "WellType";
|
||||
char wellStatus_WellStatus[] = "WellStatus";
|
||||
|
||||
// Octave data structure : CaseGroupInfo
|
||||
char caseGroupInfo_CaseGroupId[] = "CaseGroupId";
|
||||
char caseGroupInfo_CaseGroupName[] = "CaseName";
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
set(CMAKE_MAJOR_VERSION 0)
|
||||
set(CMAKE_MINOR_VERSION 9)
|
||||
set(CMAKE_PATCH_VERSION 24)
|
||||
set(CMAKE_PATCH_VERSION 25)
|
||||
|
||||
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
|
||||
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})
|
||||
|
Loading…
Reference in New Issue
Block a user