mirror of
				https://github.com/OPM/ResInsight.git
				synced 2025-02-25 18:55:39 -06:00 
			
		
		
		
	Octave: Change default port number and add custom port number to Preferences
This commit is contained in:
		@@ -1076,7 +1076,7 @@ QStringList RiaApplication::octaveArguments() const
 | 
			
		||||
    arguments.append( "--path" );
 | 
			
		||||
    arguments << QApplication::applicationDirPath();
 | 
			
		||||
 | 
			
		||||
    if ( !m_preferences->octaveShowHeaderInfoWhenExecutingScripts )
 | 
			
		||||
    if ( !m_preferences->octaveShowHeaderInfoWhenExecutingScripts() )
 | 
			
		||||
    {
 | 
			
		||||
        // -q
 | 
			
		||||
        // Don't print the usual greeting and version message at startup.
 | 
			
		||||
@@ -1119,6 +1119,19 @@ QProcessEnvironment RiaApplication::octaveProcessEnvironment() const
 | 
			
		||||
    penv.insert( "LD_LIBRARY_PATH", ldPath );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // Set the environment variable for the port number used by Octave plugins
 | 
			
		||||
    // The plugins can access the port number using riOctavePlugin::portNumber()
 | 
			
		||||
    // If the port number is not set in preferences, the plugins will use the default port number
 | 
			
		||||
    const QString key = QString::fromStdString( riOctavePlugin::portNumberKey() );
 | 
			
		||||
    if ( !m_preferences->octavePortNumber().isEmpty() )
 | 
			
		||||
    {
 | 
			
		||||
        penv.insert( key, m_preferences->octavePortNumber() );
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        penv.remove( key );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return penv;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -118,11 +118,14 @@ RiaPreferences::RiaPreferences()
 | 
			
		||||
    m_octaveExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
 | 
			
		||||
    m_octaveExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
 | 
			
		||||
 | 
			
		||||
    CAF_PDM_InitField( &octaveShowHeaderInfoWhenExecutingScripts,
 | 
			
		||||
    CAF_PDM_InitField( &m_octaveShowHeaderInfoWhenExecutingScripts,
 | 
			
		||||
                       "octaveShowHeaderInfoWhenExecutingScripts",
 | 
			
		||||
                       false,
 | 
			
		||||
                       "Show Text Header When Executing Scripts" );
 | 
			
		||||
    caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &octaveShowHeaderInfoWhenExecutingScripts );
 | 
			
		||||
    caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_octaveShowHeaderInfoWhenExecutingScripts );
 | 
			
		||||
 | 
			
		||||
    CAF_PDM_InitFieldNoDefault( &m_octavePortNumber, "octavePortNumber", "Octave Port Number" );
 | 
			
		||||
    m_octavePortNumber.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxAndTextEditor::uiEditorTypeName() );
 | 
			
		||||
 | 
			
		||||
    CAF_PDM_InitField( &m_pythonExecutable, "pythonExecutable", QString( "python" ), "Python Executable Location" );
 | 
			
		||||
    m_pythonExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
 | 
			
		||||
@@ -449,7 +452,8 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
 | 
			
		||||
    {
 | 
			
		||||
        caf::PdmUiGroup* octaveGroup = uiOrdering.addNewGroup( "Octave" );
 | 
			
		||||
        octaveGroup->add( &m_octaveExecutable );
 | 
			
		||||
        octaveGroup->add( &octaveShowHeaderInfoWhenExecutingScripts );
 | 
			
		||||
        octaveGroup->add( &m_octaveShowHeaderInfoWhenExecutingScripts );
 | 
			
		||||
        octaveGroup->add( &m_octavePortNumber );
 | 
			
		||||
 | 
			
		||||
#ifdef ENABLE_GRPC
 | 
			
		||||
        caf::PdmUiGroup* pythonGroup = uiOrdering.addNewGroup( "Python" );
 | 
			
		||||
@@ -1008,6 +1012,24 @@ QString RiaPreferences::octaveExecutable() const
 | 
			
		||||
    return m_octaveExecutable().trimmed();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
///
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
bool RiaPreferences::octaveShowHeaderInfoWhenExecutingScripts() const
 | 
			
		||||
{
 | 
			
		||||
    return m_octaveShowHeaderInfoWhenExecutingScripts();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
///
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
QString RiaPreferences::octavePortNumber() const
 | 
			
		||||
{
 | 
			
		||||
    if ( m_octavePortNumber().first ) return m_octavePortNumber().second;
 | 
			
		||||
 | 
			
		||||
    return {};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
///
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -119,7 +119,11 @@ public:
 | 
			
		||||
 | 
			
		||||
    // Script paths
 | 
			
		||||
    QString pythonExecutable() const;
 | 
			
		||||
 | 
			
		||||
    // Octave
 | 
			
		||||
    QString octaveExecutable() const;
 | 
			
		||||
    bool    octaveShowHeaderInfoWhenExecutingScripts() const;
 | 
			
		||||
    QString octavePortNumber() const;
 | 
			
		||||
 | 
			
		||||
    QString loggerFilename() const;
 | 
			
		||||
    int     loggerFlushInterval() const;
 | 
			
		||||
@@ -137,7 +141,6 @@ public:
 | 
			
		||||
 | 
			
		||||
    caf::PdmField<QString> scriptDirectories;
 | 
			
		||||
    caf::PdmField<QString> scriptEditorExecutable;
 | 
			
		||||
    caf::PdmField<bool>    octaveShowHeaderInfoWhenExecutingScripts;
 | 
			
		||||
    caf::PdmField<bool>    showPythonDebugInfo;
 | 
			
		||||
 | 
			
		||||
    caf::PdmField<QString> ssihubAddress;
 | 
			
		||||
@@ -211,8 +214,12 @@ private:
 | 
			
		||||
    caf::PdmField<caf::FilePath> m_gridCalculationExpressionFolder;
 | 
			
		||||
    caf::PdmField<caf::FilePath> m_summaryCalculationExpressionFolder;
 | 
			
		||||
 | 
			
		||||
    // Script paths
 | 
			
		||||
    // Octave
 | 
			
		||||
    caf::PdmField<QString>                  m_octaveExecutable;
 | 
			
		||||
    caf::PdmField<bool>                     m_octaveShowHeaderInfoWhenExecutingScripts;
 | 
			
		||||
    caf::PdmField<std::pair<bool, QString>> m_octavePortNumber;
 | 
			
		||||
 | 
			
		||||
    // Python
 | 
			
		||||
    caf::PdmField<QString> m_pythonExecutable;
 | 
			
		||||
 | 
			
		||||
    // Logging
 | 
			
		||||
 
 | 
			
		||||
@@ -56,15 +56,24 @@ RiaSocketServer::RiaSocketServer( QObject* parent )
 | 
			
		||||
    m_nextPendingConnectionTimer->setInterval( 100 );
 | 
			
		||||
    m_nextPendingConnectionTimer->setSingleShot( true );
 | 
			
		||||
 | 
			
		||||
    if ( !m_tcpServer->listen( QHostAddress::LocalHost, 40001 ) )
 | 
			
		||||
    int portNumber = riOctavePlugin::defaultPortNumber;
 | 
			
		||||
    if ( !RiaPreferences::current()->octavePortNumber().isEmpty() )
 | 
			
		||||
    {
 | 
			
		||||
        QString txt = "Disabled communication with Octave due to another ResInsight process running.";
 | 
			
		||||
        portNumber = RiaPreferences::current()->octavePortNumber().toInt();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ( !m_tcpServer->listen( QHostAddress::LocalHost, portNumber ) )
 | 
			
		||||
    {
 | 
			
		||||
        QString txt = QString( "Not able to communicate with Octave plugins. Failed to use port number : %1" ).arg( portNumber );
 | 
			
		||||
 | 
			
		||||
        RiaLogging::warning( txt );
 | 
			
		||||
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString txt = QString( "Octave is using port: %1" ).arg( portNumber );
 | 
			
		||||
    RiaLogging::info( txt );
 | 
			
		||||
 | 
			
		||||
    connect( m_nextPendingConnectionTimer, SIGNAL( timeout() ), this, SLOT( slotNewClientConnection() ) );
 | 
			
		||||
    connect( m_tcpServer, SIGNAL( newConnection() ), this, SLOT( slotNewClientConnection() ) );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,9 +16,21 @@
 | 
			
		||||
//
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <QDataStream>
 | 
			
		||||
 | 
			
		||||
namespace riOctavePlugin
 | 
			
		||||
{
 | 
			
		||||
const int qtDataStreamVersion = QDataStream::Qt_4_0;
 | 
			
		||||
 | 
			
		||||
// https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
 | 
			
		||||
// Use a port number in the dynamic/private range (49152-65535)
 | 
			
		||||
const int defaultPortNumber = 52025;
 | 
			
		||||
 | 
			
		||||
inline const std::string portNumberKey()
 | 
			
		||||
{
 | 
			
		||||
    return "RESINSIGHT_OCTAVE_PORT_NUMBER";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace riOctavePlugin
 | 
			
		||||
 
 | 
			
		||||
@@ -143,7 +143,7 @@ DEFUN_DLD (riGetActiveCellCenters, args, nargout,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    NDArray cellCenterValues;
 | 
			
		||||
    getActiveCellCenters(cellCenterValues, "127.0.0.1", 40001, caseId, porosityModel.c_str());
 | 
			
		||||
    getActiveCellCenters(cellCenterValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, porosityModel.c_str());
 | 
			
		||||
 | 
			
		||||
    return octave_value(cellCenterValues);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -143,7 +143,7 @@ DEFUN_DLD (riGetActiveCellCorners, args, nargout,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    NDArray cellCornerValues;
 | 
			
		||||
    getActiveCellCorners(cellCornerValues, "127.0.0.1", 40001, caseId, porosityModel.c_str());
 | 
			
		||||
    getActiveCellCorners(cellCornerValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, porosityModel.c_str());
 | 
			
		||||
 | 
			
		||||
    return octave_value(cellCornerValues);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -158,7 +158,7 @@ DEFUN_DLD (riGetActiveCellInfo, args, nargout,
 | 
			
		||||
            }
 | 
			
		||||
        }     
 | 
			
		||||
 | 
			
		||||
        getActiveCellInfo(propertyFrames, "127.0.0.1", 40001, caseId, porosityModel);
 | 
			
		||||
        getActiveCellInfo(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, porosityModel);
 | 
			
		||||
 | 
			
		||||
        return octave_value(propertyFrames);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -193,7 +193,7 @@ DEFUN_DLD (riGetActiveCellProperty, args, nargout,
 | 
			
		||||
        return octave_value_list ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getActiveCellProperty(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
    getActiveCellProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
 | 
			
		||||
    return octave_value(propertyFrames);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -103,7 +103,7 @@ DEFUN_DLD (riGetCaseGroups, args, nargout,
 | 
			
		||||
    {
 | 
			
		||||
        std::vector<QString> groupNames;
 | 
			
		||||
        std::vector<int> groupIds;
 | 
			
		||||
        getCaseGroups(groupNames, groupIds, "127.0.0.1", 40001);
 | 
			
		||||
        getCaseGroups(groupNames, groupIds, "127.0.0.1", riOctavePlugin::portNumber());
 | 
			
		||||
 | 
			
		||||
        size_t groupCount = groupNames.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@ DEFUN_DLD (riGetCases, args, nargout,
 | 
			
		||||
            caseGroupId = argCaseId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        getCases(caseIds, caseNames, caseTypes, caseGroupIds, caseGroupId, "127.0.0.1", 40001);
 | 
			
		||||
        getCases(caseIds, caseNames, caseTypes, caseGroupIds, caseGroupId, "127.0.0.1", riOctavePlugin::portNumber());
 | 
			
		||||
 | 
			
		||||
        size_t caseCount = caseIds.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -126,7 +126,7 @@ DEFUN_DLD (riGetCellCenters, args, nargout,
 | 
			
		||||
            gridIndex = args(1).uint_value();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        getCellCenters(cellCenterValues, "127.0.0.1", 40001, caseId, gridIndex);
 | 
			
		||||
        getCellCenters(cellCenterValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIndex);
 | 
			
		||||
 | 
			
		||||
        return octave_value(cellCenterValues);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -128,7 +128,7 @@ DEFUN_DLD (riGetCellCorners, args, nargout,
 | 
			
		||||
            gridIndex = args(1).uint_value();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        getCellCorners(cellCornerValues, "127.0.0.1", 40001, caseId, gridIndex);
 | 
			
		||||
        getCellCorners(cellCornerValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIndex);
 | 
			
		||||
 | 
			
		||||
        return octave_value(cellCornerValues);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@ DEFUN_DLD (riGetCoarseningInfo, args, nargout,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        int32NDArray coarseningInfo;
 | 
			
		||||
        getCoarseningInfo(coarseningInfo, "127.0.0.1", 40001, caseId);
 | 
			
		||||
        getCoarseningInfo(coarseningInfo, "127.0.0.1", riOctavePlugin::portNumber(), caseId);
 | 
			
		||||
 | 
			
		||||
        return octave_value(coarseningInfo);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -93,7 +93,7 @@ DEFUN_DLD (riGetCurrentCase, args, nargout,
 | 
			
		||||
        QString caseType;
 | 
			
		||||
        qint64  caseGroupId = -1;
 | 
			
		||||
 | 
			
		||||
        getCurrentCase(caseId, caseName, caseType, caseGroupId, "127.0.0.1", 40001);
 | 
			
		||||
        getCurrentCase(caseId, caseName, caseType, caseGroupId, "127.0.0.1", riOctavePlugin::portNumber());
 | 
			
		||||
 | 
			
		||||
        octave_map fieldMap;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -155,7 +155,7 @@ DEFUN_DLD (riGetDynamicNNCValues, args, nargout,
 | 
			
		||||
    if (argIndices[1] >= 0) propertyName       = args(argIndices[1]).char_matrix_value().row_as_string(0);
 | 
			
		||||
    if (argIndices[2] >= 0) requestedTimeSteps = args(argIndices[2]).int32_array_value();
 | 
			
		||||
 | 
			
		||||
    getDynamicNNCValues(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps);
 | 
			
		||||
    getDynamicNNCValues(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps);
 | 
			
		||||
 | 
			
		||||
    return octave_value(propertyFrames);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -119,7 +119,7 @@ DEFUN_DLD (riGetGridDimensions, args, nargout,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        int32NDArray gridDimensions;
 | 
			
		||||
        getGridDimensions(gridDimensions, "127.0.0.1", 40001, caseId);
 | 
			
		||||
        getGridDimensions(gridDimensions, "127.0.0.1", riOctavePlugin::portNumber(), caseId);
 | 
			
		||||
 | 
			
		||||
        return octave_value(gridDimensions);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -211,7 +211,7 @@ DEFUN_DLD (riGetGridProperty, args, nargout,
 | 
			
		||||
        return octave_value_list ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getGridProperty(propertyFrames, "127.0.0.1", 40001, caseId, gridIdx, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
    getGridProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIdx, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
 | 
			
		||||
    return octave_value(propertyFrames);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -193,7 +193,7 @@ DEFUN_DLD (riGetGridPropertyForSelectedCells, args, nargout,
 | 
			
		||||
        return octave_value_list ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getGridPropertyForSelectedCells(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
    getGridPropertyForSelectedCells(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
 | 
			
		||||
    return octave_value(propertyFrames);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -101,9 +101,9 @@ DEFUN_DLD (riGetMainGridDimensions, args, nargout,
 | 
			
		||||
        int32NDArray propertyFrames;
 | 
			
		||||
 | 
			
		||||
        if (nargin > 0)
 | 
			
		||||
            getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, args(0).char_matrix_value().row_as_string(0).c_str());
 | 
			
		||||
            getMainGridDimensions(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), args(0).char_matrix_value().row_as_string(0).c_str());
 | 
			
		||||
        else
 | 
			
		||||
            getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, "");
 | 
			
		||||
            getMainGridDimensions(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), "");
 | 
			
		||||
 | 
			
		||||
        return octave_value(propertyFrames);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -122,7 +122,7 @@ DEFUN_DLD(riGetNNCConnections, args, nargout,
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        getNNCConnections(connections, "127.0.0.1", 40001, caseId);
 | 
			
		||||
        getNNCConnections(connections, "127.0.0.1", riOctavePlugin::portNumber(), caseId);
 | 
			
		||||
 | 
			
		||||
        Cell cellValuesGridIndex(connections.size(), 2);
 | 
			
		||||
        Cell cellValuesI(connections.size(), 2);
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@ DEFUN_DLD (riGetNNCPropertyNames, args, nargout,
 | 
			
		||||
        std::vector<QString> propertyNames;
 | 
			
		||||
        std::vector<QString> propertyTypes;
 | 
			
		||||
 | 
			
		||||
        getNNCPropertyNames(propertyNames, propertyTypes, "127.0.0.1", 40001, argCaseId);
 | 
			
		||||
        getNNCPropertyNames(propertyNames, propertyTypes, "127.0.0.1", riOctavePlugin::portNumber(), argCaseId);
 | 
			
		||||
                
 | 
			
		||||
        size_t caseCount = propertyNames.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -135,7 +135,7 @@ DEFUN_DLD (riGetPropertyNames, args, nargout,
 | 
			
		||||
        std::vector<QString> propertyNames;
 | 
			
		||||
        std::vector<QString> propertyTypes;
 | 
			
		||||
 | 
			
		||||
        getPropertyNames(propertyNames, propertyTypes, "127.0.0.1", 40001, argCaseId, porosityModel);
 | 
			
		||||
        getPropertyNames(propertyNames, propertyTypes, "127.0.0.1", riOctavePlugin::portNumber(), argCaseId, porosityModel);
 | 
			
		||||
                
 | 
			
		||||
        size_t caseCount = propertyNames.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -105,7 +105,7 @@ DEFUN_DLD (riGetSelectedCases, args, nargout,
 | 
			
		||||
        std::vector<QString> caseTypes;
 | 
			
		||||
        std::vector<qint64>  caseGroupIds;
 | 
			
		||||
 | 
			
		||||
        getSelectedCases(caseIds, caseNames, caseTypes, caseGroupIds, "127.0.0.1", 40001);
 | 
			
		||||
        getSelectedCases(caseIds, caseNames, caseTypes, caseGroupIds, "127.0.0.1", riOctavePlugin::portNumber());
 | 
			
		||||
 | 
			
		||||
        size_t caseCount = caseIds.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -125,7 +125,7 @@ DEFUN_DLD (riGetSelectedCells, args, nargout,
 | 
			
		||||
 | 
			
		||||
        int32NDArray propertyFrames;
 | 
			
		||||
 | 
			
		||||
        getSelectedCells(propertyFrames, "127.0.0.1", 40001, caseId);
 | 
			
		||||
        getSelectedCells(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId);
 | 
			
		||||
 | 
			
		||||
        return octave_value(propertyFrames);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -128,7 +128,7 @@ DEFUN_DLD (riGetStaticNNCValues, args, nargout,
 | 
			
		||||
    if (argIndices[0] >= 0) caseId       = args(argIndices[0]).int_value();
 | 
			
		||||
    if (argIndices[1] >= 0) propertyName = args(argIndices[1]).char_matrix_value().row_as_string(0);
 | 
			
		||||
 | 
			
		||||
    getStaticNNCValues(propertyValues, "127.0.0.1", 40001, caseId, propertyName.c_str());
 | 
			
		||||
    getStaticNNCValues(propertyValues, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str());
 | 
			
		||||
 | 
			
		||||
    dim_vector dv(2, 1);
 | 
			
		||||
    dv(0) = propertyValues.size();
 | 
			
		||||
 
 | 
			
		||||
@@ -140,7 +140,7 @@ DEFUN_DLD (riGetTimeStepDates, args, nargout,
 | 
			
		||||
        std::vector<qint32> minuteValues;
 | 
			
		||||
        std::vector<qint32> secondValues;
 | 
			
		||||
 | 
			
		||||
        getTimeStepDates(yearValues, monthValues, dayValues, hourValues, minuteValues, secondValues, caseId, "127.0.0.1", 40001);
 | 
			
		||||
        getTimeStepDates(yearValues, monthValues, dayValues, hourValues, minuteValues, secondValues, caseId, "127.0.0.1", riOctavePlugin::portNumber());
 | 
			
		||||
 | 
			
		||||
        size_t timeStepDateCount = yearValues.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -108,7 +108,7 @@ DEFUN_DLD (riGetTimeStepDays, args, nargout,
 | 
			
		||||
 | 
			
		||||
        std::vector<double> decimalDays;
 | 
			
		||||
 | 
			
		||||
        getTimeStepDates(decimalDays, caseId, "127.0.0.1", 40001);
 | 
			
		||||
        getTimeStepDates(decimalDays, caseId, "127.0.0.1", riOctavePlugin::portNumber());
 | 
			
		||||
 | 
			
		||||
        dim_vector dv(2, 1);
 | 
			
		||||
        dv(0) = decimalDays.size();
 | 
			
		||||
 
 | 
			
		||||
@@ -209,7 +209,7 @@ DEFUN_DLD (riGetWellCells, args, nargout,
 | 
			
		||||
        cellStatuses,
 | 
			
		||||
        branchIds,
 | 
			
		||||
        segmentIds,
 | 
			
		||||
        "127.0.0.1", 40001, 
 | 
			
		||||
        "127.0.0.1", riOctavePlugin::portNumber(), 
 | 
			
		||||
        caseId, QString::fromStdString(wellName), requestedTimeStep);
 | 
			
		||||
 | 
			
		||||
    size_t cellCount = cellIs.size();
 | 
			
		||||
 
 | 
			
		||||
@@ -106,7 +106,7 @@ DEFUN_DLD (riGetWellNames, args, nargout,
 | 
			
		||||
 | 
			
		||||
        std::vector<QString> wellNames;
 | 
			
		||||
 | 
			
		||||
        getWellNames(wellNames, "127.0.0.1", 40001, argCaseId);
 | 
			
		||||
        getWellNames(wellNames, "127.0.0.1", riOctavePlugin::portNumber(), argCaseId);
 | 
			
		||||
                
 | 
			
		||||
        size_t caseCount = wellNames.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -170,7 +170,7 @@ DEFUN_DLD (riGetWellStatus, args, nargout,
 | 
			
		||||
    std::vector<QString> wellType;
 | 
			
		||||
    std::vector<int> wellStatus;
 | 
			
		||||
 | 
			
		||||
    getWellStatus(wellType, wellStatus, "127.0.0.1", 40001, caseId, QString::fromStdString(wellName), requestedTimeSteps);
 | 
			
		||||
    getWellStatus(wellType, wellStatus, "127.0.0.1", riOctavePlugin::portNumber(), caseId, QString::fromStdString(wellName), requestedTimeSteps);
 | 
			
		||||
 | 
			
		||||
    size_t caseCount = wellType.size();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -219,7 +219,7 @@ DEFUN_DLD (riSetActiveCellProperty, args, nargout,
 | 
			
		||||
        return octave_value_list ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setEclipseProperty(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
    setEclipseProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps, porosityModel.c_str());
 | 
			
		||||
 | 
			
		||||
    return octave_value_list ();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -258,7 +258,7 @@ DEFUN_DLD (riSetGridProperty, args, nargout,
 | 
			
		||||
        return octave_value_list ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setEclipseProperty(propertyFrames, "127.0.0.1", 40001, caseId, gridIndex, propertyName.c_str(), timeStepIndices, porosityModel.c_str());
 | 
			
		||||
    setEclipseProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, gridIndex, propertyName.c_str(), timeStepIndices, porosityModel.c_str());
 | 
			
		||||
 | 
			
		||||
    return octave_value_list ();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -186,7 +186,7 @@ DEFUN_DLD (riSetNNCProperty, args, nargout,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setNNCProperty(propertyFrames, "127.0.0.1", 40001, caseId, propertyName.c_str(), requestedTimeSteps);
 | 
			
		||||
    setNNCProperty(propertyFrames, "127.0.0.1", riOctavePlugin::portNumber(), caseId, propertyName.c_str(), requestedTimeSteps);
 | 
			
		||||
 | 
			
		||||
    return octave_value_list ();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -76,5 +76,16 @@ namespace riOctavePlugin
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int portNumber()
 | 
			
		||||
    {
 | 
			
		||||
        QString portStr = getenv(riOctavePlugin::portNumberKey().data());
 | 
			
		||||
        if (!portStr.isEmpty())
 | 
			
		||||
        {
 | 
			
		||||
            return portStr.toInt();
 | 
			
		||||
        }
 | 
			
		||||
            
 | 
			
		||||
        return riOctavePlugin::defaultPortNumber;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user