home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.2 KB | 57 lines |
-
- package examples.machine;
-
-
- import simula.*;
- import simula.simset.simulation.*;
- import simula.random.* ;
- /**
- * Worker wich fixes broken machines
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class RepairMan extends simula.simset.simulation.Process {
-
-
- Negexp negexp ;
-
- /**
- * @param _sim The active Simulation
- */
-
- public RepairMan (Simulation _sim) {
- super(_sim);
- MachineSimulation sim = (MachineSimulation)this.sim ;
- this.negexp=new Negexp(sim.seed,sim.rep) ;
- }
- /**
- * 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 each local variable and enter infinite loop ;
- Machine mach ;
-
-
- while (true) {
- this.out() ;
- while (!(sim.broken.empty())) {
- mach=(Machine)(sim.broken.first()) ;
- mach.out() ;
- sim.hold(this.negexp.draw().asReal()) ;
- sim.activate(mach) ;
- }
- this.into(sim.available) ;
- sim.passivate() ;
- }
-
- } catch (Exception e ) {
- System.err.println ("Exception caught in " + this.toString() + " :\n" + e) ;
- System.exit(1) ;
- }
- }
- }