Pyjevsim Snapshot Manager

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 an object, SnapshotManager, that manages snapshots of the association between BehaivorModel and Model.

class pyjevsim.snapshot_manager.SnapshotManager(restore_handler=None)[source]

Bases: object

SnapshotManager performs snapshots or restores snapshotted data. It manages the models you want to snapshot and the SnapshotCondition for those models. It snapshots simulations (the directory where all the models and their releases are stored). It also manages the RestoreHandler, which performs a restore of the model or simulation.

get_engine()[source]

Returns the SysExecutor.

Returns:

Restored SysExecutor

get_snapshot_factory()[source]

Creates a SnapshotFactory with the SnapshotConditions entered by the user.

Returns:

SnapshotFactory that generates a SnapshotExecutor that takes the snapshot

Return type:

SnapshotFactory

load_snapshot(name, shotmodel)[source]

_summary_

Parameters:
  • name (str) – The name of the snapshot Model to restore.

  • shotmodel (Binary) – Data from snapshotted models.

Returns:

Restored BehaviorModel

Return type:

restore_handler.load_snapshot(name, shotmodel)

register_snapshot_condition(_name, _snapshot_condition)[source]

Associate the model you want to take a snapshot of with the model’s SnapshotCondition.

Parameters:
  • _name (str) – BehaivorModel name

  • _snapshot_condition (SnapshotCondition) – Concrete SnapshotCondition

snapshot_simulation(relation_map, model_map, name, directory_path='.')[source]

Takes a snapshot of the simulation. Snapshot simulation model information and relationships to the “directory_path/name” location.

Parameters:
  • relation_map (dict) – The relation map of SysExecutor

  • model_map (dict) – The model map of SysExecutor

  • name (str) – The name of Simulation

  • directory_path (str) – The directory path to save the snapshot

Pyjevsim Restore Handler

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

class pyjevsim.restore_handler.RestoreHandler(t_resol=1, ex_mode=ExecutionType.V_TIME, name='project', path='./snapshot')[source]

Bases: object

Restore a snapshotted model or project.

get_engine()[source]

Returns the SysExecutor.

Returns:

Restored SysExecutor

load_models(model_list)[source]

Loads models from files and registers them with SysExecutor.

Parameters:

model_list (list) – List of model names

load_snapshot(name, shotmodel)[source]

Loads BehaviorModel.

Parameters:
  • name (str) – The name of Model

  • shotmodel (bytes) – Binary data of the model snapshot

Returns:

The loaded model

Return type:

object(BehaivorModel)

Raises:

Exception – If the model type is not ModelType.BEHAVIORAL

relations(relation_map)[source]

Sets up coupling relations in SysExecutor.

Parameters:

relation_map (dict) – The relation map / 관계 맵

restore_engine()[source]

Sets up SysExecutor with the relation map and model map.

Pyjevsim Snapshot Condition

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

class pyjevsim.snapshot_condition.SnapshotCondition(behavior_executor)[source]

Bases: object

A class for filling in the snapshot condition of a model. Users inherit from SnapshotCondition to fill in the model snapshot condition. Snapshot conditions can be placed before or after functions in the behavior model.

abstract static create_executor(behavior_executor)[source]

This method is an abstractstatic method. Specify the SnapshotCondition you created as the return value of this method.

Parameters:

behavior_executor (BehaviorExecutor) – Set the BehaviorExecutor of the BehaviorModel you want to snapshot.

Returns:

Returns the SnapshotCondition as configured by the user.

Return type:

SnapshotCondition

abstract snapshot_post_condition_ext(port, msg, cur_state)[source]

Abstract method for post-condition of external transition snapshot.

Parameters:
  • port (str) – The port name

  • msg (SysMessage) – The message

  • cur_state (str) – The current state

abstract snapshot_post_condition_int(cur_state)[source]

Abstract method for post-condition of internal transition snapshot.

Parameters:

cur_state (str) – The current state

abstract snapshot_post_condition_out(msg, cur_state)[source]

Abstract method for post-condition of output snapshot.

Parameters:
  • msg (SysMessage) – The message

  • cur_state (str) – The current state

abstract snapshot_pre_condition_ext(port, msg, cur_state)[source]

Abstract method for pre-condition of external transition snapshot.

Parameters:
  • port (str) – The port name

  • msg (SysMessage) – The message

  • cur_state (str) – The current state

abstract snapshot_pre_condition_int(cur_state)[source]

Abstract method for pre-condition of internal transition snapshot.

Parameters:

cur_state (str) – The current state

abstract snapshot_pre_condition_out(cur_state)[source]

Abstract method for pre-condition of output snapshot.

Parameters:

cur_state (str) – The current state

abstract snapshot_time_condition(global_time)[source]

Abstract method for snapshot time condition.

Parameters:

global_time (float) – The global time / simulation time