66 offsetTimeMs_ = offsetTimeMs;
74 if (fpBegin_ != NULL) {
82 if (fpBegin_ != NULL) {
89 offsetTimeMs_ = offsetTimeMs;
96 offsetTimeMs_ = offsetTimeMs;
100 for (
int i=0; i<nNeur_; i++) {
101 spikesIt_.push_back(spikes_[i].begin());
105 void SpikeGeneratorFromFile::openFile() {
106 std::string funcName =
"openFile("+fileName_+
")";
107 fpBegin_ = fopen(fileName_.c_str(),
"rb");
114 szByteHeader_ = 4*
sizeof(int)+1*
sizeof(
float);
115 fseek(fp,
sizeof(
int)+
sizeof(
float), SEEK_SET);
120 for (
int i=1; i<=3; i++) {
121 size_t result = fread(&grid,
sizeof(
int), 1, fp);
130 void SpikeGeneratorFromFile::init() {
137 for (
int i=0; i<nNeur_; i++) {
138 spikes_.push_back(std::vector<int>());
143 fseek(fp, szByteHeader_, SEEK_SET);
145 std::string funcName =
"readFile("+fileName_+
")";
148 size_t result1, result2;
151 result1 = fread(&tmpTime,
sizeof(
int), 1, fp);
153 result2 = fread(&tmpNeurId,
sizeof(
int), 1, fp);
155 if (result1 + result2 == 2)
156 spikes_[tmpNeurId].push_back(tmpTime);
160 for (
int neurId=0; neurId<1; neurId++) {
161 printf(
"[%d]: ",neurId);
162 for (
int i=0; i<spikes_[neurId].size(); i++) {
163 printf(
"%d ",spikes_[neurId][i]);
175 assert(nid < nNeur_);
177 if (spikesIt_[nid] != spikes_[nid].end()) {
180 if (*(spikesIt_[nid])+offsetTimeMs_ < endOfTimeSlice) {
184 printf(
"[%d][%d]: currTime=%u, lastTime=%u, endOfTime=%u, offsetTimeMs=%u, nextSpike=%u\n", grpId, nid,
185 currentTime, lastScheduledSpikeTime, endOfTimeSlice, offsetTimeMs_,
186 (
unsigned int) (*(spikesIt_[nid])+offsetTimeMs_));
190 return (
unsigned int)(*(spikesIt_[nid]++)+offsetTimeMs_);