#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "plxstructs.h"
FILE *plxfile = NULL; //Global file pointer is ok for now...
struct PL_FileHeader fileheader; //we'll slurp in the file header to fileheader
struct PL_ChanHeader channelheader[128]; //This is max channels in any system right now
struct PL_SlowChannelHeader continuousheader[384]; //this is max (128 * 3) continuous channels right now
struct PL_EventHeader eventheader[64]; //Not sure what the max is, this is an overshoot
int main(void)
{
//This is helpful debug info if necessary...
/* char mydir[128];
getcwd(mydir, 100);
printf("pwd = %s\n", mydir);
*/
//Set up the file pointer and a little error checking
const char *filename = "64chWB-LargeFile.plx";
plxfile = fopen(filename, "r");
if (plxfile == NULL)
{
printf ("error opening file\n");
return 0;
}
//First read in the file header
fread(&fileheader, sizeof(struct PL_FileHeader), 1, plxfile);
printf("Number of DSP (AKA ""spike"") channels: %i\n", fileheader.NumDSPChannels);
printf("Number of continuous (""wideband, spike, FP"") channels: %i\n", fileheader.NumSlowChannels);
printf("Number of event channels %i\n", fileheader.NumEventChannels);
//Second read in the spike channel headers
int x;
fread(&channelheader, sizeof(struct PL_ChanHeader) * fileheader.NumDSPChannels, 1, plxfile);
for (x = 0; x < fileheader.NumDSPChannels; x++)
{
printf("Spike Channel Name: %s\n", channelheader[x].Name);
}
//Third read in the event headers
int z;
fread(&eventheader, sizeof(struct PL_EventHeader) * fileheader.NumEventChannels, 1, plxfile);
for (z = 0; z < fileheader.NumEventChannels; z++)
{
printf("Event Channel Name: %s\n", eventheader[z].Name);
}
//Fourth read in the continuous (AKA slow) channel headers
int y;
fread(&continuousheader, sizeof(struct PL_SlowChannelHeader) * fileheader.NumSlowChannels, 1, plxfile);
for (y = 0; y < fileheader.NumSlowChannels; y++)
{
printf("Continuous Channel Name: %s\n", continuousheader[y].Name);
}
fclose(plxfile);
return 0;
}