CARLsim  6.1.0
CARLsim: a GPU-accelerated SNN simulator
group_monitor_core.h
Go to the documentation of this file.
1 /* * Copyright (c) 2016 Regents of the University of California. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. The names of its contributors may not be used to endorse or promote
15 * products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * *********************************************************************************************** *
31 * CARLsim
32 * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
33 * maintained by:
34 * (MA) Mike Avery <averym@uci.edu>
35 * (MB) Michael Beyeler <mbeyeler@uci.edu>,
36 * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
37 * (TSC) Ting-Shuo Chou <tingshuc@uci.edu>
38 * (HK) Hirak J Kashyap <kashyaph@uci.edu>
39 *
40 * CARLsim v1.0: JM, MDR
41 * CARLsim v2.0/v2.1/v2.2: JM, MDR, MA, MB, KDC
42 * CARLsim3: MB, KDC, TSC
43 * CARLsim4: TSC, HK
44 * CARLsim5: HK, JX, KC
45 * CARLsim6: LN, JX, KC, KW
46 *
47 * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
48 * Ver 12/31/2016
49 */
50 
51 #ifndef _GROUP_MON_CORE_H_
52 #define _GROUP_MON_CORE_H_
53 
54 
55 #include <carlsim_datastructures.h> // Neuromodulator
56 #include <stdio.h> // FILE
57 #include <vector> // std::vector
58 
59 class SNN; // forward declaration of SNN class
60 
67 public:
68 
69  /*
70  * \brief
71  *
72  * LN TODO backward compatibility DA_MODE default
73  *
74  */
75 
76  // 1>src\snn_manager.cpp(1099): error C2664: 'GroupMonitorCore::GroupMonitorCore(const GroupMonitorCore &)': cannot convert argument 4 from 'int' to 'GroupMonitorCore::mode_t'
77  //enum mode_t {DA_MODE=0, ALL_MODE};
78  static const int DA_MODE = 0;
79  static const int ALL_MODE = 1;
80 
82  GroupMonitorCore(SNN* snn, int monitorId, int grpId, int mode = DA_MODE);
83 
86 
87 
88  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
89 
91  int getGrpId() { return grpId_; }
92 
94  int getGrpNumNeurons() { return nNeurons_; }
95 
97  int getMonitorId() { return monitorId_; }
98 
100  bool getPersistentData() { return persistentData_; }
101 
103  int getRecordingTotalTime() { return totalTime_; }
104 
106  int getRecordingStartTime() { return startTime_; }
107 
109  int getRecordingLastStartTime() { return startTimeLast_; }
110 
112  int getRecordingStopTime() { return stopTime_; }
113 
115  bool isRecording() { return recordSet_; }
116 
117  bool isInAllMode() { return mode_ == ALL_MODE; };
118 
120  void pushData(int time, float data);
121 
123  void pushData(int time, float _DA, float _5HT, float _ACh, float _NE);
124 
125 
127  void setPersistentData(bool persistentData) { persistentData_ = persistentData; }
128 
130  void startRecording();
131 
133  void stopRecording();
134 
135 
136 
138  std::vector<float> getDataVector();
139 
140  enum transmitter_t {_DA,_5HT,_ACh,_NE};
142  std::vector<float> getDataVector(transmitter_t transmitter);
143 
145  std::vector<int> getTimeVector();
146 
148  std::vector<float> getPeakValueVector();
149 
151  std::vector<int> getPeakTimeVector();
152 
154  std::vector<float> getSortedPeakValueVector();
155 
157  std::vector<int> getSortedPeakTimeVector();
158 
159  // +++++ PUBLIC METHODS THAT SHOULD NOT BE EXPOSED TO INTERFACE +++++++++//
160 
162  void clear();
163 
165  FILE* getGroupFileId() { return groupFileId_; }
166 
168  void setGroupFileId(FILE* groupFileId);
169 
171  int getLastUpdated() { return grpMonLastUpdated_; }
172 
174  void setLastUpdated(unsigned int lastUpdate) { grpMonLastUpdated_ = lastUpdate; }
175 
176 private:
178  void init();
179 
181  void writeGroupFileHeader();
182 
184  bool needToWriteFileHeader_;
185 
186  SNN* snn_;
187  int monitorId_;
188  int grpId_;
189  int nNeurons_;
190  int mode_;
191 
192  FILE* groupFileId_;
193  int groupFileSignature_;
194  float groupFileVersion_;
195 
197  std::vector<int> timeVector_;
198  std::vector<float> dataVector_;
199  std::vector<float> data4Vector_[4];
200 
201  bool recordSet_;
202  int startTime_;
203  int startTimeLast_;
204  int stopTime_;
205  int totalTime_;
206  int accumTime_;
207 
208  int grpMonLastUpdated_;
209 
211  bool persistentData_;
212 
213  // file pointers for error logging
214  const FILE* fpInf_;
215  const FILE* fpErr_;
216  const FILE* fpDeb_;
217  const FILE* fpLog_;
218 };
219 
220 #endif
std::vector< float > getDataVector()
get the group data
int getRecordingLastStartTime()
returns the timestamp of the last startRecording in ms
static const int ALL_MODE
int getGrpId()
returns the group ID
std::vector< int > getSortedPeakTimeVector()
get the sorted timestamps for peak values
bool isRecording()
returns recording status
~GroupMonitorCore()
destructor, cleans up all the memory upon object deletion
int getRecordingTotalTime()
returns the total recorded time in ms
int getLastUpdated()
returns timestamp of last GroupMonitor update
std::vector< int > getTimeVector()
get the timestamps for group data
std::vector< float > getPeakValueVector()
get the peak values of group data
void setGroupFileId(FILE *groupFileId)
sets pointer to group data file
void pushData(int time, float data)
inserts group data (time, value) into the vectors , if monitor is in DA_MODE
void setPersistentData(bool persistentData)
sets status of PersistentData mode
int getRecordingStopTime()
returns the timestamp of stopRecording
void setLastUpdated(unsigned int lastUpdate)
sets timestamp of last GroupMonitor update
int getMonitorId()
returns the GroupMonitor ID
static const int DA_MODE
void startRecording()
starts recording group data
std::vector< float > getSortedPeakValueVector()
get the sorted peak values of group data
void clear()
deletes the data vector
int getRecordingStartTime()
retunrs the timestamp of the first startRecording in ms
Contains all of CARLsim&#39;s core functionality.
Definition: snn.h:138
GroupMonitorCore(SNN *snn, int monitorId, int grpId, int mode=DA_MODE)
constructor (called by CARLsim::setGroupMonitor)
void stopRecording()
stops recording group data
std::vector< int > getPeakTimeVector()
get the timestamps for peak values
GroupMonitor private core implementation.
bool getPersistentData()
returns status of PersistentData mode
FILE * getGroupFileId()
returns a pointer to the group data file
int getGrpNumNeurons()
returns number of neurons in the group