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

SimulationWidget.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 SIMULATIONWIDGET_H
00024 #define SIMULATIONWIDGET_H
00025 
00026 //SpikeStream includes
00027 #include "SimulationManager.h"
00028 #include "DBInterface.h"
00029 #include "MonitorArea.h"
00030 #include "BusyDialog.h"
00031 #include "NeuronParametersDialog.h"
00032 #include "SynapseParametersDialog.h"
00033 #include "GlobalParametersDialog.h"
00034 #include "ScriptRunner.h"
00035 #include "NoiseParametersDialog.h"
00036 #include "MonitorDataPlotter.h"
00037 #include "GlobalVariables.h"
00038 
00039 //Qt includes
00040 #include <qwidget.h>
00041 #include <qlineedit.h>
00042 #include <qlabel.h>
00043 #include <qpushbutton.h>
00044 #include <qcombobox.h>
00045 #include <qstringlist.h>
00046 #include <qradiobutton.h>
00047 #include <qtable.h>
00048 #include <qgroupbox.h>
00049 #include <qlayout.h>
00050 #include <qstring.h>
00051 #include <qtabwidget.h>
00052 #include <qvalidator.h>
00053 #include <qapplication.h>
00054 
00055 
00056 /*! Comparison function for simulation error map. */
00057 struct qstringCompare{
00058   bool operator()(const QString* s1, const QString* s2) const {
00059     return strcmp(s1->ascii(), s2->ascii()) < 0;
00060   }
00061 };
00062 
00063 
00064 //------------------------ Simulation Widget -------------------------------
00065 /*! Used to control simulation, adjust simulation parameters and visualise 
00066         what is going on in the neural networks.*/
00067 
00068 /*FIXME Setting parameters could do with a check similar to that used for
00069         viewing and saving weights. */
00070 //--------------------------------------------------------------------------
00071 
00072 class SimulationWidget : public QWidget {
00073         Q_OBJECT
00074  
00075         public:
00076                 SimulationWidget(QWidget *parent, DBInterface*, DBInterface*, DBInterface*, DBInterface*);
00077                 ~SimulationWidget();
00078                 SimulationManager* getSimulationManager();
00079                 static unsigned int getSimulationStartTime();
00080                 void hideOpenWindows();
00081                 void reloadConnectionGroups();
00082                 void reloadDevices();
00083                 void reloadNeuronGroups();
00084                 void reloadPatterns();
00085                 void setFromNeuronID(unsigned int neurGrpID, unsigned int fromNeurID);
00086                 void setMonitorArea(MonitorArea*);
00087                 void setToNeuronID(unsigned int toNeurID);
00088                 void showOpenWindows();
00089 
00090 
00091         private slots:
00092                 void checkSimManagerForErrors();
00093                 void checkViewWeightsSaved();
00094                 void checkWeightsLoadState();
00095                 void checkWeightsSaveState();
00096                 void dockAllButtonClicked();
00097                 void fireNeuronButtonPressed();
00098                 void fireNeuronComboActivated(const QString &string);
00099                 void frameRateComboChanged(int);
00100                 void globalParamButtonPressed();
00101                 void hideGraphsButtonClicked();
00102                 void initialiseButtonToggled(bool);
00103                 void injectNoiseButtonPressed();
00104                 void monitorButtonPressed();
00105                 void monitorNeuronButtonPressed();
00106                 void monitorNeuronComboActivated(const QString &string);
00107                 void monitorSynapseButtonPressed();
00108                 void neuronParamButtonPressed();
00109                 void noiseParamButtonPressed();
00110                 void recordButtonToggled(bool);
00111                 void reloadWeightsButtonPressed();
00112                 void saveWeightsButtonPressed();
00113                 void setSimulationStartTime(unsigned int simStartTime);
00114                 void showGraphsButtonClicked();
00115                 void simModeComboChanged(int);
00116                 void simStartButtonToggled(bool);
00117                 void simStepButtonPressed();
00118                 void simStopButtonPressed();
00119                 void synapseParamButtonPressed();
00120                 void undockAllButtonClicked();
00121                 void viewWeightsButtonPressed();
00122 
00123 
00124         private:
00125                 //======================== VARIABLES ==============================
00126                 //References to database handling classes
00127                 DBInterface *networkDBInterface;
00128                 DBInterface *archiveDBInterface;
00129                 DBInterface *patternDBInterface;
00130                 DBInterface *deviceDBInterface;
00131 
00132                 //Positions of columns that need to be referenced later
00133                 int deviceNeurGrpCol;
00134                 int deviceFiringModeCol;
00135                 int patternNeurGrpCol;
00136                 int deviceIDCol;
00137                 int patternIDCol;
00138 
00139                 /*! Reference to monitor area for docking and undocking of monitor windows.*/
00140                 MonitorArea *monitorArea;
00141 
00142                 /*! Reference to simulation manager to control simulation.*/
00143                 SimulationManager *simulationManager;
00144 
00145                 /*! Short version of reference to QApplication for processing events.*/
00146                 SpikeStreamApplication *spikeStrApp;
00147 
00148                 /*! Sometimes will need to change initialise button's state
00149                         without doing anything.*/
00150                 bool ignoreInitialiseButton;
00151 
00152                 /*! Sometimes will need to change record button's state
00153                         without doing anything.*/
00154                 bool ignoreRecordButton;
00155                 
00156                 /*! Start time of simulation. Used by the load archive dialog
00157                         to prevent deletion of archives that are currently being
00158                         accessed by simulation.*/
00159                 static unsigned int simulationStartTime;
00160 
00161                 //Qt widgets for simulation settings
00162                 QGroupBox *settingsGrpBox;
00163                 QLineEdit *archNameText;
00164                 QComboBox *archMonitorTypeCombo;
00165                 QTabWidget *inputTabWidget;
00166                 QTable *patternTable;
00167                 QTable *deviceTable;
00168                 QLineEdit *timeStepsPatternText;
00169 
00170                 //Qt widgets for live parameters
00171                 NeuronParametersDialog *neuronParametersDialog;
00172                 SynapseParametersDialog *synapseParametersDialog;
00173                 GlobalParametersDialog *globalParametersDialog;
00174                 NoiseParametersDialog *noiseParametersDialog;
00175 
00176                 //Qt widgets for simulation controls
00177                 QPushButton *initialiseButton;
00178                 QPushButton *reloadWeightsButton;
00179                 QPushButton *saveWeightsButton;
00180                 QPushButton *simStartButton;
00181                 QPushButton *simStepButton;
00182                 QPushButton *simStopButton;
00183                 QPushButton *recordButton;
00184                 QComboBox *neuronGrpMonitorCombo;
00185                 QComboBox *liveMonitorTypeCombo;
00186                 QPushButton *monitorButton;
00187                 QPushButton *injectNoiseButton;
00188                 QComboBox *injectNoiseNeurGrpCombo;
00189                 QComboBox *injectNoiseAmntCombo;
00190                 QPushButton *viewWeightsButton;
00191                 QComboBox *frameRateCombo;
00192                 QComboBox* simModeCombo;
00193 
00194                 //Fire neuron widgets and variables
00195                 QComboBox *fireNeuronCombo;
00196                 QLineEdit *fireNeuronText;
00197                 QPushButton *fireNeuronButton;
00198                 QIntValidator *fireNeuronValidator;
00199                 unsigned int maxFireNeuronID;
00200                 unsigned int minFireNeuronID;
00201 
00202                 //Monitor neuron widgets and variables
00203                 QComboBox *monitorNeuronCombo;
00204                 QLineEdit *monitorNeuronText;
00205                 QPushButton *monitorNeuronButton;
00206                 QIntValidator *monitorNeuronValidator;
00207                 unsigned int maxMonitorNeuronID;
00208                 unsigned int minMonitorNeuronID;
00209 
00210                 //Monitor synapse widgets and variables
00211                 QLabel* monitorSynapseFromLabel;
00212                 QLabel* monitorSynapseToLabel;
00213                 QLabel* monitorSynapseFromNumLabel;
00214                 QLabel* monitorSynapseToNumLabel;
00215                 QPushButton *monitorSynapseButton;
00216 
00217                 //Button to show/hide graphs
00218                 QPushButton *hideGraphsButton;
00219                 QPushButton *showGraphsButton;
00220 
00221                 //Qt Docking controls
00222                 QPushButton *dockAllButton;
00223                 QPushButton *undockAllButton;
00224 
00225                 /*! Dialog to show when something is happening whose progress cannot be measured.*/
00226                 BusyDialog *busyDialog;
00227 
00228                 /*! Timer to check simulation manager for errors whilst simulation is running.*/
00229                 QTimer* simErrorCheckTimer;
00230 
00231                 /*! Map of the errors received from the simulation manager
00232                         designed for error filtering.*/
00233                 map<QString*, bool, qstringCompare> simulationErrorMap;
00234 
00235                 /*! Map holding all of the monitors plotting neuron data.*/
00236                 map<unsigned int, MonitorDataPlotter*> neuronMonitorMap;
00237 
00238                 /*! Map holding all of the monitors plotting synapse data.*/
00239                 map<unsigned int*, MonitorDataPlotter*, synapseKeyCompare> synapseMonitorMap;
00240 
00241 
00242                 //======================== METHODS =================================
00243                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00244                 SimulationWidget (const SimulationWidget&);
00245 
00246                 /*! Declare assignment private so it cannot be used inadvertently.*/
00247                 SimulationWidget operator = (const SimulationWidget&);
00248 
00249                 void getNeuronGrpNames(QStringList&, unsigned int w, unsigned int l);
00250                 void loadDeviceTable();
00251                 void loadNeuronGrpNames(QComboBox *comboBox);
00252                 void loadPatternTable();
00253                 bool neuronGroupsIsolated();
00254 
00255 };
00256 
00257 
00258 #endif//SIMULATIONWIDGET_H
00259 
00260 

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