AtomicDEVS Model Description
This model represents the basic component for atomic Parallel DEVS models.
It implements the behavior of an atomic model, independently of the actions performed by the transition, output and time advance functions.
Basically, it detects the occurrence of events and executes the functions that correspond to the detected events.
The actions performed by these functions have to be defined by the user
The state of the model and its initialization also has to be defined by the user.
Interface Ports
The input ports have to be defined by the user.
In order to allow any number of input and output ports, four arrays (iEvent, iQueue, oEvent and oQueue) have been defined in the model
and internally represent the input (iEvent and iQueue) and output (oEvent and oQueue) ports.
The length of these arrays is defined by the parameters numIn and numOut.
The user must set these parameters to the correct number of input and output ports (the minimum value is 1).
An equation must be defined between the port and its corresponding position in each of the arrays.
The event variable of the port is connected to the Event array, and the queue variable is connected to the Queue array
(i.e. inputPort1.event = iEvent[1], inputPort1.queue = iQueue[1] ,outputPort1.event = oEvent[1] and outputPort1.queue = oQueue[1]).
Functions
Five replaceable functions are defined in this model and represent the transition, output and time advance functions (Fcon, Fext, Fint, Fout and Fta
respectively).
These functions do not perform any action and must be redeclared by the user.
Models without input or output ports does not need the external, confluent or internal transition functions, so they do not have to be redeclared.
The prototype of each function is:
- sout := Fcon (s,e,bag), where sout is the state after the confluent transition,
soutput is the state that will be used by the output function to generate an output,
s is the current state, e is the elapsed time since the last transition and bag is the reference to the storage of input messages.
- sout := Fint (s), where sout is the state after the confluent transition, and s is the current state.
- sout := Fext (s,e,bag), where sout is the state after the confluent transition, and s is the current state,
e is the elapsed time since the last transition, and bag is the reference to the storage of input messages.
- sigma := Fta(s), where sigma is the time interval until the next internal transition, and s is the current state.
- Fout (s,queues[nports],nports), where s is the current state, queues[nports] is the array that contains references to the queues that will receive the messages sent by this function,
and nports is the number of ports connected to the model that executes the function.
Alternatively to these parameters, any other parameter can be added to these functions.
New parameters can be added at the end of the function inputs.
The value of the parameter can be set in the redeclaration of the function, when constructing a new model.
Continuous or discrete input values can be passed to these functions using this method.
State
The state of the model is represented by the record st.
Any number of variables can be included in that record in order to represent the state of the model.
In Dymola 6.2, only simple types (Real, Integer and Boolean) can be included. This bug is fixed in newer versions.
The modified state can be redeclared in the construction of a new model.
The initialization of the state is performed by the initState function.
This function is called once before the beginning of the simulation.
Event Detection
The detection of the events is performed by the equations at the end of the model.
The internal events are detected by the following equation:
internalEvent = if time >= pre(nextInternalTransition) then 1 else 0;
Every time the time reaches the value of the nextInternalTransition variable, an internal transition is triggered.
The external events are detected by the following equations:
for i in 1:numIn loop
receivedEvents[i] = - integer(iEvent[i]);
externalEventNum[i] = if (receivedEvents[i] > pre(receivedEvents[i])) or (receivedEvents[i] < pre(receivedEvents[i])) then 1 else 0;
end for;
externalEvent = if sum(externalEventNum) > 0 then 2 else 0;
The for loop is neccesary to check the reception of new messages in all the input ports that could have been defined by the user.
The confluent event checks the simultaneous occurrence of internal and external events.
confluentEvent = externalEvent + internalEvent;
The transition to execute is decided by the following equations, that use the previously calculated variables:
confluentTransition = confluentEvent == 3 and time > 0;
externalTransition = externalEvent == 2 and time > 0 and not confluentTransition;
internalTransition = internalEvent == 1 and time > 0 and not confluentTransition;
Generated at 2024-11-21T19:25:40Z
by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos