home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.6 KB | 73 lines |
-
- package examples.network;
-
-
- import simula.*;
- import simula.simset.* ;
- import simula.simset.simulation.*;
- import simula.random.* ;
-
- /**
- * A class describing a node in the network
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class Station {
- /** Main simulation */
- NetworkSimulation sim ;
-
- // declarations
- /** Service rate */
- double ser ;
-
- /** array [0..N] routing probabilities */
- double[] q ;
- /** Nodes list */
- Head queue ;
- /** Server to run */
- Server device ;
- /** Node counter*/
- int j ;
-
-
- /**
- * Create a server, bind it to this station and initialize routing probability
- * @param _sim The active Simulation
- */
-
- public Station (NetworkSimulation sim) {
- super();
-
-
- double sum = 0;
- this.sim=sim ;
- try {
- // Should be [0..N]
- q = new double[sim.n+1] ;
-
- // actions
- Lang.outtext("Station Num. "+ sim.i +" initialization") ;
-
- Lang.outtext(" service rate [jobs served per unit of time] ?") ;
- ser=Lang.inreal() ;
- for(j=0;j<=sim.n;j++){
- if (j == 0)
- Lang.outtext(" probability of getting out the network from this station [0,1] ?") ;
- else
- Lang.outtext(" probability of getting routed to station "+j+" from this station [0,"+(1.0 - sum)+"] ?") ;
- q[j]=Lang.inreal() ;
- if (q[j] > (1.0 - sum)) q[j] = 1.0 - sum;
- sum += q[j];
- }
- queue=new Head() ;
- device=new Server(sim,this) ;
- sim.activate(device) ;
-
- } catch (Exception e ) {
- System.err.println ("Exception caught in " + this.toString() + " :\n" + e) ;
- System.exit(1) ;
- }
-
- }
- }