Atomic Object with Simulator Functionalities
stored in DEVS_PATH/00-simulator/atomic.p
Is provided as p-code.
Contents
Based on modified parallel DEVS algorithms (Zeigler, Schwatinski). |
All user defined atomic models have to be derived from class atomic. |
C. Deatcu 2016 |
Description
Class definition file for an associated simulator for atomic PDEVS models
constructor call: obj = atomic(name,x,y,s,elapsed,sysparams)
Superclass
devs
Inherited properties
- sub_of : string, name of the superordinate model --> for debugging purposes
- tnext : float, time of next event
- tlast : float, time of last event
- name : string, (unique) name of this model --> for debugging purposes max. 12 characters for "nice" debug-look ;-)
- x : structure, set of inport name/input value (cell array) pairs
- y : structure, set of outport name/output value (cell array) pairs
- debug_flag: 0|1|2|3, no messages|messages|steps|visualize x, y, and s (default 0)
- observe_flag: 0|1, log states of atomic subcomponents or not (default 0)
Properties
- s : structure, set of states
- elapsed : float, time elapsed since last transition (only for initialization)
- sysparams : structure, set of system parameters, can be set only once at instantiation
- observed : cell array including time stamps and a copy of s (structure of states)
Class Methods
Simulation Messages
- i_msg(obj,gt) : initialization message - sets tlast and calls tafun() of model to calculate tnext
- s_msg(obj,gt,flag): star message - called when atomic is imminent, calls deltaint() and tafun() of model, sets tlast and tnext
- x_msg(obj,gt) : x message - called, if external event arrives, calls deltaconffun() or deltaextfun() of model
- y_msg(obj,gt) : inperpellation y message - calls lambdafun of model
Set Methods for Flags
- set_debug(obj, debug_flag): set flag for debug messages to 0|1|2|3
- set_observe(obj, observe_flag): set flag for tracking states to 0|1
Set Methods for States
- set_states(obj, statenames): initializes the structure obj.s. with fields defined in statenames
- set.s(obj,svalues): safe setting of state values in s
Display Methods
- showall(obj) : display the object
- showxports(obj) : display x-ports and values
- showyports(obj) : display y-ports and values
- showstates(obj) : display states in s
- showsysparams(obj): display system parameters in sysparams
i_MSG
function i_msg(obj,gt)
WHAT HAPPENS IN I_MSG?
- set time tlast by calculating from current simulation time gt and elapsed tnext at all objects
- call time advance function of associated model
- set time for next internal event tnext
S_MSG
function obj=s_msg(obj,gt,flag)
WHAT HAPPENS IN S_MSG?
- call internal transition function of associated model
- set time tlast to current time gt
- call time advance function of associated model
- set time for next internal event tnext
flag == 1 --> s_msg from ROOT, flag == 0 --> s_msg from other
flag here just for adapting debug-message, no different reactions depending on if from root or other components!
X_MSG
function x_msg(obj,gt)
WHAT HAPPENS IN X_MSG?
- if there is an external and internal event at the same time (current time gt == tnext), call confluent function of associated model
- if there is just an external event, call external transition function of associated model
- set time tlast to current time gt
- call time advance function of associated model
- set time for next internal event tnext
Y_MSG
function y_msg(obj,gt)
WHAT HAPPENS IN Y_MSG?
- call output function of associated model
- propagate output to superordinate coordinator
DEVS Tbx Home Examples Modelbase << Back