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

- rename CLIENT_VIEW into CLIENT_MERGE_FILE
- new CLIENT_PARSE_STRING
parent b430cbf7
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,8 @@ class GmshServer {
CLIENT_WARNING = 11,
CLIENT_ERROR = 12,
CLIENT_PROGRESS = 13,
CLIENT_VIEW = 20,
CLIENT_MERGE_FILE = 20, // old name: CLIENT_VIEW
CLIENT_PARSE_STRING = 21,
CLIENT_OPTION_1 = 100,
CLIENT_OPTION_2 = 101,
CLIENT_OPTION_3 = 102,
......@@ -226,6 +227,21 @@ class GmshServer {
}
return 0;
}
int ReceiveMessageHeader(int *type, int *len)
{
_ReceiveData(type, sizeof(int));
if(_ReceiveData(len, sizeof(int)))
return 1;
return 0;
}
int ReceiveMessageBody(int len, char *str)
{
if(_ReceiveData(str, len) == len) {
str[len] = '\0';
return 1;
}
return 0;
}
int StopClient()
{
if(_portno < 0){
......
// $Id: Solvers.cpp,v 1.43 2006-02-22 17:25:03 geuzaine Exp $
// $Id: Solvers.cpp,v 1.44 2006-02-23 21:59:08 geuzaine Exp $
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
......@@ -89,7 +89,7 @@ int WaitForData(int socket, int num, int pollint, double waitint)
int Solver(int num, char *args)
{
char command[1024], sockname[1024], str[1024], prog[1024], buf[1024];
char command[1024], sockname[1024], prog[1024], tmp[1024], tmp2[1024];
new_connection:
......@@ -119,18 +119,18 @@ int Solver(int num, char *args)
if(!strstr(CTX.solver.socket_name, ":")){
// file socket
if(num >= 0)
sprintf(str, "%s%s-%d", CTX.home_dir, CTX.solver.socket_name, num);
sprintf(tmp, "%s%s-%d", CTX.home_dir, CTX.solver.socket_name, num);
else
sprintf(str, "%s%s", CTX.home_dir, CTX.solver.socket_name);
FixWindowsPath(str, sockname);
sprintf(tmp, "%s%s", CTX.home_dir, CTX.solver.socket_name);
FixWindowsPath(tmp, sockname);
}
else
strcpy(sockname, CTX.solver.socket_name);
if(num >= 0){
sprintf(str, "\"%s\"", sockname);
sprintf(buf, SINFO[num].socket_command, str);
sprintf(command, "%s %s %s", prog, args, buf);
sprintf(tmp, "\"%s\"", sockname);
sprintf(tmp2, SINFO[num].socket_command, tmp);
sprintf(command, "%s %s %s", prog, args, tmp2);
#if !defined(WIN32)
strcat(command, " &");
#endif
......@@ -182,12 +182,14 @@ int Solver(int num, char *args)
if(stop || (num >= 0 && SINFO[num].pid < 0))
break;
int type;
if(server.ReceiveString(&type, str)){
int type, length;
if(server.ReceiveMessageHeader(&type, &length)){
char *message = new char[length+1];
if(server.ReceiveMessageBody(length, message)){
switch (type) {
case GmshServer::CLIENT_START:
if(num >= 0)
SINFO[num].pid = atoi(str);
SINFO[num].pid = atoi(message);
break;
case GmshServer::CLIENT_STOP:
stop = 1;
......@@ -196,56 +198,67 @@ int Solver(int num, char *args)
break;
case GmshServer::CLIENT_PROGRESS:
if(num >= 0)
Msg(STATUS3N, "%s %s", SINFO[num].name, str);
Msg(STATUS3N, "%s %s", SINFO[num].name, message);
else
Msg(STATUS3N, "%s", str);
Msg(STATUS3N, "%s", message);
break;
case GmshServer::CLIENT_OPTION_1:
if(num >= 0)
strcpy(SINFO[num].option[0][SINFO[num].nbval[0]++], str);
strcpy(SINFO[num].option[0][SINFO[num].nbval[0]++], message);
break;
case GmshServer::CLIENT_OPTION_2:
if(num >= 0)
strcpy(SINFO[num].option[1][SINFO[num].nbval[1]++], str);
strcpy(SINFO[num].option[1][SINFO[num].nbval[1]++], message);
break;
case GmshServer::CLIENT_OPTION_3:
if(num >= 0)
strcpy(SINFO[num].option[2][SINFO[num].nbval[2]++], str);
strcpy(SINFO[num].option[2][SINFO[num].nbval[2]++], message);
break;
case GmshServer::CLIENT_OPTION_4:
if(num >= 0)
strcpy(SINFO[num].option[3][SINFO[num].nbval[3]++], str);
strcpy(SINFO[num].option[3][SINFO[num].nbval[3]++], message);
break;
case GmshServer::CLIENT_OPTION_5:
if(num >= 0)
strcpy(SINFO[num].option[4][SINFO[num].nbval[4]++], str);
strcpy(SINFO[num].option[4][SINFO[num].nbval[4]++], message);
break;
case GmshServer::CLIENT_VIEW:
case GmshServer::CLIENT_MERGE_FILE:
printf("merging %s\n", message);
if(num < 0 || (num >= 0 && SINFO[num].merge_views)) {
int n = List_Nbr(CTX.post.list);
MergeProblem(str);
MergeProblem(message);
Draw();
if(n != List_Nbr(CTX.post.list))
WID->set_context(menu_post, 0);
}
break;
case GmshServer::CLIENT_PARSE_STRING:
ParseString(message);
Draw();
break;
case GmshServer::CLIENT_INFO:
Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", str);
Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message);
break;
case GmshServer::CLIENT_WARNING:
case GmshServer::CLIENT_ERROR:
Msg(SOLVERR, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", str);
Msg(SOLVERR, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message);
break;
default:
Msg(WARNING, "Unknown type of message received from %s",
num >= 0 ? SINFO[num].name : "client");
Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", str);
Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message);
break;
}
WID->check();
}
else{
Msg(WARNING, "Failed to received data on socket: arborting");
Msg(WARNING, "Failed to receive message body on socket: arborting");
break;
}
delete [] message;
}
else{
// didn't get any header, just abort
break;
}
}
......
// $Id: OpenFile.cpp,v 1.88 2006-01-28 04:50:36 geuzaine Exp $
// $Id: OpenFile.cpp,v 1.89 2006-02-23 21:59:08 geuzaine Exp $
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
......@@ -214,7 +214,8 @@ void ParseString(char *str)
if(!str)
return;
if((fp = fopen(CTX.tmp_filename_fullpath, "w"))) {
fprintf(fp, "%s\n", str);
fprintf(fp, str);
fprintf(fp, "\n");
fclose(fp);
ParseFile(CTX.tmp_filename_fullpath, 0, 1);
}
......
......@@ -59,7 +59,8 @@ class GmshClient {
CLIENT_WARNING = 11,
CLIENT_ERROR = 12,
CLIENT_PROGRESS = 13,
CLIENT_VIEW = 20,
CLIENT_MERGE_FILE = 20, // old name was CLIENT_VIEW
CLIENT_PARSE_STRING = 21,
CLIENT_OPTION_1 = 100,
CLIENT_OPTION_2 = 101,
CLIENT_OPTION_3 = 102,
......@@ -195,7 +196,16 @@ class GmshClient {
}
void View(char *str)
{
_SendString(CLIENT_VIEW, str);
// deprecated: use MergeFile(str) instead
_SendString(CLIENT_MERGE_FILE, str);
}
void MergeFile(char *str)
{
_SendString(CLIENT_MERGE_FILE, str);
}
void ParseString(char *str)
{
_SendString(CLIENT_PARSE_STRING, str);
}
void Option(int num, char *str)
{
......
// $Id: solver.cpp,v 1.6 2005-03-12 07:52:56 geuzaine Exp $
// $Id: solver.cpp,v 1.7 2006-02-23 21:59:08 geuzaine Exp $
//
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
//
......@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
fprintf(file, "SP(%d,0,0){%g};\n", j,sin(j*i*M_PI/10.));
fprintf(file, "};\n");
fclose(file);
client.View("solver.pos");
client.MergeFile("solver.pos");
}
}
client.Info("Done!");
......
......@@ -35,7 +35,9 @@
#define GMSH_CLIENT_WARNING 11
#define GMSH_CLIENT_ERROR 12
#define GMSH_CLIENT_PROGRESS 13
#define GMSH_CLIENT_VIEW 20
#define GMSH_CLIENT_VIEW 20 /* deprecated: use MERGE_FILE instead */
#define GMSH_CLIENT_MERGE_FILE 20
#define GMSH_CLIENT_PARSE_STRING 21
#define GMSH_CLIENT_OPTION 100
#define GMSH_CLIENT_OPTION_1 (GMSH_CLIENT_OPTION+0)
#define GMSH_CLIENT_OPTION_2 (GMSH_CLIENT_OPTION+1)
......@@ -47,4 +49,5 @@ int Gmsh_Connect(char *sockname);
void Gmsh_SendString(int socket, int type, char str[]);
void Gmsh_Disconnect(int sock);
#endif
/* $Id: solver.c,v 1.2 2005-01-17 18:52:49 geuzaine Exp $ */
/* $Id: solver.c,v 1.3 2006-02-23 21:59:08 geuzaine Exp $ */
/*
* Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
*
......@@ -193,7 +193,7 @@ int main(int argc, char *argv[])
fprintf(file, "ST(0,0,0,1,0,0,0,1,0){0,1,2};\n");
fprintf(file, "};\n");
fclose(file);
Gmsh_SendString(s, GMSH_CLIENT_VIEW, "solver.pos");
Gmsh_SendString(s, GMSH_CLIENT_MERGE_FILE, "solver.pos");
}
break;
}
......
# $Id: GMSH_CLIENT.pm,v 1.2 2005-01-16 20:41:42 geuzaine Exp $
# $Id: GMSH_CLIENT.pm,v 1.3 2006-02-23 21:59:09 geuzaine Exp $
#
# Copyright (c) 2002 Laurent CHAMPANEY <laurent.champaney@meca.uvsq.fr>.
# All rights reserved.
......@@ -14,7 +14,9 @@ $INFO = 10;
$WARNING = 11;
$ERROR = 12;
$PROGRESS = 13;
$VIEW = 20;
$VIEW = 20; # deprecated: use MERGE_FILE instead
$MERGE_FILE = 20;
$PARSE_STRING = 21;
$OPTION = 100;
$OPTION_1 = ($OPTION+0);
$OPTION_2 = ($OPTION+1);
......
#!/usr/bin/perl
#
# $Id: solver.pl,v 1.2 2005-01-17 18:52:49 geuzaine Exp $
# $Id: solver.pl,v 1.3 2006-02-23 21:59:09 geuzaine Exp $
#
# Copyright (c) 2002 Laurent CHAMPANEY <laurent.champaney@meca.uvsq.fr>.
#
......@@ -92,7 +92,7 @@ if ($opt_run) {
print POSFIC "ST(0,0,0,1,0,0,0,1,0){0,1,2};\n";
print POSFIC "};\n";
close POSFIC;
GMSH_CLIENT::SendString(CLIENT, $GMSH_CLIENT::VIEW, "solver.pos");
GMSH_CLIENT::SendString(CLIENT, $GMSH_CLIENT::MERGE_FILE, "solver.pos");
};
#
# 3.3. We can now disconnect the solver from Gmsh:
......
......@@ -32,7 +32,9 @@ INFO = 10
WARNING = 11
ERROR = 12
PROGRESS = 13
VIEW = 20
VIEW = 20 # deprecated: use MERGE_FILE instead
MERGE_FILE = 20
PARSE_STRING = 21
OPTION = 100
OPTION_1 = OPTION + 0
OPTION_2 = OPTION + 1
......@@ -72,8 +74,8 @@ def send(message, type=INFO):
type -- the type of message being sent (default INFO)
As of Gmsh version 1.56, type should be one of:
START STOP INFO WARNING ERROR PROGRESS VIEW OPTION
OPTION_1 OPTION_2 OPTION_3 OPTION_4 OPTION_5
START STOP INFO WARNING ERROR PROGRESS MERGE_FILE PARSE_FILE
OPTION OPTION_1 OPTION_2 OPTION_3 OPTION_4 OPTION_5
If no socket has been opened (using a Gmsh.Client instance) then print the
string sys.stderr.
......
......@@ -305,4 +305,4 @@ else:
else:
pmesh.makeviews(posfile)
posfile.close()
Gmsh.send(posfile.name, Gmsh.VIEW)
Gmsh.send(posfile.name, Gmsh.MERGE_FILE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment