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

DeviceManager.h

Go to the documentation of this file.
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 DEVICEMANAGER_H
00024 #define DEVICEMANAGER_H
00025 
00026 //SpikeStream includes
00027 #include "Neuron.h"
00028 #include "DBInterface.h"
00029 #include "UDPSynchronizedClient.h"
00030 #include "UDPSynchronizedServer.h"
00031 #include "TCPSynchronizedClient.h"
00032 #include "TCPSynchronizedServer.h"
00033 
00034 //Other includes
00035 #include <google/dense_hash_map> 
00036 using HASH_NAMESPACE::hash;
00037 using GOOGLE_NAMESPACE::dense_hash_map;
00038 
00039 
00040 //----------------------------- Device Manager -----------------------------
00041 /*! Used to get input from an external device, such as SIMNOS or CRONOS, or 
00042         to send output to an external device and update the neurons' firing
00043         state appropriately. */
00044 //--------------------------------------------------------------------------
00045 
00046 class DeviceManager {
00047 
00048         public:
00049                 DeviceManager(unsigned int devID, unsigned int neurGrpID, double devFiringMode, DBInterface* deviceDB, DBInterface *networkDB);
00050                 DeviceManager();
00051                 ~DeviceManager();
00052                 bool closeDevice();
00053                 bool fetchData();
00054                 unsigned int getDeviceType();
00055                 unsigned int getExternalComputeTime_us();
00056                 bool getExternalSyncDelay();
00057                 bool isInputDevice();
00058                 bool isOutputDevice();
00059                 void setNeuronArray(Neuron **neurArr);
00060                 void setNeuronUpdateMap(dense_hash_map<unsigned int, bool, hash<unsigned int> >* neurUdtMp);
00061                 void setNeuronVector(vector<unsigned int> *neurVectPtr, unsigned int startNeuronID);
00062                 bool updateDevice();
00063                 void updateNeurons();
00064 
00065 
00066         private:
00067                 //=========================== VARIABLES =============================
00068                 //References to the database interfaces
00069                 DBInterface *deviceDBInterface;
00070                 DBInterface *networkDBInterface;
00071 
00072                 /*! Device ID.*/
00073                 unsigned int deviceID;
00074 
00075                 /*! Device type.*/
00076                 unsigned int deviceType;
00077 
00078                 /*! Is the device open or not.*/
00079                 bool deviceOpen;
00080 
00081                 //Information about the neuron group
00082                 unsigned int neuronGrpWidth;
00083                 unsigned int neuronGrpLength;
00084                 unsigned int startNeuronID;
00085                 unsigned int neuronGrpID;
00086 
00087                 /*! Reference to the neuron array in SpikeStreamSimulation.*/
00088                 Neuron **neuronArray;
00089 
00090                 /*! Pointer to the map holding all the neurons that have received a spike or
00091                         been changed during this timestep. Neurons in this map are updated when 
00092                         all spikes have been received. Map is used rather than vector to avoid 
00093                         filtering out multiple spikes to the same neuron. The key is the full 
00094                         neuronID.*/
00095                 dense_hash_map<unsigned int, bool, hash<unsigned int> >* neuronUpdateMap;
00096 
00097                 /*! Is the pattern rotated wrt the neuron group or not?.*/
00098                 //FIXME NOT IMPLEMENTED YET.
00099                 bool rotatePattern;
00100 
00101                 /*! Holds the neurons that need to be fired at each time point.*/
00102                 dense_hash_map<unsigned int, bool, hash<unsigned int> > deviceBuffer[NUMBER_OF_DELAY_VALUES];
00103 
00104                 /*! Records the current active position in the device buffer.*/
00105                 unsigned int bufferCounter;
00106 
00107                 //Clients and servers to send and receive messages over Ethernet
00108                 UDPSynchronizedClient* udpSyncClient;
00109                 UDPSynchronizedServer* udpSyncServer;
00110                 TCPSynchronizedClient* tcpSyncClient;
00111                 TCPSynchronizedServer* tcpSyncServer;
00112 
00113                 /*! Is the input pattern from an external device used to directly
00114                         fire the neurons or not?*/
00115                 bool directFiringMode;
00116 
00117                 /*! If we are in synaptic firing mode (i.e. !directFiringMode), this variable
00118                         specifies the weight.*/
00119                 double synapticWeight;
00120 
00121 
00122                 //=========================== METHODS =================================
00123                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00124                 DeviceManager (const DeviceManager&);
00125 
00126                 /*! Declare assignment private so it cannot be used.*/
00127                 DeviceManager operator = (const DeviceManager&);
00128 
00129                 void clearSynchronizationDelay();
00130                 void fillDeviceBuffer();
00131                 void loadDeviceInformation();
00132 
00133 };
00134 
00135 
00136 #endif //DEVICEMANAGER_H
00137 
00138 

Generated on Mon Sep 3 22:24:34 2007 for SpikeStream Simulation by  doxygen 1.4.4