Exemplo n.º 1
0
void solver_cb(Fl_Widget *w, void *data)
{
  if(!FlGui::instance()->onelab) return;

  if(FlGui::instance()->onelab->isBusy())
    FlGui::instance()->onelab->show();

  int num = (intptr_t)data;
  if(num >= 0){
    onelab_cb(0, (void*)"reset");
    std::string name = opt_solver_name(num, GMSH_GET, "");
    if(name.empty()) return;// TODO
    std::string exe = opt_solver_executable(num, GMSH_GET, "");
    std::string host = opt_solver_remote_login(num, GMSH_GET, "");
    OnelabDatabase::instance()->run("initialize", name);
    FlGui::instance()->onelab->addSolver(name, exe, host, num);
  }

  if(num >= 0) {
    onelab_cb(0, (void*)"check");
  }
  else {
    onelab_cb(0, (void*)"refresh");
  }
  FlGui::instance()->onelab->updateGearMenu();
}
Exemplo n.º 2
0
void drawContext::load(std::string filename)
{
  if(locked) return;

  // delete all models and post-processing views
  GmshClearProject();

  // reset onelab database
  onelab::server::instance()->clear();

  // restore default options
  GmshRestoreDefaultOptions();

  // output messages on console
  GmshSetOption("General", "Terminal", 1.0);

  // open the file with Gmsh
  GmshOpenProject(filename);

  // reset openGL view
  eventHandler(10);

  // run onelab clients to populate the database
  onelab_cb("check");

  // mark all parameters as changed to force complete first run
  onelab::server::instance()->setChanged(true);
}
Exemplo n.º 3
0
static void autoCheck(const T &pold, const T &pnew, bool force=false)
{
  if(onelabUtils::getFirstComputationFlag()){
    if(pold.getValue() != pnew.getValue())
      onelabUtils::setFirstComputationFlag(false);
  }

  if((CTX::instance()->solver.autoCheck && pnew.getAttribute("AutoCheck") != "0") ||
     pnew.getAttribute("AutoCheck") == "1"){
    if(force || pold.getValue() != pnew.getValue())
      onelab_cb(0, (void*)"check");
  }
}
Exemplo n.º 4
0
  int NonBlockingWait(double waitint, double timeout, int socket)
  {
    double start = GetTimeInSeconds();
    while(1){
      if(timeout > 0 && GetTimeInSeconds() - start > timeout)
        return 2; // timeout
      if(_client->getPid() < 0 || (_client->getExecutable().empty() &&
                                   !CTX::instance()->solver.listen))
        return 1; // process has been killed or we stopped listening
      // check if there is data (call select with a zero timeout to
      // return immediately, i.e., do polling)
      int ret = Select(0, 0, socket);
      if(ret == 0){ // nothing available
        if(timeout < 0){
          // if asked, refresh the onelab GUI, but no more than every 1/4th of
          // a second
          static double lastRefresh = 0.;
          if(start - lastRefresh > 0.25){
            std::vector<onelab::string> ps;
            onelab::server::instance()->get(ps, "Gmsh/Action");
            if(ps.size() && ps[0].getValue() == "refresh"){
              ps[0].setVisible(false);
              ps[0].setValue("");
              onelab::server::instance()->set(ps[0]);
#if defined(HAVE_FLTK)
              if(FlGui::available()) onelab_cb(0, (void*)"refresh");
#endif
            }
            lastRefresh = start;
          }
        }
        // wait at most waitint seconds and respond to FLTK events
#if defined(HAVE_FLTK)
        if(FlGui::available()) FlGui::instance()->wait(waitint);
#endif
        // return to caller (we will be back here soon again)
	if(timeout < 0) return 3;
      }
      else if(ret > 0){
        return 0; // data is there!
      }
      else{
        // an error happened
        _client->setPid(-1);
        return 1;
      }
    }
  }
Exemplo n.º 5
0
 JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_onelabCB
 (JNIEnv *env, jobject obj, jstring jaction)
 {
   const char*  action = env->GetStringUTFChars(jaction, NULL);
   return onelab_cb(action);
 }