Class AFDXSwitch

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, CommunicationAspect, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Decorator, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class AFDXSwitch
    extends AtomicCommunicationAspect
    A 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.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Gilles Lasnier, Based on BasiSwitch.java by Patricia Derler
    Pt.AcceptedRating:
    Yellow (glasnier)
    Pt.ProposedRating:
    Yellow (glasnier)
    • Field Detail

      • numberOfPorts

        public Parameter numberOfPorts
        Number of ports on the switch. This parameter must contain an IntToken. The value defaults to 2.
      • inputBufferDelay

        public Parameter inputBufferDelay
        Time it takes for a token to be put into the input queue. This parameter must contain a DoubleToken. The value defaults to 0.0.
      • outputBufferDelay

        public Parameter outputBufferDelay
        Time it takes for a token to be put into the output queue. This parameter must contain a DoubleToken. The value defaults to 0.0.
      • technologicalDelay

        public Parameter technologicalDelay
        Technological latency according to the AFDX specification. This parameter must contain a DoubleToken. The value defaults to 0.000140 (140 us).
      • bitRate

        public Parameter bitRate
        The bit rate of the bus. The value defaults to 100 Mbits/s.
      • _technologicalDelay

        protected double _technologicalDelay
        Time it takes for a token to be processed by the switch fabric.
      • _nextFireTime

        protected Time _nextFireTime
        Next time a token is sent and the next token can be processed.
      • _inputTokens

        protected java.util.HashMap<java.lang.Integer,​java.util.LinkedList<TimedEvent>> _inputTokens
        Tokens received by the switch.
      • _outputTokens

        protected java.util.HashMap<java.lang.Integer,​java.util.LinkedList<TimedEvent>> _outputTokens
        Tokens to be sent to outputs.
      • _ioPortToSwitchInPort

        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.
      • _ioPortToSwitchOutPort

        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.
      • _numberOfPorts

        protected int _numberOfPorts
        Number of switch ports.
      • _bitRate

        protected double _bitRate
        Value of the bit rate of the bus.
    • Constructor Detail

      • AFDXSwitch

        public AFDXSwitch​(CompositeEntity container,
                          java.lang.String name)
                   throws IllegalActionException,
                          NameDuplicationException
        Construct a Bus with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.
        Parameters:
        container - The container.
        name - The name of this actor.f
        Throws:
        IllegalActionException - If the container is incompatible with this actor.
        NameDuplicationException - If the name coincides with an actor already in the container.
    • Method Detail

      • getReceiver

        public IntermediateReceiver getReceiver​(Receiver receiver)
                                         throws IllegalActionException
        Create an intermediate receiver that wraps a given receiver. For now, we only support wrapping input ports.
        Parameters:
        receiver - The receiver that is being wrapped.
        Returns:
        A new intermediate receiver.
        Throws:
        IllegalActionException - If the receiver is an output port.
      • getReceiver

        public Receiver getReceiver​(Receiver receiver,
                                    IOPort port)
                             throws IllegalActionException
        Create a receiver to mediate a communication via the specified receiver. This receiver is linked to a specific port of the communication aspect.
        Parameters:
        receiver - Receiver whose communication is to be mediated.
        port - Port of the communication aspect.
        Returns:
        A new receiver.
        Throws:
        IllegalActionException - If the receiver cannot be created.
      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        If the attribute for the input, output, technological delay or bit rate is changed, then ensure that the value is non-negative.
        Overrides:
        attributeChanged in class NamedObj
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - If the buffer delays are negative.
      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone this actor into the specified workspace. The new actor is not added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container. A container must be set before much can be done with this actor.
        Overrides:
        clone in class AtomicCommunicationAspect
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        A new Bus.
        Throws:
        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.
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • fire

        public void fire()
                  throws IllegalActionException
        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. When moving tokens between queues the appropriate delays are considered.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - If the token cannot be sent to target receiver.
      • sendToken

        public void sendToken​(Receiver source,
                              Receiver receiver,
                              Token token)
                       throws IllegalActionException
        Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor if there is not one already scheduled.
        Parameters:
        source - Sender of the token.
        receiver - The sending receiver.
        token - The token to send.
        Throws:
        IllegalActionException - If the refiring request fails.
      • setPortIn

        public void setPortIn​(Port port,
                              int portIn)
        Set the id of the switch input that is receiving tokens from this actor port.
        Parameters:
        port - The actor port.
        portIn - The id of the switch port.
      • setPortOut

        public void setPortOut​(Port port,
                               int portOut)
        Set the id of the switch output that is sending tokens to this actor port.
        Parameters:
        port - The actor port.
        portOut - The id of the switch port.
      • reset

        public void reset()
        Reset the communication aspect and clear the tokens.
      • _getPortID

        protected int _getPortID​(Receiver receiver,
                                 boolean input)
        Return the IO of the switch port where this receiver is connected to. The port ID's are set via parameters.
        Parameters:
        receiver - The actor receiver.
        input - Whether the port is an input port.
        Returns:
        The port ID.
      • _getNextFireTime

        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.
        Parameters:
        nextFireTime - Minimum next fire time.
        tokens - The set of tokens.
        Returns:
        The next time this actor should be fired based on the tokens in the queue.
      • _scheduleRefire

        protected void _scheduleRefire()
                                throws IllegalActionException
        Schedule a refiring of this actor based on the tokens in the queues.
        Throws:
        IllegalActionException - If actor cannot be refired at the computed time.