From f8ff53b73dbc8511806acde1100a29d31ec212b8 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 16 Aug 2014 06:18:19 +0000 Subject: [PATCH] better OnelabRun --- Common/GmshMessage.cpp | 25 ++++++++++++++++++++----- Common/GmshMessage.h | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 6ed43a3339..c5771d5302 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -27,6 +27,7 @@ #if defined(HAVE_ONELAB) #include "onelab.h" +#include "gmshLocalNetworkClient.h" #endif #if defined(HAVE_PETSC) @@ -862,6 +863,7 @@ static void _setStandardOptions(onelab::parameter *p, // numbers if(fopt.count("Visible")) p->setVisible(fopt["Visible"][0] ? true : false); if(fopt.count("ReadOnly")) p->setReadOnly(fopt["ReadOnly"][0] ? true : false); + if(fopt.count("NeverChanged")) p->setNeverChanged(fopt["NeverChanged"][0] ? true : false); if(fopt.count("ReadOnlyRange")) p->setAttribute("ReadOnlyRange", fopt["ReadOnlyRange"][0] ? "1" : "0"); if(fopt.count("AutoCheck")) @@ -1083,19 +1085,32 @@ void Msg::ImportPhysicalsAsOnelabRegions() #endif } -void Msg::RunOnelabClient(const std::string &name) +void Msg::RunOnelabClient(const std::string &name, const std::string &command) { #if defined(HAVE_ONELAB) onelab::server::citer it = onelab::server::instance()->findClient(name); - if(it == onelab::server::instance()->lastClient()){ - Msg::Error("Unknown ONELAB client `%s'", name.c_str()); - return; + onelab::client *client = 0; + if(it != onelab::server::instance()->lastClient()){ + client = it->second; + } + else{ + if(command.empty()){ + Msg::Error("Unknown ONELAB client `%s'", name.c_str()); + return; + } + onelab::string o(name + "/Action", "initialize"); + o.setVisible(false); + o.setNeverChanged(true); + onelab::server::instance()->set(o); + Msg::Info("Creating new ONELAB client `%s' (%s)", name.c_str(), command.c_str()); + client = new gmshLocalNetworkClient(name, command); + client->run(); } onelab::string o(name + "/Action", "compute"); o.setVisible(false); o.setNeverChanged(true); onelab::server::instance()->set(o); - it->second->run(); + client->run(); #endif } diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index 609c6721e8..131e47ae56 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -113,7 +113,7 @@ class Msg { std::map<std::string, std::vector<double> > &fopt, std::map<std::string, std::vector<std::string> > &copt); static void UndefineOnelabParameter(const std::string &name); - static void RunOnelabClient(const std::string &name); + static void RunOnelabClient(const std::string &name, const std::string &command=""); static void ImportPhysicalsAsOnelabRegions(); }; -- GitLab