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

📄 sequence.java

📁 Rakiura JFern是一个非常轻型的带有模拟器的Petri网络框架
💻 JAVA
字号:
// This is copyrighted source file, part of Rakiura JFern package. // See the file LICENSE for copyright information and the terms and conditions// for copying, distributing and modifications of Rakiura JFern package.// Copyright (C) 1999-2002 by Mariusz Nowostawski and others  [http://www.rakiura.org]package org.rakiura.cpn.lib;/**/import java.util.ArrayList;import java.util.List;import org.rakiura.cpn.InputArc;import org.rakiura.cpn.Multiset;import org.rakiura.cpn.OutputArc;import org.rakiura.cpn.Place;import org.rakiura.cpn.Transition;/** * Simple control pattern representing Sequence Pattern. This pattern * net begins with the input place, which makes the first transition * enabled, and ends with transition n-th, which puts the processed * token into the final output place. All intermediate places and arcs  * are not visible to the user, they simply propagate single token at * the time. This sequence does not wait till the token is passed till * the end of the sequence, and can fire another sequence once the * input place has at least one token (first transition is enabled). *  *<br><br> * SequenceTT.java<br> * Created: Tue Oct  3 09:21:20 2000<br> * * @author Mariusz Nowostawski * @version 2.1.0 $Revision: 1.6 $ */public class Sequence extends PatternPT {  protected Place outputPlace;  protected OutputArc outputArc;  protected List transitionList;  /** @todo write comments. */  public Sequence() {        final Transition trans2 = new Transition();    transitionList = new ArrayList(10);    transitionList.add(transition);    transitionList.add(trans2);    final Place tmpPlace = new Place();    createOutputArc(transition, tmpPlace);    createInputArc(tmpPlace, trans2);    outputPlace = new Place();    createOutputArc(trans2, outputPlace);    add(tmpPlace).add(trans2).add(outputPlace);  }  public List transitions(){    return this.transitionList;  }  public Place inputPlace(){    return this.inputPlace;  }  public Place outputPlace(){    return this.outputPlace;  }  private InputArc createInputArc(Place p, Transition t) {    final InputArc arc = new InputArc(p, t);    arc.setGuard(arc.new Guard() {        public boolean evaluate() {          final Multiset multiset = getMultiset();          return (multiset.size()>0);        }              });    arc.setExpression(arc.new Expression() {        public void evaluate() {          var("X");        }             });    return arc;  }    private OutputArc createOutputArc(Transition t, Place p){    final OutputArc arc = new OutputArc(t, p);    arc.setExpression(arc.new Expression() {        public Multiset evaluate() {          final Multiset multiset = getMultiset();          final Multiset result = new Multiset();          result.add(multiset.getAny());          return result;        }      });    return arc;  }  } // Sequence//////////////////// end of file ////////////////////

⌨️ 快捷键说明

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