// C++ code Copyright (C) David R. Evans G4AMJ/NQ0I

#ifndef PDSDRH
#define PDSDRH

// classes for PDS data records

#include <data.h>
// ***************************  pdsdr_record  **************************
// the PDS data record class

class science_edr_record;

class pdsdr_record : public data_record
{ boolean _toggle;
  byte _attenuation, _format, _frequency, _por_counter, _pra_mode, 
       _pra_submode, _sc_mode;
  char _pol3;
  int16 _record_duration, _n_bytes;
  uint16 _sc_mode_command, _sc_configuration_command;
  uint32 _fixlo_frequency;
  
public:
  pdsdr_record(const science_edr_record&, const int n_sweep);
  pdsdr_record(void) { };
  
  void operator=(char*);        // ASCII read
  void operator=(FILE*);        // binary read

  reveal(byte, format, _format);
  reveal(int, duration, _record_duration);
  reveal(int, pra_mode, _pra_mode);
  reveal(int, pra_submode, _pra_submode);
  reveal(char, pol3, _pol3);
  reveal(int, toggle, _toggle);
  reveal(int, por_counter, _por_counter);
  reveal(int, attenuation, _attenuation);
  reveal(uint16, sc_mode_command, _sc_mode_command);
  reveal(uint16, sc_configuration_command, _sc_configuration_command);
  reveal(int, frequency, _frequency);
  reveal(uint32, fixlo_frequency, _fixlo_frequency);
  reveal(int, record_duration, _record_duration);
  reveal(int, n_bytes, _n_bytes);
  reveal(uint16, sc_mode, _sc_mode);

  void read(FILE*);
  void write(FILE*);
  inline int16 datum(const int n) const
    { return _int16_record[n]; }  // wrt 0
};

extern ostream& operator<<(ostream&, const pdsdr_record&);

// ************************  pdsdr_file  ****************************
class pdsdr_file : public data_file
{ uint32 _get_file_size(void);
  
  uint32 ** start_of_record_index;
  
public:
  pdsdr_file(DREstring& filename, const char* mode = "rb" );
  ~pdsdr_file(void) { }; 
  void read(pdsdr_record&, const int rec_nr = -1);
  void read(GMDR&, const int rec_nr = -1);
  uint32 size(void);
};

#endif

