aboutsummaryrefslogtreecommitdiff
path: root/src/Server.c
diff options
context:
space:
mode:
authorgoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-16 20:10:28 +0000
committergoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-16 20:10:28 +0000
commit5a7d5ee4c0831d666233535ae8856684310c69ba (patch)
tree06cf1048e853380e00b8d6ce0565a72fd923cf08 /src/Server.c
parent26bf3412fc4693fc7d61598a542b66e375353abc (diff)
Added ability to pause and terminate the simulation.
Also can select how many iterations between steering events. Can now start simulation as 'standalone' twiddle with parameters, then start the simulation, pause it, and kill it. Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@31 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Server.c')
-rw-r--r--src/Server.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/Server.c b/src/Server.c
index 9bf56f7..dc9aaca 100644
--- a/src/Server.c
+++ b/src/Server.c
@@ -212,6 +212,113 @@ int HTTP_Write(httpRequest *request, const char *buffer, size_t count)
return retval;
}
+ /*@@
+ @routine HTTP_UpdateState
+ @date Sat Sep 16 21:12:23 2000
+ @author Tom Goodale
+ @desc
+ Updates the state of the server from the latest parameter values.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int HTTP_UpdateState(cGH *cctkGH, httpState *state)
+{
+ int type;
+ CCTK_INT *value;
+
+ static int steering = 1;
+ static int last_steered = -1;
+
+ value = (CCTK_INT *)CCTK_ParameterGet("pause",CCTK_THORNSTRING, &type);
+
+ state->paused = *value;
+
+ if(cctkGH && ! state->paused)
+ {
+ if(steering)
+ {
+ value = (CCTK_INT *)CCTK_ParameterGet("steering_frequency",CCTK_THORNSTRING, &type);
+
+ if(*value > 0 &&
+ *value+last_steered <= cctkGH->cctk_iteration)
+ {
+ /* Time to steer */
+ state->steer = 1;
+ last_steered = cctkGH->cctk_iteration;
+ }
+ else
+ {
+ state->steer = 0;
+ }
+
+ if(*value <= 0)
+ {
+ /* Once steering is switched off, can't restart it ! */
+ steering = 0;
+ }
+ }
+ }
+ else
+ {
+ state->steer = 1;
+ }
+
+
+
+ value = (CCTK_INT *)CCTK_ParameterGet("terminate",CCTK_THORNSTRING, &type);
+
+ state->terminate = *value;
+
+ value = (CCTK_INT *)CCTK_ParameterGet("standalone",CCTK_THORNSTRING, &type);
+
+ state->standalone = *value;
+
+ if(!state->paused)
+ {
+
+ value = (CCTK_INT *)CCTK_ParameterGet("timeout_seconds",CCTK_THORNSTRING, &type);
+
+ state->timeout_seconds = *value;
+
+ value = (CCTK_INT *)CCTK_ParameterGet("timeout_useconds",CCTK_THORNSTRING, &type);
+
+ state->timeout_useconds = *value;
+ }
+ else
+ {
+ state->timeout_seconds = -1;
+ state->timeout_useconds = -1;
+ }
+
+ return 0;
+}
+
+ /*@@
+ @routine HTTP_Terminate
+ @date Sat Sep 16 21:40:27 2000
+ @author Tom Goodale
+ @desc
+ Terminate the simulation.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int HTTP_Terminate(cGH *cctkGH)
+{
+ CCTK_Exit(cctkGH, 0);
+
+ return 0;
+}
+
/********************************************************************
********************* Local Routines *************************
********************************************************************/