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

  1.  
  2. package examples.warehouse;
  3.  
  4.  
  5. import simula.*;
  6. import simula.simset.simulation.*;
  7. import simula.random.* ;
  8. /**
  9.  * Activity concerned with outgoing batchs
  10.  * @author Andrea Poltronieri
  11.  * @version 1.0 12 Feb 1998
  12.  */
  13.  
  14. public class Removals extends simula.simset.simulation.Process {
  15.  
  16.  
  17.  
  18. /**
  19. * @param _sim The active Simulation
  20. */
  21.  
  22.         public Removals (Simulation _sim){
  23.           super(_sim);
  24.         }
  25. /**     
  26.   * Executes actions for this object. Called by simulation on activate
  27.   * @see simula.simset.simulation.Simulation
  28. */
  29.  
  30.  
  31.  
  32.         public void run() {
  33.                 WareHouseSimulation sim = (WareHouseSimulation)this.sim ;
  34.                 Negexp negexp=new Negexp(sim.seed,sim.rem) ;
  35.                 Randint randint=new Randint(sim.seed,sim.out1,sim.out2) ;
  36.                 //declare local integers for size of outgoing batch and number removed, and enter infinite loop
  37.                         int size, number;
  38.                         try {
  39.                             while (true)  {
  40.                                 while (sim.n > 0) {
  41.                                         sim.hold(negexp.draw().asReal()) ;
  42.                                         sim.iharea += sim.n * (sim.time()-sim.lastevent) ;
  43.                                         sim.lastevent = sim.time() ;
  44.                                         size = randint.draw().asInteger();
  45.                                         number = (size < sim.n)? size : sim.n;
  46.                                         sim.n -= number;
  47.                                         //sim.update() ;
  48.                                     
  49.                                 }
  50.                                 // warehouse is now empty
  51.                                 //System.err.println(this.toString()+" passivating") ;
  52.                                 sim.passivate() ;
  53.                             }
  54.                     } catch (Exception e) {
  55.                         System.err.println ("Removals exception caught: " + e) ;
  56.                         System.exit(1) ;
  57.                     }
  58.         }
  59. }