public class AFDXSwitch extends AtomicCommunicationAspect
CommunicationAspect
actor that, when its
sendToken(Receiver, Receiver, Token)
method is called, delays
the delivery of the specified token to the specified receiver
according to a service rule. This communication aspect is used on
input ports by setting a parameter with an ObjectToken that refers
to this CommunicationAspect at the port. Note that the name of this
parameter is irrelevant.
This communication aspect implements an AFDX switch. It has a parameter specifying the number of ports. On each port, an actor is connected. Note that these ports are not represented as ptolemy actor ports. This actor can send tokens to the switch and receive tokens from the switch. The mapping of ports to actors is done via parameters of this communication aspect.
Internally, this switch has a buffer for every input, a buffer for the switch fabric and a buffer for every output. The delays introduced by the buffers are configured via parameters. Tokens are processed simultaneously on the buffers.
This switch implements the specific switch for the AFDX network. This implementation is based on the basic switch implementation.
Modifier and Type | Class and Description |
---|---|
static class |
AFDXSwitch.AfdxSwitchAttributes
The attributes configured per port which is mediated by a
AfdxSwitch.
|
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected double |
_bitRate
Value of the bit rate of the bus.
|
protected java.util.HashMap<java.lang.Integer,java.util.LinkedList<TimedEvent>> |
_inputTokens
Tokens received by the switch.
|
protected java.util.HashMap<Port,java.lang.Integer> |
_ioPortToSwitchInPort
Tokens sent to ports mediated by this communication aspect
are rerouted to the switch ports with the IDs specified in this
map.
|
protected java.util.HashMap<Port,java.lang.Integer> |
_ioPortToSwitchOutPort
Tokens set to ports mediated by this communication aspect are
processed by this communication aspect and then forwarded
to the port through the switch port with ID specified here.
|
protected Time |
_nextFireTime
Next time a token is sent and the next token can be processed.
|
protected int |
_numberOfPorts
Number of switch ports.
|
protected java.util.HashMap<java.lang.Integer,java.util.LinkedList<TimedEvent>> |
_outputTokens
Tokens to be sent to outputs.
|
protected double |
_technologicalDelay
Time it takes for a token to be processed by the switch fabric.
|
Parameter |
bitRate
The bit rate of the bus.
|
Parameter |
inputBufferDelay
Time it takes for a token to be put into the input queue.
|
Parameter |
numberOfPorts
Number of ports on the switch.
|
Parameter |
outputBufferDelay
Time it takes for a token to be put into the output queue.
|
Parameter |
technologicalDelay
Technological latency according to the AFDX specification.
|
_parameters, _tokenCount
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
decoratorHighlightColorName
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
AFDXSwitch(CompositeEntity container,
java.lang.String name)
Construct a Bus with a name and a container.
|
Modifier and Type | Method and Description |
---|---|
protected Time |
_getNextFireTime(Time nextFireTime,
java.util.LinkedList<TimedEvent> tokens)
Get next fire time for a set of tokens which is either the minimum
next fire time passed as an argument or the smallest timestamp of
the tokens in the set.
|
protected int |
_getPortID(Receiver receiver,
boolean input)
Return the IO of the switch port where this receiver is
connected to.
|
protected void |
_scheduleRefire()
Schedule a refiring of this actor based on the tokens in the queues.
|
void |
attributeChanged(Attribute attribute)
If the attribute for the input, output, technological delay or bit rate is
changed, then ensure that the value is non-negative.
|
java.lang.Object |
clone(Workspace workspace)
Clone this actor into the specified workspace.
|
DecoratorAttributes |
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.
|
void |
fire()
Move tokens from the input queue to the switch fabric, move tokens
from the switch fabric queue to the output queues and send tokens from the
output queues to the target receivers.
|
IntermediateReceiver |
getReceiver(Receiver receiver)
Create an intermediate receiver that wraps a given receiver.
|
Receiver |
getReceiver(Receiver receiver,
IOPort port)
Create a receiver to mediate a communication via the specified receiver.
|
void |
initialize()
Initialize the actor variables.
|
boolean |
postfire()
If there are still tokens in the queue and a token has been
produced in the fire, schedule a refiring.
|
void |
reset()
Reset the communication aspect and clear the tokens.
|
void |
sendToken(Receiver source,
Receiver receiver,
Token token)
Initiate a send of the specified token to the specified
receiver.
|
void |
setContainer(CompositeEntity container)
Make sure that this communication aspect is only used in the DE domain.
|
void |
setPortIn(Port port,
int portIn)
Set the id of the switch input that is receiving tokens from this actor port.
|
void |
setPortOut(Port port,
int portOut)
Set the id of the switch output that is sending tokens to this actor port.
|
_sendToReceiver, createIntermediateReceiver, decoratedObjects, isGlobalDecorator, registerListener, sendCommunicationEvent
_containedTypeConstraints, _customTypeConstraints, _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, 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
description, getContainer, getDisplayName, getFullName, getName, getName, setName
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
getDerivedLevel, getDerivedList, propagateValue
public Parameter numberOfPorts
public Parameter inputBufferDelay
public Parameter outputBufferDelay
public Parameter technologicalDelay
public Parameter bitRate
protected double _technologicalDelay
protected Time _nextFireTime
protected java.util.HashMap<java.lang.Integer,java.util.LinkedList<TimedEvent>> _inputTokens
protected java.util.HashMap<java.lang.Integer,java.util.LinkedList<TimedEvent>> _outputTokens
protected java.util.HashMap<Port,java.lang.Integer> _ioPortToSwitchInPort
protected java.util.HashMap<Port,java.lang.Integer> _ioPortToSwitchOutPort
protected int _numberOfPorts
protected double _bitRate
public AFDXSwitch(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor.fIllegalActionException
- If the container is incompatible
with this actor.NameDuplicationException
- If the name coincides with
an actor already in the container.public IntermediateReceiver getReceiver(Receiver receiver) throws IllegalActionException
receiver
- The receiver that is being wrapped.IllegalActionException
- If the receiver is an
output port.public Receiver getReceiver(Receiver receiver, IOPort port) throws IllegalActionException
receiver
- Receiver whose communication is to be mediated.port
- Port of the communication aspect.IllegalActionException
- If the receiver cannot be created.public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class AtomicCommunicationAspect
container
- The container of this actor.IllegalActionException
- If thrown by the super class or if the
director of this actor is not a DEDirector.NameDuplicationException
- If thrown by the super class.ComponentEntity.getContainer()
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the buffer delays are negative.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class AtomicCommunicationAspect
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If cloned ports cannot have
as their container the cloned entity (this should not occur), or
if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public DecoratorAttributes createDecoratorAttributes(NamedObj target)
createDecoratorAttributes
in interface Decorator
createDecoratorAttributes
in class AtomicCommunicationAspect
target
- The NamedObj that will be decorated.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicCommunicationAspect
IllegalActionException
- If the superclass throws it or
the switch table could not be parsed from the actor parameters.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the token cannot be sent to
target receiver.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the refiring cannot be scheduled or
by super class.public void sendToken(Receiver source, Receiver receiver, Token token) throws IllegalActionException
source
- Sender of the token.receiver
- The sending receiver.token
- The token to send.IllegalActionException
- If the refiring request fails.public void setPortIn(Port port, int portIn)
port
- The actor port.portIn
- The id of the switch port.public void setPortOut(Port port, int portOut)
port
- The actor port.portOut
- The id of the switch port.public void reset()
protected int _getPortID(Receiver receiver, boolean input)
receiver
- The actor receiver.input
- Whether the port is an input port.protected Time _getNextFireTime(Time nextFireTime, java.util.LinkedList<TimedEvent> tokens)
nextFireTime
- Minimum next fire time.tokens
- The set of tokens.protected void _scheduleRefire() throws IllegalActionException
IllegalActionException
- If actor cannot be refired
at the computed time.