⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookingtest.java

📁 Rakiura JFern是一个非常轻型的带有模拟器的Petri网络框架
💻 JAVA
字号:
package org.rakiura.cpn.example.booking;/**/import org.rakiura.cpn.*;import org.rakiura.cpn.gui.*;/** * A wee test for the booking net example. * To run the test, generate the java source for the nest first * <pre> java -classpath lib/rakiura-jfern.jar org.rakiura.cpn.NetGenerator example/BookingNet.xml</pre> * and then run this class to execute the generated net.  *  *<br><br> * BookingTest.java<br> * Created: Thu Nov  1 00:44:57 2001<br> * * @author Mariusz Nowostawski  (mariusz@rakiura.org) * @version $Revision: 1.13 $ $Date: 2002/05/31 07:33:14 $ */public class BookingTest  {    public static void main(String[] args) throws Exception {    if(args.length < 1){      System.out.println("Call it with the service as an argument:");      System.out.println("\te.g.  java BookingTest biking");      return;    }    // First net test, static    long begin = System.currentTimeMillis();    final BookingNet net = new BookingNet();    System.out.println("\n"+net.banner+"\n");    Multiset m = new Multiset();    for (int i = 0; i < args.length; i++) {      m.add(new String(args[i]));    }    final Place startPlace = (Place) net.forName("p001");    startPlace.addTokens(m);    final Simulator sim = new BasicSimulator(net);    sim.run();    long end = System.currentTimeMillis();    long time1 = end - begin;    System.out.println("### Running the net in the Native Mode: "+time1+"millis");        // Second net test, dynamic    begin = System.currentTimeMillis();    NetGenerator ng = new NetGenerator();    final Net net2 = ng.generateNet(new java.io.FileReader("example/BookingNet2.xml"));    System.out.println("\n\n\n"+((BookingNet2) net2).banner+"\n");    final Multiset m2 = new Multiset();    for (int i=0; i < args.length; i++) {      m2.add(new String(args[i]));    }    final Place startPlace2 = (Place) net2.forName("p001");    startPlace2.addTokens(m2);    final Simulator sim2 = new BasicSimulator(net2);    sim2.run();    end = System.currentTimeMillis();    long time2 = end - begin;    System.out.println("### Running the net in the Dynamic Mode: "+time2+"millis\n");    System.out.println("Conclusion:\n   static vs dynamic loading ratio - dynamic loading is "+ Math.round((float)time2 / time1)+" times slower");    System.out.println("\nDone.  Lets try some GUI now ;o)");    /////////////  GUI test    Multiset m3 = new Multiset();    for(int i=0; i < args.length; i++){      m3.add(new String(args[i]));    }    ((Place) net2.forName("p001")).addTokens(m3);    new NetViewer(net2).getFrame().show();    // simple hack to give the user some time and     // to allow the user orgnize the net view by mouse    System.out.println("Hit <enter> to run the booking demo....");    try {      System.in.read();    } catch (java.io.IOException e) {}    final Simulator sim3 = new BasicSimulator(net2);    sim3.run();        System.out.println("\nDONE.");  }  } // BookingTest//////////////////// end of file ////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -