Behavior Model¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
This module contains a BehaivorModel object that allows you to implement the Discrete Event System Specification AtomicModel.
- class pyjevsim.behavior_model.BehaviorModel(_name='')[source]¶
Bases:
CoreModelBehaviorModel template to inherit when constructing a new Model.
- Parameters:
_name (str) – Unique model name
- deserialize(json)[source]¶
Deserializes the behavior model from a JSON object
- Parameters:
json (dict) – JSON object containing the model data
- abstract ext_trans(port, msg)[source]¶
Defines the external transition, to be implemented by subclasses
- find_external_transition(pre_state)[source]¶
Checks if there are external transitions for a given state
- Parameters:
pre_state (str) – Previous state
- Returns:
True if transitions exist, False otherwise
- Return type:
bool
- find_internal_transition(pre_state)[source]¶
Checks if there are internal transitions for a given state
- Parameters:
pre_state (str) – Previous state
- Returns:
True if transitions exist, False otherwise
- Return type:
bool
- find_state(name)[source]¶
Checks if a state exists
- Parameters:
name (str) – State name
- Returns:
True if state exists, False otherwise
- Return type:
bool
- insert_external_transition(pre_state, event, post_state)[source]¶
Inserts an external transition
- Parameters:
pre_state (str) – Previous state
event (str) – Event causing the transition
post_state (str) – Next state
- insert_internal_transition(pre_state, event, post_state)[source]¶
Inserts an internal transition
- Parameters:
pre_state (str) – Previous state
event (str) – Event causing the transition
post_state (str) – Next state
- insert_state(name, deadline='inf')[source]¶
Insert “state” into the BehaviorModel
- Parameters:
name (str) – State name
deadline (str or Infinite) – Time until the state is active. Defaults to Infinite.
- retrieve_external_transition(pre_state)[source]¶
Retrieves external transitions for a given state
- Parameters:
pre_state (str) – Previous state
- Returns:
List of external transitions
- Return type:
list
- retrieve_internal_transition(pre_state)[source]¶
Retrieves internal transitions for a given state
- Parameters:
pre_state (str) – Previous state
- Returns:
List of internal transitions
- Return type:
list
- retrieve_next_external_state(pre_state, event)[source]¶
Retrieves the next state for a given external transition
- Parameters:
pre_state (str) – Previous state
event (str) – Event causing the transition
- Returns:
Next state
- Return type:
str
- retrieve_next_internal_state(pre_state, event)[source]¶
Retrieves the next state for a given internal transition
- Parameters:
pre_state (str) – Previous state
event (str) – Event causing the transition
- Returns:
Next state
- Return type:
str
Structural Model¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
This module contains a StructuralModel object that allows you to implement the Discrete Event System Specification CoupledModel.
Core Model¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
This module contains CoreModel, the parent class of all Model Types.
- class pyjevsim.core_model.CoreModel(_name, _type)[source]¶
Bases:
SystemObjectAll forms of Models in Pyjevsim have a CoreModel as their foundation. CoreModel class serves as a base model with basic functionalities for input and output ports.
- get_model_type()[source]¶
Returns the type of the model.
- Returns:
Type of the model
- Return type:
(ModelType.BEHAVIORAL or ModelType.STRUCTURAL or ModelType.UTILITY)
- insert_input_port(port)[source]¶
Inserts an input port to the model.
- Parameters:
port (str) – Name of the input port
- insert_output_port(port)[source]¶
Inserts an output port to the model.
- Parameters:
port (str) – Name of the output port
- model_snapshot()[source]¶
Snapshot the information of the running model.
- Returns:
Dictionary containing model type, model name, and model data
- Return type:
dict
- retrieve_input_ports()[source]¶
Retrieves all input ports of the model.
- Returns:
List of input ports
- Return type:
list