Note: This block will be end-of-life in the next release. Please use the ExpressionList block.
Full Library / Algorithmic / Analog / control-analog function / Expression
Block Name: Expression
- public class Expression
- extends TypedAtomicActor
- On each firing, evaluate an expression that may include references to the inputs, current time, and a count of the firing. The ports are referenced by the identifiers that have the same name as the port. To use this class, instantiate it, then add ports (instances of TypedIOPort). In ModelBuilder, you can add ports by right clicking on the icon and selecting "Configure Ports". In MoML you can add ports by just including ports of class TypedIOPort, set to be inputs, as in the following example:
<entity name="exp" class="VisualSim.actor.lib.Expression">
<port name="in" class="VisualSim.actor.TypedIOPort">
<property name="input"/>
</port>
</entity>
The type is polymorphic, with the only constraint that the types of the inputs must all be less than (in the type order) the type of the output. What this means (loosely) is that the types of the input tokens can be converted losslessly into tokens with the type of the output. If this is not the case, then the types of the output ports must be set manually.
- The expression parameter specifies an expression that can refer to the inputs by name. By default, the expression is empty, and attempting to execute the actor without setting it triggers an exception.
-
- The expression language understood by this actor is the same as that used to set any parameter value, with the exception that the expressions evaluated by this actor can refer to the values of inputs, and to the current time by the identifier name "time", and to the current iteration count by the identifier named "iteration."
-
- This actor can be used instead of many of the arithmetic actors, such as AddSubtract, MultiplyDivide, and TrigFunction. However, those actors will be usually be more efficient, and sometimes more convenient to use.
-
- This actor requires its all of its inputs to be present. If inputs are not all present, then an exception will be thrown.
-
- NOTE: There are a number of limitations in the current implementation. First, the type constraints on the ports are the default, that input ports must have a type that can be losslessly converted to the type of the output. The type constraints have nothing to do with the expression. This is a severe limitation, but removing it depends on certain extensions to the VisualSim type system which are in progress. Second, multiports are not supported. Also, if name duplications occur, for example if a parameter and a port have the same name, then the results are unpredictable. They will depend on the order in which things are defined, which may not be the same in the constructor as in the clone method. This class attempts to detect name duplications and throw an exception.
-
- Refer RegEx Language in Basic Technology for more details.
- Version:
- $Id: Expression.java,v 1.88 2003/05/05 18:15:04
-
output
public TypedIOPort output
expression
public StringAttribute expression
- The expression that is evaluated to produce the output.
Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad