/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : ahrsServer.cc                                                 */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#include <stdio.h>
#include <string.h>

#include "Syslog.h"
#include "Exception.h"
#include "System.h"
#include "AHRSServer.h"

int main(int argc, char **argv)
{
  const char *driverProgram;

  // Set task priority
  if (System::setTaskPriority(CriticalServerPriority) == -1)
    return 1;

  Boolean error = False;

  switch (argc) {

  case 1:
    // Default driver
    driverProgram = "crossbow";
    break;

  case 2:
    if (!strcmp(argv[1], "kvh"))
      driverProgram = "kvhDriver";
    else if (!strcmp(argv[1], "crossbow"))
      driverProgram = "crossbow";
    else {
      fprintf(stderr, "Invalid option: %s", argv[1]);
      error = True;
    }
    break;

  default:
    error = True;
  }


  if (error) {

    fprintf(stderr, 
	    "usage: %s [driver]   (driver is \"kvh\" or \"crossbow\")\n",
	    argv[0]);
    return 1;
  }

  try
  {
    AHRSServer *ahrsServer = new AHRSServer(driverProgram);

    ahrsServer->run();
  }
  catch (Exception e)
  {
    Syslog::write("AHRSServer  Exception %s\n", e.msg);
  }

  return 0;
}

