[477] | 1 | package simulator; |
---|
| 2 | |
---|
| 3 | import eduni.simjava.Sim_exception; |
---|
| 4 | import eduni.simjava.Sim_system; |
---|
| 5 | import gridsim.GridSim; |
---|
| 6 | import gridsim.GridSimRandom; |
---|
| 7 | import gridsim.GridSimShutdown; |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | import java.util.Calendar; |
---|
| 11 | |
---|
| 12 | public class GridSimWrapper extends GridSim { |
---|
| 13 | |
---|
| 14 | protected GridSimWrapper(String name) throws Exception { |
---|
| 15 | super(name); |
---|
| 16 | |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | protected GridSimWrapper(String name, double baudRate) throws Exception { |
---|
| 20 | super(name, baudRate); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | protected static void initCommonVariable(Calendar cal, boolean traceFlag, int numUser, String reportWriterName) |
---|
| 24 | throws Exception { |
---|
| 25 | // NOTE: the order for the below 3 lines are important |
---|
| 26 | Sim_system.initialise(); |
---|
| 27 | Sim_system.set_trc_level(1); |
---|
| 28 | Sim_system.set_auto_trace(traceFlag); |
---|
| 29 | |
---|
| 30 | // Set the current Wall clock time as the starting time of simulation |
---|
| 31 | calendar_ = cal; |
---|
| 32 | if (cal == null) { |
---|
| 33 | calendar_ = Calendar.getInstance(); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | SimulationStartDate = calendar_.getTime(); |
---|
| 37 | rand = new GridSimRandom(); |
---|
| 38 | |
---|
| 39 | // creates a GridSimShutdown object |
---|
| 40 | GridSimShutdown shutdown = new GridSimShutdown("GridSimShutdown", numUser, reportWriterName); |
---|
| 41 | shutdownID_ = shutdown.get_id(); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | public static void startSimulation() throws NullPointerException |
---|
| 45 | { |
---|
| 46 | System.out.println("Starting GridSim version 4.0"); |
---|
| 47 | try { |
---|
| 48 | Sim_system.run(); |
---|
| 49 | } |
---|
| 50 | catch (Sim_exception e) |
---|
| 51 | { |
---|
| 52 | throw new NullPointerException("GridSim.startGridSimulation() :" + |
---|
| 53 | " Error - you haven't initialized GridSim."); |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | public static void setSeed(long seed){ |
---|
| 58 | Sim_system.set_seed(seed); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | public static void setTraceSettings() { |
---|
| 62 | Sim_system.set_trace_detail(true, true, true); |
---|
| 63 | Sim_system.set_trace_level(Integer.MAX_VALUE); |
---|
| 64 | } |
---|
| 65 | } |
---|