public class Test extends NonStrictTest
This actor compares the inputs against the value specified by the correctValues parameter. That parameter is an ArrayToken, where each element of the array should have the same type as the input. The length of this array is the number of iterations of this actor that are tested. Subsequent iterations always succeed, so the actor can be used as a "power-up" test for a model, checking the first few iterations against some known results.
The input is a multiport. If there is more than one channel connected to it, then each element of correctValues must itself be an ArrayToken, with length matching the number of channels. Suppose for example that the width of the input is one, and the first three inputs should be 1, 2, and 3. Then you can set correctValues to
{1, 2, 3}
Suppose instead that the input has width two, and the correct values in the first iteration are 1 on the first channel and 2 on the second. Then on the second iteration, the correct values are 3 on the first channel and 4 on the second. Then you can set correctValues to
{{1, 2}, {3, 4}}
With this setting, no tests are performed after the first two iterations of this actor.
The input values are checked in the fire() method, which checks to make sure that each input channel has a token. If an input value is missing or differs from what it should be, then fire() throws an exception. Thus, the test passes if no exception is thrown. If you need to check the input value in postfire() (say, after a fixed-point iteration has converged), then use NonStrictTest.
If the input is a DoubleToken or ComplexToken, then the comparison passes if the value is close to what it should be, within the specified tolerance (which defaults to 10-9. The input data type is undeclared, so it can resolve to anything.
On each firing, this actor produces the output false until it reaches the end of the correctValues array, at which point it outputs true. This can be fed, for example, to an instance of the Stop actor to stop the test upon successfully matching the test data. In training mode, the output is always false.
NonStrictTest
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
TypedIOPort |
output
Boolean output that is false as long as there is data to
compare against the input, but becomes true on the first
firing after such data has been exhausted.
|
_firedOnce, _initialized, _iteration, _matchedValues, _numberOfInputTokensSeen, _tolerance, _trainingTokens, correctValues, requireAllCorrectValues, requireOrderedValues, tolerance, TRAINING_MODE_ERROR_MESSAGE, trainingMode
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
Test(CompositeEntity container,
java.lang.String name)
Construct an actor with an input multiport.
|
Modifier and Type | Method and Description |
---|---|
void |
fire()
Read one token from each input channel and compare against
the value specified in correctValues.
|
boolean |
postfire()
Override the base class to do nothing and return true.
|
_checkRangeOfTolerance, _customTypeConstraints, _isClose, _isCloseToIfNilArrayElement, _isCloseToIfNilRecordElement, attributeChanged, clone, initialize, wrapup
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
_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, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public TypedIOPort output
public Test(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name of this actor.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void fire() throws IllegalActionException
If the iteration count is larger than the length of correctValues, then output true and return, indicating that the test is complete, i.e. that all values in correctValues have been matched.
If the requireOrderedValues parameter is false, then the input can match any as yet unmatched value in correctValues.
fire
in interface Executable
fire
in class NonStrictTest
IllegalActionException
- If an input is missing,
or if its value does not match the required value.NonStrictTest._firedOnce
public boolean postfire()
postfire
in interface Executable
postfire
in class NonStrictTest