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

📄 inputarc.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;/** * Represents an input Arc in JFern Petri Net model. *  *<br><br> * InputArc.java<br> * Created: Mon Sep 25 11:49:12 2000<br> * *@author  <a href="mariusz@rakiura.org">Mariusz Nowostawski</a> *@version 2.1.0 $Revision: 1.14 $ *@since 1.0 */public class InputArc extends AbstractArc {  /** Default guard. */  private Guard guard = new Guard() {      public boolean evaluate() {        Multiset multiset = getMultiset();        return (multiset.size() > 0);       }    };    /** Default expression. */  private Expression expr = new Expression() {      public void evaluate() {        //System.out.println("*** JFERN WARNING: uninitialised input arc expression");      }    };  /**/  protected InputArc() {  }    /**/  public InputArc(final Place aFrom, final Transition aTo) {    super(aFrom, aTo);    aTo.addInput(this);    aFrom.addInput(this);  }    /**   * Checks if this arc is enabled.   *@return this call evaluates the guard, and returns    *  <code>true</code> if the arc is enabled,    *  <code>false</code> otherwise.   */  public boolean guard() {    return this.guard.evaluate();  }    /**   * Evaluates this arc expression. The actual result of this   * expression evaluation is accessible from the context. The    * arc expression is evaluated many times during net simulation,   * thus should not have any side effects, apart from selecting   * tokens via {@link org.rakiura.cpn.Context} methods.   */  public void expression() {    this.expr.evaluate();  }  /**   * Sets a guard for this arc.   *@param aGuard a guard.   */   public void setGuard(final Guard aGuard) {    this.guard = aGuard;  }    /**   * Sets the multiset expression.   *@param anExpr an expression   */    public void setExpression(final Expression anExpr){    this.expr = anExpr;  }  /**   * Visitor pattern.   */  public NetElement apply(NetVisitor aVisitor) {    aVisitor.inputArc(this);    return this;  }  /**   * Represents an input arc multiset expression.   *    *   *@author  <a href="mariusz@rakiura.org">Mariusz</a>   *@version 2.1.0 $Revision: 1.14 $ $Date: 2002/05/30 15:01:39 $   *@since 2.0   */  public abstract class Expression implements Context {      /**     * Evaluates this expression. This method implements the      * actual expression on the input arc, which given     * a  multiset from an input place evaluates to a set      * of tokens (a single multiset). Picking up and binding     * tokens is achieved via the {@link #var} method.     */    public abstract void evaluate();    public void var(final String aVariable) {      getContext().var(aVariable);    }    public void var(final int aNumber) {      getContext().var(aNumber);    }    public Object get(final String aVariable) {      return getContext().get(aVariable);    }    public Multiset getMultiset() {      return getContext().getMultiset();    }  } // Expression  /**   * Represents a generic input arc guard.   * Note, in JFern, due to pure Java based inscription   * language, all the partial matches must be done   * explicitely via input arc guards. In such a guard   * no references other to variables from this arc   * should be made.   *   *   *@author  <a href="mariusz@rakiura.org">Mariusz</a>   *@version 2.1.0 $Revision: 1.14 $   *@since 2.0   */  public abstract class Guard implements Context {    /**     * Guard function.     *@return <code>true</code> if this guard evaluates      * to enabled transition/arc;     * <code>false</code> otherwise.     */    public abstract boolean evaluate();    public void var(final String aVariable) {      getContext().var(aVariable);    }    public void var(final int aNumber) {      getContext().var(aNumber);    }    public Object get(final String aVariable) {      return getContext().get(aVariable);    }    public Multiset getMultiset() {      return getContext().getMultiset();    }   } // Guard} // InputArc//////////////////// end of file ////////////////////

⌨️ 快捷键说明

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