Package xdevs.core.modeling
Class Coupled
- java.lang.Object
-
- xdevs.core.modeling.Component
-
- xdevs.core.modeling.Coupled
-
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected LinkedList<Component>componentsThe components of the coupled model.protected LinkedList<Coupling<?>>eicThe external input couplings of the coupled model.protected LinkedList<Coupling<?>>eocThe external output couplings of the coupled model.protected LinkedList<Coupling<?>>icThe input couplings of the coupled model.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddComponent(Component component)Adds a component to the coupled model.protected voidaddComponentsAndCouplings(Element xmlCoupled)Given a XML representation of a coupled model, this method adds the components and couplings to the current coupled model.voidaddCoupling(String cFromName, String pFromName, String cToName, String pToName)This method add a connection to the DEVS component.voidaddCoupling(Component cFrom, int oPortIndex, Component cTo, int iPortIndex)This method add a connection to the DEVS component.voidaddCoupling(Component cFrom, Port<?> pFrom, Component cTo, Port<?> pTo)Deprecated.This method add a connection to the DEVS component.voidaddCoupling(Port<?> pFrom, Port<?> pTo)This member adds a connection between ports pFrom and pTovoidaddInPort(Port<?> port)This method adds a input port to the DEVS component.voidaddOutPort(Port<?> port)This method adds a output port to the DEVS component.intcountAtomicComponents()This method returns the number of atomic components in the coupled model.voidexit()This method is called by the simulator right after the simulation ends.Coupledflatten()This method flattens the coupled model, removing all the coupled models and adding their components to the parent coupled model.ComponentgetComponentByName(String name)Get the first component (including this coupled model) whose name match with name argument.Collection<Component>getComponents()Get the components of the coupled model.LinkedList<Coupling<?>>getEIC()Get the external input couplings of the coupled model.LinkedList<Coupling<?>>getEOC()Get the external output couplings of the coupled model.LinkedList<Coupling<?>>getIC()Get the input couplings of the coupled model.ComponentgetParent()Returns the parent of the DEVS component.voidinitialize()This method is called by the simulator to initialize the DEVS component.protected voidremoveComponent(Component child)Remove a component, and related coupling relations from the coupled model.voidsetParent(Component parent)Sets the parent of the DEVS component.booleanstructuralTransition()This method is called by the simulator to check possible structural changes.StringtoXml()This method returns the XML representation of the coupled model.-
Methods inherited from class xdevs.core.modeling.Component
getInPort, getInPorts, getName, getOutPort, getOutPorts, isInputEmpty, toString
-
-
-
-
Field Detail
-
components
protected LinkedList<Component> components
The components of the coupled model.
-
ic
protected LinkedList<Coupling<?>> ic
The input couplings of the coupled model.
-
eic
protected LinkedList<Coupling<?>> eic
The external input couplings of the coupled model.
-
eoc
protected LinkedList<Coupling<?>> eoc
The external output couplings of the coupled 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:
initializein classComponent
-
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.
-
getParent
public Component getParent()
Returns the parent of the DEVS component.
-
setParent
public void setParent(Component parent)
Sets 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 connectionoPortIndex- Index of the source port in cFrom, starting at 0cTo- Component at the end of the connectioniPortIndex- 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.
-
addOutPort
public void addOutPort(Port<?> port)
This method adds a output port to the DEVS component.- Overrides:
addOutPortin classComponent- 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 theparentattribute, both componentscFromandcToare no longer needed inside the Coupling class.- Parameters:
cFrom- Component at the beginning of the connectionpFrom- Port at the beginning of the connectioncTo- Component at the end of the connectionpTo- 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 connectionpFromName- Name of the port at the beginning of the connectioncToName- Name of the component at the end of the connectionpToName- 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 connectionpTo- 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.
-
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.
-
-