Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

nsd.c File Reference

#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <assert.h>
#include <string.h>
#include <openedf.h>
#include <nsnet.h>
#include <nsutil.h>
#include <config.h>
#include <neuro/cmdhandler.h>
#include "nsd.h"

Go to the source code of this file.

Data Structures

struct  Client

Defines

#define MAXEDFCHANNELS   64
#define TIMEOUT   30

Enumerations

enum  RoleCode { Unknown, EEG, Display, Controller }

Functions

const char * stringifyRole (enum RoleCode role)
int countInRole (enum RoleCode role)
void sendClientMsg (int cliInd, const char *msg)
void sendClientMsgNL (int cliInd, const char *msg)
const char * getLineBuf (void)
void sendResponseOK (int cliInd)
void sendResponseBadRequest (int cliInd)
void cmdgo (struct CommandHandler *ch, int cliInd)
void cmdnogo (struct CommandHandler *ch, int cliInd)
void cmdRole (struct CommandHandler *ch, int cliInd)
void cmdUnwatch (struct CommandHandler *ch, int cliInd)
void cmdWatch (struct CommandHandler *ch, int cliInd)
void cmdDataFrame (struct CommandHandler *ch, int cliInd)
void cmdGetHeader (struct CommandHandler *ch, int cliInd)
void cmdSetHeader (struct CommandHandler *ch, int cliInd)
void cmdStatus (struct CommandHandler *ch, int cliInd)
void cmdClose (struct CommandHandler *ch, int cliInd)
void cmdDisplay (struct CommandHandler *ch, int cliInd)
void cmdEEG (struct CommandHandler *ch, int cliInd)
void cmdControl (struct CommandHandler *ch, int cliInd)
void cmdHello (struct CommandHandler *ch, int cliInd)
int makeNewClient (struct CommandHandler *ch, sock_t fd)
int main ()

Variables

EDFDecodedConfig current
Client clients [MAXCLIENTS]
int clientCount = 0


Define Documentation

#define MAXEDFCHANNELS   64
 

Definition at line 40 of file nsd.c.

Referenced by cmdDataFrame().

#define TIMEOUT   30
 

Definition at line 42 of file nsd.c.

Referenced by main().


Enumeration Type Documentation

enum RoleCode
 

Enumeration values:
Unknown 
EEG 
Display 
Controller 

Definition at line 44 of file nsd.c.


Function Documentation

void cmdClose struct CommandHandler ch,
int  cliInd
 

Definition at line 272 of file nsd.c.

References clients, Client::markedForDeletion, and sendResponseOK().

Referenced by main().

void cmdControl struct CommandHandler ch,
int  cliInd
 

Definition at line 298 of file nsd.c.

References clients, Controller, countInRole(), Client::role, sendResponseBadRequest(), sendResponseOK(), and Unknown.

Referenced by main().

void cmdDataFrame struct CommandHandler ch,
int  cliInd
 

Definition at line 191 of file nsd.c.

References buf, clientCount, clients, fetchIntParameters(), Client::isDisplaying, MAXEDFCHANNELS, MAXLEN, samples, sendClientMsg(), sendResponseBadRequest(), and sendResponseOK().

Referenced by main().

void cmdDisplay struct CommandHandler ch,
int  cliInd
 

Definition at line 278 of file nsd.c.

References clients, Display, Client::role, sendResponseBadRequest(), sendResponseOK(), and Unknown.

Referenced by main().

void cmdEEG struct CommandHandler ch,
int  cliInd
 

Definition at line 288 of file nsd.c.

References clients, EEG, Client::role, sendResponseBadRequest(), sendResponseOK(), and Unknown.

Referenced by main().

void cmdGetHeader struct CommandHandler ch,
int  cliInd
 

Definition at line 224 of file nsd.c.

References clientCount, clients, Display, EEG, fetchIntParameters(), Client::headerLen, Client::role, sendClientMsgNL(), sendResponseBadRequest(), and sendResponseOK().

Referenced by main().

void cmdgo struct CommandHandler ch,
int  cliInd
 

command for Controllers: start go trial

go 0 activates a go trial (for event related potentials) in EEG device 0

Definition at line 122 of file nsd.c.

References clientCount, clients, Controller, EEG, fetchIntParameters(), Client::role, rprintf(), sendClientMsgNL(), sendResponseBadRequest(), and sendResponseOK().

Referenced by main().

void cmdHello struct CommandHandler ch,
int  cliInd
 

Definition at line 308 of file nsd.c.

References sendResponseOK().

Referenced by main().

void cmdnogo struct CommandHandler ch,
int  cliInd
 

Definition at line 137 of file nsd.c.

References clientCount, clients, Controller, EEG, fetchIntParameters(), Client::role, rprintf(), sendClientMsgNL(), sendResponseBadRequest(), and sendResponseOK().

Referenced by main().

void cmdRole struct CommandHandler ch,
int  cliInd
 

Definition at line 155 of file nsd.c.

References clients, rprintf(), sendClientMsgNL(), sendResponseOK(), and stringifyRole().

Referenced by main().

void cmdSetHeader struct CommandHandler ch,
int  cliInd
 

Definition at line 238 of file nsd.c.

References buf, clients, current, EEG, getLineBuf(), Client::headerBuf, Client::headerLen, makeREDFConfig(), readEDFString(), Client::role, rprintf(), sendResponseBadRequest(), sendResponseOK(), and writeEDFString().

Referenced by main().

void cmdStatus struct CommandHandler ch,
int  cliInd
 

Definition at line 261 of file nsd.c.

References buf, clientCount, clients, sendClientMsg(), sendResponseOK(), and stringifyRole().

Referenced by main().

void cmdUnwatch struct CommandHandler ch,
int  cliInd
 

Definition at line 162 of file nsd.c.

References clientCount, clients, Display, EEG, fetchIntParameters(), Client::isDisplaying, Client::role, sendResponseBadRequest(), and sendResponseOK().

Referenced by main().

void cmdWatch struct CommandHandler ch,
int  cliInd
 

Definition at line 177 of file nsd.c.

References clientCount, clients, Display, EEG, fetchIntParameters(), Client::isDisplaying, Client::role, sendResponseBadRequest(), and sendResponseOK().

Referenced by main().

int countInRole enum RoleCode  role  ) 
 

Definition at line 313 of file nsd.c.

References clientCount, clients, and Client::role.

Referenced by cmdControl().

const char* getLineBuf void   ) 
 

Definition at line 78 of file nsd.c.

References lineBuf.

Referenced by cmdSetHeader().

int main  ) 
 

Definition at line 359 of file nsd.c.

References clientCount, clients, cmdClose(), cmdControl(), cmdDataFrame(), cmdDisplay(), cmdEEG(), cmdGetHeader(), cmdgo(), cmdHello(), cmdnogo(), cmdRole(), cmdSetHeader(), cmdStatus(), cmdUnwatch(), cmdWatch(), DEFAULTPORT, Display, EEG, enregisterCommand(), handleLine(), ib, inputBufferEmpty(), Client::isDisplaying, isEOF(), Client::lastAlive, Client::lineBuf, lineBuf, Client::linePos, linePos, makeNewClient(), Client::markedForDeletion, max_fd, MAXLEN, my_read(), newCommandHandler(), OSTYPESTR, raccept(), rbindAll(), rexit(), rinitNetworking(), Client::role, rprintf(), rselect(), rshutdown(), rsocket(), rtime(), sock_fd, sock_t, TIMEOUT, and updateMaxFd().

int makeNewClient struct CommandHandler ch,
sock_t  fd
 

Definition at line 343 of file nsd.c.

References clientCount, clients, Client::fd, Client::headerLen, ib, initInputBuffer(), initOutputBuffer(), Client::linePos, Client::markedForDeletion, newClientStarted(), ob, Client::role, rtime(), and Unknown.

Referenced by main().

void sendClientMsg int  cliInd,
const char *  msg
 

Definition at line 83 of file nsd.c.

References clients, Client::markedForDeletion, ob, rprintf(), rtime(), and writen().

Referenced by cmdDataFrame(), cmdStatus(), sendClientMsgNL(), sendResponseBadRequest(), and sendResponseOK().

void sendClientMsgNL int  cliInd,
const char *  msg
 

Definition at line 72 of file nsd.c.

References sendClientMsg().

Referenced by cmdGetHeader(), cmdgo(), cmdnogo(), and cmdRole().

void sendResponseBadRequest int  cliInd  ) 
 

Definition at line 111 of file nsd.c.

References sendClientMsg().

Referenced by cmdControl(), cmdDataFrame(), cmdDisplay(), cmdEEG(), cmdGetHeader(), cmdgo(), cmdnogo(), cmdSetHeader(), cmdUnwatch(), and cmdWatch().

void sendResponseOK int  cliInd  ) 
 

Definition at line 105 of file nsd.c.

References sendClientMsg().

Referenced by cmdClose(), cmdControl(), cmdDataFrame(), cmdDisplay(), cmdEEG(), cmdGetHeader(), cmdgo(), cmdHello(), cmdnogo(), cmdRole(), cmdSetHeader(), cmdStatus(), cmdUnwatch(), and cmdWatch().

const char * stringifyRole enum RoleCode  role  ) 
 

Definition at line 322 of file nsd.c.

References Controller, Display, EEG, and Unknown.

Referenced by cmdRole(), and cmdStatus().


Variable Documentation

int clientCount = 0
 

Definition at line 65 of file nsd.c.

Referenced by cmdDataFrame(), cmdGetHeader(), cmdgo(), cmdnogo(), cmdStatus(), cmdUnwatch(), cmdWatch(), countInRole(), main(), and makeNewClient().

struct Client clients[MAXCLIENTS]
 

Definition at line 64 of file nsd.c.

Referenced by cmdClose(), cmdControl(), cmdDataFrame(), cmdDisplay(), cmdEEG(), cmdGetHeader(), cmdgo(), cmdnogo(), cmdRole(), cmdSetHeader(), cmdStatus(), cmdUnwatch(), cmdWatch(), countInRole(), main(), makeNewClient(), and sendClientMsg().

struct EDFDecodedConfig current
 

Definition at line 46 of file nsd.c.

Referenced by cmdSetHeader(), and main().


Generated on Tue Feb 8 00:05:18 2005 for Neuroserver by doxygen 1.3.3