home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / JSL.ZIP / JSL20 / examples / network / Job.java < prev    next >
Encoding:
Java Source  |  1998-02-20  |  1.0 KB  |  53 lines

  1.  
  2. package examples.network;
  3.  
  4.  
  5. import simula.*;
  6. import simula.simset.* ;
  7. import simula.simset.simulation.*;
  8. import simula.random.* ;
  9.  
  10. /**
  11.  * The job is an object without actions (= empty constructor)
  12.  * @author Andrea Poltronieri
  13.  * @version 1.0 12 Feb 1998
  14.  */
  15.  
  16. public class  Job extends simula.simset.Link {
  17.     /** The active simulation */
  18.     NetworkSimulation sim ;
  19.     /** Starting job time */
  20.     double arrtime ;
  21.  
  22.  
  23.  
  24. /**
  25. * @param _sim The active Simulation
  26. */
  27.  
  28.     public  Job (NetworkSimulation sim) {
  29.       super();
  30.         this.sim=sim ;
  31.     }
  32.     public void move(int n, double a[])  {
  33.         try {
  34.             int i ;
  35.             i=sim.choice(n,a) ;
  36.             if (i>0) {
  37.                 this.into(sim.node[i].queue) ;
  38.                 if (sim.node[i].device.idle()) 
  39.                     sim.activate(sim.node[i].device) ;
  40.             }
  41.             else {
  42.                 sim.sojourn+=sim.time()-arrtime ;
  43.                 sim.numthrough++ ;
  44.                 this.out() ;
  45.             }
  46.             
  47.                 
  48.         } catch (Exception e ) { 
  49.             System.err.println ("Exception caught in " + this.toString() + " :\n" + e) ;
  50.             System.exit(1) ;
  51.         }
  52.     }
  53. }