Skip to content
Snippets Groups Projects
Commit 8f4ea8d0 authored by jsiegle's avatar jsiegle
Browse files

Rudimentary header implemented in data files

parent 3429a92f
Branches
Tags
No related merge requests found
......@@ -65,6 +65,6 @@ void Channel::reset()
void Channel::createDefaultName()
{
name = String("Channel ");
name = String("CH");
name += num;
}
\ No newline at end of file
......@@ -223,12 +223,16 @@ void RecordNode::setParameter (int parameterIndex, float newValue)
File f = File(channelPointers[i]->filename);
bool fileExists = f.exists();
channelPointers[i]->file = fopen(channelPointers[i]->filename.toUTF8(), "a+b");
if (!f.exists())
if (!fileExists)
{
// create header (needs more details, obviously)
String header = "THIS IS A HEADER.";
// create header
String header = generateHeader(channelPointers[i]);
std::cout << "Header size: " << header.getNumBytesAsUTF8() << std::endl;
fwrite(header.toUTF8(), 1, header.getNumBytesAsUTF8(), channelPointers[i]->file);
}
......@@ -271,14 +275,47 @@ void RecordNode::setParameter (int parameterIndex, float newValue)
if (isRecording) {
std::cout << "OPENING FILE: " << channelPointers[currentChannel]->filename << std::endl;
File f = File(channelPointers[currentChannel]->filename);
bool fileExists = f.exists();
channelPointers[currentChannel]->file =
fopen(channelPointers[currentChannel]->filename.toUTF8(), "a+b");
if (!fileExists)
{
// create header
String header = generateHeader(channelPointers[currentChannel]);
fwrite(header.toUTF8(), 1, header.getNumBytesAsUTF8(), channelPointers[currentChannel]->file);
}
}
}
}
}
}
String RecordNode::generateHeader(Channel* ch)
{
String header = "header.description = 'OPEN EPHYS DATA FORMAT v0.0;' \n";
header += "header.channel = '";
header += ch->name;
header += "';\n";
header += "header.bitVolts = ";
header += String(ch->bitVolts);
header += ";\n";
header = header.paddedRight(' ', HEADER_SIZE);
std::cout << header << std::endl;
return header;
}
void RecordNode::closeAllFiles()
{
......
......@@ -36,6 +36,8 @@
#include "GenericProcessor.h"
#include "Channel.h"
#define HEADER_SIZE 1024
/**
Receives inputs from all processors that want to save their data.
......@@ -135,34 +137,18 @@ private:
*/
Time timer;
/** Holds information for a given channel to be recorded to
its own file.
*/
// struct Channel
// {
// int nodeId;
// int chan;
// String name;
// bool isRecording;
// String filename;
// FILE* file;
// };
/** Closes all open files after recording has finished.
*/
void closeAllFiles();
/** Pointers to all continuous channels */
Array<Channel*> channelPointers;
Array<Channel*> eventChannelPointers;
/** Map of continuous channels.
*/
//std::map<int, Channel> continuousChannels;
/** Pointers to all event channels */
Array<Channel*> eventChannelPointers;
/** Map of event channels.
*/
//std::map<int, std::map<int,Channel> > eventChannels;
/** Generates a header for a given channel */
String generateHeader(Channel* ch);
/** Method for writing continuous buffers to disk.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment