Class Coupled

  • Direct Known Subclasses:
    CoupledDistributed, DevStone, Ef, Efp, Factory, Gpt, GptXml

    public class Coupled
    extends Component
    Class for the coupled models in the DEVS formalism. A coupled model is a model that contains other models, and it is used to create hierarchical models. The coupled model can contain atomic models and other coupled models. The coupled model is used to create the structure of the DEVS model.
    • Constructor Detail

      • Coupled

        public Coupled​(String name)
        The constructor of the coupled model.
        Parameters:
        name - The name of the coupled model.
      • Coupled

        public Coupled()
        The constructor of the coupled model.
      • Coupled

        public Coupled​(Element xmlCoupled)
        The constructor of the coupled model.
        Parameters:
        xmlCoupled - The XML element that contains the information of the coupled model.
    • Method Detail

      • initialize

        public void initialize()
        This method is called by the simulator to initialize the DEVS component.
        Specified by:
        initialize in class Component
      • structuralTransition

        public boolean structuralTransition()
        This method is called by the simulator to check possible structural changes.
        Returns:
        true if the model has changed its structure, false otherwise
      • exit

        public void exit()
        This method is called by the simulator right after the simulation ends.
        Specified by:
        exit in class Component
      • getParent

        public Component getParent()
        Returns the parent of the DEVS component.
        Overrides:
        getParent in class Component
        Returns:
        The parent component of the component.
      • setParent

        public void setParent​(Component parent)
        Sets the parent of the DEVS component.
        Overrides:
        setParent in class Component
        Parameters:
        parent - The parent of the DEVS component.
      • addCoupling

        public void addCoupling​(Component cFrom,
                                int oPortIndex,
                                Component cTo,
                                int iPortIndex)
        This method add a connection to the DEVS component.
        Parameters:
        cFrom - Component at the beginning of the connection
        oPortIndex - Index of the source port in cFrom, starting at 0
        cTo - Component at the end of the connection
        iPortIndex - Index of the destination port in cTo, starting at 0
      • addInPort

        public void addInPort​(Port<?> port)
        This method adds a input port to the DEVS component.
        Overrides:
        addInPort in class Component
        Parameters:
        port - The input port to be added to the component.
      • addOutPort

        public void addOutPort​(Port<?> port)
        This method adds a output port to the DEVS component.
        Overrides:
        addOutPort in class Component
        Parameters:
        port - The output port to be added to the component.
      • addCoupling

        public void addCoupling​(Component cFrom,
                                Port<?> pFrom,
                                Component cTo,
                                Port<?> pTo)
        Deprecated.
        This method add a connection to the DEVS component. This method is deprecated because since the addition of the parent attribute, both components cFrom and cTo are no longer needed inside the Coupling class.
        Parameters:
        cFrom - Component at the beginning of the connection
        pFrom - Port at the beginning of the connection
        cTo - Component at the end of the connection
        pTo - Port at the end of the connection
      • addCoupling

        public final void addCoupling​(String cFromName,
                                      String pFromName,
                                      String cToName,
                                      String pToName)
        This method add a connection to the DEVS component.
        Parameters:
        cFromName - Name of the component at the beginning of the connection
        pFromName - Name of the port at the beginning of the connection
        cToName - Name of the component at the end of the connection
        pToName - Name of the port at the end of the connection
      • addCoupling

        public void addCoupling​(Port<?> pFrom,
                                Port<?> pTo)
        This member adds a connection between ports pFrom and pTo
        Parameters:
        pFrom - Port at the beginning of the connection
        pTo - Port at the end of the connection
      • getComponents

        public Collection<Component> getComponents()
        Get the components of the coupled model.
        Returns:
        The components of the coupled model.
      • getComponentByName

        public Component getComponentByName​(String name)
        Get the first component (including this coupled model) whose name match with name argument.
        Parameters:
        name - The name of the component to find
        Returns:
        The component, which name is equal to the argument. If no component is found, null is returned.
      • addComponent

        public final void addComponent​(Component component)
        Adds a component to the coupled model.
        Parameters:
        component - The component to add to the coupled model.
      • getIC

        public LinkedList<Coupling<?>> getIC()
        Get the input couplings of the coupled model.
        Returns:
        The input couplings of the coupled model.
      • getEIC

        public LinkedList<Coupling<?>> getEIC()
        Get the external input couplings of the coupled model.
        Returns:
        The external input couplings of the coupled model.
      • getEOC

        public LinkedList<Coupling<?>> getEOC()
        Get the external output couplings of the coupled model.
        Returns:
        The external output couplings of the coupled model.
      • flatten

        public Coupled flatten()
        This method flattens the coupled model, removing all the coupled models and adding their components to the parent coupled model.
        Returns:
        this, as the coupled model after the flattening.
      • removeComponent

        protected void removeComponent​(Component child)
        Remove a component, and related coupling relations from the coupled model.
        Parameters:
        child - The component to remove
      • toXml

        public String toXml()
        This method returns the XML representation of the coupled model.
        Specified by:
        toXml in class Component
        Returns:
        The XML representation of the coupled model.
      • countAtomicComponents

        public int countAtomicComponents()
        This method returns the number of atomic components in the coupled model.
        Returns:
        The number of atomic components in the coupled model.
      • addComponentsAndCouplings

        protected void addComponentsAndCouplings​(Element xmlCoupled)
        Given a XML representation of a coupled model, this method adds the components and couplings to the current coupled model.
        Parameters:
        xmlCoupled - The XML representation of the coupled model.