Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
3d436aa8
Commit
3d436aa8
authored
12 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
arbitrary depth subclients
parent
141d25dd
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Fltk/gmshLocalNetworkClient.h
+21
-2
21 additions, 2 deletions
Fltk/gmshLocalNetworkClient.h
Fltk/onelabGroup.cpp
+28
-20
28 additions, 20 deletions
Fltk/onelabGroup.cpp
with
49 additions
and
22 deletions
Fltk/gmshLocalNetworkClient.h
+
21
−
2
View file @
3d436aa8
...
...
@@ -16,13 +16,24 @@ class gmshLocalNetworkClient : public onelab::localNetworkClient{
// metamodel that calls several underlying models); _clients keeps track of
// the master (this) and the subclients.
std
::
vector
<
gmshLocalNetworkClient
*>
_clients
;
// client that launched this one (with GMSH_CONNECT); _father is zero for the
// master client (the one created by Gmsh).
gmshLocalNetworkClient
*
_father
;
public:
gmshLocalNetworkClient
(
const
std
::
string
&
name
,
const
std
::
string
&
executable
,
const
std
::
string
&
remoteLogin
=
""
)
:
onelab
::
localNetworkClient
(
name
,
executable
,
remoteLogin
)
:
onelab
::
localNetworkClient
(
name
,
executable
,
remoteLogin
)
,
_father
(
0
)
{
addClient
(
this
);
}
void
setFather
(
gmshLocalNetworkClient
*
father
)
{
_father
=
father
;
}
gmshLocalNetworkClient
*
getFather
()
{
return
_father
;
}
void
addClient
(
gmshLocalNetworkClient
*
client
)
{
_clients
.
push_back
(
client
);
...
...
@@ -39,7 +50,15 @@ class gmshLocalNetworkClient : public onelab::localNetworkClient{
if
(
i
>=
0
&&
i
<
getNumClients
())
return
_clients
[
i
];
return
0
;
}
bool
receiveMessage
(
int
&
type
);
int
getNumConnectedClients
()
{
int
n
=
0
;
for
(
int
i
=
0
;
i
<
getNumClients
();
i
++
){
if
(
_clients
[
i
]
->
getPid
()
!=
-
1
)
n
++
;
}
return
n
;
}
bool
receiveMessage
(
gmshLocalNetworkClient
*
master
);
bool
run
();
bool
kill
();
};
...
...
This diff is collapsed.
Click to expand it.
Fltk/onelabGroup.cpp
+
28
−
20
View file @
3d436aa8
...
...
@@ -145,8 +145,11 @@ class onelabGmshServer : public GmshServer{
}
};
bool
gmshLocalNetworkClient
::
receiveMessage
(
int
&
type
)
bool
gmshLocalNetworkClient
::
receiveMessage
(
gmshLocalNetworkClient
*
master
)
{
// receive a message on the associated GmshServer; 'master' is only used when
// creating subclients with GMSH_CONNECT.
double
timer
=
GetTimeInSeconds
();
if
(
!
getGmshServer
()){
...
...
@@ -154,11 +157,13 @@ bool gmshLocalNetworkClient::receiveMessage(int &type)
return
false
;
}
int
length
,
swap
;
int
type
,
length
,
swap
;
if
(
!
getGmshServer
()
->
ReceiveHeader
(
&
type
,
&
length
,
&
swap
)){
Msg
::
Error
(
"Abnormal server termination (did not receive message header)"
);
return
false
;
}
else
if
(
false
)
// debug
std
::
cout
<<
"Client "
<<
getName
()
<<
" receives header: "
<<
type
<<
std
::
endl
;
std
::
string
message
(
length
,
' '
);
if
(
!
getGmshServer
()
->
ReceiveMessage
(
length
,
&
message
[
0
])){
...
...
@@ -172,6 +177,11 @@ bool gmshLocalNetworkClient::receiveMessage(int &type)
break
;
case
GmshSocket
::
GMSH_STOP
:
setPid
(
-
1
);
if
(
getFather
()){
std
::
string
reply
=
getName
();
// reply is dummy
getFather
()
->
getGmshServer
()
->
SendMessage
(
GmshSocket
::
GMSH_STOP
,
reply
.
size
(),
&
reply
[
0
]);
}
break
;
case
GmshSocket
::
GMSH_PARAMETER
:
{
...
...
@@ -333,12 +343,13 @@ bool gmshLocalNetworkClient::receiveMessage(int &type)
if
(
sock
<
0
){
// could not establish the connection: aborting
server
->
Shutdown
();
delete
server
;
Msg
::
Error
(
"Could not connect client '%s'
...
"
,
subClient
->
getName
().
c_str
());
Msg
::
Error
(
"Could not connect client '%s'"
,
subClient
->
getName
().
c_str
());
}
else
{
Msg
::
StatusBar
(
true
,
"Running '%s'..."
,
subClient
->
getName
().
c_str
());
subClient
->
setGmshServer
(
server
);
addClient
(
subClient
);
subClient
->
setFather
(
this
);
master
->
addClient
(
subClient
);
}
}
break
;
...
...
@@ -428,21 +439,13 @@ bool gmshLocalNetworkClient::run()
}
}
}
// break the while(1) if the master client has stopped or if we encountered
// a problem
if
(
stop
)
break
;
// if data is available try to get the message from the corresponding
// client; break the while(1) if we could not receive the message
int
type
=
0
;
if
(
haveData
&&
!
c
->
receiveMessage
(
type
))
break
;
// if the client is a subclient and it stopped, notify the master
if
((
c
!=
this
)
&&
(
type
==
GmshSocket
::
GMSH_STOP
)){
std
::
string
reply
=
c
->
getName
();
getGmshServer
()
->
SendMessage
(
GmshSocket
::
GMSH_STOP
,
reply
.
size
(),
&
reply
[
0
]);
}
if
(
haveData
&&
!
c
->
receiveMessage
(
this
))
break
;
// break the while(1) if the master client has stopped
if
(
c
==
this
&&
c
->
getPid
()
<
0
)
break
;
...
...
@@ -452,10 +455,12 @@ bool gmshLocalNetworkClient::run()
// subclients, if any. The servers are not deleted upon GMSH_STOP in
// receiveMessage() to make sure we always delete them, even when the
// disconnect was not clean.
std
::
vector
<
gmshLocalNetworkClient
*>
toDelete
;
for
(
int
i
=
0
;
i
<
getNumClients
();
i
++
){
gmshLocalNetworkClient
*
c
=
getClient
(
i
);
GmshServer
*
s
=
c
->
getGmshServer
();
c
->
setGmshServer
(
0
);
c
->
setFather
(
0
);
if
(
s
){
s
->
Shutdown
();
delete
s
;
...
...
@@ -463,9 +468,12 @@ bool gmshLocalNetworkClient::run()
if
(
c
!=
this
){
if
(
c
->
getPid
()
>
0
)
Msg
::
Error
(
"Subclient %s was not stopped correctly"
,
c
->
getName
().
c_str
());
removeClient
(
c
);
delete
c
;
toDelete
.
push_back
(
c
);
}
}
for
(
unsigned
int
i
=
0
;
i
<
toDelete
.
size
();
i
++
){
removeClient
(
toDelete
[
i
]);
delete
toDelete
[
i
];
}
Msg
::
StatusBar
(
true
,
"Done running '%s'"
,
_name
.
c_str
());
...
...
@@ -1166,7 +1174,7 @@ static void onelab_number_output_range_cb(Fl_Widget *w, void *data)
Fl_Widget
*
onelabGroup
::
_addParameterWidget
(
onelab
::
number
&
p
,
Fl_Tree_Item
*
n
,
bool
highlight
,
Fl_Color
c
)
{
n
->
labelsize
(
FL_NORMAL_SIZE
+
5
);
n
->
labelsize
(
FL_NORMAL_SIZE
+
4
);
int
ww
=
_baseWidth
-
(
n
->
depth
()
+
1
)
*
_indent
;
ww
/=
2
;
...
...
@@ -1354,7 +1362,7 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, Fl_Tree_Item *n,
}
ww
/=
2
;
n
->
labelsize
(
FL_NORMAL_SIZE
+
5
);
n
->
labelsize
(
FL_NORMAL_SIZE
+
4
);
// non-editable value
if
(
p
.
getReadOnly
()){
...
...
@@ -1432,7 +1440,7 @@ static void onelab_region_input_cb(Fl_Widget *w, void *data)
Fl_Widget
*
onelabGroup
::
_addParameterWidget
(
onelab
::
region
&
p
,
Fl_Tree_Item
*
n
,
bool
highlight
,
Fl_Color
c
)
{
n
->
labelsize
(
FL_NORMAL_SIZE
+
5
);
n
->
labelsize
(
FL_NORMAL_SIZE
+
4
);
int
ww
=
_baseWidth
-
(
n
->
depth
()
+
1
)
*
_indent
;
ww
/=
2
;
...
...
@@ -1456,7 +1464,7 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::region &p, Fl_Tree_Item *n,
Fl_Widget
*
onelabGroup
::
_addParameterWidget
(
onelab
::
function
&
p
,
Fl_Tree_Item
*
n
,
bool
highlight
,
Fl_Color
c
)
{
n
->
labelsize
(
FL_NORMAL_SIZE
+
5
);
n
->
labelsize
(
FL_NORMAL_SIZE
+
4
);
int
ww
=
_baseWidth
-
(
n
->
depth
()
+
1
)
*
_indent
;
ww
/=
2
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment