Skip to content
Snippets Groups Projects
Commit 702d1956 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Enforce that we have a single network client at the time in the onelabWindow.

parent 9717446b
No related branches found
No related tags found
No related merge requests found
...@@ -118,15 +118,11 @@ bool onelab::localNetworkClient::run() ...@@ -118,15 +118,11 @@ bool onelab::localNetworkClient::run()
std::string action = (ps.empty() ? "" : ps[0].getValue()); std::string action = (ps.empty() ? "" : ps[0].getValue());
get(ps, getName() + "/1ModelName"); get(ps, getName() + "/1ModelName");
std::string modelName = (ps.empty() ? "" : ps[0].getValue()); std::string modelName = (ps.empty() ? "" : ps[0].getValue());
get(ps, getName() + "/9InitializeCommand");
std::string initializeCommand = (ps.empty() ? "" : ps[0].getValue());
get(ps, getName() + "/9CheckCommand"); get(ps, getName() + "/9CheckCommand");
std::string checkCommand = (ps.empty() ? "" : ps[0].getValue()); std::string checkCommand = (ps.empty() ? "" : ps[0].getValue());
get(ps, getName() + "/9ComputeCommand"); get(ps, getName() + "/9ComputeCommand");
std::string computeCommand = (ps.empty() ? "" : ps[0].getValue()); std::string computeCommand = (ps.empty() ? "" : ps[0].getValue());
if(action == "initialize") if(action == "check")
command += " " + modelName + " " + initializeCommand;
else if(action == "check")
command += " " + modelName + " " + checkCommand; command += " " + modelName + " " + checkCommand;
else if(action == "compute") else if(action == "compute")
command += " " + modelName + " " + computeCommand; command += " " + modelName + " " + computeCommand;
...@@ -1021,15 +1017,31 @@ void onelabWindow::rebuildSolverList() ...@@ -1021,15 +1017,31 @@ void onelabWindow::rebuildSolverList()
void onelabWindow::addSolver(const std::string &name, const std::string &commandLine, void onelabWindow::addSolver(const std::string &name, const std::string &commandLine,
int index) int index)
{ {
onelab::server::citer it = onelab::server::instance()->findClient(name); if(onelab::server::instance()->findClient(name) !=
if(it == onelab::server::instance()->lastClient()){ onelab::server::instance()->lastClient()) return; // solver already exists
onelab::localNetworkClient *c = new onelab::localNetworkClient(name, commandLine);
c->setIndex(index); // unregister the other non-local clients so we keep only the new one
opt_solver_name(index, GMSH_SET, name); std::vector<onelab::client*> networkClients;
if(commandLine.empty()) for(onelab::server::citer it = onelab::server::instance()->firstClient();
onelab_choose_executable_cb(0, (void *)c); it != onelab::server::instance()->lastClient(); it++)
if(it->second->isNetworkClient())
networkClients.push_back(it->second);
for(unsigned int i = 0; i < networkClients.size(); i++){
onelab::server::instance()->unregisterClient(networkClients[i]);
delete networkClients[i];
} }
// create and register the new client
onelab::localNetworkClient *c = new onelab::localNetworkClient(name, commandLine);
c->setIndex(index);
opt_solver_name(index, GMSH_SET, name);
if(commandLine.empty())
onelab_choose_executable_cb(0, (void *)c);
FlGui::instance()->onelab->rebuildSolverList(); FlGui::instance()->onelab->rebuildSolverList();
// initialize the client
onelab_cb(0, (void*)"initialize");
} }
void onelabWindow::removeSolver(const std::string &name) void onelabWindow::removeSolver(const std::string &name)
...@@ -1054,18 +1066,9 @@ void solver_cb(Fl_Widget *w, void *data) ...@@ -1054,18 +1066,9 @@ void solver_cb(Fl_Widget *w, void *data)
int num = (intptr_t)data; int num = (intptr_t)data;
if(num >= 0){ if(num >= 0){
// unregister all non-local clients
for(onelab::server::citer it = onelab::server::instance()->firstClient();
it != onelab::server::instance()->lastClient(); it++){
onelab::client *c = it->second;
if(c->isNetworkClient())
onelab::server::instance()->unregisterClient(c);
}
// register new client
std::string name = opt_solver_name(num, GMSH_GET, ""); std::string name = opt_solver_name(num, GMSH_GET, "");
std::string exe = opt_solver_executable(num, GMSH_GET, ""); std::string exe = opt_solver_executable(num, GMSH_GET, "");
FlGui::instance()->onelab->addSolver(name, exe, num); FlGui::instance()->onelab->addSolver(name, exe, num);
onelab_cb(0, (void*)"initialize");
} }
else else
FlGui::instance()->onelab->rebuildSolverList(); FlGui::instance()->onelab->rebuildSolverList();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment