65 offsetTimeMs_ = offsetTimeMs;
73 if (fpBegin_ != NULL) {
81 if (fpBegin_ != NULL) {
88 offsetTimeMs_ = offsetTimeMs;
95 offsetTimeMs_ = offsetTimeMs;
99 for (
int i=0; i<nNeur_; i++) {
100 spikesIt_.push_back(spikes_[i].begin());
104 void SpikeGeneratorFromFile::openFile() {
105 std::string funcName =
"openFile("+fileName_+
")";
106 fpBegin_ = fopen(fileName_.c_str(),
"rb");
113 szByteHeader_ = 4*
sizeof(int)+1*
sizeof(
float);
114 fseek(fp,
sizeof(
int)+
sizeof(
float), SEEK_SET);
119 for (
int i=1; i<=3; i++) {
120 size_t result = fread(&grid,
sizeof(
int), 1, fp);
129 void SpikeGeneratorFromFile::init() {
136 for (
int i=0; i<nNeur_; i++) {
137 spikes_.push_back(std::vector<int>());
142 fseek(fp, szByteHeader_, SEEK_SET);
144 std::string funcName =
"readFile("+fileName_+
")";
147 size_t result1, result2;
150 result1 = fread(&tmpTime,
sizeof(
int), 1, fp);
152 result2 = fread(&tmpNeurId,
sizeof(
int), 1, fp);
154 if (result1 + result2 == 2)
155 spikes_[tmpNeurId].push_back(tmpTime);
159 for (
int neurId=0; neurId<1; neurId++) {
160 printf(
"[%d]: ",neurId);
161 for (
int i=0; i<spikes_[neurId].size(); i++) {
162 printf(
"%d ",spikes_[neurId][i]);
174 assert(nid < nNeur_);
176 if (spikesIt_[nid] != spikes_[nid].end()) {
179 if (*(spikesIt_[nid])+offsetTimeMs_ < endOfTimeSlice) {
183 printf(
"[%d][%d]: currTime=%u, lastTime=%u, endOfTime=%u, offsetTimeMs=%u, nextSpike=%u\n", grpId, nid,
184 currentTime, lastScheduledSpikeTime, endOfTimeSlice, offsetTimeMs_,
185 (
unsigned int) (*(spikesIt_[nid])+offsetTimeMs_));
189 return (
unsigned int)(*(spikesIt_[nid]++)+offsetTimeMs_);