/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : System.h                                                      */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _SYSTEM_H
#define _SYSTEM_H

#include <sys/types.h>

// Period of Navigation task
#define NavigationPeriodMillisec 200

// Environment variable names
#define AuvConfigDirName "AUV_CONFIG_DIR"
#define AuvLogDirName    "AUV_LOG_DIR"
#define AuvPlanDirName   "AUV_PLAN_DIR"

// Link to latest data log subdirectory
#define LatestLogDirName "latest"

// System period in millisec
#define SystemPeriodMillisec 200

// Highest reasonable priority for QNX 
#define HighestPriority 	  19

#define CriticalDriverPriority    19
#define NavigationPriority        18
#define NavigationServerPriority  17
#define DynamicControlPriority    16
#define TailconeDriverPriority    15
#define LayeredControlPriority    14

#define CriticalServerPriority    10	// Servers use Floating Priority
#define NonCriticalDriverPriority 10
#define NonCriticalServerPriority 10	// Servers use Floating Priority
#define DynamicCtrlServerPriority 10	// Servers use Floating Priority
#define TailconeServerPriority    10	// Servers use Floating Priority
#define LayeredCtrlServerPriority 10	// Servers use Floating Priority

#define BackgroundPriority        10

/*
CLASS 
System

DESCRIPTION
Various utilities for AUV system configuration

AUTHOR
Tom O'Reilly
*/
class System {

public:

  ///////////////////////////////////////////////////////////////////
  // Default configuration file name
  // [input] basename: Name of configuration file, sans directory
  //                   (e.g. "vehicle.cfg")
  static const char *configurationFile(const char *basename);

  ///////////////////////////////////////////////////////////////////
  // Default mission plan file name
  // [input] basename: Name of mission plan file, sans directory
  //                   (e.g. "abort.plan")
  static const char *missionPlanFile(const char *basename);

  ///////////////////////////////////////////////////////////////////
  // Spawn specified program, with specified arguments
  static pid_t spawn(const char *programName, const char *args);

  ///////////////////////////////////////////////////////////////////
  // Set process priority to specified value
  static int setTaskPriority(int priority);

  ///////////////////////////////////////////////////////////////////
  // Copy specified file to log directory
  static void copyToLogDir(const char *filename);

  ///////////////////////////////////////////////////////////////////
  // Sleep for the indicated period
  static void milliSleep( unsigned long millisecs);

};


#endif
