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

UDPSynchronizedClient Class Reference

#include <UDPSynchronizedClient.h>

List of all members.

Public Member Functions

 UDPSynchronizedClient (unsigned int neurGrpWidth, unsigned int neurGrpLength)
 ~UDPSynchronizedClient ()
bool clientThreadRunning ()
bool closeDevice ()
bool deviceOpen ()
unsigned int getExternalComputeTime_us ()
bool getExternalSyncDelay ()
void lockMutex ()
bool openSocket (string groupAddress, int port)
void run ()
void start ()
void stop ()
void unlockMutex ()

Public Attributes

unsigned int spikeCount
unsigned int * spikeBuffer

Private Member Functions

 UDPSynchronizedClient (const UDPSynchronizedClient &)
UDPSynchronizedClient operator= (const UDPSynchronizedClient &)

Private Attributes

unsigned int neuronGrpWidth
unsigned int neuronGrpLength
bool threadRunning
bool socketOpen
pthread_t clientThread
bool externalSyncDelay
unsigned int externalComputeTime_us
unsigned int timeStepsNoMessagesCount
int socketHandle
sockaddr_in socketAddress
unsigned char * messageBuffer


Detailed Description

Thread that listens for incoming UDP messages and calculates the update time between them to enable the simulation to change its update rate to match that of the external device.

Definition at line 38 of file UDPSynchronizedClient.h.


Constructor & Destructor Documentation

UDPSynchronizedClient::UDPSynchronizedClient unsigned int  neurGrpWidth,
unsigned int  neurGrpLength
 

Constructor.

Definition at line 70 of file UDPSynchronizedClient.cpp.

References externalComputeTime_us, externalSyncDelay, MESSAGE_BUFFER_SIZE, messageBuffer, neuronGrpLength, neuronGrpWidth, socketOpen, SPIKE_BUFFER_SIZE, spikeBuffer, spikeCount, threadRunning, and timeStepsNoMessagesCount.

UDPSynchronizedClient::~UDPSynchronizedClient  ) 
 

Destructor.

Definition at line 92 of file UDPSynchronizedClient.cpp.

References closeDevice(), messageBuffer, and spikeBuffer.

UDPSynchronizedClient::UDPSynchronizedClient const UDPSynchronizedClient  )  [private]
 

Declare copy constructor private so it cannot be used inadvertently.


Member Function Documentation

bool UDPSynchronizedClient::clientThreadRunning  ) 
 

Returns true if the thread is still in its run method and in the state of receiving UDP data.

Definition at line 112 of file UDPSynchronizedClient.cpp.

References threadRunning.

Referenced by DeviceManager::fetchData().

bool UDPSynchronizedClient::closeDevice  ) 
 

Closes the socket and/or stops the thread.

Definition at line 118 of file UDPSynchronizedClient.cpp.

References clientThread, socketHandle, socketOpen, SpikeStreamSimulation::systemError(), SpikeStreamSimulation::systemInfo(), and threadRunning.

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

bool UDPSynchronizedClient::deviceOpen  ) 
 

Returns true if socket is open or thread is running.

Definition at line 147 of file UDPSynchronizedClient.cpp.

References socketOpen, and threadRunning.

unsigned int UDPSynchronizedClient::getExternalComputeTime_us  ) 
 

This method is called at each time step to get the current external compute time. It increases a counter each time it is called which is used to increase the external compute time in the absence of any messages from the other processes, up to a maximum. This prevents the external compute time remaining at a low value when there is no external input.

Definition at line 160 of file UDPSynchronizedClient.cpp.

References externalComputeTime_us, MAX_EXTERNAL_COMPUTE_TIME_US, and timeStepsNoMessagesCount.

Referenced by DeviceManager::getExternalComputeTime_us().

bool UDPSynchronizedClient::getExternalSyncDelay  ) 
 

Returns true if the external device is delaying itself.

Definition at line 175 of file UDPSynchronizedClient.cpp.

References externalSyncDelay.

Referenced by DeviceManager::getExternalSyncDelay().

void UDPSynchronizedClient::lockMutex  ) 
 

Used by external class to lock this thread's mutex and prevent it accessing shared data.

Definition at line 182 of file UDPSynchronizedClient.cpp.

References threadMutex.

Referenced by DeviceManager::fillDeviceBuffer().

bool UDPSynchronizedClient::openSocket string  groupAddress,
int  port
 

Opens a socket to receive spikes Adapted from http://ntrg.cs.tcd.ie/undergrad/4ba2/multicast/antony/index.html.

Definition at line 189 of file UDPSynchronizedClient.cpp.

References socketHandle, socketOpen, and SpikeStreamSimulation::systemError().

Referenced by DeviceManager::loadDeviceInformation().

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

Declare assignment private so it cannot be used.

void UDPSynchronizedClient::run  ) 
 

Run method for this class, called by the thread that is started.

Definition at line 247 of file UDPSynchronizedClient.cpp.

References externalComputeTime_us, externalSyncDelay, MESSAGE_BUFFER_SIZE, messageBuffer, neuronGrpLength, neuronGrpWidth, socketAddress, socketHandle, socketOpen, SPIKE_BUFFER_SIZE, spikeBuffer, spikeCount, STEP_COUNTER_MAX, SpikeStreamSimulation::systemError(), SpikeStreamSimulation::systemInfo(), threadMutex, threadRunning, and timeStepsNoMessagesCount.

void UDPSynchronizedClient::start  ) 
 

Starts the thread running and listening for messages.

Definition at line 399 of file UDPSynchronizedClient.cpp.

References clientThread, startThreadFunction(), SpikeStreamSimulation::systemError(), and threadRunning.

Referenced by DeviceManager::loadDeviceInformation().

void UDPSynchronizedClient::stop  ) 
 

Stops the thread from running.

Definition at line 412 of file UDPSynchronizedClient.cpp.

References threadRunning.

void UDPSynchronizedClient::unlockMutex  ) 
 

Used by external applications to unlock the thread's mutex.

Definition at line 418 of file UDPSynchronizedClient.cpp.

References threadMutex.

Referenced by DeviceManager::fillDeviceBuffer().


Member Data Documentation

pthread_t UDPSynchronizedClient::clientThread [private]
 

Thread to listen for incoming packets from broadcast group.

Definition at line 80 of file UDPSynchronizedClient.h.

Referenced by closeDevice(), and start().

unsigned int UDPSynchronizedClient::externalComputeTime_us [private]
 

Compute time of external device.

Definition at line 86 of file UDPSynchronizedClient.h.

Referenced by getExternalComputeTime_us(), run(), and UDPSynchronizedClient().

bool UDPSynchronizedClient::externalSyncDelay [private]
 

External device is delaying its time steps.

Definition at line 83 of file UDPSynchronizedClient.h.

Referenced by getExternalSyncDelay(), run(), and UDPSynchronizedClient().

unsigned char* UDPSynchronizedClient::messageBuffer [private]
 

Buffer used to receive messages from the network.

Definition at line 99 of file UDPSynchronizedClient.h.

Referenced by run(), UDPSynchronizedClient(), and ~UDPSynchronizedClient().

unsigned int UDPSynchronizedClient::neuronGrpLength [private]
 

The first ID in the neuron group.

Definition at line 71 of file UDPSynchronizedClient.h.

Referenced by run(), and UDPSynchronizedClient().

unsigned int UDPSynchronizedClient::neuronGrpWidth [private]
 

Neuron group width.

Definition at line 68 of file UDPSynchronizedClient.h.

Referenced by run(), and UDPSynchronizedClient().

struct sockaddr_in UDPSynchronizedClient::socketAddress [private]
 

Address of the socket.

Definition at line 96 of file UDPSynchronizedClient.h.

Referenced by run().

int UDPSynchronizedClient::socketHandle [private]
 

Integer used to access the socket.

Definition at line 93 of file UDPSynchronizedClient.h.

Referenced by closeDevice(), openSocket(), and run().

bool UDPSynchronizedClient::socketOpen [private]
 

Records whether the socket has been opened.

Definition at line 77 of file UDPSynchronizedClient.h.

Referenced by closeDevice(), deviceOpen(), openSocket(), run(), and UDPSynchronizedClient().

unsigned int* UDPSynchronizedClient::spikeBuffer
 

Buffer holding the spikes that have been received by this class from the external device.

Definition at line 62 of file UDPSynchronizedClient.h.

Referenced by DeviceManager::fillDeviceBuffer(), run(), UDPSynchronizedClient(), and ~UDPSynchronizedClient().

unsigned int UDPSynchronizedClient::spikeCount
 

Number of spikes in the spike buffer.

Definition at line 58 of file UDPSynchronizedClient.h.

Referenced by DeviceManager::fillDeviceBuffer(), run(), and UDPSynchronizedClient().

bool UDPSynchronizedClient::threadRunning [private]
 

Controls whether the thread is running.

Definition at line 74 of file UDPSynchronizedClient.h.

Referenced by clientThreadRunning(), closeDevice(), deviceOpen(), run(), start(), stop(), and UDPSynchronizedClient().

unsigned int UDPSynchronizedClient::timeStepsNoMessagesCount [private]
 

Counter to record the number of time steps that have taken place in the absence of input from the external process.

Definition at line 90 of file UDPSynchronizedClient.h.

Referenced by getExternalComputeTime_us(), run(), and UDPSynchronizedClient().


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