#ifndef _SERIALDEVICE_H
#define _SERIALDEVICE_H

#include "MicroApp.h"

/*
CLASS 
SerialDevice

DESCRIPTION
Abstract class for serial device. A SerialDevice object can be added to 
certain IbcCard types, e.g. QuadSerialCard.

AUTHOR
Tom O'Reilly
*/
class SerialDevice {
  public:

  ///////////////////////////////////////////////////////////////////
  // Constructor
  // [input] name: Name of device
  SerialDevice(const char *systemName,
	       const char *appName,
	       const char *deviceName,
	       Word channelNo
	       );

  ~SerialDevice();

  ///////////////////////////////////////////////////////////////////
  // Initialize DM items and micro
  virtual STATUS handleResetEvent() = 0;
  
  ///////////////////////////////////////////////////////////////////
  // Add DM items to monitored group
  // [input] dmMonitor: DmMonitor which monitors component
  virtual STATUS startMonitoring(DmMonitor *dmMonitor) = 0;

  ///////////////////////////////////////////////////////////////////
  // Process changes to DM items
  virtual STATUS processDmChanges(DmGroup *dmGroup) = 0;

  ///////////////////////////////////////////////////////////////////
  // Start providers for sampling
  virtual STATUS startSampling() = 0;

  ///////////////////////////////////////////////////////////////////
  // Read micro and update DM items
  virtual STATUS sampleMicro() = 0;

  ///////////////////////////////////////////////////////////////////
  // Call after receiving SRQ
  virtual MBool handleSrq(Word requestCode, Byte *packet) = 0;

  ///////////////////////////////////////////////////////////////////
  // Call after receiving reset SRQ
  virtual STATUS handleResetSrq() = 0;
  
  ///////////////////////////////////////////////////////////////////
  // Return name of card
  const char *name();


  ///////////////////////////////////////////////////////////////////
  // Return channel number
  Word channelNo();

 protected:

  Word _channelNo;

  char *_systemName;
  char *_appName;
  char *_name;

  ///////////////////////////////////////////////////////////////////
  // Prefix to use for DataManager item  names
  char *_dmPrefix;
};


#endif

