Main Page | Namespace List | Alphabetical List | Class List | Directories | File List | Class Members | File Members

TCPSynchronizedClient Class Reference

#include <TCPSynchronizedClient.h>

List of all members.

Public Member Functions

 TCPSynchronizedClient (unsigned int neurGrpWidth, unsigned int neurGrpLength)
 ~TCPSynchronizedClient ()
bool closeDevice ()
bool deviceOpen ()
bool fetchData ()
bool openSocket (string groupAddress, int port)
void setTwoByteCoords (bool)

Public Attributes

unsigned int spikeCount
unsigned int * spikeBuffer
int socketHandle
sockaddr_in externalDevAddr
bool socketConnected

Private Member Functions

 TCPSynchronizedClient (const TCPSynchronizedClient &)
TCPSynchronizedClient operator= (const TCPSynchronizedClient &)
void printMessageBuffer (unsigned char *msgBuf, unsigned int msgBufSize)

Private Attributes

unsigned int neuronGrpWidth
unsigned int neuronGrpLength
unsigned char * msgBuffer
bool socketOpen
unsigned char requestDataMsgArray [1]
bool twoByteCoordinates


Detailed Description

Client that requests data from an external device using TCP This client blocks until it receives the data.

Definition at line 43 of file TCPSynchronizedClient.h.


Constructor & Destructor Documentation

TCPSynchronizedClient::TCPSynchronizedClient unsigned int  neurGrpWidth,
unsigned int  neurGrpLength
 

Constructor.

Definition at line 63 of file TCPSynchronizedClient.cpp.

References MESSAGE_BUFFER_SIZE, msgBuffer, neuronGrpLength, neuronGrpWidth, requestDataMsgArray, socketOpen, SPIKE_BUFFER_SIZE, spikeBuffer, spikeCount, and twoByteCoordinates.

TCPSynchronizedClient::~TCPSynchronizedClient  ) 
 

Destructor.

Definition at line 85 of file TCPSynchronizedClient.cpp.

References closeDevice(), msgBuffer, and spikeBuffer.

TCPSynchronizedClient::TCPSynchronizedClient const TCPSynchronizedClient  )  [private]
 

Declare copy constructor private so it cannot be used inadvertently.


Member Function Documentation

bool TCPSynchronizedClient::closeDevice  ) 
 

Closes the socket.

Definition at line 104 of file TCPSynchronizedClient.cpp.

References socketHandle, and socketOpen.

Referenced by DeviceManager::closeDevice(), and ~TCPSynchronizedClient().

bool TCPSynchronizedClient::deviceOpen  ) 
 

Returns true if the socket is open.

Definition at line 114 of file TCPSynchronizedClient.cpp.

References socketOpen.

bool TCPSynchronizedClient::fetchData  ) 
 

Waits for a message containing data from the external device and unpacks the data.

Definition at line 120 of file TCPSynchronizedClient.cpp.

References msgBuffer, neuronGrpLength, neuronGrpWidth, printMessageBuffer(), requestDataMsgArray, socketHandle, socketOpen, spikeBuffer, spikeCount, SpikeStreamSimulation::systemError(), and twoByteCoordinates.

Referenced by DeviceManager::fetchData().

bool TCPSynchronizedClient::openSocket string  externalDeviceIPAddr,
int  externalDevicePort
 

Opens the TCP socket. The connection to the socket is handled by a separate thread so that a failed connection can be timed out. Adapated from: http://cs.baylor.edu/~donahoo/practical/CSockets/textcode.html.

Definition at line 277 of file TCPSynchronizedClient.cpp.

References externalDevAddr, socketConnected, socketHandle, socketOpen, startTCPClientConnectThread(), and SpikeStreamSimulation::systemError().

Referenced by DeviceManager::loadDeviceInformation().

TCPSynchronizedClient TCPSynchronizedClient::operator= const TCPSynchronizedClient  )  [private]
 

Declare assignment private so it cannot be used.

void TCPSynchronizedClient::printMessageBuffer unsigned char *  msgBuffer,
unsigned int  msgBufSize
[private]
 

Prints out the message buffer received from the external device for debugging.

Definition at line 342 of file TCPSynchronizedClient.cpp.

Referenced by fetchData().

void TCPSynchronizedClient::setTwoByteCoords bool  twoBtCds  ) 
 

Vision data is potentially larger than 255, so need to use two bytes to encode the coordinates within a vision map, which replaces the timing information.

Definition at line 331 of file TCPSynchronizedClient.cpp.

References twoByteCoordinates.

Referenced by DeviceManager::loadDeviceInformation().


Member Data Documentation

struct sockaddr_in TCPSynchronizedClient::externalDevAddr
 

Address of the socket.

Definition at line 66 of file TCPSynchronizedClient.h.

Referenced by openSocket(), and startTCPClientConnectThread().

unsigned char* TCPSynchronizedClient::msgBuffer [private]
 

Buffer to unpack message into.

Definition at line 80 of file TCPSynchronizedClient.h.

Referenced by fetchData(), TCPSynchronizedClient(), and ~TCPSynchronizedClient().

unsigned int TCPSynchronizedClient::neuronGrpLength [private]
 

Neuron group length.

Definition at line 77 of file TCPSynchronizedClient.h.

Referenced by fetchData(), and TCPSynchronizedClient().

unsigned int TCPSynchronizedClient::neuronGrpWidth [private]
 

Neuron group width.

Definition at line 74 of file TCPSynchronizedClient.h.

Referenced by fetchData(), and TCPSynchronizedClient().

unsigned char TCPSynchronizedClient::requestDataMsgArray[1] [private]
 

Array holding the request for data from the device. This is sent to the device to request the data.

Definition at line 87 of file TCPSynchronizedClient.h.

Referenced by fetchData(), and TCPSynchronizedClient().

bool TCPSynchronizedClient::socketConnected
 

Records whether socket has been successfully connected.

Definition at line 69 of file TCPSynchronizedClient.h.

Referenced by openSocket(), and startTCPClientConnectThread().

int TCPSynchronizedClient::socketHandle
 

Integer used to access the socket.

Definition at line 63 of file TCPSynchronizedClient.h.

Referenced by closeDevice(), fetchData(), openSocket(), and startTCPClientConnectThread().

bool TCPSynchronizedClient::socketOpen [private]
 

Records whether the socket has been opened.

Definition at line 83 of file TCPSynchronizedClient.h.

Referenced by closeDevice(), deviceOpen(), fetchData(), openSocket(), and TCPSynchronizedClient().

unsigned int* TCPSynchronizedClient::spikeBuffer
 

Holds the spikes that have been received from the network.

Definition at line 60 of file TCPSynchronizedClient.h.

Referenced by fetchData(), DeviceManager::fillDeviceBuffer(), TCPSynchronizedClient(), and ~TCPSynchronizedClient().

unsigned int TCPSynchronizedClient::spikeCount
 

Holds the number of spikes in the spike buffer.

Definition at line 57 of file TCPSynchronizedClient.h.

Referenced by fetchData(), DeviceManager::fillDeviceBuffer(), and TCPSynchronizedClient().

bool TCPSynchronizedClient::twoByteCoordinates [private]
 

Vision coordinates are too big to fit in a single byte. Set this to true when it is a vision connection.

Definition at line 91 of file TCPSynchronizedClient.h.

Referenced by fetchData(), setTwoByteCoords(), and TCPSynchronizedClient().


The documentation for this class was generated from the following files:
Generated on Mon Sep 3 22:24:34 2007 for SpikeStream Simulation by  doxygen 1.4.4