Skip to content
Snippets Groups Projects
Commit e34780e7 authored by Francois Henrotte's avatar Francois Henrotte
Browse files

No commit message

No commit message
parent 97625f5a
No related branches found
No related tags found
No related merge requests found
......@@ -410,8 +410,6 @@ bool localSolverClient::checkCommandLine(){
getCommandLine().c_str(), getName().c_str());
if(!isActive()) return true;
//if(*getCommandLine().rbegin() != '=') return false;
if(!getCommandLine().empty()){
if(isNative()){
setAction("initialize");
......@@ -578,11 +576,12 @@ 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);
#if defined(WIN32)
Sleep((int)(OLMsg::GetOnelabNumber("RSYNCDELAY")*1000));
#else
sleep(OLMsg::GetOnelabNumber("RSYNCDELAY"));
#endif
// #if defined(WIN32)
// Sleep((int)(OLMsg::GetOnelabNumber("RSYNCDELAY")*1000));
// #else
// sleep(OLMsg::GetOnelabNumber("RSYNCDELAY"));
// #endif
SleepInSeconds(OLMsg::GetOnelabNumber("RSYNCDELAY"));
return mySystem(cmd);
}
else{
......@@ -595,8 +594,9 @@ bool remoteClient::syncInputFile(const std::string &wdir, const std::string &fil
//should be found local
std::string fullName = wdir+fileName;
if(checkIfPresent(fullName)){
cmd.assign("rsync -e ssh -auv "+fullName+" "+_remoteHost+":"+_remoteDir+"/"+fileName);
//FIXME sleep(OLMsg::GetOnelabNumber("RSYNCDELAY"));
cmd.assign("rsync -e ssh -auv "+fullName+" " + _remoteHost);
cmd.append(":" + _remoteDir + "/"+fileName);
SleepInSeconds(OLMsg::GetOnelabNumber("RSYNCDELAY"));
return mySystem(cmd);
}
else{
......@@ -626,7 +626,7 @@ bool remoteClient::syncOutputFile(const std::string &wdir, const std::string &fi
+fileName.substr(pos,std::string::npos)+" .");
if(!wdir.empty())
cmd.append(dirSep+wdir);
//FIXME sleep(OLMsg::GetOnelabNumber("RSYNCDELAY"));
SleepInSeconds(OLMsg::GetOnelabNumber("RSYNCDELAY"));
return mySystem(cmd);
}
}
......@@ -1226,9 +1226,9 @@ std::string FixExecPath(const std::string &in)
split0.assign(SplitFileName(cmd)[0]);
split1.assign(SplitFileName(cmd)[1]);
split2.assign(SplitFileName(cmd)[2]);
std::cout << "0=<" << split0 << ">" << std::endl;
std::cout << "1=<" << split1 << ">" << std::endl;
std::cout << "2=<" << split2 << ">" << std::endl;
// std::cout << "0=<" << split0 << ">" << std::endl;
// std::cout << "1=<" << split1 << ">" << std::endl;
// std::cout << "2=<" << split2 << ">" << std::endl;
if(split2==".app")
cmd.assign(cmd + "/Contents/MacOS/" + split1);
......@@ -1243,9 +1243,7 @@ std::string FixExecPath(const std::string &in)
else
if(cmd[0] != '\"') cmd.assign(quote(cmd));
std::cout << "cmd=<" << cmd << ">" << std::endl;
//exit(1);
//std::cout << "cmd=<" << cmd << ">" << std::endl;
return cmd;
}
......
......@@ -18,7 +18,7 @@
// Onelab file extension
static std::string onelabExtension(".ol");
// Possible actions for clients
enum parseMode {INITIALIZE, REGISTER, ANALYZE, COMPUTE, EXIT, STOP};
enum parseMode {REGISTER, ANALYZE, COMPUTE, EXIT};
#if defined(WIN32)
static std::string dirSep("\\");
......@@ -140,6 +140,7 @@ class localSolverClient : public onelab::localClient{
const bool isOnelabBlock() { return _onelabBlock; }
const void openOnelabBlock() { _onelabBlock=true; }
const void closeOnelabBlock() { _onelabBlock=false; }
std::string resolveString(const std::string &line);
std::string resolveGetVal(std::string line);
bool resolveLogicExpr(std::vector<std::string> arguments);
bool resolveRange(const std::string &in, std::vector<double> &arguments);
......
......@@ -168,7 +168,35 @@ std::string localSolverClient::longName(const std::string name){
return fullName;
}
std::string localSolverClient::resolveString(const std::string &line) {
//looks for the first OL.get() statement,
//returns a onelab::string value from the server, if any, or "" otherwise
//if no OL.get() statement found, returns line unchanged.
std::vector<onelab::string> strings;
std::vector<std::string> arguments;
size_t pos,cursor;
if((pos=line.find(olkey::getValue)) != std::string::npos){
cursor = pos+olkey::getValue.length();
int NumArg=enclosed(line.substr(cursor),arguments,pos);
if(NumArg<1){
OLMsg::Error("Misformed %s statement: <%s>",
olkey::getValue.c_str(),line.c_str());
return "??";
}
std::string paramName=longName(arguments[0]);
get(strings,paramName);
if (strings.size())
return strings[0].getValue();
else
return "";
}
return line;
}
std::string localSolverClient::resolveGetVal(std::string line) {
//looks for OL.get() statements, substitute the value from server
//then ealuate the resulting string with mathex.
std::vector<onelab::number> numbers;
std::vector<onelab::string> strings;
std::vector<std::string> arguments;
......@@ -265,7 +293,7 @@ std::string localSolverClient::resolveGetVal(std::string line) {
}
}
else{
get(strings,longName(paramName));
get(strings,paramName);
if (strings.size())
buff.assign(strings[0].getValue());
else{
......@@ -304,13 +332,33 @@ std::string localSolverClient::resolveGetVal(std::string line) {
bool localSolverClient::resolveLogicExpr(std::vector<std::string> arguments) {
std::vector<onelab::number> numbers;
double val1, val2;
std::string str1,str2;
bool condition=false;
if(arguments.size()==1){
str1.assign(resolveString(arguments[0]));
if(str1.size())
return true;
val1 = atof( resolveGetVal(arguments[0]).c_str() );
if(arguments.size()==1)
condition=(bool)val1;
return (bool)val1;
}
else if(arguments.size()==3){
str1.assign(resolveString(arguments[0]));
str2.assign(resolveString(arguments[2]));
if(str1.size() && str2.size()){
if (!arguments[1].compare("=="))
condition = !str1.compare(str2);
else if (!arguments[1].compare("!="))
condition = str1.compare(str2);
else
OLMsg::Error("Unknown logical operator <%s> for strings",
arguments[1].c_str());
}
else{
val1 = atof( resolveGetVal(arguments[0]).c_str() );
val2 = atof( resolveGetVal(arguments[2]).c_str() );
if(!arguments[1].compare("<"))
condition = (val1<val2);
......@@ -327,6 +375,7 @@ bool localSolverClient::resolveLogicExpr(std::vector<std::string> arguments) {
else
OLMsg::Error("Unknown logical operator <%s>", arguments[1].c_str());
}
}
else
OLMsg::Error("Invalid logical expression");
return condition;
......@@ -1358,11 +1407,11 @@ void MetaModel::client_sentence(const std::string &name,
set(strings[0]);
}
localSolverClient *c;
if((c=findClientByName(name))){
if(c->checkCommandLine() && !OLMsg::GetErrorNum())
if(!OLMsg::GetErrorNum())
if((c=findClientByName(name)))
if(c->checkCommandLine())
c->analyze();
}
}
else if(isTodo(ANALYZE)){
localSolverClient *c;
if((c=findClientByName(name))) c->analyze();
......
......@@ -11,6 +11,7 @@ void initializeMetamodel(const std::string &loaderName, onelab::client *olclient
//Initilizes also the wait function the Gmsh Gui
//so that Gmsh windows may remain active during client computations.
OLMsg::SetOnelabClient(olclient);
OLMsg::Info("I can now communicate with gmsh");
OLMsg::SetOnelabString("LoaderPathName",loaderName,false);
OLMsg::SetGuiWaitFunction(gui_wait_fct);
}
......@@ -23,40 +24,32 @@ int metamodel(const std::string &action){
OLMsg::ResetErrorNum();
parseMode todo;
if(action == "initialize")
todo = INITIALIZE;
else if(action == "check")
todo = ANALYZE;
else if(action == "compute"){
// if(action == "initialize")
// todo = INITIALIZE;
if(action == "compute")
todo = COMPUTE;
}
else{
todo = EXIT;
OLMsg::Error("Unknown action <%s>", action.c_str());
todo = ANALYZE;
}
std::string modelName = OLMsg::GetOnelabString("Arguments/FileName");
std::string workingDir = OLMsg::GetOnelabString("Arguments/WorkingDir");
std::string clientName = "meta";
MetaModel *myModel =
new MetaModel("meta", workingDir, "meta", modelName);
myModel->setTodo(todo);
if(OLMsg::GetOnelabNumber("LOGFILES")){
if(workingDir.size()) workingDir.append(dirSep);
std::string mystdout = FixWindowsQuotes(workingDir + "stdout.txt");
std::string mystderr = FixWindowsQuotes(workingDir + "stderr.txt");
freopen(mystdout.c_str(),"w",stdout);
freopen(mystderr.c_str(),"w",stderr);
OLMsg::Info("Redirecting stdout into <%s>",mystdout.c_str());
OLMsg::Info("Redirecting stderr into <%s>",mystderr.c_str());
freopen(mystdout.c_str(),"w",stdout);
freopen(mystderr.c_str(),"w",stderr);
}
MetaModel *myModel =
new MetaModel("meta", workingDir, "meta", modelName);
myModel->setTodo(todo);
//if not all clients have valid commandlines -> exit metamodel
// if(!myModel->checkCommandLines())
// myModel->setTodo(EXIT);
if(OLMsg::GetErrorNum()) myModel->setTodo(EXIT);
if( myModel->isTodo(ANALYZE)){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment