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

more remote tests

parent 8fed36a8
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
#include <sstream> #include <sstream>
#include "GmshMessage.h" #include "GmshMessage.h"
#include "OS.h"
#include "GmshSocket.h" #include "GmshSocket.h"
#include "OpenFile.h"
#include "OS.h"
#include "PView.h" #include "PView.h"
#include "PViewOptions.h" #include "PViewOptions.h"
#include "PViewData.h" #include "PViewData.h"
...@@ -80,6 +81,14 @@ int GmshDaemon(std::string socket) ...@@ -80,6 +81,14 @@ int GmshDaemon(std::string socket)
else if(type == GmshSocket::GMSH_VERTEX_ARRAY){ else if(type == GmshSocket::GMSH_VERTEX_ARRAY){
computeAndSendVertexArrays(client); computeAndSendVertexArrays(client);
} }
else if(type == GmshSocket::GMSH_MERGE_FILE){
MergeFile(msg);
computeAndSendVertexArrays(client);
}
else if(type == GmshSocket::GMSH_PARSE_STRING){
ParseString(msg);
computeAndSendVertexArrays(client);
}
else if(type == GmshSocket::GMSH_SPEED_TEST){ else if(type == GmshSocket::GMSH_SPEED_TEST){
client.Info("Sending huge array"); client.Info("Sending huge array");
std::string huge(500000000, 'a'); std::string huge(500000000, 'a');
...@@ -88,6 +97,8 @@ int GmshDaemon(std::string socket) ...@@ -88,6 +97,8 @@ int GmshDaemon(std::string socket)
else{ else{
client.Error("Ignoring unknown message"); client.Error("Ignoring unknown message");
} }
delete [] msg;
} }
client.Info("Remote Gmsh is stopped"); client.Info("Remote Gmsh is stopped");
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <FL/Fl_Box.H> #include <FL/Fl_Box.H>
#include <FL/fl_ask.H>
#include "GmshConfig.h" #include "GmshConfig.h"
#include "GmshMessage.h" #include "GmshMessage.h"
#include "GmshRemote.h" #include "GmshRemote.h"
...@@ -148,28 +149,42 @@ static void file_clear_cb(Fl_Widget *w, void *data) ...@@ -148,28 +149,42 @@ static void file_clear_cb(Fl_Widget *w, void *data)
static void file_remote_cb(Fl_Widget *w, void *data) static void file_remote_cb(Fl_Widget *w, void *data)
{ {
GmshServer *server = GmshRemote::get(99)->getServer();
std::string str((const char*)data); std::string str((const char*)data);
if(str == "start"){ if(str == "start"){
Msg::Info("Starting remote Gmsh server"); if(server){
if(GmshRemote::get(99)->getServer()){
Msg::Error("A server is already running"); Msg::Error("A server is already running");
return;
} }
else{
GmshRemote::get(99)->name = "Remote"; GmshRemote::get(99)->name = "Remote";
GmshRemote::get(99)->socketSwitch = "-socket %s"; GmshRemote::get(99)->socketSwitch = "-socket %s";
GmshRemote::get(99)->executable = connectionChooser(); GmshRemote::get(99)->executable = connectionChooser();
if(GmshRemote::get(99)->executable.size()) if(GmshRemote::get(99)->executable.size())
GmshRemote::get(99)->run(""); GmshRemote::get(99)->run("");
} }
else{
if(!server){
Msg::Error("Cannot %s: server not running", str.c_str());
return;
}
if(str == "stop"){
server->SendString(GmshSocket::GMSH_STOP, "Disconnect!");
} }
else if(str == "stop"){ else if(str == "merge"){
if(GmshRemote::get(99)->getServer()){ const char *file = fl_input("File:", "~/data/res00.pos");
GmshRemote::get(99)->getServer()->SendString if(file) server->SendString(GmshSocket::GMSH_MERGE_FILE, file);
(GmshSocket::GMSH_STOP, "Disconnect!");
} }
else{ else if(str == "clear"){
Msg::Error("Cannot stop remote Gmsh: server not running"); server->SendString(GmshSocket::GMSH_PARSE_STRING, "Delete All;");
for(int i = PView::list.size() - 1; i >= 0; i--)
if(PView::list[i]->getData()->isRemote()) delete PView::list[i];
FlGui::instance()->updateViews();
drawContext::global()->draw();
}
else if(str == "test"){
server->SendString(GmshSocket::GMSH_SPEED_TEST, "Test connection speed");
} }
} }
} }
...@@ -2163,8 +2178,6 @@ static void view_applybgmesh_cb(Fl_Widget *w, void *data) ...@@ -2163,8 +2178,6 @@ static void view_applybgmesh_cb(Fl_Widget *w, void *data)
} }
} }
#define TEST_SERVER
// The static menus (we cannot use the 'g', 'm' 's' and 'p' mnemonics // The static menus (we cannot use the 'g', 'm' 's' and 'p' mnemonics
// since they are already defined as global shortcuts) // since they are already defined as global shortcuts)
static Fl_Menu_Item bar_table[] = { static Fl_Menu_Item bar_table[] = {
...@@ -2173,16 +2186,19 @@ static Fl_Menu_Item bar_table[] = { ...@@ -2173,16 +2186,19 @@ static Fl_Menu_Item bar_table[] = {
{"&Open...", FL_CTRL+'o', (Fl_Callback *)file_open_cb, 0}, {"&Open...", FL_CTRL+'o', (Fl_Callback *)file_open_cb, 0},
{"M&erge...", FL_CTRL+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0}, {"M&erge...", FL_CTRL+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0},
{"&Clear", 0, (Fl_Callback *)file_clear_cb, 0, FL_MENU_DIVIDER}, {"&Clear", 0, (Fl_Callback *)file_clear_cb, 0, FL_MENU_DIVIDER},
{"Remote", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU},
{"Start...", 0, (Fl_Callback *)file_remote_cb, (void*)"start"},
{"Merge...", 0, (Fl_Callback *)file_remote_cb, (void*)"merge"},
{"Clear", 0, (Fl_Callback *)file_remote_cb, (void*)"clear"},
{"Test Connection Speed", 0, (Fl_Callback *)file_remote_cb, (void*)"test"},
{"Stop", 0, (Fl_Callback *)file_remote_cb, (void*)"stop"},
{0},
{"New Window", 0, (Fl_Callback *)file_window_cb, (void*)"new"}, {"New Window", 0, (Fl_Callback *)file_window_cb, (void*)"new"},
{"Split Window", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU}, {"Split Window", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU},
{"Horizontally", 0, (Fl_Callback *)file_window_cb, (void*)"split_h"}, {"Horizontally", 0, (Fl_Callback *)file_window_cb, (void*)"split_h"},
{"Vertically", 0, (Fl_Callback *)file_window_cb, (void*)"split_v"}, {"Vertically", 0, (Fl_Callback *)file_window_cb, (void*)"split_v"},
{"Clear", 0, (Fl_Callback *)file_window_cb, (void*)"split_u"}, {"Clear", 0, (Fl_Callback *)file_window_cb, (void*)"split_u"},
{0}, {0},
#if defined(TEST_SERVER)
{"Start Remote Gmsh...", 0, (Fl_Callback *)file_remote_cb, (void*)"start"},
{"Stop Remote Gmsh", 0, (Fl_Callback *)file_remote_cb, (void*)"stop", FL_MENU_DIVIDER},
#endif
{"&Rename...", FL_CTRL+'r', (Fl_Callback *)file_rename_cb, 0}, {"&Rename...", FL_CTRL+'r', (Fl_Callback *)file_rename_cb, 0},
{"Save &As...", FL_CTRL+'s', (Fl_Callback *)file_save_as_cb, 0}, {"Save &As...", FL_CTRL+'s', (Fl_Callback *)file_save_as_cb, 0},
{"Sa&ve Mesh", FL_CTRL+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0}, {"Sa&ve Mesh", FL_CTRL+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0},
...@@ -2221,16 +2237,19 @@ static Fl_Menu_Item sysbar_table[] = { ...@@ -2221,16 +2237,19 @@ static Fl_Menu_Item sysbar_table[] = {
{"Open...", FL_META+'o', (Fl_Callback *)file_open_cb, 0}, {"Open...", FL_META+'o', (Fl_Callback *)file_open_cb, 0},
{"Merge...", FL_META+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0}, {"Merge...", FL_META+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0},
{"Clear", 0, (Fl_Callback *)file_clear_cb, 0, FL_MENU_DIVIDER}, {"Clear", 0, (Fl_Callback *)file_clear_cb, 0, FL_MENU_DIVIDER},
{"Remote", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU},
{"Start...", 0, (Fl_Callback *)file_remote_cb, (void*)"start"},
{"Merge...", 0, (Fl_Callback *)file_remote_cb, (void*)"merge"},
{"Clear", 0, (Fl_Callback *)file_remote_cb, (void*)"clear"},
{"Test Connection Speed", 0, (Fl_Callback *)file_remote_cb, (void*)"test"},
{"Stop", 0, (Fl_Callback *)file_remote_cb, (void*)"stop"},
{0},
{"New Window", 0, (Fl_Callback *)file_window_cb, (void*)"new"}, {"New Window", 0, (Fl_Callback *)file_window_cb, (void*)"new"},
{"Split Window", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU}, {"Split Window", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU},
{"Horizontally", 0, (Fl_Callback *)file_window_cb, (void*)"split_h"}, {"Horizontally", 0, (Fl_Callback *)file_window_cb, (void*)"split_h"},
{"Vertically", 0, (Fl_Callback *)file_window_cb, (void*)"split_v"}, {"Vertically", 0, (Fl_Callback *)file_window_cb, (void*)"split_v"},
{"Clear", 0, (Fl_Callback *)file_window_cb, (void*)"split_u"}, {"Clear", 0, (Fl_Callback *)file_window_cb, (void*)"split_u"},
{0}, {0},
#if defined(TEST_SERVER)
{"Start Remote Gmsh...", 0, (Fl_Callback *)file_remote_cb, (void*)"start"},
{"Stop Remote Gmsh", 0, (Fl_Callback *)file_remote_cb, (void*)"stop", FL_MENU_DIVIDER},
#endif
{"Rename...", FL_META+'r', (Fl_Callback *)file_rename_cb, 0}, {"Rename...", FL_META+'r', (Fl_Callback *)file_rename_cb, 0},
{"Save As...", FL_META+'s', (Fl_Callback *)file_save_as_cb, 0}, {"Save As...", FL_META+'s', (Fl_Callback *)file_save_as_cb, 0},
{"Save Mesh", FL_META+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0}, {"Save Mesh", FL_META+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0},
......
This diff is collapsed.
...@@ -2130,10 +2130,7 @@ Delete : ...@@ -2130,10 +2130,7 @@ Delete :
| tDelete tSTRING tEND | tDelete tSTRING tEND
{ {
if(!strcmp($2, "Meshes") || !strcmp($2, "All")){ if(!strcmp($2, "Meshes") || !strcmp($2, "All")){
for(unsigned int i = 0; i < GModel::list.size(); i++){ ClearProject();
GModel::list[i]->destroy();
GModel::list[i]->getGEOInternals()->destroy();
}
} }
else if(!strcmp($2, "Model")){ else if(!strcmp($2, "Model")){
GModel::current()->destroy(); GModel::current()->destroy();
......
...@@ -198,6 +198,7 @@ class PViewData { ...@@ -198,6 +198,7 @@ class PViewData {
virtual bool combineSpace(nameData &nd); virtual bool combineSpace(nameData &nd);
// ask to fill vertex arrays remotely // ask to fill vertex arrays remotely
virtual bool isRemote(){ return false; }
virtual int fillRemoteVertexArrays(){ return 0; } virtual int fillRemoteVertexArrays(){ return 0; }
// I/O routines // I/O routines
......
...@@ -55,6 +55,7 @@ class PViewDataRemote : public PViewData { ...@@ -55,6 +55,7 @@ class PViewDataRemote : public PViewData {
if(step >= (int)_time.size()) _time.resize(step + 1); if(step >= (int)_time.size()) _time.resize(step + 1);
_time[step] = time; _time[step] = time;
} }
bool isRemote(){ return true; }
int fillRemoteVertexArrays() int fillRemoteVertexArrays()
{ {
GmshServer *server = _remote->getServer(); GmshServer *server = _remote->getServer();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment