00001 00005 #ifndef _READOUT_H_ 00006 #define _READOUT_H_ 00007 00008 #include "advanceable.h" 00009 #include "analogfilter.h" 00010 #include "spikefilter.h" 00011 #include "preprocessor.h" 00012 #include "algorithm.h" 00013 #include <list> 00014 #include <string> 00015 #include <pthread.h> 00016 #include "csimclass.h" 00017 #include "modelinput.h" 00018 00019 #define EPSILON 10e-20 00020 00021 00022 00024 00031 class Readout : public Advancable, public ModelInput { 00032 00033 DO_REGISTERING 00034 00035 public: 00036 00038 Readout(void); 00039 00041 ~Readout(void); 00042 00044 virtual int advance(); 00045 00047 virtual int addIncoming(Advancable *Incoming); 00048 00050 virtual int addOutgoing(Advancable *a); 00051 00053 virtual int addInputField(csimClass *O, char *fieldname); 00054 00056 virtual void reset(); 00057 00060 void setAnalogFilter(AnalogFilter *af); 00061 00064 void setSpikeFilter(SpikeFilter *sf); 00065 00070 int appendPreprocessor(Preprocessor *pp); 00071 00076 int prependPreprocessor(Preprocessor *pp); 00077 00083 int insertPreprocessor(Preprocessor *pp, int position); 00084 00087 int getNumberPreprocessors(); 00088 00094 int importPreprocessor(int ind, double *rep, int rep_length); 00095 00100 double* exportPreprocessor(int ind, int *rep_length); 00101 00105 string getPreprocessorFormatDescription(int ind); 00106 00110 int setLearningAlgorithm(Algorithm *learner); 00111 00116 int importAlgorithm(double *rep, int rep_length); 00117 00121 double* exportAlgorithm(int *rep_length); 00122 00125 string getAlgorithmFormatDescription(); 00126 00127 00131 void setRange(double lower_bound, double upper_bound); 00132 00133 00134 00136 inline uint32 getAnalogFilterID(void) { if (analogFilter) return analogFilter->getId(); else return 0; } 00137 00139 inline bool hasAnalogFilter(void) { return (analogFilter != 0); } 00140 00142 inline uint32 getSpikeFilterID(void) { if (spikeFilter) return spikeFilter->getId(); else return 0; }; 00143 00145 inline bool hasSpikeFilter(void) { return (spikeFilter != 0); } 00146 00148 inline uint32 getAlgorithmID(void) { if (algorithm) return algorithm->getId(); else return 0; }; 00149 00151 inline bool hasAlgorithm(void) { return (algorithm != 0); } 00152 00154 void getPreprocessorIDs(uint32 *idx); 00155 00156 00158 int enabled; 00159 00160 00162 double offset; 00163 00165 double range; 00166 00167 00168 // We must also implement some recorder interface, because we want to use 00169 // not only the psr of neurons as input, but also other fields 00170 00171 00172 protected: 00173 00175 struct RecField { 00177 short i; 00178 00180 csimClass *o; 00181 00183 char *p; 00184 00186 short type; 00187 }; 00188 00190 int add(RecField *f); 00191 00192 00194 int nRecFields; 00195 00197 int lRecFields; 00198 00200 RecField **recFields; 00201 00203 int nAnalogFields; 00205 int lAnalogFields; 00206 00208 int *analogIndices; 00209 00211 int nSpikingFields; 00213 int lSpikingFields; 00214 00216 int *spikingIndices; 00217 00218 00219 00221 SynapseTarget **outgoing; 00222 00224 int nOutgoing; 00226 int lOutgoing; 00227 00228 00229 00230 00232 // double output; 00233 00235 list<Preprocessor *> pre_processors; 00236 00238 AnalogFilter *analogFilter; 00239 00241 SpikeFilter *spikeFilter; 00242 00244 Algorithm *algorithm; 00245 00246 00248 static double* m_response; 00250 static double* m_target; 00251 00253 static int lReservedMemory; 00254 00256 static pthread_mutex_t mutex_temp_memory; 00257 00259 static int nReadouts; 00260 00261 }; 00262 00263 00264 #endif