#ifndef _FIRECONTROLDM_H
#define _FIRECONTROLDM_H

#include "DataManager.h"

#define FireControlPasswordLen 32
#define ArmPassword "arming"
#define FirePassword "firing"


/*
CLASS 
FireControlDm

DESCRIPTION
DataManager interface for applications which include a FireControl object

AUTHOR
Tom O'Reilly
*/

class FireControlDm {

public:

  ///////////////////////////////////////////////////////////////////
  // State of the fire-control circuit
  enum State {
    Unknown,
    Disarmed,
    Armed,
    FastFiring,
    SlowFiring,
    Fired
  };

  ///////////////////////////////////////////////////////////////////
  // Logical bits (from hardware) which are used to compute State
  enum StateBits {
    ArmedBit = 01,
    FiredBit = 02,
    PressureSwitchBit = 04,
    FastFiringBit = 010,
    SlowFiringBit = 020
  };


  ///////////////////////////////////////////////////////////////////
  // Constructor
  // [input] platformName: Name of platform (e.g. "TIBURON")
  // [input] appName: Application name (e.g. "DSLED")
  FireControlDm(const char *platformName, const char *appName);

  ///////////////////////////////////////////////////////////////////
  // Destructor
  ~FireControlDm();

  ///////////////////////////////////////////////////////////////////
  // Commands
  DmEmptyObject *arm;
  DmEmptyObject *fastFire;
  DmEmptyObject *disarm;

  ///////////////////////////////////////////////////////////////////
  // Arm and fire commands are password-protected
  DmStringObject *armPassword;
  DmStringObject *firePassword;

  ///////////////////////////////////////////////////////////////////
  // Alarms
  DmBooleanObject *armedAlarm;
  DmBooleanObject *firingAlarm;

  ///////////////////////////////////////////////////////////////////
  // State
  DmEnumObject *state;

  ///////////////////////////////////////////////////////////////////
  // Status of pressure safety switch
  // True - switch is closed and firing is possible
  // False - switch is open and cutter cannot be fired
  DmBooleanObject *pressureSwitchStatus;

  ///////////////////////////////////////////////////////////////////
  // Return State corresponding to hardware bits
  static State computeState(unsigned char stateBits);
};


#endif
