From 67ea7b6e8989fdfbbac0aea73aa64dd41bcf460e Mon Sep 17 00:00:00 2001 From: Francois Henrotte <francois.henrotte@ulg.ac.be> Date: Sun, 21 Oct 2012 15:59:10 +0000 Subject: [PATCH] --- Common/CommandLine.cpp | 2 +- contrib/onelab/OnelabClients.cpp | 7 +++-- contrib/onelab/OnelabClients.h | 14 +++++++--- contrib/onelab/OnelabMessage.cpp | 4 +-- contrib/onelab/OnelabParser.cpp | 44 ++++++++++++++++---------------- contrib/onelab/loader.cpp | 2 ++ 6 files changed, 42 insertions(+), 31 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 44e671823a..ec867de016 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -137,7 +137,7 @@ void GetOptions(int argc, char *argv[]) } #endif - Msg::SetExecutableName(argc?argv[0]:""); + if(argc) Msg::SetExecutableName(argv[0]); // get command line options int i = 1; diff --git a/contrib/onelab/OnelabClients.cpp b/contrib/onelab/OnelabClients.cpp index 85baae7766..4da0983f35 100644 --- a/contrib/onelab/OnelabClients.cpp +++ b/contrib/onelab/OnelabClients.cpp @@ -411,7 +411,6 @@ bool localSolverClient::checkCommandLine(){ run(); // does nothing for Interfaced clients, initializes native clients } else{ - std::cout << "FHF hasGmsh=" << OLMsg::hasGmsh << std::endl; if(OLMsg::hasGmsh) { // exits metamodel and restores control to the onelab window OLMsg::Error("The command line of client <%s> is undefined.", @@ -553,7 +552,11 @@ bool remoteClient::syncInputFile(const std::string &wdir, const std::string &fil std::string fullName = wdir+trueName; if(checkIfPresent(fullName)){ cmd.assign("rsync -e ssh -auv "+fullName+" "+_remoteHost+":"+_remoteDir+"/"+trueName); - //FIXME sleep(OLMsg::GetOnelabNumber("RSYNCDELAY")); +#if defined(WIN32) + Sleep((int)(OLMsg::GetOnelabNumber("RSYNCDELAY")*1000)); +#else + sleep(OLMsg::GetOnelabNumber("RSYNCDELAY")); +#endif return mySystem(cmd); } else{ diff --git a/contrib/onelab/OnelabClients.h b/contrib/onelab/OnelabClients.h index 5fcd47419b..44b6a54db8 100644 --- a/contrib/onelab/OnelabClients.h +++ b/contrib/onelab/OnelabClients.h @@ -90,14 +90,18 @@ uses localNetworkSolverClient::run instead of onelab::client::run(). Both "localSolverNetworkClient" and "localSolverClient" are pure virtual. -The combination of two alternatives native/interfaced and local/remote -yields 4 clients: -InterfacedClient, RemoteInterfacesClient -NativeClient, RemoteINterfacedClient +Encapsulated clients are interfaced clients called through a gmsh capsule +so that the GUI may remain active. The base class "remoteClient" is a base class for clients running on a remote host. It provides appropriate versions of checkIfPresent() and checkCommandLine(). + +The combination of native/interfaced/encapsulated and local/remote +yields 6 clients: +NativeClient, RemoteINterfacedClient +InterfacedClient, RemoteInterfacesClient +Encapsulated, RemoteEncapsulated */ class localSolverClient : public onelab::localClient{ private: @@ -154,6 +158,7 @@ class localSolverClient : public onelab::localClient{ bool checkIfPresentLocal(const std::string &fileName){ return checkIfPresent(getWorkingDir()+fileName); } + virtual bool isNative() { return false; } virtual bool checkCommandLine(); virtual void analyze() =0; virtual void compute() =0; @@ -187,6 +192,7 @@ class localNetworkSolverClient : public localSolverClient{ int getRemote(){ return _remote; } void setRemote(bool rem){ _remote = rem; } + bool isNative() { return true; } virtual std::string buildCommandLine(); std::string appendArguments(); virtual bool run(); diff --git a/contrib/onelab/OnelabMessage.cpp b/contrib/onelab/OnelabMessage.cpp index ae8db4afc1..c997a1bc09 100644 --- a/contrib/onelab/OnelabMessage.cpp +++ b/contrib/onelab/OnelabMessage.cpp @@ -95,9 +95,9 @@ void OLMsg::Fatal(const char *fmt, ...) OLMsg::SetOnelabString("MetaModel/STATUS","STOP"); //FinalizeClient(); - FinalizeOnelab(); + //FinalizeOnelab(); //delete loader; - Exit(1); + //Exit(1); } void OLMsg::Error(const char *fmt, ...) diff --git a/contrib/onelab/OnelabParser.cpp b/contrib/onelab/OnelabParser.cpp index 4d269e6a7d..8d9a6efc7e 100644 --- a/contrib/onelab/OnelabParser.cpp +++ b/contrib/onelab/OnelabParser.cpp @@ -1281,6 +1281,11 @@ void MetaModel::client_sentence(const std::string &name, strings[0].setVisible(false); set(strings[0]); } + localSolverClient *c; + if((c=findClientByName(name))){ + c->checkCommandLine(); // initialize client if native + c->analyze(); + } } else if(isTodo(ANALYZE)){ localSolverClient *c; @@ -1334,22 +1339,20 @@ void MetaModel::client_sentence(const std::string &name, OLMsg::Fatal("Wrong number of arguments <%d> for <%s>", arguments.size(), action.c_str()); } - else if(!action.compare("check")){ - localSolverClient *c; - if((c=findClientByName(name))){ - c->checkCommandLine(); - c->analyze(); - } - else - OLMsg::Fatal("Unknown client <%s>", name.c_str()); - } - else if(!action.compare("compute")){ - localSolverClient *c; - if((c=findClientByName(name))){ - c->checkCommandLine(); - if(isTodo(REGISTER)) - c->analyze(); // computes nothing at registration - else{ + // else if(!action.compare("check")){ + // localSolverClient *c; + // if((c=findClientByName(name))){ + // c->checkCommandLine(); + // c->analyze(); + // } + // else + // OLMsg::Fatal("Unknown client <%s>", name.c_str()); + // } + else if(!action.compare("alwaysCompute")){ + if(isTodo(ANALYZE)){ + localSolverClient *c; + if((c=findClientByName(name))){ + //c->checkCommandLine(); c->compute(); onelab::server::instance()->setChanged(false, c->getName()); } @@ -1370,24 +1373,21 @@ void MetaModel::client_sentence(const std::string &name, } } } - else if(!action.compare("computeMerge")){ + else if(!action.compare("frontPage")){ std::vector<std::string> choices; for(unsigned int i = 0; i < arguments.size(); i++){ choices.push_back(resolveGetVal(arguments[i])); } localSolverClient *c; if((c=findClientByName(name))) { - c->checkCommandLine(); - if(isTodo(REGISTER)) - c->analyze(); // computes nothing at registration - else{ + //c->checkCommandLine(); + if(isTodo(ANALYZE) || isTodo(COMPUTE)) if(onelab::server::instance()->getChanged(c->getName())){ c->compute(); c->GmshMerge(choices); OLMsg::SetOnelabNumber("Gmsh/NeedReloadGeom",1,false); onelab::server::instance()->setChanged(false, c->getName()); } - } } } else diff --git a/contrib/onelab/loader.cpp b/contrib/onelab/loader.cpp index 6d58d2ead0..14072372e1 100644 --- a/contrib/onelab/loader.cpp +++ b/contrib/onelab/loader.cpp @@ -227,6 +227,8 @@ int main(int argc, char *argv[]){ std::string caseName="", todo="compute", modelName="", workingDir=""; onelab::remoteNetworkClient *client = 0; + //if(argc) OLMsg::SetExecutableName(argv[0]); + while(i < argc) { if(argv[i][0] == '-') { if(!strcmp(argv[i] + 1, "a")) { -- GitLab