home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.2 KB | 55 lines |
-
- package examples.network;
-
-
- import simula.*;
- import simula.simset.* ;
- import simula.simset.simulation.*;
- import simula.random.* ;
-
- /**
- * A universal service process
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class Server extends simula.simset.simulation.Process {
- /** Node to wich access */
- Station s ;
-
-
-
- /**
- * @param _sim The active Simulation
- * @param s Station in wich run and from wich access attributes
- */
-
- public Server (Simulation _sim, Station s) {
- super(_sim);
- this.s=s ;
- }
- /**
- * Executes actions for this object. Called by simulation on activate
- * @see simula.simset.simulation.Simulation
- */
-
- public void run() {
- NetworkSimulation sim = (NetworkSimulation)this.sim ;
- try {
- // initialize random generator
- Negexp negexp = new Negexp(sim.seed,s.ser) ;
- Job j ;
- while (true) {
- while (!(s.queue.empty())) {
- j=(Job)(s.queue.first()) ;
- sim.hold(negexp.draw().asReal()) ;
- j.move(sim.n,s.q) ;
- }
- sim.passivate() ;
- }
- } catch (Exception e ) {
- System.err.println ("Exception caught in " + this.toString() + " :\n" + e) ;
- System.exit(1) ;
- }
- }
- }