/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : DropWeight.h                                                  */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _DropWeight_H
#define _DropWeight_H
#include "StreamSerialDriver.h"
#include "SerialDevice.h"
#include "DropWeightIF.h"
#include "DropWeightLog.h"
#include "DropWeightOutput.h"

class DropWeight : public StreamSerialDriver {

  friend class DropWeightLog;

public:

  DropWeight(SerialDevice *device);
  ~DropWeight();

  ////////////////////////////////////////////////////////////////////
  // Initialize device. Returned DeviceIF::Status
  // will be propagated to subscribers in other tasks.
  virtual DeviceIF::Status initialize();

  ////////////////////////////////////////////////////////////////////
  // Read a fixed-length record - use the default:
  // virtual DeviceIF::Status readRecord(...)

  ////////////////////////////////////////////////////////////////////
  // Process device data record. Returned DeviceIF::Status
  // will be propagated to subscribers in other tasks.
  // [input] record: Record from device
  // [input] nRecordBytes: Bytes in record
  virtual DeviceIF::Status processRecord(unsigned char *record,
                                         int nRecordBytes);



protected:

  void release(void);
  void fireGulper(void);
  short watchdogTimeout(void);
  void resetWatchdog(void);
  int spawnAuxTasks();
  void resetRelayAndCounters(void);
  void resetRelayAndPIC(void);

  DropWeightLog *_log;
  DropWeightOutput *_dwOutput;
private:

  //
  // ReleaseEnum is defined in DropWeightOutput.h
  //
  ReleaseEnum ReleaseState;

  long WatchDogTimeout;
  long Counter;
  short Wdt, Bwt, WDC, ACommsDN, WDSt_out, DW_out;
  short GulperSolenoidOut, GulperProxIn, GulperHighSideStat, GulperSolenoidFB;

};

#endif
