home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.3 KB | 61 lines |
-
- package examples.machine;
-
-
- import simula.*;
- import simula.simset.simulation.*;
- import simula.random.* ;
- /**
- * Machine wich breaks periodically
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class Machine extends simula.simset.simulation.Process {
-
-
- private Negexp negexp ;
-
-
- /**
- * @param _sim The active Simulation
- */
-
- public Machine (Simulation _sim) {
- super(_sim);
- MachineSimulation sim = (MachineSimulation)this.sim ;
- this.negexp = new Negexp(sim.seed,sim.brk) ;
- }
- /**
- * Executes actions for this object. Called by simulation on activate
- * @see simula.simset.simulation.Simulation
- */
-
-
- public void run() {
- MachineSimulation sim = (MachineSimulation)this.sim ;
-
- try {
- // declare local variable and enter infinite loop ;
- double lastbreak ;
-
-
-
- while (true) {
- sim.hold(this.negexp.draw().asReal()) ;
- this.into(sim.broken) ;
- lastbreak=sim.time() ;
- if (!(sim.available.empty() ))
- sim.activate((RepairMan)(sim.available.first()) ) ;
- sim.passivate() ;
- sim.breaks++ ;
- sim.downtime+=sim.time()-lastbreak ;
-
- }
-
- } catch (Exception e ) {
- System.err.println ("Exception caught in " + this.toString() + " :\n" + e) ;
- System.exit(1) ;
- }
- }
- }