@@ -57,13 +57,15 @@ void HDF5Recording::registerProcessor(GenericProcessor* proc)
5757 fileArray.add (new KWDFile ());
5858 bitVoltsArray.add (new Array<float >);
5959 sampleRatesArray.add (new Array<float >);
60+ channelsPerProcessor.add (0 );
6061 processorIndex++;
6162}
6263
6364void HDF5Recording::resetChannels ()
6465{
6566 processorIndex = -1 ;
6667 fileArray.clear ();
68+ channelsPerProcessor.clear ();
6769 bitVoltsArray.clear ();
6870 sampleRatesArray.clear ();
6971 processorMap.clear ();
@@ -106,15 +108,15 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int recordi
106108 int index = processorMap[i];
107109 if (getChannel (i)->getRecordState ())
108110 {
109- if (!fileArray[index]->isOpen ())
111+ if (!fileArray[index]->isOpen ())
110112 {
111113 fileArray[index]->initFile (getChannel (i)->nodeId ,basepath);
112- fileArray[index]->open ();
113114 if (hasAcquired)
114115 infoArray[index]->start_time = (*timestamps)[getChannel (i)->sourceNodeId ]; // the timestamps of the first channel
115116 else
116117 infoArray[index]->start_time = 0 ;
117118 }
119+ channelsPerProcessor.set (index, channelsPerProcessor[index] + 1 );
118120 bitVoltsArray[index]->add (getChannel (i)->bitVolts );
119121 sampleRatesArray[index]->add (getChannel (i)->sampleRate );
120122 if (getChannel (i)->sampleRate != infoArray[index]->sample_rate )
@@ -125,6 +127,10 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int recordi
125127 }
126128 for (int i = 0 ; i < fileArray.size (); i++)
127129 {
130+ if ((!fileArray[i]->isOpen ()) && (fileArray[i]->isReadyToOpen ()))
131+ {
132+ fileArray[i]->open (channelsPerProcessor[i]);
133+ }
128134 if (fileArray[i]->isOpen ())
129135 {
130136 File f (fileArray[i]->getFileName ());
@@ -158,6 +164,7 @@ void HDF5Recording::closeFiles()
158164 fileArray[i]->close ();
159165 bitVoltsArray[i]->clear ();
160166 }
167+ channelsPerProcessor.set (i, 0 );
161168 }
162169}
163170
0 commit comments