"""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/LICENSEThis module contains an ExecutorFactory that decorates an object of type Model into an Executor that is executable by a SysExecutor. """from.definitionimportModelTypefrom.behavior_executorimportBehaviorExecutor
[docs]classExecutorFactory:"""Factory class to create different types of executors."""def__init__(self):pass
[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 """ifmodel.get_model_type()==ModelType.BEHAVIORAL:returnself.create_behavior_executor(global_time,ins_t,des_t,en_name,model,parent)elifmodel.get_model_type()==ModelType.STRUCTURAL:returnself.create_structural_executor(global_time,ins_t,des_t,en_name,model,parent)else:returnNone
[docs]defcreate_behavior_executor(self,_,ins_t,des_t,en_name,model,parent):"""Create BehaviorModelexecutor Args: _ (float): Unused global time ins_t (float): Instance creation time des_t (float): Destruction time en_name (str): SysExecutor name model (BehaviorModel): Behavior model to execute Returns: BehaviorModelExecutor: The created BehaviorModelexecutor """returnBehaviorExecutor(ins_t,des_t,en_name,model,parent)
[docs]defcreate_structural_executor(self,global_time,ins_t,des_t,en_name,model,parent):"""Create StructuralModelExecutor Args: global_time (float): Global simulation time ins_t (float): Instance creation time des_t (float): Destruction time en_name (str): SysExecutor name model (StructuralModel): StructuralModel to execute Returns: StructuralModelExecutor: created StructuralModelExecutor """from.structural_executorimportStructuralExecutorreturnStructuralExecutor(global_time,ins_t,des_t,en_name,model,parent,self)