#include "graf.h"

using namespace std;

int main(int argc, char *argv[]){
  try {
    char* file;
    int max_inputs=50, max_gates=0, kl_runs=5, tests=1;
    
    cout << "-DEKOMPOZICE LOGICKYCH OBVODU S OHLEDEM NA DIAGNOSTIKU-" << endl << endl;
    if (argc<3){
        cout << "Napoveda - parametry: <jmeno souboru> <pocet vstupu> <pocet hradel> <pocet pokusu>" << endl << endl;        
        cout << "<jmeno souboru> nazev souboru ve formatu netlist*" << endl;
        cout << "<pocet vstupu> maximalni pocet vstupu pro podobvody*" << endl;
        cout << "*povinne parametry" << endl;        
        cout << "<pocet hradel> maximalni pocet, ktery muze byt v podobvodu (0=vypnuto)" << endl;
        cout << "<pocet pokusu> pocet vykonanych pokusu o dekompozici (1)" << endl;    
        cout << "(v zavorkach jsou uvedeny defaultni hodnoty pri nezadani)" << endl << endl;            
    }else{
        file=argv[1];
        max_inputs=atoi(argv[2]);
        if (argc>3) max_gates=atoi(argv[3]);
        if (argc>4) tests=atoi(argv[4]);
        if ((max_inputs<5)||(tests<1)) throw string ("Nepovolene parametry!");
        
        time_t start, end;
        double dif;
        time (&start);
        srand((unsigned)time(NULL));     
        
        Graf x1(file);
        x1.decompose(max_inputs, max_gates, kl_runs, tests);
    
        time (&end);
        dif = difftime (end,start);
        printf ("Hotovo za %.01f sekund.\n\n", dif);        
    }
  }  
  catch (string exc){
    cout << exc << endl;      
  }     
  system("PAUSE");
  return EXIT_SUCCESS;
}
