Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include "plxstructs.h"
  5.  
  6. FILE *plxfile = NULL; //Global file pointer is ok for now...
  7. struct PL_FileHeader fileheader; //we'll slurp in the file header to fileheader
  8. struct PL_ChanHeader channelheader[128]; //This is max channels in any system right now
  9. struct PL_SlowChannelHeader continuousheader[384]; //this is max (128 * 3) continuous channels right now
  10. struct PL_EventHeader eventheader[64]; //Not sure what the max is, this is an overshoot
  11.  
  12.  
  13. int main(void)
  14. {
  15.  
  16. //This is helpful debug info if necessary...
  17. /*  char mydir[128];
  18.  
  19.     getcwd(mydir, 100);
  20.     printf("pwd = %s\n", mydir);
  21. */
  22.  
  23. //Set up the file pointer and a little error checking
  24.     const char *filename = "64chWB-LargeFile.plx";
  25.     plxfile = fopen(filename, "r");
  26.     if (plxfile == NULL)
  27.         {
  28.             printf ("error opening file\n");
  29.             return 0;
  30.         }
  31.  
  32. //First read in the file header
  33.     fread(&fileheader, sizeof(struct PL_FileHeader), 1, plxfile);
  34.  
  35.     printf("Number of DSP (AKA ""spike"") channels: %i\n", fileheader.NumDSPChannels);
  36.     printf("Number of continuous (""wideband, spike, FP"") channels: %i\n", fileheader.NumSlowChannels);
  37.     printf("Number of event channels %i\n", fileheader.NumEventChannels);
  38.  
  39. //Second read in the spike channel headers
  40.     int x;
  41.     fread(&channelheader, sizeof(struct PL_ChanHeader) * fileheader.NumDSPChannels, 1, plxfile);
  42.     for (x = 0; x < fileheader.NumDSPChannels; x++)
  43.         {
  44.         printf("Spike Channel Name: %s\n", channelheader[x].Name);
  45.         }
  46.  
  47. //Third read in the event headers
  48.     int z;
  49.     fread(&eventheader, sizeof(struct PL_EventHeader) * fileheader.NumEventChannels, 1, plxfile);
  50.     for (z = 0; z < fileheader.NumEventChannels; z++)
  51.         {
  52.         printf("Event Channel Name: %s\n", eventheader[z].Name);
  53.         }
  54.  
  55. //Fourth read in the continuous (AKA slow) channel headers
  56.     int y;
  57.     fread(&continuousheader, sizeof(struct PL_SlowChannelHeader) * fileheader.NumSlowChannels, 1, plxfile);
  58.     for (y = 0; y < fileheader.NumSlowChannels; y++)
  59.         {
  60.         printf("Continuous Channel Name: %s\n", continuousheader[y].Name);
  61.         }
  62.  
  63.     fclose(plxfile);
  64.     return 0;
  65. }