
#ifndef _DvlOutput_H
#define _DvlOutput_H

#include "SharedData.h"

#define DvlOutputName "DvlOutput_ShmemName"

#define NX                  3		/* number of cartesian dof            */
#define NXE                 4		/* number of cartesian dof & error    */

/*
CLASS 
DvlOutput

DESCRIPTION
Passes the DVL data from the driver, through shared memory, to the server.

AUTHOR
The long arm of Tom O'Reilly
*/
#include "DvlIF.h"

class DvlOutput : public SharedData {

public:

  struct Data {
    TimeIF::TimeSpec sampleTime;
    //
    // m/s wrto the bottom, in SNAME standard ship coordinates.  The 4th 
    // component is the least-squares error.  No coordinate transformation
    // is done on this component.
    //
    DvlIF::Vector bottomTrackVelocity;
    //
    // Bitmap showing good/bad correlation and good/bad echo intensity for
    // each of the 4 beams.
    //
    long bottomStatus;
    //boolean flag indicating validity of altitude
    Boolean bottomDetectStatus;
    //
    // m/s wrto a water layer, in SNAME standard ship coordinates.  The 4th 
    // component is the least-squares error.  No coordinate transformation
    // is done on this component.
    //
    // The distance and thickness of the water layer are set in 
    // Dvl::initialize().
    //
    DvlIF::Vector waterMassVelocity;
    //
    // Bitmap showing good/bad correlation and good/bad echo intensity for
    // each of the 4 beams.
    //
    long waterStatus;
    //
    // Time at which the ping was sent, in seconds.  This counter starts
    // from zero when the instrument begins pinging. (Check this)
    //
    double pingTime;
    //
    // Range to the bottom, meters.  It's cos(30) times the average of the 4
    // beam ranges.
    //
    double range;
    //
    // DVL temp in Deg C.
    //
    double temp;
    //
    // Bitmap.  Nonzero means that the DVL reported a bad velocity by setting
    // a component to -32768.
    //
    double pitch;
    //
    // DVL tilt sensor pitch, Degrees.
    //
    double roll;
    //
    // DVL tilt sensor roll, Degrees.
    //
    double heading;
    double beam1;
    double beam2;
    double beam3;
    double beam4;
    double spdsnd;
    double toping;
    //
    // DVL compass heading, Degrees.
    //
    long dataStatus;
    //
    // Bad communication flag.  I would rather this be a Boolean, or even
    // an int, but apparently idl accepts neither.
    //
    // Some examples of causes of bad communications are a checksum failure, or
    // a timeout by readNChars().
    //
    long badComms;
  };

  DvlOutput(Access access = NoAccess, Boolean init = False);

  ~DvlOutput();

  ////////////////////////////////////////////////////////////////////
  // 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();

  ////////////////////////////////////////////////////////////////////
  // Your application accesses the fields of this Data object, before 
  // calling write() or after calling read().
  struct Data data;

};

#endif
