/****************************************************************************/
/* terminal.h  (c++)                                                        */
/*------------------------------------------------------------------------- */
/* Licencia GPL                                                             */
/* Programa de prueba de la clase Rhino                                     */
/****************************************************************************/
/* Marco Alvarez Reyna                                                      */
/* CIII UTN-FRC Argentina                                                   */
/* Mayo 2007 / Abril 2008                                                   */
/* mail: marcoalrey@gmail.com                                               */
/****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
//#include <curses.h>
#include "rhino.h"

/*****************************/
/*  Declaraciones            */
/*****************************/

Rhino *RhinoBot = NULL;
unsigned int uiCommandEnumeration;
unsigned int uiCode;
unsigned int uiLogLevel;
char sMessage[MSG_LENGTH];
char sAux[4];

/*****************************/
/*  Funcion Principal        */
/*****************************/
int main(void){
/*
Prueba general de todos los niveles de logueo de mensajes y todos los mensajes de estado y error de la clase RHINO
*/
    for(int j=0; j<4; j++){

	RhinoBot = new(Rhino);

	for(int i=0; i<256; i++){
	    RhinoBot->set_LogLevel(j);
	    RhinoBot->ProcessCommandToRhino("SS");
	    sprintf(sAux,"%d", i);
	    RhinoBot->ProcessMessageFromRhino(sAux);

	    if(RhinoBot->CBkMsg()){
		RhinoBot->get_CBkMsg(sMessage);
		printf("CBkMsg:\n%s\n", sMessage);
	    }
	}

	for(int i=0; i<256; i++){
	    RhinoBot->set_LogLevel(j);
	    RhinoBot->ProcessCommandToRhino("SA");
	    sprintf(sAux,"%d", i);
	    RhinoBot->ProcessMessageFromRhino(sAux); 

	    if(RhinoBot->CBkMsg()){
		RhinoBot->get_CBkMsg(sMessage);
		printf("CBkMsg:\n%s\n", sMessage);
	    }
	}
    
	for(int i=0; i<129; i++){
	    RhinoBot->set_LogLevel(j);
	    RhinoBot->ProcessCommandToRhino("SE");
	    sprintf(sAux,"%d", i);
	    RhinoBot->ProcessMessageFromRhino(sAux);

	    if(RhinoBot->CBkMsg()){
		RhinoBot->get_CBkMsg(sMessage);
		printf("CBkMsg:\n%s\n", sMessage);
	    }
	}

	delete(RhinoBot);

    }

/*
Prueba de las funciones "ProcessCommandToRhino" y "ProcessMessageFromRhino" para el paso de mensajes de la clase al programa principal
*/
/*
    RhinoBot = new(Rhino);
    
    for(int i=0; i<8; i++){

	fprintf(stdout,"%s","Ingrese Log Level: ");
	fscanf(stdin,"%s",sAux);
	RhinoBot->set_LogLevel(atoi(sAux));
	
	fprintf(stdout,"%s","Ingrese comando: ");
	fscanf(stdin,"%s",sAux);
	RhinoBot->ProcessCommandToRhino(sAux, &uiCommandEnumeration);
	
	fprintf(stdout,"%s","Ingrese argumento: ");
	fscanf(stdin,"%s",sAux);
	RhinoBot->ProcessMessageFromRhino(uiCommandEnumeration, sAux, &uiCode, sMessage);

	RhinoBot->get_LogLevel(&uiLogLevel);
	printf("Terminal->Main:\n\tCode:\t%d\n\tLogLevel:\t%d\n\tMessage:\t%s\n", uiCode, uiLogLevel, sMessage );

    }

    delete(RhinoBot);
*/

/*
Prueba de la funcion CBkMsg para el paso de mensajes de la clase al programa principal
*/
/*
    RhinoBot = new(Rhino);

    for(int i=0; i<8; i++){

	fprintf(stdout,"%s","Ingrese Log Level: ");
	fscanf(stdin,"%s",sAux);
	RhinoBot->set_LogLevel(atoi(sAux));
	
	fprintf(stdout,"%s","Ingrese comando: ");
	fscanf(stdin,"%s",sAux);
	RhinoBot->ProcessCommandToRhino(sAux);
	
	fprintf(stdout,"%s","Ingrese argumento: ");
	fscanf(stdin,"%s",sAux);
	RhinoBot->ProcessMessageFromRhino(sAux);

	if(RhinoBot->CBkMsg()){
	    RhinoBot->get_CBkMsg(sMessage);
	    printf("CBkMsg:\n%s\n", sMessage);
	}
    }
    
    delete(RhinoBot);
*/
    fprintf(stdout,"%s","\nAUFWIEDERSEHEN\n");
    return 0;
}

