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 PATTERNMANAGER_H 00024 #define PATTERNMANAGER_H 00025 00026 //SpikeStream includes 00027 #include "DBInterface.h" 00028 #include "Neuron.h" 00029 00030 //Other includes 00031 #include <string> 00032 00033 00034 //-------------------------- Pattern Manager ------------------------------- 00035 /*! Reads in patterns from the database and applies them to the neurons in 00036 this task. Works using its own set of buffers to manage the delays of 00037 temporally smeared patterns. These buffers can advance independently of 00038 the time step so that the same pattern can be applied for several steps. 00039 00040 Temporal patterns are applied once and then a new pattern is applied 00041 after a number of timesteps. Fixed patterns are applied every time step. 00042 */ 00043 /* FIXME CHANGE STRINGS FOR STRAIGHT DATA IN THE DATABASE TO SPEED UP 00044 LOADING AND SAVE SPACE. */ 00045 //-------------------------------------------------------------------------- 00046 00047 class PatternManager { 00048 00049 public: 00050 PatternManager(DBInterface *netDBInterface, DBInterface *pattDBInterface, unsigned int neurGrpID, unsigned int patternGrpID); 00051 ~PatternManager(); 00052 void fireNeurons(); 00053 void loadPatternData(); 00054 void setNeuronArray(Neuron** neurArr, int neurArrLen); 00055 00056 00057 private: 00058 //===================== VARIABLES ============================== 00059 //References to database handling classes 00060 DBInterface *networkDBInterface; 00061 DBInterface *patternDBInterface; 00062 00063 /*! Store references to query class to enable us to move 00064 progressively through the pattern in the database.*/ 00065 mysqlpp::Query *patternQuery; 00066 00067 /*! Need a new connection to the database to be able to use 00068 ResUse for the pattern query.*/ 00069 mysqlpp::Connection *patternConnection; 00070 00071 /*! Store references to result class to enable us to move 00072 progressively through the pattern in the database.*/ 00073 mysqlpp::ResUse *patternResults; 00074 00075 /*! The id of the neuron group that is being simulated by this task.*/ 00076 unsigned int neuronGrpID; 00077 00078 /*! Records when a pattern has been loaded.*/ 00079 bool patternLoaded; 00080 00081 /*! Current pattern type.*/ 00082 unsigned int patternGrpID; 00083 00084 /*! Current pattern type.*/ 00085 unsigned int patternType; 00086 00087 /*! Width of the neuron group.*/ 00088 unsigned int neuronGrpWidth; 00089 00090 /*! Length of the neuron group.*/ 00091 unsigned int neuronGrpLength; 00092 00093 /*! Array into which the pattern data is loaded from the database 00094 by extracting it from a string.*/ 00095 int* patternArray; 00096 00097 /*! The length of the pattern array.*/ 00098 int patternArrayLength; 00099 00100 /*! Reference to the neuron array in SpikeStreamSimulation.*/ 00101 Neuron **neuronArray; 00102 00103 /*! Length of the neuron array in SpikeStreamSimulation.*/ 00104 int numberOfNeurons; 00105 00106 /*! Is the pattern rotated wrt the neuron group or not?.*/ 00107 //FIXME NOT IMPLEMENTED 00108 bool rotatePattern; 00109 00110 /*! Holds the neurons that need to be fired at each time point.*/ 00111 vector<unsigned int> patternBuffer[NUMBER_OF_DELAY_VALUES]; 00112 00113 /*! The current position in the pattern buffer.*/ 00114 unsigned int bufferCounter; 00115 00116 00117 //===================== METHODS ============================== 00118 /*! Declare copy constructor private so it cannot be used inadvertently. */ 00119 PatternManager (const PatternManager&); 00120 00121 /*! Declare assignment private so it cannot be used.*/ 00122 PatternManager operator = (const PatternManager&); 00123 00124 void fillPatternArray(string &patternString); 00125 void loadPatternGroup(unsigned int pattGrpID); 00126 void unloadPatternGroup(); 00127 00128 }; 00129 00130 00131 #endif //PATTERNMANAGER_H 00132 00133
1.4.4