Package adams.flow.condition.bool
Class Counting
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<BooleanCondition>
,SizeOfHandler
,Stoppable
,BooleanCondition
,Serializable
public class Counting extends AbstractBooleanCondition
Counts the tokens passing through and returns 'true' if min/max/interval are met.
Valid options are:
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-min <int> (property: minimum) The minimum number of tokens to count before activating (-1 to disable). default: -1 minimum: -1
-max <int> (property: maximum) The maximum number of tokens to count before de-activating (-1 to disable ). default: -1 minimum: -1
-interval <int> (property: interval) The number of tokens (or multiples) to count before teeing-off the input token. default: -1 minimum: -1
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_Current
the current count.protected int
m_Interval
the number of tokens after which to tee-off token.protected int
m_Maximum
the maximum number of tokens to process before de-activating.protected int
m_Minimum
the minimum number of tokens to process before activating.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description Counting()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]
accepts()
Returns the class that the consumer accepts.void
defineOptions()
Adds options to the internal list of options.protected boolean
doEvaluate(Actor owner, Token token)
Performs the actual evaluation.protected int
getCurrent()
Returns the counter of how many tokens have passed through so far.int
getInterval()
Returns the number of tokens after which to tee off the input token.int
getMaximum()
Returns the maximum of counts before de-activating.int
getMinimum()
Returns the minimum of counts before activating.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
globalInfo()
Returns a string describing the object.String
intervalTipText()
Returns the tip text for this property.String
maximumTipText()
Returns the tip text for this property.String
minimumTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.void
setInterval(int value)
Sets the number of tokens after which to tee off the input token.void
setMaximum(int value)
Sets the maximum number of counts before de-activating.void
setMinimum(int value)
Sets the minimum number of counts before activating.-
Methods inherited from class adams.flow.condition.bool.AbstractBooleanCondition
evaluate, preEvaluate, setUp, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Minimum
protected int m_Minimum
the minimum number of tokens to process before activating.
-
m_Maximum
protected int m_Maximum
the maximum number of tokens to process before de-activating.
-
m_Interval
protected int m_Interval
the number of tokens after which to tee-off token.
-
m_Current
protected int m_Current
the current count.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractOptionHandler
-
getCurrent
protected int getCurrent()
Returns the counter of how many tokens have passed through so far.- Returns:
- the current counter value
-
setMinimum
public void setMinimum(int value)
Sets the minimum number of counts before activating.- Parameters:
value
- the minimum (-1 to disable)
-
getMinimum
public int getMinimum()
Returns the minimum of counts before activating.- Returns:
- the minimum (-1 if disabled)
-
minimumTipText
public String minimumTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMaximum
public void setMaximum(int value)
Sets the maximum number of counts before de-activating.- Parameters:
value
- the maximum (-1 to disable)
-
getMaximum
public int getMaximum()
Returns the maximum of counts before de-activating.- Returns:
- the maximum (-1 if disabled)
-
maximumTipText
public String maximumTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setInterval
public void setInterval(int value)
Sets the number of tokens after which to tee off the input token.- Parameters:
value
- the number
-
getInterval
public int getInterval()
Returns the number of tokens after which to tee off the input token.- Returns:
- the number
-
intervalTipText
public String intervalTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceBooleanCondition
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Specified by:
getQuickInfo
in classAbstractBooleanCondition
- Returns:
- null if no info available, otherwise short string
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
accepts
in interfaceBooleanCondition
- Specified by:
accepts
in classAbstractBooleanCondition
- Returns:
- adams.flow.core.Unknown.class
-
doEvaluate
protected boolean doEvaluate(Actor owner, Token token)
Performs the actual evaluation.- Specified by:
doEvaluate
in classAbstractBooleanCondition
- Parameters:
owner
- the owning actortoken
- the current token passing through- Returns:
- the result of the evaluation
-
-