00001 /*************************************************************************** 00002 * SpikeStream Simulation * 00003 * Copyright (C) 2007 by David Gamez * 00004 * david@davidgamez.eu * 00005 * Version 0.1 * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 ***************************************************************************/ 00022 00023 #ifndef TCPSYNCHRONIZEDSERVER_H 00024 #define TCPSYNCHRONIZEDSERVER_H 00025 00026 //SpikeStream includes 00027 #include "DBInterface.h" 00028 00029 //Other includes 00030 #include <arpa/inet.h> 00031 00032 00033 //---------------------- TCP Synchronized Server --------------------------- 00034 /*! Sends spikes out to external device using TCP synchronization method. 00035 Does not technically operate as a server, but called such because it is 00036 a provider of spikes to the external device, rather than a receiver. */ 00037 //-------------------------------------------------------------------------- 00038 00039 class TCPSynchronizedServer { 00040 00041 public: 00042 TCPSynchronizedServer(unsigned int neurGrpWidth); 00043 ~TCPSynchronizedServer(); 00044 bool closeDevice(); 00045 bool openSocket(string ipAddress, int port); 00046 bool sendSpikeData(); 00047 void setNeuronVector(vector<unsigned int> *neurVectPtr, unsigned int startNeurID); 00048 00049 00050 //=============================== VARIABLES ============================== 00051 /*! Integer used to access the socket.*/ 00052 int socketHandle; 00053 00054 /*! Address of the socket.*/ 00055 struct sockaddr_in socketAddress; 00056 00057 /*! Records whether socket has been successfully connected.*/ 00058 bool socketConnected; 00059 00060 00061 private: 00062 //=============================== VARIABLES ============================== 00063 /*! Neuron group width.*/ 00064 unsigned int neuronGrpWidth; 00065 00066 /*! First ID of neuron group.*/ 00067 unsigned int startNeuronID; 00068 00069 /*! Records whether socket is open.*/ 00070 bool socketOpen; 00071 00072 /*! Reference to the vector of currently firing neurons held in 00073 SpikeStreamSimulation.*/ 00074 vector<unsigned int> *neuronVectorPtr; 00075 00076 00077 //=============================== METHODS ================================= 00078 /*! Declare copy constructor private so it cannot be used inadvertently. */ 00079 TCPSynchronizedServer (const TCPSynchronizedServer&); 00080 00081 /*! Declare assignment private so it cannot be used. */ 00082 TCPSynchronizedServer operator = (const TCPSynchronizedServer&); 00083 00084 }; 00085 00086 00087 #endif//TCPSYNCHRONIZEDSERVER_H 00088 00089
1.4.4