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

NetworkMonitor.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   SpikeStream Application                                               *
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 NETWORKMONITOR_H
00024 #define NETWORKMONITOR_H
00025 
00026 //SpikeStream includes
00027 #include "DBInterface.h"
00028 #include "NeuronGroup.h"
00029 #include "SpikeStreamApplication.h"
00030 
00031 //Qt includes
00032 #include <qwidget.h>
00033 #include <qgl.h>
00034 #include <qmutex.h>
00035 
00036 
00037 //-------------------------- Network Monitor --------------------------------
00038 /*! Displays the firing of the neural networks either as emitted spike 
00039         patterns or activity patterns in the layer. Used both for live simulation
00040         monitoring and for the play back of archived data. Different constructor
00041         is called depending on how it is being used. */
00042 
00043 /* FIXME THERE IS CURRENTLY SOME CONFLIGT BETWEEN THIS CLASS AND THE NETWORK
00044         VIEWER IN FULL RENDER MODE DUE TO INTERLACING OF OPENGL COMMANDS.
00045 
00046         FIXME THE WINDOW CHANGES TO BLACK WHEN EXPANDED BEYOND A CERTAIN POINT.
00047         THIS IS A PROBLEM IN SUSE 10.2, BUT NOT IN SUSE 10.0, SO PROBABLY A QT
00048         VERSION PROBLEM.*/
00049 //----------------------------------------------------------------------------
00050 
00051 class NetworkMonitor :  public QGLWidget {
00052         Q_OBJECT
00053         
00054         public:
00055                 NetworkMonitor(NeuronGroup, DBInterface *dbInter, QWidget *parent);
00056                 NetworkMonitor(NeuronGroup, QWidget *parent);
00057                 ~NetworkMonitor();
00058                 void reset();
00059                 
00060                 //Allow other classes to manipulate this class
00061                 friend class SimulationManager;
00062                 friend class MonitorWindow;
00063                 friend class NetworkDataXmlHandler;
00064                 friend class ArchiveManager;
00065 
00066 
00067         protected:
00068                 //Methods inherited from QGLWidget
00069                 void initializeGL();
00070                 void paintGL();
00071                 void resizeGL(int width, int height);
00072 
00073 
00074         private:
00075                 //======================= VARIABLES =================================
00076                 /*! Reference to database handlling class.*/
00077                 DBInterface *networkDBInterface;
00078 
00079                 /*! Short version of reference to the main application to halt the 
00080                         processing of events.*/
00081                 SpikeStreamApplication *spikeStrApp;
00082 
00083                 /*! Controls whether it is displaying live data from a simulation or playback 
00084                         from an archive.*/
00085                 bool liveMonitoring;
00086 
00087                 /*! Array to unpack the spikes into.*/
00088                 unsigned int* unpackArray;
00089 
00090                 /*! Define integer here to extract from neuron id.*/
00091                 unsigned int unpkFromNeurID;
00092                 
00093                 /*! First map to hold the firing neurons. 
00094                         Use two maps so that one can be loaded by another process whilst another is being
00095                         used to produce the graphical display. The active map is swapped when loading is 
00096                         complete. Use a map to easily get rid of duplicates.*/
00097                 map<unsigned int, bool> firingNeuronMap1;
00098 
00099                 /*! Second map to hold the firing neurons. 
00100                         Use two maps so that one can be loaded by another process whilst another is being
00101                         used to produce the graphical display. The active map is swapped when loading is 
00102                         complete. Use a map to easily get rid of duplicates.*/
00103                 map<unsigned int, bool> firingNeuronMap2;
00104 
00105                 /*! Pointer to the map used to draw the current display.*/
00106                 map<unsigned int, bool> *drawingMapPointer;
00107 
00108                 /*! Pointer to the map used to load data.*/
00109                 map<unsigned int, bool> *bufferMapPointer;
00110 
00111                 /*! Records which of the maps is currently active.*/
00112                 bool map1Active;
00113 
00114                 /*! Number of spikes or firing neurons in the message.*/
00115                 unsigned int numberOfSpikes;
00116 
00117                 /* Information about the neuron group being monitored and the task ID 
00118                         that is running the simulation for this neuron group */
00119                 unsigned int neuronGrpID;
00120                 int neuronGrpTaskID;
00121                 unsigned int startNeuronID;
00122                 unsigned int numberOfNeurons;
00123 
00124                 //Width and height of the neuron group
00125                 unsigned int neuronGrpWidth;
00126                 unsigned int neuronGrpLength;
00127 
00128                 //Width and height of the frame
00129                 unsigned int frameWidth;
00130                 unsigned int frameHeight;
00131 
00132                 /*! Factor used to scale the x positions depending on the frame size.*/
00133                 GLfloat scaleFactorWidth;
00134 
00135                 /*! Factor used to scale the y positions depending on the frame size.*/
00136                 GLfloat scaleFactorLength;
00137 
00138                 /*! Size of the vertex representing a neuron firing or a spike.*/
00139                 GLfloat pointSize;
00140                 
00141                 /*! Mapping between a neuron id and an x position in the widget.*/
00142                 map<unsigned int, GLfloat> neuronXPosMap;
00143 
00144                 /*! Mapping between a neuron id and a y position in the widget.*/
00145                 map<unsigned int, GLfloat> neuronYPosMap;
00146                 
00147                 /*! The current time step of the message.*/
00148                 unsigned int messageTimeStep;
00149 
00150                 /*! Font for displaying the timestep.*/
00151                 QFont *arialFont;
00152 
00153                 /*! Vertical margin around drawing area */
00154                 static GLfloat marginL;
00155 
00156                 /*! Horizontal margin around drawing area */
00157                 static GLfloat marginW;
00158 
00159 
00160                 //=========================== METHODS =================================
00161                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00162                 NetworkMonitor (const NetworkMonitor&);
00163 
00164                 /*! Declare assignment private so it cannot be used inadvertently.*/
00165                 NetworkMonitor operator = (const NetworkMonitor&);
00166 
00167                 void checkOpenGLErrors();
00168                 void printPositionMaps();
00169                 void processFiringNeuronList();
00170                 void processSpikeList();
00171                 void setPointSize();
00172                 void setTimeStep(unsigned int);
00173                 void swapMaps();
00174 
00175 };
00176 
00177 
00178 #endif //NETWORKMONITOR_H
00179 
00180 

Generated on Mon Sep 3 22:29:04 2007 for SpikeStream Application by  doxygen 1.4.4