public class UnitsConverter extends Transformer
Ontology
and an
OntologySolver
for the unitSystem ontology must be present in the model.
For data types where multiplication is not commutative (such
as matrices), whether the factor is multiplied on the left is controlled
by the scaleOnLeft parameter. Setting the parameter to true means
that the factor is multiplied on the left, and the input
on the right. Otherwise, the factor is multiplied on the right.Red (cshelton) |
Red (cshelton) |
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
StringAttribute |
conversionLabel
The conversion label string that will be displayed on the actor icon.
|
StringAttribute |
dimensionConcept
The name of the dimension from which both units are derived.
|
StringAttribute |
inputUnitConcept
The input unit measurement for the actor.
|
StringAttribute |
outputUnitConcept
The output unit measurement for the actor.
|
Parameter |
scaleOnLeft
Multiply on the left.
|
Parameter |
unitSystemOntologySolver
The unitSystem ontology solver in the model that contains the unitSystem
ontology.
|
input, output
_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 |
---|
UnitsConverter(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(Attribute attribute)
Update the conversionLabel attribute value when either the inputUnitConcept
or the outputUnitConcept attributes change.
|
void |
fire()
Transform the input value from its original units measurement to the output
units measurement.
|
UnitConcept |
getUnitConcept(boolean fromInput)
Return the UnitInformation Concept in the unitSystem ontology for the
specified string attribute which represents the unit specification
for the either the actor's input or output port.
|
OntologySolver |
getUnitOntologySolver()
Return the unitSystem ontology solver specified by the actor's
unitSystemOntologySolver parameter.
|
void |
preinitialize()
Preinitialize the actor by setting the unit system ontology
concepts for the input and output ports.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, 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, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, initialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public StringAttribute dimensionConcept
public StringAttribute conversionLabel
public StringAttribute inputUnitConcept
public StringAttribute outputUnitConcept
public Parameter scaleOnLeft
public Parameter unitSystemOntologySolver
public UnitsConverter(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name of this actor.IllegalActionException
- If the actor cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that has changed.IllegalActionException
- Thrown if there is a problem setting
the expression of the conversionLabel attribute.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If there is no director.public UnitConcept getUnitConcept(boolean fromInput) throws IllegalActionException
fromInput
- true if we want the concept specified by the inputUnitConcept
and false if we want the concept specified by the outputUnitConcept.IllegalActionException
- Thrown if the ontology solver has not
been specified, the unit name cannot be found in the unitSystem ontology, or
the attribute passed in is not one of the actor's inputUnitConcept
or outputUnitConcept attributes.public OntologySolver getUnitOntologySolver() throws IllegalActionException
IllegalActionException
- Thrown if there is a problem getting
the ontology solver object from the parameter.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- Thrown if the input or output unit
concepts are incorrectly specified.