/************************************************************************/
/* Copyright 1998 MBARI							*/
/************************************************************************/
#ifndef _TIBURONAPP_H
#define _TIBURONAPP_H
static char TiburonApp_h_id[] = "$Header: /u/oreilly/rov/tmacs/RCS/TiburonApp.h,v 1.10 1998/12/18 21:07:21 oreilly Exp $";

/*
$Log: TiburonApp.h,v $
Revision 1.10  1998/12/18 21:07:21  oreilly
Added documentation

Revision 1.9  1998/03/18 16:29:06  oreilly
*** empty log message ***

Revision 1.8  1997/09/10 08:53:43  oreilly
*** empty log message ***

 * Revision 1.7  97/08/12  14:58:42  14:58:42  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.6  97/06/16  16:01:03  16:01:03  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.5  97/05/06  16:32:20  16:32:20  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.4  97/03/20  12:37:15  12:37:15  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.3  96/11/04  15:23:14  15:23:14  oreilly (Thomas C. O'Reilly)
 * Removed system micros object
 * 
 * Revision 1.2  96/10/28  09:14:12  09:14:12  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
*/

#include <Vk/VkApp.h>
#include "DmGuiApp.h"
#include "RovMainWindow.h"
#include "SystemAlarms.h"
#include "SystemMicros.h"
#include "VehicleConfiguration.h"

#define rovEnvVar "TMACS_DIR"
#define defaultAlarmDefFile "alarmDef.dat"
#define defaultConfigFile "vehicleConfig.dat"

/*
CLASS 
TiburonApp

DESCRIPTION
TiburonApp has several responsibilities in addition to those of its 
parent class, DmGuiApp, including:

* Handle command line options,

* Provide colors for alarm priority levels,

* Provide pointer to main window,

* Contain system alarms.

There is only one instance of TiburonApp in the GUI process, and it is a 
global variable. Hence, in order to minimize the need for global variables, 
TiburonApp contains objects and pointers that are useful to many classes,
including: 

RovMainWindow
PeriodicHandler
AperiodicHandler
SystemAlarms
VehicleConfiguration

AUTHOR
Tom O'Reilly
*/
class TiburonApp: public DmGuiApp
{
  public:

  TiburonApp(
	     char *appClassName,
	     int *argc,
	     char **argv,
	     XrmOptionDescRec *optionList = NULL,
	     int sizeOfOptionList = 0
	     );

  ~TiburonApp();

  virtual const char *className()
  {
    return "TiburonApp";
  }

  ///////////////////////////////////////////////////////////////////
  // Create RovMainWindow object
  RovMainWindow *createRovMainWindow();
    
  ///////////////////////////////////////////////////////////////////
  // Return pointer to RovMainWindow
  RovMainWindow *rovMainWindow()
  {
    return _rovMainWindow;
  }
  
  ///////////////////////////////////////////////////////////////////
  // Set RovMainWindow
  void setRovMainWindow(RovMainWindow *window)
  {
    _rovMainWindow = window;
  }
  
  ///////////////////////////////////////////////////////////////////
  // Return colors used for Priority 1 alarms
  void priority1Colors(Pixel *foreground, Pixel *background)
  {
    *foreground = _priority1Foreground;
    *background = _priority1Background;
  }
  
  ///////////////////////////////////////////////////////////////////
  // Return colors used for Priority 2 alarms
  void priority2Colors(Pixel *foreground, Pixel *background)
  {
    *foreground = _priority2Foreground;
    *background = _priority2Background;
  }
  
  ///////////////////////////////////////////////////////////////////
  // Return colors used for Priority 3 alarms
  void priority3Colors(Pixel *foreground, Pixel *background)
  {
    *foreground = _priority3Foreground;
    *background = _priority3Background;
  }
  
  ///////////////////////////////////////////////////////////////////
  // Return colors used for inactive alarms
  void okColors(Pixel *foreground, Pixel *background)
  {
    *foreground = _okForeground;
    *background = _okBackground;
  }
    

  ///////////////////////////////////////////////////////////////////
  // Return colors for specified alarm priority
  void priorityColors(Priority priority, 
		      Pixel *foreground, Pixel *background)
  {
    switch (priority)
    {
      case NoPriority:
      okColors(foreground, background);
      break;
      
      case Priority1:
      priority1Colors(foreground, background);
      break;
      
      case Priority2:
      priority2Colors(foreground, background);
      break;
      
      case Priority3:
      priority3Colors(foreground, background);
      break;
    }
  }
  
  ///////////////////////////////////////////////////////////////////
  // Return fault indication colors 
  void faultColors(Pixel *foreground, Pixel *background)
  {
    *foreground = _faultForeground;
    *background = _faultBackground;
  }
  
  ///////////////////////////////////////////////////////////////////
  // Return "Power ON" indicator colors
  void powerOnColors(Pixel *foreground, Pixel *background)
  {
    *foreground = _onForeground;
    *background = _onBackground;
  }

  ///////////////////////////////////////////////////////////////////
  // Return "Power OFF" indicator colors
  void powerOffColors(Pixel *foreground, Pixel *background)
  {
    *foreground = _offForeground;
    *background = _offBackground;
  }
  
  SystemAlarms *systemAlarms;
  VehicleConfiguration *vehicleConfig;

  void systemAlarmFile(char *filename);
  void vehicleConfigFile(char *filename);

  void setIconPixmap(Widget shell);

  ///////////////////////////////////////////////////////////////////
  // Show alarm attributes
  void showAlarm(Alarm *alarm);

  ///////////////////////////////////////////////////////////////////
  // Set name of platform, for building DataManager item names. 
  // Examples: "TIBURON", "VENTANA", etc.
  void setPlatformName(const char *name);

  ///////////////////////////////////////////////////////////////////
  // Name of platform, usually a vehicle name, for building 
  // DataManager item names. E.g., "TIBURON" or "VENTANA". Default
  // name is "TIBURON".
  const char *platformName();

  protected:

  int defaultInputs(char *errorBuf);
  void getOptions(int argc, char **argv);

  static XtResource _resources[];

  static XtActionsRec _actions[];
 
  ///////////////////////////////////////////////////////////////////
  // Colors for alarm GUI
  Pixel _priority1Foreground, _priority2Foreground, _priority3Foreground;  
  Pixel _priority1Background, _priority2Background, _priority3Background;

  ///////////////////////////////////////////////////////////////////
  // General "ok" and "fault" colors
  Pixel _okForeground, _okBackground;
  Pixel _faultForeground, _faultBackground;

  ///////////////////////////////////////////////////////////////////
  // Power-on and Power-off colors
  Pixel _onForeground, _onBackground;
  Pixel _offForeground, _offBackground;
  
  
  RovMainWindow *_rovMainWindow;
  char _systemAlarmFile[256]; 
  char _vehicleConfigFile[256]; 

  Pixmap _iconPixmap;

  const char *_platformName;
};




#endif
