#ifndef _POWERSWITCHGUI_H
#define _POWERSWITCHGUI_H
static char PowerSwitchGui_h_id[] = "$Header: /usr/tiburon/unix/gui/tmacs/RCS/PowerSwitchGui.h,v 1.8 1998/03/12 16:12:05 oreilly Exp $";

/*
$Log: PowerSwitchGui.h,v $
Revision 1.8  1998/03/12 16:12:05  oreilly
Added callback method for "enable" of MotorSwitchGui

Revision 1.7  1998/02/23 16:12:15  oreilly
*** empty log message ***

Revision 1.6  1997/08/12 15:03:39  oreilly
*** empty log message ***

 * Revision 1.5  97/05/07  17:34:52  17:34:52  oreilly (Thomas C. O'Reilly)
 * Delete contained DmInputDetector in destructor.
 * 
 * Revision 1.4  97/04/09  14:02:22  14:02:22  oreilly (Thomas C. O'Reilly)
 * Added methods to get switch status, turn switch on and off
 * 
 * Revision 1.3  97/03/25  15:45:15  15:45:15  oreilly (Thomas C. O'Reilly)
 * Added callback methods, method to get status
 * 
 * Revision 1.2  97/03/20  12:36:28  12:36:28  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.1  96/10/28  09:14:00  09:14:00  oreilly (Thomas C. O'Reilly)
 * Initial revision
 * 
*/

#include <values.h>
#include "DmGuiObject.h"
#include "powerTypes.h"
#include "DynamicButton.h"
#include "DmInputDetector.h"
#include "thrusterDM.h"

#define SWITCH_REQUEST "SWITCH_REQ"
#define SWITCH_STATUS "SWITCH_STATUS"
#define SWITCH_CURRENT "CURRENT"
#define NoCurrent -MAXSHORT

class PowerSwitchGui : public DmGuiObject 
{
  public:

  static const char *const statusChangeCallback;

  PowerSwitchGui(const char *name, Widget parent, 
		 const char *switchDmPrefix,
		 const char *switchName,
		 int buttonWidth, int buttonHeight,
		 int period, Boolean showCurrent = True);

  ~PowerSwitchGui();

  virtual const char *className()
  {
    return "PowerSwitchGui";
  }
  
  virtual void updateGui(DM_Item handle = 0);
  virtual void updateFromPeer(DmGuiObject *peer, void *clientData);

  switchStatus status();

  int turnOn();
  int turnOff();

  void setSensitive(Boolean sensitive);
  

  protected:
  Boolean _dummySwitch;
  char *_switchName;
  DynamicButton *_button;
  DmEnumObject *_dmRequest;
  DmEnumObject *_dmStatus;
  DmInt16Object *_dmCurrent;
  DmInputDetector *_statusDetector;
  
  Pixel _noPwrForeground, _noPwrBackground;
  Pixel _onForeground, _onBackground;
  Pixel _offForeground, _offBackground;
  Pixel _faultForeground, _faultBackground;
  Int32 _status;
  Int16 _current;
  
  void toggleState(void);
  int requestState(switchStatus state);
  
  static XtResource _resources[];

  Boolean _showCurrent;
  
  private:
  static void callback(Widget w, XtPointer clientData, XtPointer callData);

};


class MotorSwitchGui : public PowerSwitchGui
{
  public:

  static const char *const enableStatusChangeCallback;

  MotorSwitchGui(const char *name, Widget parent, 
		 const char *switchDmPrefix,
		 const char *enableDmPrefix,
		 const char *switchName,
		 int buttonWidth, int buttonHeight,
		 int period);

  ~MotorSwitchGui();

  virtual const char *className()
  {
    return "MotorSwitchGui";
  }
  
  virtual void updateFromPeer(DmGuiObject *peer, void *clientData);

  motorEnableState enableStatus();

  protected:
  Widget _enableButton;
  DmEnumObject *_dmEnableRequest;
  DmEnumObject *_dmEnableStatus;
  Int32 _enableStatus;

  void toggleEnableState();
  
  private:
  static void enableCallback(Widget w, 
			     XtPointer clientData, XtPointer callData);  
  
};


#endif
