Patrick Wensing / ExperimentServer

Dependents:   Bezier_Trajectory_Follower Dolphin 2_131TEST Jerby ... more

Embed: (wiki syntax)

« Back to documentation index

ExperimentServer Class Reference

ExperimentServer Class Reference

Experiment Server. More...

#include <ExperimentServer.h>

Public Member Functions

 ExperimentServer ()
 Constructor.
void attachTerminal (Serial &terminal)
 Link a serial terminal to the server for debugging purposes.
void init ()
 Initialize the server.
void init (const char *addr, const char *subnet, const char *gateway, unsigned int port)
 Initialize the server with supplied configuration.
int getParams (float params[], int num_params)
 Listen for parameters passed to the server.
void sendData (float data_output[], int data_size)
 Send data back to host machine.
void setExperimentComplete ()
 Inform the host that the experiment is complete.

Detailed Description

Experiment Server.

Definition at line 10 of file ExperimentServer.h.


Constructor & Destructor Documentation

Constructor.

Constructs an empty experiment server. Server objects require additional initialization before being used. Constructs an empty experiment server. Server objects require further initialization before use.

Definition at line 4 of file ExperimentServer.cpp.


Member Function Documentation

void attachTerminal ( Serial &  terminal )

Link a serial terminal to the server for debugging purposes.

Parameters:
terminalSerial terminal to be used for debugging messages

Definition at line 9 of file ExperimentServer.cpp.

int getParams ( float  params[],
int  num_params 
)

Listen for parameters passed to the server.

This operation blocks until any data is recieved.

Parameters:
paramsFloat array of size num_params used to store incoming data
num_paramsExpected length of incoming data (# of floats)
Returns:
Success of the operation (0 - Failure, 1 - Success) The operation is considered failure if the correct number of floats is not recieved.

Definition at line 61 of file ExperimentServer.cpp.

void init (  )

Initialize the server.

Following initialization, the getParams, sendData, and setExperimentComplete methods may be used.

Applies default server configuration with ip 192.168.1.100, subnet 255.255.255.0, gateway 192.168.1.1, port 11223.

Definition at line 13 of file ExperimentServer.cpp.

void init ( const char *  addr,
const char *  subnet,
const char *  gateway,
unsigned int  port 
)

Initialize the server with supplied configuration.

Following initialization, the getParams, sendData, and setExperimentComplete methods may be used.

Parameters:
addrIP address of the server
subnetSubnet mask of the IP address
gatewayGateway/router IP address
portPort to listen on for connections from MATLAB.

Definition at line 22 of file ExperimentServer.cpp.

void sendData ( float  data_output[],
int  data_size 
)

Send data back to host machine.

To alleviate the processing burden on the host machine, data is actually buffered on the chip and sent to the host in batches.

Parameters:
data_outputFloat array of size data_size containing data to send to host
data_sizeLength of outgoing data (# of floats)

Definition at line 99 of file ExperimentServer.cpp.

void setExperimentComplete (  )

Inform the host that the experiment is complete.

This function also sends any final buffered output data that has yet to be relayed to the host.

Definition at line 107 of file ExperimentServer.cpp.