package test.brn;

import java.sql.SQLException;

import brn.distsim.ormapper.util.DBSaver;
import brn.sim.data.ForwardGraphData.Node;

import jist.runtime.JistAPI;
import jist.swans.net.NetAddress;

class Result {
  Result(int counter, String greeting) {
    this.counter = counter;
    this.greeting = greeting;
  }

  int counter;

  String greeting;
}

/**
 * Hello World with distsim.
 *
 * @author Rimon Barr <barr+jist@cs.cornell.edu> and Ulf Hermann
 * @version $Id: hello.java,v 1.7 2004/06/09 18:54:16 barr Exp $
 * @since JIST1.0
 */
public class DistsimTest implements JistAPI.Entity {

//  private Random random;
//
//  private String greeting;

  private DBSaver saver;

  private int counter;

  /**
   * Hello event.
   */
  public void myEvent() {

    counter = counter + 1;

    Node baum = new Node(new NetAddress(1), 15, (float)1.2, (float)1.5);
//    ForwardGraphData.FwdLink link = new FwdLink((Node) null, 15, (Node) null,
//        15, 15);

    try {
      saver.save(baum, "distsim-test", false);
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }



      try {
        saver.finalize();
      } catch (Throwable e1) {
        e1.printStackTrace();
      }
      return;



    // delay execution

    /*
     * try { Thread.sleep(500); } catch (InterruptedException e) { }
     */

  }

  /**
   * Program entry point: show difference between Java and JiST execution models
   * with a "hello world!" example.
   *
   * @param args
   *          command-line parameters
   */
  public static void main(String[] args) {
    System.out.println("starting simulation.");
    DistsimTest t = new DistsimTest();
    t.myEvent();
  }

  public DistsimTest() {
//    random = new Random();
//    greeting = "Hello world!";

    try {
      saver = new DBSaver("jdbc:mysql://localhost:3306/simulation",
          "root", "", "jdbc:mysql://localhost:3306/simulation", "root", "");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }

} // class: hello
