#ifndef _HEARTBEAT_H
#define _HEARTBEAT_H

extern "C"
{
#include <vxWorks.h>                /* vxWorks system declarations          */
#include <semLib.h>                 /* vxWorks semaphore functions          */
#include <stdioLib.h>               /* vxWorks standard I/O functions       */

#include "mbariTypes.h"             /* MBARI style guide type declarations  */
#include "mbariConst.h"             /* Miscellaneous constants              */

#include "usrTime.h"                /* MBARI time and date functions        */

#include "datamgr.h"                /* Data Manager declarations            */
#include "dm_errno.h"               /* Data Manager error declarations      */
};

#define HEARTBEAT_MONITOR_STACKSIZE 5000
#define HEARTBEAT_MONITOR_PRIORITY    50

class Heartbeat 
{
  public:

  Heartbeat(const char *heartbeatName, const char *aliveName,
	    Period period);

  ~Heartbeat();

  STATUS beat();
  STATUS delay();
  
  protected:

  Nat32           heartbeat; 
  Period          beatPeriod;
  DmNat32Object   *heartbeatDm;
  DmBooleanObject *aliveDm;
  
  SEM_ID          delaySem;

  Int32   monitorTaskId;
  static STATUS MonitorTask( Heartbeat *hbObj );
};

#endif


