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