/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : SimulatedDeltaT.h                                        */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
//////////////////////////////////////////////////////////////////////
//
// PURPOSE:  Simulate the DeltaT multibeam.
// AUTHOR:   McEwen
// DATE:     2013/1/18
//
//////////////////////////////////////////////////////////////////////
//
#ifndef _SimulatedDeltaT_H
#define _SimulatedDeltaT_H
#include "DeltaTIF_SK.h"
#include "SimulatorIF.h"
#include "Attributes.h"
#include "AttributeParser.h"
#include "DeltaTLog.h"
#include "TimeP.h"

#define NBEAMS 120

class SimulatedDeltaT : public DeltaTIF_SK {

   friend class DeltaTLog;

public:

  SimulatedDeltaT();
  ~SimulatedDeltaT();

protected:

  ///////////////////////////////////////////////////////////////////
  // Called when the simulator says new data is ready
//  void compute(TaskInterface *taskInterface, EventCode code);
  void compute(void);

  virtual double range(void);
  virtual unsigned short nbeams(void);
  virtual unsigned short interval(void);
  virtual Boolean enabled(void);
  virtual void update_time(TimeIF::TimeSpec *timestamp);
  virtual void get(DeltaTIF::Data *data);
  virtual void start(void);
  virtual void stop(void);

  virtual int spawnAuxTasks();

  SimulatorIF *_simulator;
  //
  // Class variables:
  //

  // Maximum measurable range
  long  _maxRange;
  double  _noReturnRange;
  long  _startGain;
  long  _absorption;
  double _absorpEng;
  long  _pulseLen;
  long  _minRange;
  long  _triggerCtrl;
  Boolean _profile;
  long  _delay;
  char  _serialStatus;
  double _trainRef;
  short  _train;
  double _sectorEng;
  unsigned char _sector;
  double _stepSizeEng;
  long   _stepSize;
  long _acousticFreqEng;
  long _acousticFreq;
  double _pingPeriod;
  long _pulseLenEng;
  long  _minRangeEng;

  double _grazing[DeltaTIF::MaxBeams];
  int _nbeams;
  float _range;
  float _interval;
  Boolean _enabled;
  float _beam_ranges[NBEAMS];
  int _intensities[NBEAMS];

  long  _time;

  double _xzAngle;
  double zMax;


  double _los_B[NBEAMS][3];
  double _minGrazing;

  long _bisectCnt[DeltaTIF::MaxBeams];

  TimeIF::TimeSpec _sampleTime;

  timespec _epoch;

  int _k;

  Boolean _echoReceived;


  //PSA916Log *_log;

  DeltaTLog *_log;
  char _echoData[DeltaTIF::MaxBeams];

  long _askTime, _ansTime;

//  Attributes _attributes;
};

#endif
