/****************************************************************************/
/* Copyright (c) 2012 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : DeltaTOutput.h                                                */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 09/17/2012                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/

#ifndef _DeltaTOutput_H
#define _DeltaTOutput_H

#include <time.h>
#include "TimeIF.h"
#include "SharedData.h"

#define DeltaTOutputName "DeltaTOutput_ShmemName"

/*
CLASS 
DeltaTOutput

DESCRIPTION
Output of DeltaT driver

AUTHOR
Henthorn
*/

#define  MAX_BEAMS  480

class DeltaTOutput : public SharedData {

public:

  struct Data {

    TimeIF::TimeSpec update_time;
    Boolean enabled;
    float dt_range;               // Altitude calculated by the DeltaT
    float dt_interval;            // Time between pings
    unsigned long ping_number;
    int   nbeams;
    float beam_ranges[MAX_BEAMS];
    int   intensities[MAX_BEAMS];
    double interrogation_time;     // Time beamformer pinged epochseconds.msec

  };

  //DeltaTOutput(Access access = NoAccess, Boolean init = False);
  DeltaTOutput(const char* name = DeltaTOutputName,
	       Access access = NoAccess, Boolean init = False);

  ~DeltaTOutput();

  // A single function to build a unique name for the memory.
  // User passes in a suffix to append to DeltaTOutputName, a buffer
  // to place the resulting name, and the length of the buffer.
  // Returns a pointer to the buffer as well.
  // Usage:
  //  char buf[100];
  //  _input = new DeltaTOutput(DeltaTOutput::makeName("suf",buf,sizeof(buf)));
  //
  static char* makeName(char* dest, char* suffix, int destlen);

  ////////////////////////////////////////////////////////////////////
  // Read from shared memory to this object's Data::data element
  void read();

  ////////////////////////////////////////////////////////////////////
  // Write from this object's Data::data element to shared memory
  void write();

  Data data;

};

#endif
