Hybrid Atomic Object with Simulator Functionalities
stored in DEVS_PATH/00-simulator/hybridatomic.p
Is provided as p-code.
Contents
Based on modified parallel DEVS algorithms (Zeigler, Schwatinski) and wrapper extension (Deatcu). |
All hybrid user defined atomic models have to be derived from class hybridatomic. |
C. Deatcu 2016 |
Description
Class definition file for an associated simulator for hybrid atomic DEVS models. Extends the discrete associated simulator.
constructor call: obj = hybridatomic(name,x,y,s,c_states,elapsed,sysparams)
Superclass
atomic
Inherited properties
inherited from devs:
- 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)
inherited from atomic:
- 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)
Properties
- c_states : vector of continuous state variables
- mealy : 1 if it is of Mealy type, 0 if it is of Moore type needs to be set by the modeler in constructor method
- num_c_state_events : number of cont. state events
- event_offset : offset in global event location vector
- state_offset : offset in global state vector
- output_offset : offset in global output vector
- output_length : length of output-vector returned by lamda_c
- input_offset : input offsets in global x vector
- input_length : length of input from global x vector
Class methods
inherited from atomic:
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 discrete 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
--------------------------------------------------------------------
Additional methods for hybrid simulation:
- [obj,gstatvec,gevveclen,outoffs] = z_msg(obj,gt,soff,eoff) : z message - vector configuration of hybrid atomics
- obj = z2_msg(obj,gt,ioffs) : z2 message - second run vector configuration of hybrid atomics (setting the index of local input variables)
- [obj,event_flag] = se_msg(obj,te,ye,ie) : state event message - is called when a state event occurred somewhere in entire model (for hybrid simulation only); if state event occured in THIS model, set event_flag and calculate tnext
- showall(obj) : display the object
Z_MSG
function [obj,gstatvec,gevveclen,outoffs]=z_msg(obj,gt,soff,eoff)
WHAT HAPPENS IN Z_MSG?
- message for vector configuration (for hybrid simulation only)
Z2_MSG
function obj=z2_msg(obj,gt,ioffs)
WHAT HAPPENS IN Z2_MSG?
- message for vector configuration (for hybrid simulation only)
- second run for setting the index of local input variables
SE_MSG
function [obj,event_flag]=se_msg(obj,te,ye,ie)
WHAT HAPPENS IN SE_MSG?
- state event message
- is called when an state event occurred somewhere in entire model (for hybrid simulation only)
- if state event occured in THIS model, set event_flag and calculate t_next
DEVS Tbx Home Examples Modelbase << Back