diff options
author | jshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178> | 2000-10-09 23:02:27 +0000 |
---|---|---|
committer | jshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178> | 2000-10-09 23:02:27 +0000 |
commit | 6e58da114dfe3b00df6a3a307dcc140d547c06d8 (patch) | |
tree | 672083fa3572a42398dea678efabf2ba1ca4e8a6 /src | |
parent | 52dbed6e928d2882b0c0f7005a0e269755dea5a2 (diff) |
Now we have steering too.
I'm not really doing a sufficient amount of checking on the steering,
but it works as long as you send "properly formed" commands. I'll
do a pass on error-checking/correcting after I get IsoView updated
in CVS.
So now the C-version of the isosurfacer does pretty much everything
that the C++ version does (aside from depending on external modules
for communication/steering that is).
I left the HDF5 remote sending commented out. However, since the
HDF5 stream is in fact also written in C, it should be able to
work. If someone wants to just check the arguments on that as
well as the #defines to enable it, that should work as well.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@11 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
Diffstat (limited to 'src')
-rw-r--r-- | src/IsoSurfacer.c | 10 | ||||
-rw-r--r-- | src/IsoSurfacerGH.h | 11 | ||||
-rw-r--r-- | src/Sockets.c | 56 |
3 files changed, 64 insertions, 13 deletions
diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c index d761ada..b81edfc 100644 --- a/src/IsoSurfacer.c +++ b/src/IsoSurfacer.c @@ -58,6 +58,7 @@ static void WriteHDF5(cGH *GH, polypatch *totals, isosurfacerGH *myGH, /***************************************************************************/ static int IsoSurfacerHandleCommands(cGH *GH) { + IsoCommand command; isosurfacerGH *myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; /* Grab all events that are waiting in queue */ @@ -108,6 +109,15 @@ static int IsoSurfacerHandleCommands(cGH *GH) /* puts("Nuthin to do (yet)"); */ /* Here it just needs to read from the control socket and then change the isosurface appropriately */ + IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd); + + if(Iso_PollCommand(GH,&command)){ +#ifdef VERBOSE + printf("+++++++++Process Command [%s] [%s] [%s]\n", + command.cmd.object,command.cmd.target,command.cmd.value); +#endif + myGH->isovalue=atof(command.cmd.value); /* steer it. */ + } return 0; } diff --git a/src/IsoSurfacerGH.h b/src/IsoSurfacerGH.h index ac299e7..943cf7c 100644 --- a/src/IsoSurfacerGH.h +++ b/src/IsoSurfacerGH.h @@ -14,6 +14,17 @@ surfacer to run without output for benchmarking purposes */ +typedef struct CmdSet { + char object[64]; + char target[64]; + char value[64]; +} CmdSet; + +typedef union IsoCommand { + char buffer[64+64+64]; + CmdSet cmd; +} IsoCommand; + typedef struct polypatch { CCTK_REAL4 *verts; diff --git a/src/Sockets.c b/src/Sockets.c index fea3c92..322b628 100644 --- a/src/Sockets.c +++ b/src/Sockets.c @@ -71,6 +71,7 @@ CCTK_FILEVERSION(DevThorns_isosurfacer_Socket_c) #define MSG_NOSIGNAL 0 #endif + typedef enum {closed, open} isoSocketState; typedef struct ISOSocket @@ -85,6 +86,7 @@ typedef struct ISOSocket ********************* Local Routine Prototypes ********************* ********************************************************************/ +IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd); int Iso_Write(isoSocket *connection, const char *buffer, size_t count); static SOCKET Iso_MakeSocket (unsigned long port, int *hunt); @@ -95,7 +97,7 @@ static void SocketClose(isoSocket *this); static int InitialiseTCP(void); -static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this); +static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this,IsoCommand *cmd); /******************************************************************** ********************* Other Routine Prototypes ********************* @@ -342,22 +344,46 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec) SocketCreate(new, &controlsocklist); } + + return 0; +} + +IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd){ +#ifdef HAVE_SOCKLEN_T + socklen_t size; +#else + int size; +#endif + fd_set read_fd_set; + struct sockaddr_in clientname; + struct timeval timeout; + struct timeval *real_timeout; + + isoSocket *this; + isoSocket *next; + /* always a timeout of 0 */ + timeout.tv_sec = 0; + timeout.tv_usec = 0; + real_timeout = &timeout; - for(this = controlsocklist; this; this = next) - { - next = this->next; - if(FD_ISSET (this->filedes, &read_fd_set)) - { + /* Check if any input is available on one or more active sockets. */ + read_fd_set = active_fd_set; + + if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))){ + perror ("select"); + CCTK_Abort(cctkGH, EXIT_FAILURE); + } + /* get next command on the control socket list */ + for(this = controlsocklist; this; this = this->next){ + if(FD_ISSET (this->filedes, &read_fd_set)){ /* Data arriving on an already-connected socket. */ - if (Iso_ReadFromClient (cctkGH, this) < 0) - { - SocketDestroy(this, &controlsocklist); + if (Iso_Read (this, cmd->buffer,64+64+64) <= 0){ + SocketDestroy(this, &controlsocklist); } + else return cmd; /* return immediately with the new command (first available) */ } } - - - return 0; + return NULL; } int IsoWriteDataToClients(const char *metadata, @@ -801,8 +827,12 @@ static void SocketClose(isoSocket *this) @endhistory @@*/ -static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this) +static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this,IsoCommand *command) { + /* Need to have 64+64+64 buffer here (datastruct) + put the buffer in a union. + */ + return -1; } |