CARLsim  5.0.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 *
46 * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
47 * Ver 12/31/2016
48 */
49 
50 #ifndef _GROUP_MON_CORE_H_
51 #define _GROUP_MON_CORE_H_
52 
53 #include <carlsim_datastructures.h> // Neuromodulator
54 #include <stdio.h> // FILE
55 #include <vector> // std::vector
56 
57 class SNN; // forward declaration of SNN class
58 
65 public:
67  GroupMonitorCore(SNN* snn, int monitorId, int grpId);
68 
71 
72 
73  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
74 
76  int getGrpId() { return grpId_; }
77 
79  int getGrpNumNeurons() { return nNeurons_; }
80 
82  int getMonitorId() { return monitorId_; }
83 
85  bool getPersistentData() { return persistentData_; }
86 
88  int getRecordingTotalTime() { return totalTime_; }
89 
91  int getRecordingStartTime() { return startTime_; }
92 
94  int getRecordingLastStartTime() { return startTimeLast_; }
95 
97  int getRecordingStopTime() { return stopTime_; }
98 
100  bool isRecording() { return recordSet_; }
101 
103  void pushData(int time, float data);
104 
106  void setPersistentData(bool persistentData) { persistentData_ = persistentData; }
107 
109  void startRecording();
110 
112  void stopRecording();
113 
115  std::vector<float> getDataVector();
116 
118  std::vector<int> getTimeVector();
119 
121  std::vector<float> getPeakValueVector();
122 
124  std::vector<int> getPeakTimeVector();
125 
127  std::vector<float> getSortedPeakValueVector();
128 
130  std::vector<int> getSortedPeakTimeVector();
131 
132  // +++++ PUBLIC METHODS THAT SHOULD NOT BE EXPOSED TO INTERFACE +++++++++//
133 
135  void clear();
136 
138  FILE* getGroupFileId() { return groupFileId_; }
139 
141  void setGroupFileId(FILE* groupFileId);
142 
144  int getLastUpdated() { return grpMonLastUpdated_; }
145 
147  void setLastUpdated(unsigned int lastUpdate) { grpMonLastUpdated_ = lastUpdate; }
148 
149 private:
151  void init();
152 
154  void writeGroupFileHeader();
155 
157  bool needToWriteFileHeader_;
158 
159  SNN* snn_;
160  int monitorId_;
161  int grpId_;
162  int nNeurons_;
163 
164  FILE* groupFileId_;
165  int groupFileSignature_;
166  float groupFileVersion_;
167 
169  std::vector<int> timeVector_;
170  std::vector<float> dataVector_;
171 
172  bool recordSet_;
173  int startTime_;
174  int startTimeLast_;
175  int stopTime_;
176  int totalTime_;
177  int accumTime_;
178 
179  int grpMonLastUpdated_;
180 
182  bool persistentData_;
183 
184  // file pointers for error logging
185  const FILE* fpInf_;
186  const FILE* fpErr_;
187  const FILE* fpDeb_;
188  const FILE* fpLog_;
189 };
190 
191 #endif
GroupMonitorCore::setLastUpdated
void setLastUpdated(unsigned int lastUpdate)
sets timestamp of last GroupMonitor update
Definition: group_monitor_core.h:147
GroupMonitorCore::getMonitorId
int getMonitorId()
returns the GroupMonitor ID
Definition: group_monitor_core.h:82
carlsim_datastructures.h
GroupMonitorCore::startRecording
void startRecording()
starts recording group data
Definition: group_monitor_core.cpp:180
GroupMonitorCore::getPeakTimeVector
std::vector< int > getPeakTimeVector()
get the timestamps for peak values
Definition: group_monitor_core.cpp:126
GroupMonitorCore::getPersistentData
bool getPersistentData()
returns status of PersistentData mode
Definition: group_monitor_core.h:85
GroupMonitorCore::clear
void clear()
deletes the data vector
Definition: group_monitor_core.cpp:98
GroupMonitorCore::getSortedPeakValueVector
std::vector< float > getSortedPeakValueVector()
get the sorted peak values of group data
Definition: group_monitor_core.cpp:165
GroupMonitorCore::getDataVector
std::vector< float > getDataVector()
get the group data
Definition: group_monitor_core.cpp:118
GroupMonitorCore::getRecordingStartTime
int getRecordingStartTime()
retunrs the timestamp of the first startRecording in ms
Definition: group_monitor_core.h:91
GroupMonitorCore::getGrpNumNeurons
int getGrpNumNeurons()
returns number of neurons in the group
Definition: group_monitor_core.h:79
GroupMonitorCore
GroupMonitor private core implementation.
Definition: group_monitor_core.h:64
GroupMonitorCore::stopRecording
void stopRecording()
stops recording group data
Definition: group_monitor_core.cpp:207
GroupMonitorCore::~GroupMonitorCore
~GroupMonitorCore()
destructor, cleans up all the memory upon object deletion
Definition: group_monitor_core.cpp:89
GroupMonitorCore::getGroupFileId
FILE * getGroupFileId()
returns a pointer to the group data file
Definition: group_monitor_core.h:138
GroupMonitorCore::isRecording
bool isRecording()
returns recording status
Definition: group_monitor_core.h:100
GroupMonitorCore::getRecordingLastStartTime
int getRecordingLastStartTime()
returns the timestamp of the last startRecording in ms
Definition: group_monitor_core.h:94
GroupMonitorCore::getSortedPeakTimeVector
std::vector< int > getSortedPeakTimeVector()
get the sorted timestamps for peak values
Definition: group_monitor_core.cpp:138
GroupMonitorCore::getGrpId
int getGrpId()
returns the group ID
Definition: group_monitor_core.h:76
GroupMonitorCore::getRecordingTotalTime
int getRecordingTotalTime()
returns the total recorded time in ms
Definition: group_monitor_core.h:88
GroupMonitorCore::GroupMonitorCore
GroupMonitorCore(SNN *snn, int monitorId, int grpId)
constructor (called by CARLsim::setGroupMonitor)
Definition: group_monitor_core.cpp:57
GroupMonitorCore::setGroupFileId
void setGroupFileId(FILE *groupFileId)
sets pointer to group data file
Definition: group_monitor_core.cpp:223
SNN
Contains all of CARLsim's core functionality.
Definition: snn.h:115
GroupMonitorCore::setPersistentData
void setPersistentData(bool persistentData)
sets status of PersistentData mode
Definition: group_monitor_core.h:106
GroupMonitorCore::getTimeVector
std::vector< int > getTimeVector()
get the timestamps for group data
Definition: group_monitor_core.cpp:122
GroupMonitorCore::getPeakValueVector
std::vector< float > getPeakValueVector()
get the peak values of group data
Definition: group_monitor_core.cpp:153
GroupMonitorCore::getLastUpdated
int getLastUpdated()
returns timestamp of last GroupMonitor update
Definition: group_monitor_core.h:144
GroupMonitorCore::getRecordingStopTime
int getRecordingStopTime()
returns the timestamp of stopRecording
Definition: group_monitor_core.h:97
GroupMonitorCore::pushData
void pushData(int time, float data)
inserts group data (time, value) into the vectors
Definition: group_monitor_core.cpp:111