public class Chop extends SDFTransformer
A simple use of this actor is to pad a block of inputs with zeros. Set offset to zero and use numberToWrite > numberToRead.
Another simple use is to obtain overlapping windows from an input stream. Set usePastInputs to true, use numberToWrite > numberToRead, and set offset equal to numberToWrite - numberToRead.
The general operation is illustrated with the following examples. If offset is positive, there two possible scenarios, illustrated by the following examples:
iiiiii numberToRead = 6
\ \ offset = 2
ppiiiiii00 numberToWrite = 10
iiiiii numberToRead = 6
\ \ \ offset = 2
ppiii numberToWrite = 5
The symbol "i" refers to any input token. The leftmost symbol refers to the oldest input token of the ones consumed in a given firing. The symbol "p" refers to a token that is either zero (if usePastInputs is false) or is equal to a previously consumed input token (if usePastInputs is true). The symbol "0" refers to a zero-valued token. In the first of the above examples, the entire input block is copied to the output, and then filled out with zeros. In the second example, only a portion of the input block fits. The remaining input tokens are discarded, although they might be used in subsequent firings if usePastInputs is true.
When the offset is negative, this indicates that the first offset input tokens that are read should be discarded. The corresponding scenarios are shown below:
iiiiii numberToRead = 6
/ / / offset = -2
iiii000000 numberToWrite = 10
iiiiii numberToRead = 6
/ / // offset = -2
iii numberToWrite = 3
In the first of these examples, the first two input tokens are discarded. In the second example, the first two and the last input token are discarded.
The zero-valued tokens are constructed using the zero() method of the first input token that is read in the firing. This returns a zero-valued token with the same type as the input.
| Yellow (neuendor) |
| Green (eal) |
Entity.ContainedObjectsIterator| Modifier and Type | Field and Description |
|---|---|
Parameter |
numberToRead
The number of input tokens to read.
|
Parameter |
numberToWrite
The number of tokens to write to the output.
|
Parameter |
offset
Start of output block relative to start of input block.
|
Parameter |
usePastInputs
If offset is greater than 0, specify whether to use previously
read inputs (otherwise use zeros).
|
input, input_tokenConsumptionRate, output, output_tokenInitProduction, output_tokenProductionRate_typesValid_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKSCOMPLETED, NOT_READY, STOP_ITERATING| Constructor and Description |
|---|
Chop(CompositeEntity container,
java.lang.String name)
Construct an actor in the specified container with the specified
name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
attributeChanged(Attribute attribute)
Check the validity of parameter values and using the new
values, recompute the size of the internal buffers.
|
void |
fire()
Consume the specified number of input tokens, and produce
the specified number of output tokens.
|
void |
initialize()
Override the base class to ensure that the past buffer
gets initialized.
|
prefire_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspaceequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortListisFireFunctional, isStrict, iterate, postfire, stop, stopFire, terminateaddInitializable, preinitialize, removeInitializable, wrapupdescription, getContainer, getDisplayName, getFullName, getName, getName, setNamegetDerivedLevel, getDerivedList, propagateValuepublic Parameter numberToRead
public Parameter numberToWrite
public Parameter offset
public Parameter usePastInputs
public Chop(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container - The container.name - The name.IllegalActionException - If the actor cannot be contained
by the proposed container.NameDuplicationException - If the name coincides with
an actor already in the container.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged in class NamedObjattribute - The attribute that has changed.IllegalActionException - If the parameters are out of range.public void fire()
throws IllegalActionException
fire in interface Executablefire in class AtomicActor<TypedIOPort>IllegalActionException - If there is no director.public void initialize()
throws IllegalActionException
initialize in interface Initializableinitialize in class AtomicActor<TypedIOPort>IllegalActionException - If the superclass throws it.