home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.4 KB | 58 lines |
-
- package examples.priosys;
-
-
- import simula.*;
- import simula.simset.simulation.*;
- import simula.random.* ;
- /**
- * Customer process
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class Customer extends simula.simset.simulation.Process {
- /** Priority level */
- int type ;
- /** Time required for service*/
- double sertime ;
-
-
-
- /**
- * @param _sim The active Simulation
- * @param type Priority category : 1 is the highes
- * @param sertime Time required for service
- */
- public Customer (Simulation _sim,int type, double sertime){
- super(_sim);
- this.type = type ;
- this.sertime = sertime ;
- }
- /**
- * Executes actions for this object. Called by simulation on activate
- * @see simula.simset.simulation.Simulation
- */
-
- public void run() {
- double arrtime ;
- PrioSysSimulation sim = (PrioSysSimulation)this.sim ;
- try {
- arrtime = sim.time() ;
- //System.out.println("Queuing");
- this.into(sim.queue[this.type]) ;
- if (type < sim.top)
- sim.top = type ;
- if (!(sim.available.empty()))
- sim.activate((simula.simset.simulation.Process)(sim.available.first())) ;
- sim.passivate() ;
- sim.sojourn[type] += sim.time()-arrtime ;
- sim.numthrough[type]++ ;
- //System.out.println("Customer said bye");
- sim.passivate();
- } catch (Exception e ) {
- System.err.println("Exception caught in " + this.toString() + " :\n" + e) ;
- System.exit(1) ;
- }
- }
- }