예제 #1
0
  /**
   * EPML2PNML
   *
   * @param args String[]
   */
  private static void EPML2PNML(String[] args) {
    if (args.length != 2) {
      System.out.println("���ṩEPML�ļ�·����PNML���Ŀ¼!");
      System.exit(-1);
    }
    epmlImport epml = new epmlImport();
    // load the single epml file
    String filename = args[0];
    try {
      EPCResult epcRes = (EPCResult) epml.importFile(new FileInputStream(filename));
      // convert all epc models to pnml files
      ArrayList<ConfigurableEPC> alEPCs = epcRes.getAllEPCs();
      PnmlExport export = new PnmlExport();
      for (ConfigurableEPC epc : alEPCs) {
        String id = epc.getIdentifier();
        if (id.equals("1An_klol")
            || id.equals("1An_l1y8")
            || id.equals("1Ex_dzq9")
            || id.equals("1Ex_e6dx")
            || id.equals("1Ku_9soy")
            || id.equals("1Ku_a4cg")
            || id.equals("1Or_lojl")
            || id.equals("1Pr_d1ur")
            || id.equals("1Pr_djki")
            || id.equals("1Pr_dkfa")
            || id.equals("1Pr_dl73")
            || id.equals("1Ve_musj")
            || id.equals("1Ve_mvwz")) continue;
        // save pnml files to the same folder
        File outFile = new File(args[1] + "/" + id + ".pnml");
        if (outFile.exists()) continue;
        FileOutputStream fos = new FileOutputStream(outFile);
        PetriNet petri = AMLtoPNML.convert(epc);
        try {
          export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos);
        } catch (Exception ex1) {
          ex1.printStackTrace(System.out);
        }
      }
    } catch (IOException ex) {
      ex.printStackTrace(System.out);
    }

    System.out.println("EPML Conversion Done");
  }
예제 #2
0
  private static void AML2PNML(String[] args) {
    if (args.length != 3) {
      System.out.println("���ṩAML����Ŀ¼��PNML���Ŀ¼�Լ��ֵ��ļ�!");
      System.exit(-1);
    }
    System.out.println("����Ŀ¼��" + args[0]);
    System.out.println("���Ŀ¼��" + args[1]);
    System.out.println("�ֵ��ļ���" + args[2]);
    // load the dict
    AMLtoPNML.loadDict(args[2]);
    File srcDir = new File(args[0]);
    File[] lstAML = srcDir.listFiles();
    PnmlExport export = new PnmlExport();
    for (int i = 0; i < lstAML.length; i++) {
      if (lstAML[i].isDirectory()) {
        continue;
      }
      System.out.print(lstAML[i].getName() + "==>");
      try {
        FileInputStream fis = new FileInputStream(lstAML[i]);
        int idx = lstAML[i].getName().indexOf(".xml");
        File outFile = new File(args[1] + "/" + lstAML[i].getName().substring(0, idx) + ".pnml");
        FileOutputStream fos = new FileOutputStream(outFile);
        EPCResult epcRes = (EPCResult) AMLtoPNML.importFile(fis);
        ConfigurableEPC epc = epcRes.getMainEPC();
        PetriNet petri = AMLtoPNML.convert(epc);
        export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos);
        System.out.println(outFile.getName());
      } catch (FileNotFoundException ex) {
        ex.printStackTrace(System.out);
      } catch (IOException ioe) {
        ioe.printStackTrace(System.out);
      } catch (Exception e) {
        e.printStackTrace(System.out);
      }
    }

    System.out.println("Conversion Done");
  }