|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.actor.util.DFUtilities
public class DFUtilities
This class factors code out of the SDF domain, for use in different schedulers, so that they can be implemented in a consistent fashion. This interface contains static methods that are often useful from outside of an SDFDirector, and so are provided here in an interface that can be imported.
Red (neuendor) |
Red (neuendor) |
Nested Class Summary | |
---|---|
static class |
DFUtilities.NamedObjComparator
A comparator for named objects. |
Constructor Summary | |
---|---|
DFUtilities()
|
Method Summary | |
---|---|
private static Variable |
_getOrCreate(NamedObj container,
java.lang.String name)
|
static int |
getRate(IOPort port)
Return the number of tokens that will be produced or consumed on the given port. |
static Variable |
getRateVariable(Port port,
java.lang.String name)
Get the Variable with the specified name in the given port, or with the specified name preceded by an underscore. |
static int |
getRateVariableValue(Port port,
java.lang.String name,
int defaultValue)
Get the integer value stored in the Variable with the specified name. |
static int |
getTokenConsumptionRate(IOPort port)
Get the number of tokens that are consumed on the given port. |
static int |
getTokenInitProduction(IOPort port)
Get the number of tokens that are produced on the given port during initialization. |
static int |
getTokenProductionRate(IOPort port)
Get the number of tokens that are produced on the given port. |
static void |
setExpressionIfNotDefined(Port port,
java.lang.String name,
java.lang.String value)
If a variable with the given name does not exist, then create a variable with the given name and set the value of that variable to the specified value. |
static void |
setIfNotDefined(Port port,
java.lang.String name,
int value)
If a variable with the given name does not exist, then create a variable with the given name and set the value of that variable to the specified value. |
static void |
setOrCreate(NamedObj container,
java.lang.String name,
int value)
If the specified container does not contain a variable with the specified name, then create such a variable and set its value to the specified integer. |
static void |
setOrCreate(NamedObj container,
java.lang.String name,
java.lang.String expression)
If the specified container does not contain a variable with the specified name, then create such a variable and set its expression to the specified string. |
static Variable |
setRate(Port port,
java.lang.String name,
int rate)
Set the rate variable with the specified name to the specified value. |
static void |
setRateVariable(Port port,
java.lang.String name,
int value)
If a variable with the given name does not exist, then create a variable with the given name. |
static void |
setTokenConsumptionRate(IOPort port,
int rate)
Set the tokenConsumptionRate parameter of the given port to the given rate. |
static void |
setTokenInitProduction(IOPort port,
int rate)
Set the tokenInitProduction parameter of the given port to the given rate. |
static void |
setTokenProductionRate(IOPort port,
int rate)
Set the tokenProductionRate parameter of the given port to the given rate. |
static void |
showRate(Port port,
boolean flag)
Depending on the given flag, add an invisible, persistent variable named "_showRate" with value true to the given port that indicates to the user interface that rate parameters on the given port should be displayed in the user interface. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DFUtilities()
Method Detail |
---|
public static int getRate(IOPort port) throws NotSchedulableException, IllegalActionException
port
- The given port.
NotSchedulableException
- If the port is both an input and
an output, or is neither an input nor an output.
IllegalActionException
- If a rate does not contain a
valid expression.setRate(ptolemy.kernel.Port, java.lang.String, int)
public static Variable getRateVariable(Port port, java.lang.String name)
port
- The port.name
- The name of the variable.
IllegalActionException
- Not thrown in this method.setRateVariable(Port, String, int)
public static int getRateVariableValue(Port port, java.lang.String name, int defaultValue) throws IllegalActionException
port
- The port.name
- The name of the variable.defaultValue
- The default value of the variable.
IllegalActionException
- If the variable does not contain
a valid token, or the token is not an IntToken.public static int getTokenConsumptionRate(IOPort port) throws IllegalActionException
port
- The given port.
IllegalActionException
- If the tokenConsumptionRate
parameter has an invalid expression.setTokenConsumptionRate(ptolemy.actor.IOPort, int)
public static int getTokenInitProduction(IOPort port) throws IllegalActionException
port
- The given port.
IllegalActionException
- If the tokenInitProduction
parameter has an invalid expression.setTokenInitProduction(ptolemy.actor.IOPort, int)
public static int getTokenProductionRate(IOPort port) throws IllegalActionException
port
- The given port.
IllegalActionException
- If the tokenProductionRate
parameter has an invalid expression.setTokenProductionRate(ptolemy.actor.IOPort, int)
public static void setExpressionIfNotDefined(Port port, java.lang.String name, java.lang.String value) throws IllegalActionException
port
- The port.name
- Name of the variable.value
- The value.
IllegalActionException
- If a new parameter can not be
created for the give port.public static void setIfNotDefined(Port port, java.lang.String name, int value) throws IllegalActionException
port
- The port.name
- Name of the variable.value
- The value.
IllegalActionException
- If a new parameter can not be
created for the given port, or the given value is not an acceptable.public static void setOrCreate(NamedObj container, java.lang.String name, int value) throws IllegalActionException
container
- The container.name
- Name of the variable.value
- The value.
IllegalActionException
- If the variable exists and
its value cannot be set.public static void setOrCreate(NamedObj container, java.lang.String name, java.lang.String expression) throws IllegalActionException
container
- The container.name
- Name of the variable.expression
- The expression.
IllegalActionException
- If the variable exists and
its value cannot be set.public static Variable setRate(Port port, java.lang.String name, int rate) throws IllegalActionException
port
- The port.name
- The variable name.rate
- The rate value.
IllegalActionException
- If the rate is a negative integer,
or the rate can not be set.getRate(IOPort)
public static void setRateVariable(Port port, java.lang.String name, int value) throws IllegalActionException
port
- The port.name
- Name of the variable.value
- The value.
IllegalActionException
- If a new parameter can not be
created for the given port, or the given value is not an acceptable.getRateVariable(Port, String)
public static void setTokenConsumptionRate(IOPort port, int rate) throws IllegalActionException
port
- The given port.rate
- The given rate.
IllegalActionException
- If the rate is negative.getTokenConsumptionRate(ptolemy.actor.IOPort)
public static void setTokenInitProduction(IOPort port, int rate) throws IllegalActionException
port
- The given port.rate
- The given rate.
IllegalActionException
- If the rate is negative.getTokenInitProduction(ptolemy.actor.IOPort)
public static void setTokenProductionRate(IOPort port, int rate) throws IllegalActionException
port
- The given port.rate
- The given rate.
IllegalActionException
- If the rate is negative.getTokenProductionRate(ptolemy.actor.IOPort)
public static void showRate(Port port, boolean flag) throws IllegalActionException
port
- The port.flag
- The flag.
IllegalActionException
- If a new parameter can not be
created for the given port, or the given flag is not an acceptable.private static Variable _getOrCreate(NamedObj container, java.lang.String name)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |