package csc454.net;
import java.util.*;
/* This class was designed to extract and localize the confusion about 
   simulated time. It is used in reporting how much time has elapsed since 
   the start of the program.  It is designed with a normalization feature
   which is useful in simulation projects of this type.  

   At construction, an object will use the Date class to establish a start 
   time.  The method time here will report the relative time from the 
   starting point mentioned. The normalization multiplier which is set at 
   construction, reports the relative time taking into account the 
   normalization that takes place in the delays in the other parts of the
   program.  Let me explain:

     The reason for the normalization in this package is that the 
     "actual" time of contention and message transmission is too small. 
     The network is represented graphically here.  If the time 
     for contention is too small, it becomes hard to notice that activity
     when the the network changes color to show contention for
     a split second.  We like to normalize our delays in various parts
     of the program so that the graphical representation of the network
     would depict clearly what is going on, yet we would like to 
     provide timing reports at the end that are indicative of the
     actual behavior of the network.

     time is always reported in milliseconds.
*/
public class time {
  protected Date d_;
  protected double norm_;
  public time (double norm) {
    d_ = new Date();
    norm_=norm;
  }
public synchronized  double timeOfOrigin() {return (float)d_.getTime();} 
  public synchronized  double elapsed () {
    Date temp = new Date();
    return (double)(temp.getTime()-d_.getTime()) / norm_;
  }
}
