Class CanBus

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

    @Deprecated
    public class CanBus
    extends AtomicCommunicationAspect
    Deprecated.
    This does not appear to work!
    This actor is an CommunicationAspect that simulates a CAN bus network When its sendToken(Receiver, Receiver, Token) method is called, the delivery of the specified token to the specified receiver is delayed according to the CAN protocol.

    The CAN bus is a serial communication protocol that supports real-time systems with high reliability. Its main features are: priority-based bus access and non destructive content-based arbitration. If two or more nodes attempt to transmit a message on the idle bus, the access conflicts are resolved by performing a bitwise arbitration (non destructive) according to a priority (called here CanPriority). Our CommunicationAspect simulates such content-based arbitration. A node attempting to transmit a message when the bus is busy must try again when the bus will be free (in fact, there is a queue with messages that did not win the bus during arbitration or arrived when the bus is busy).

    In order to perform such an arbitration, it is needed to set a parameter called CanPriority to each receiving switch port. CanPriority is a positive integer. The higher is CanPriority the lower is the priority. (note that in the reality the arbitration is done bit to bit. The higher is the identifier the higher is the priority) It is just needed to set this parameter, using the Parameter dialogs offered by the Decorator mechanism, to the port(s) we want to connect to the bus. The CanPriority parameter is already added and is visible on Parameter dialogs when the CanBus QM is deployed in a model (enhancing visibility).

    Messages sent on the Bus are stored and delivered on due time. Since the CAN protocol cover the second layer of the OSI model, messages sent on the bus are encapsulated in frames according to the CAN protocol. We consider that messages sent by actors correspond to exactly one frame. Also, two formats of frames are provided by the CAN standard: the base frame and the extended frame. We can choose the standard according to which the simulation will be performed.

    Of course, the bit rate of the bus is also a parameter that can be modified. Typical bit rates for the CAN bus range from 125 Kbits/second to 1 Mbits/second.

    Future work: implementing an application layer of the OSI model based on CAN, taking errors into account by delaying the deliveries of messages, finest management of time by dividing the time continuum in periods of 1/bitRate, bit stuffing...

    For more information please refer to: CAN bus simulator using a communication aspect.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    D. Marciano, G. Lasnier, P. Derler
    Pt.AcceptedRating:
    Yellow (glasnier)
    Pt.ProposedRating:
    Yellow (glasnier)
    • Field Detail

      • bitRate

        public Parameter bitRate
        Deprecated.
        The bit rate of the bus. This is a double with default value to 125 (Kbit/second). It is required to be positive.
      • canFormatOfFrame

        public Parameter canFormatOfFrame
        Deprecated.
        The format of frame. This is a string with default value to "Standard frame". It is required to be either "Standard frame" or "Extended frame".
      • canFramePolicy

        public Parameter canFramePolicy
        Deprecated.
        The selected policy for the frame queue behavior. This is a string with the default value "Send All Frames".
      • _ioPortToCanPriority

        protected java.util.HashMap<Port,​java.lang.Integer> _ioPortToCanPriority
        Deprecated.
        Tokens sent to ports mediated by this communication aspect are rerouted to the switch ports with the IDs specified in this map.
    • Constructor Detail

      • CanBus

        public CanBus​(CompositeEntity container,
                      java.lang.String name)
               throws IllegalActionException,
                      NameDuplicationException
        Deprecated.
        Construct a CanBus 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.
        Throws:
        IllegalActionException - If the container is incompatible with this actor.
        NameDuplicationException - If the name coincides with an actor already in the container.
    • Method Detail

      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Deprecated.
        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 CanBus.
        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)
      • getReceiver

        public Receiver getReceiver​(Receiver receiver,
                                    IOPort port)
                             throws IllegalActionException
        Deprecated.
        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.
      • nextCanPriority

        public int nextCanPriority()
        Deprecated.
        Method that computes the identifier ('CanPriority') of the message that has the highest priority.
        Returns:
        The identifier ('CanPriority') of the message that has the highest priority.
      • nextToken

        public Token nextToken()
        Deprecated.
        Return the next token to be sent according to the CAN protocol.
        Returns:
        The next token to be sent according to the CAN protocol.
      • nextTokenSize

        public int nextTokenSize()
        Deprecated.
        Method that compute the size of the next token that need to be sent according to the CAN protocol This method uses the serialization API to compute the size of the token that need to be sent Actually, this method is never called in the current version of the code If you want to use a variable size for objects sent through the network, you need to uncomment the line dedicated to this functionality in the nextTokenSize() method.
        Returns:
        The size of the next token to be sent.
      • nextTokenTransmissionTime

        public double nextTokenTransmissionTime()
        Deprecated.
        Compute the transmission time of the next token through the network In the current version of this CommunicationAspect the size of a token (message) is fixed In order to have a variable token size please uncomment the dedicated line in this method.
        Returns:
        Transmission time for the next token to be sent through the network.
      • printTokenTree

        public void printTokenTree()
        Deprecated.
        Method that print in a human readable way the content of _tokenTree.
      • setCanBusPriority

        public void setCanBusPriority​(Port port,
                                      int canPriority)
        Deprecated.
        Set the canbus priority attached to this actor port.
        Parameters:
        port - The actor port.
        canPriority - The priority attached to the port.
      • reset

        public void reset()
        Deprecated.
        Reset the communication aspect.
      • sendToken

        public void sendToken​(Receiver source,
                              Receiver receiver,
                              Token token)
                       throws IllegalActionException
        Deprecated.
        Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor according to the requirements of the CAN protocol.
        Parameters:
        source - Sender of the token.
        receiver - The receiver to send to.
        token - The token to send.
        Throws:
        IllegalActionException - If the refiring request fails.
      • _getCanBusPriority

        protected int _getCanBusPriority​(Receiver receiver)
        Deprecated.
        Return the priority of the CanBus port where this receiver is connected to. The port ID's are set via parameters.
        Parameters:
        receiver - The actor receiver.
        Returns:
        The port ID.