#ifndef _IBCAPP_H
#define _IBCAPP_H

#include "DataManager.h"
#include "MicroApp.h"
#include "Sio32Interface.h"
#include "IbcCardManager.h"
#include "WaterAlarm.h"
#include "DynamicArray.h"

#define HasJboxWaterAlarm TRUE
#define NoJboxWaterAlarm FALSE

#define HumidityWarnThreshold 25
#define HumidityAlarmThreshold 35

class IbcCardManager;


/*
CLASS 
IbcApp

DESCRIPTION
IbcApp is a subclass of MicroApp. It differs from that class
in that it contains a IbcCardManager container object and references a 
Sio32Interface object.

AUTHOR
Tom O'Reilly
*/
class IbcApp : public MicroApp
{
  public:
  
  ///////////////////////////////////////////////////////////////////
  // Constructor
  // [input] systemName:  e.g., "TIBURON"
  // [input] appName: e.g., "MWSLED"
  // [input] device: Sio32Interface device
  IbcApp(const char *systemName,
	 const char *appName,   
	 Sio32Interface *device);
  
  ~IbcApp();
  
  IbcCardManager *ibc;

  Sio32Interface *device;
  
  DynamicArray waterAlarms;
  
  protected:

  ///////////////////////////////////////////////////////////////////
  // Enumerations for water alarm types
  enum WaterAlarmType {
    HousingWaterAlarm,
    JboxWaterAlarm
  };

  ///////////////////////////////////////////////////////////////////
  // Add WaterAlarm object to waterAlarms list. 
  // [input] type: WaterAlarmType
  // [input] getCmd: Micro command to get alarm bits
  // [input] thisAlarmMask: Bitmask for this alarm
  // [input] getThreshCmd: Micro command to get alarm threshold
  // [input] setThreshCmd: Micro command to set alarm threshold
  // [input] onSrqOpcode: SRQ code for alarm turning on
  // [input] offSrqOpcode: SRQ code for alarm turning off
  WaterAlarm *addWaterAlarm(WaterAlarmType type,
			    Word getCmd,
			    Word thisAlarmMask,
			    Word getThreshCmd,    
			    Word setThreshCmd,
			    Word onSrqOpcode,
			    Word offSrqOpcode);
  
  
  ///////////////////////////////////////////////////////////////////
  // Called before main run() loop
  virtual int initialize();
  
  ///////////////////////////////////////////////////////////////////
  // Process SRQ from micro. Return 0 on success, -1 on error
  // [input] srqPacket: packet read from micro
  // [input] nPacketBytes: # of bytes in srqPacket
  virtual int processSrq(Byte *srqPacket, int nPacketBytes);

  ///////////////////////////////////////////////////////////////////
  // Handle Micro reset
  virtual DeviceInterface::LinkState processMicroReset();

};


#endif



