"""Author: Changbeom Choi (@cbchoi)Copyright (c) 2014-2020 Handong Global UniversityCopyright (c) 2021-2024 Hanbat National UniversityLicense: MIT. The full license text is available at:https://github.com/eventsim/pyjevsim/blob/main/LICENSE"""from.executor_factoryimportExecutorFactoryfrom.snapshot_executorimportSnapshotExecutor
[docs]classSnapshotFactory(ExecutorFactory):""" The SnapshotManager determines which model you want to take a snapshot of, and sets it to a SnapshotExecutor in a form that the SystemExecutor can execute. And for models that don't take snapshots, it creates an Executor for each model's type. """def__init__(self,snapshot_map):""" Args: snapshot_map(dictionary): _description_ """super().__init__()self.snapshot_condition_map=snapshot_mappass
[docs]defcreate_executor(self,global_time,ins_t,des_t,en_name,model,parent):"""Creates an executor based on the model type. Args: global_time (float): Global simulation time ins_t (float): Instance creation time des_t (float): Destruction time en_name (str): Engine name model(ModelType.BEHAVIORAL of ModelType.STRUCTURAL): The model to execute Returns: Executor: The created executor """model=super().create_executor(global_time,ins_t,des_t,en_name,model,parent)returnself.create_snapshot_executor(model)
[docs]defcreate_snapshot_executor(self,model):"""Create a SnapshotExecutor for the model you want to snapshot. Args: model (BehaviorModel): _description_ Returns: _type_: _description_ """ifmodel.get_name()inself.snapshot_condition_map:returnSnapshotExecutor(model,self.snapshot_condition_map[model.get_name()](model),model.parent)else:returnmodel