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

SimulationClock.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 SIMULATIONCLOCK_H
00024 #define SIMULATIONCLOCK_H
00025 
00026 //Other includes
00027 #include <sys/time.h>
00028 
00029 
00030 //--------------------------- Simulation Clock -----------------------------
00031 /*! Keeps track of the time and the time step of the simulation. Time is in 
00032         milliseconds. Each time step includes the processing of all messages up 
00033         to the sending of the spike lists to other tasks, after which the time 
00034         step is advanced. In live mode the time is advanced in real time; in 
00035         other modes it is advanced by the time step duration. */
00036 //--------------------------------------------------------------------------
00037 
00038 class SimulationClock {
00039 
00040         public:
00041                 SimulationClock();
00042                 ~SimulationClock();
00043                 double getSimulationTime();
00044                 unsigned int getTimeStep();
00045                 double getTimeStepDuration_ms();
00046 
00047                 /* Make SpikeStreamSimulation a friend so that only this class
00048                         can call advance(), reset() and other methods on the clock. */
00049                 friend class SpikeStreamSimulation;
00050 
00051 
00052         private:
00053                 //========================= VARIABLES =============================
00054                 /*! Holds the number of update cycles of the simulation.*/
00055                 unsigned int timeStep;
00056 
00057                 /*! The amount of simulated time for each time step.*/
00058                 double timeStepDuration_millisec;
00059 
00060                 /*! The total amount of simulated time that has elapsed in millisedonds.*/
00061                 double simulationTime;
00062 
00063                 /*! Controls whether simulationTime is derived by adding timeStep_millisec
00064                         or getting the actual system time.*/
00065                 bool liveMode;
00066 
00067                 /*! Structure used to get and hold the start simulation time 
00068                         for live mode operation.*/
00069                 timeval startTimeStruct;
00070 
00071                 /*! Structure used to get and hold the current simulation time 
00072                         for live mode operation.*/
00073                 timeval currentTimeStruct;
00074 
00075 
00076                 //========================== METHODS ==============================
00077                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00078                 SimulationClock (const SimulationClock&);
00079 
00080                 /*! Declare assignment private so it cannot be used.*/
00081                 SimulationClock operator = (const SimulationClock&);
00082 
00083                 void advance();
00084                 void reset();
00085                 void setLiveMode(bool lMode);
00086                 void setTimeStepDuration(double);
00087 
00088 };
00089 
00090 
00091 #endif //SIMULATIONCLOCK_H
00092 
00093 

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