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: CoreModel

BehaviorModel template to inherit when constructing a new Model.

Parameters:

_name (str) – Unique model name

cancel_rescheduling()[source]

Canceled scheduling

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

get_cancel_flag()[source]

Returns the cancel reschedule flag

init_state(state)[source]

Sets the initial state

Parameters:

state (str) – Initial state name

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.

abstract int_trans()[source]

Defines the internal transition, to be implemented by subclasses

abstract output(msg_deliver)[source]

Defines the output function, to be implemented by subclasses

reset_cancel_flag()[source]

Resets the cancel reschedule flag to False

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

retrieve_states()[source]

Returns the states dictionary

serialize()[source]

Serializes the behavior model to a JSON object

Returns:

Serialized JSON object

Return type:

OrderedDict

set_global_time(gtime)[source]

Set gloabl time

Parameters:

gtime (float) – Global time

update_state(name, deadline='inf')[source]

Updates an existing state in the BehaviorModel

Parameters:
  • name (str) – state name to update

  • deadline (str or Infinite) – Time until the state is active. Defaults to Infinite.

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.

class pyjevsim.structural_model.StructuralModel(_name='')[source]

Bases: CoreModel

coupling_relation(src_obj, src_port, dst_obj, dst_port)[source]
find_model(name)[source]
get_couplings()[source]
get_models()[source]
register_entity(obj)[source]
remove_model(obj)[source]

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: SystemObject

All 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)

get_name()[source]

Returns the name of the model.

Returns:

Name of the model

Return type:

str

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

retrieve_output_ports()[source]

Retrieves all output ports of the model.

Returns:

List of output ports

Return type:

list

set_name(_name)[source]

Sets the name of the model.

Parameters:

_name (str) – New name of the model