#ifndef _POWERBUS_H
#define _POWERBUS_H
static char PowerBus_h_id[] = "$Header: /usr/tiburon/unix/gui/tmacs/RCS/PowerBus.h,v 1.3 1998/05/18 20:18:09 oreilly Exp $";

/*
$Log: PowerBus.h,v $
Revision 1.3  1998/05/18 20:18:09  oreilly
*** empty log message ***

Revision 1.2  1996/10/28 09:13:57  oreilly
*** empty log message ***

*/


#include <Vk/VkNode.h>
#include <Vk/VkGraph.h>
#include "PowerSwitchGui.h"
#include "PowerSwitchStatus.h"
#include "VehicleComponent.h"
#include "array.h"

#define BusThickness 12

class PowerSwitchNode : public VkNode
{
  public:
  
  PowerSwitchNode(const char *name, 
		  const char *switchName,
		  const char *switchDmPrefix,
		  int buttonWidth,
		  int buttonHeight,
		  int period, 
		  Boolean showCurrent,
		  Boolean readOnly);
  
  ~PowerSwitchNode();

  virtual const char *className()
  {
    return "PowerSwitchNode";
  }
  
  protected:
  virtual void build(Widget parent);
  int _buttonWidth, _buttonHeight;
  char *_switchName;
  char *_switchDmPrefix;
  PowerSwitchGui *_powerSwitch;
  PowerSwitchStatus *_powerStatus;
  int _period;
  Boolean _showCurrent;
  Boolean _readOnly;
};


class MotorSwitchNode : public PowerSwitchNode
{
  public:
  
  MotorSwitchNode(const char *name, 
		  const char *switchName,
		  const char *switchDmPrefix,
		  const char *enableDmPrefix,
		  int buttonWidth,
		  int buttonHeight,
		  int period);

  ~MotorSwitchNode();
  
  protected:
  virtual void build(Widget parent);
  char *_enableDmPrefix;
  
};


class SwitchGroupNode : public VkNode
{
  public:
  SwitchGroupNode(const char *name, 
		  int buttonWidth,
		  int buttonHeight,
		  int period
		  );
  
  ~SwitchGroupNode();

  virtual const char *className()
  {
    return "SwitchGroupNode";
  }
  
  void addSwitch(const char *switchName, 
		 const char *dmSwitchPrefix,
		 Boolean readOnly);

  
  protected:

  virtual void build(Widget parent);

  int _buttonWidth, _buttonHeight;
  int _period;  

  struct SwitchDescription
  {
    SwitchDescription();
    ~SwitchDescription();

    char *name;
    char *dmPrefix;
    Boolean readOnly;
    PowerSwitchGui *powerSwitch;
    PowerSwitchStatus *powerStatus;
  };

  DynArray<SwitchDescription *> _switchDescriptions;
};



class PowerBus : public VkComponent
{
  public:

  PowerBus(const char *name, Widget parent, Bus *bus,
	   int buttonWidth, int buttonHeight);

  ~PowerBus();

  virtual void afterRealizeHook();
  
  protected:

  Pixel _onColor, _offColor;

  void createNodes(VehicleComponent *parent, VkNode *parentNode,
		   int index, int buttonWidth, int buttonHeight);
  
  VkGraph *_graph;
  
  DynArray<VkNode *> _nodes;
  
  private:
  static XtResource _resources[];
};


#endif
