#ifdef SYSTEMC
#include "systemc.h"
#endif
#include "../include/TTY.h"
#include <iostream>

using namespace std;
using namespace environment;
using namespace environment::tty;

#ifdef SYSTEMC
int sc_main (int argc, char * argv[])
#else
int    main (int argc, char * argv[])
#endif
{
  cout << "<main> Begin" << endl;

  uint32_t nb_tty = 4;
  string * name_tty = new string [nb_tty];

  name_tty [0] = "tty_0";
  name_tty [1] = "tty_1";
  name_tty [2] = "tty_2";
  name_tty [3] = "tty_3";

  Parameters * param = new Parameters (nb_tty,
				       name_tty,
				       true);

  TTY * tty = new TTY ("my_tty", param);
  tty->reset();

  cout << *tty << endl;
  
  char * message_0 =  "Ici Londre : Adeline aime la saucisse de Frankort.\nJe repete : Adeline aime la saucisse de Frankort"  ;
  char * message_1 =  "Ici Londre : Maurice a garer le camion de bernard dans la cour.\nJe repete Maurice a garer le camion de bernard dans la cour";
  char * message_2 =  "Ici Londre : Londre est la ville qui diffuse des messages a la con.\nJe repete : Londre est la ville qui diffuse des messages a la con";
  char * message_3 =  "Ici Londre : Non, le debarquement n'aura pas lieu le 6 juin 1944 en Normandie, et je ne me repete pas";

  char * message [nb_tty];
  message[0] = message_0;
  message[1] = message_1;
  message[2] = message_2;
  message[3] = message_3;

  for (uint32_t j = 0; j < nb_tty ; j ++)
    {
      for (uint32_t i = 0; i < strlen(message[j]); i++)
	tty->write(j,message[j][i]);
    }

  cout << "<main> Press <Enter> to stop the test" << endl;
  getchar();

  delete    tty;
  delete    param;
  delete [] name_tty;
  cout << "<main> End" << endl;
  
  return EXIT_SUCCESS;
}
