BaseDEVS¶
- class pypdevs.DEVS.BaseDEVS(name)[source]¶
Abstract base class for AtomicDEVS and CoupledDEVS classes.
This class provides basic DEVS attributes and query/set methods.
- addInPort(name=None)[source]¶
Add an input port to the DEVS model.
addInPort is the only proper way to add input ports to a DEVS model. As for the CoupledDEVS.addSubModel method, calls to addInPort and addOutPort can appear in any DEVS’ descriptive class constructor, or the methods can be used with an instantiated object.
The methods add a reference to the new port in the DEVS’ IPorts attributes and set the port’s hostDEVS attribute. The modeler should typically save the returned reference somewhere.
- Parameters
name – the name of the port. A unique ID will be generated in case None is passed
- Returns
port – the generated port
- addOutPort(name=None)[source]¶
Add an output port to the DEVS model.
addOutPort is the only proper way to add output ports to DEVS. As for the CoupledDEVS.addSubModel method, calls to addInPort and addOutPort can appear in any DEVS’ descriptive class constructor, or the methods can be used with an instantiated object.
The methods add a reference to the new port in the DEVS’ OPorts attributes and set the port’s hostDEVS attribute. The modeler should typically save the returned reference somewhere.
- Parameters
name – the name of the port. A unique ID will be generated in case None is passed
- Returns
port – the generated port
- addPort(name, is_input)[source]¶
Utility function to create a new port and add it everywhere where it is necessary
- Parameters
name – the name of the port
is_input – whether or not this is an input port
- getModelFullName()[source]¶
Get the full model name, including the path from the root
- Returns
string – the fully qualified name of the model
- Raises
AttributeError – when the model is not fully initialized for simulation
- getModelFullNameRec()[source]¶
Get the full model name, including the path from the root, using recursion.
- Returns
string – the fully qualified name of the model
- getVCDVariables()[source]¶
Fetch all the variables, suitable for VCD variable generation
- Returns
list – all variables needed for VCD tracing
- modelTransition(state)[source]¶
DEFAULT function for Dynamic Structure DEVS, always returning False (thus indicating that no structural change is needed)
- Parameters
state – a dict that can be used to save some kind of state, this object is maintained by the kernel and will be passed each time
- Returns
bool – whether or not a structural change is necessary
- removePort(port)[source]¶
Remove a port (either input or output) from the model, disconnecting all of its connections.
- Parameters
port – the port to remove
- simSettings(simulator)[source]¶
Modifies the simulation settings from within the model.
This function is called _before_ direct connection and distribution is performed, so the user can still access the complete hierarchy.
Note
This function is only called on the root model of the simulation, thus the model passed to the constructor of the Simulator object.
- Parameters
simulator – the simulator object on which settings can be configured