/* ROVER CONTROL SOFTWARE VERSION 1.1 */

#include <ctype.h>
#include <stdio.h>
#include <timing.h>
#include <stdlib.h>

#include "rovlib.h"
#include "rovint.h"
#include "rovsys.h"
#include "test.h"

#ifdef AZTEC_C
#include <userio.h>

#else
#include <conio.h>
#include "tt7pclib.h"
#include "tt7pcio.h"
#endif

/*FUNCTION PROTOTYPES*/

int deploy(void);
int setup(void);
int offload(void);

/* EXTERNAL VARIABLES */


/* MISC VARIABLES */



/*********************************************/

main() {
  
   char inkey; 

   tt7init();
   printf("\nTattletale Model7 Initialized");

   while(1) {
     printf("\n\n\nRover System Main Menu V1.1");
     printf("\n\n  1 -- Test Functions");
     printf("\n  2 -- Setup Deployment");
     printf("\n  3 -- Deploy");
     printf("\n  4 -- Offload Data");
     printf("\n  8 -- Test Deployment");
     printf("\n  9 -- Reset");
     QueryChar("\nEnter Selection: ",0,"1239",&inkey);
     switch(inkey){
       case '1':
	 testfunc();
	 break;
       case '2':
	 setup();
	 break;
       case '3':
	 deploy();
	 break;
       case '4':
	 offload();
	 break;
       case '8':
	 testdeploy();
	 break;
       case '9':
	 reset();
	 break;
     }
   }
} /*main*/

/*********************************************
      SETUP FUNCTION
*********************************************/

int setup(void){
  char menukey;
  struct tm	t;

  do{
    printf("\n\n\nRover Setup Menu");
    printf("\n\n  1 -- Set Clock");
    printf("\n  2 -- Change Mission Defaults");
    printf("\n  3 -- Change System Defaults");
    printf("\n  4 -- Change Calibration Coefficients");
    printf("\n  9 -- Exit");
    QueryChar("\nEnter Selection: ",'9',"12349",&menukey);

    switch(menukey){
      case '1':  /*Set Clock*/
	printf("\nSet Current Date and Time (CMD-D from CrossCut)");
	if(! QueryDateTime("\n<CR> for default", TRUE, &t))
	  return;
	SetTimeTM(&t, NULL);
	break;

      case '2':  /* Mission Defaults */
	while(!kbhit()){
	printf("\nTime in Tens of Milliseconds: %ld", TensMilliSecs());
	delaysecs(1);
	}
	break;

      case '3':  /* System Defaults */
	break;

      case '4':  /* Calibration Coefficients */
	break;
    }

  } while(menukey != '9');

}

/*******************************************************
	      Deploy Function
********************************************************/

int deploy(void){
  long delaytime = 240;

  QueryNum("\n\nEnter Deployment Delay Time (min): ","%ld","%ld", &delaytime);
  printf("\nRover will activate in %ld minutes.", delaytime);
  printf("\nDisconnect comm. cable and deploy");

  return 0;
}


/*******************************************************
	      Offload Function
********************************************************/
int offload(void){

  return 0;
}