2017-07-27 10:49:28 +02:00
|
|
|
#include "RicfRunOctaveScript.h"
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-07-27 10:49:28 +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-07-27 10:49:28 +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-07-27 10:49:28 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicfRunOctaveScript.h"
|
|
|
|
|
|
2026-09-16 17:52:36 +02:00
|
|
|
#include "RicfCommandForwarding.h"
|
2017-07-27 10:49:28 +02:00
|
|
|
|
2026-09-16 17:52:36 +02:00
|
|
|
#include "RimCase.h"
|
2019-04-05 09:34:02 +02:00
|
|
|
#include "RimProject.h"
|
2026-09-16 17:52:36 +02:00
|
|
|
#include "RimcProject.h"
|
2019-04-04 21:37:22 +02:00
|
|
|
|
2020-08-21 11:13:07 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-03-10 14:11:22 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfRunOctaveScript, "runOctaveScript" );
|
2017-07-27 10:49:28 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-07-27 10:49:28 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RicfRunOctaveScript::RicfRunOctaveScript()
|
|
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector<int>(), "Case IDs" );
|
2017-07-27 10:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-07-27 10:49:28 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse RicfRunOctaveScript::execute()
|
2017-07-27 10:49:28 +02:00
|
|
|
{
|
2026-09-16 17:52:36 +02:00
|
|
|
const QString commandName = classKeyword();
|
2017-07-27 10:49:28 +02:00
|
|
|
|
2026-09-16 17:52:36 +02:00
|
|
|
std::vector<RimCase*> cases;
|
|
|
|
|
for ( int caseId : m_caseIds() )
|
2019-04-05 09:34:02 +02:00
|
|
|
{
|
2026-09-16 17:52:36 +02:00
|
|
|
auto rimCase = RicfForwarding::findCase( caseId );
|
|
|
|
|
if ( !rimCase ) return RicfForwarding::errorResponse( rimCase.error(), commandName );
|
|
|
|
|
cases.push_back( rimCase.value() );
|
2019-04-05 09:34:02 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-16 17:52:36 +02:00
|
|
|
RimProject_runOctaveScript method( RimProject::current() );
|
|
|
|
|
method.setPath( m_path() );
|
|
|
|
|
method.setCases( cases );
|
2019-05-23 13:59:19 +02:00
|
|
|
|
2026-09-16 17:52:36 +02:00
|
|
|
return RicfForwarding::toScriptResponse( method.execute(), commandName );
|
2017-07-27 10:49:28 +02:00
|
|
|
}
|