Source code for examples.banksim.model.model_result
"""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 Banksim User Generator Model """importosfrompyjevsim.behavior_modelimportBehaviorModelfrompyjevsim.definitionimport*
[docs]classBankResult(BehaviorModel):"""A Model representing a bank user generator."""def__init__(self,name,max_user):""" Args: name (str): Name of Model cycle (float): Generation cycle time max_user (int): Maximum number of users to generate proc_time (float): Processing time for each user """BehaviorModel.__init__(self,name)self.init_state("WAIT")# Initialize initial stateself.insert_state("WAIT",Infinite)# Add "WAIT" stateself.insert_input_port("process")# Add input port "process"self.insert_input_port("drop")# Add input port "drop"self.max_user=max_user# Maximum number of users to generate#self.proc_time = proc_time # Processing time for each userself.user_count=0self.user=[]self.drop_user=[]self.drop_user_count=0
[docs]defext_trans(self,port,msg):""" Handles external transitions based on the input port. Args: port (str): The port that received the message msg (SysMessage): The received message """ifport=="process":proc=msg.retrieve()[0]_user=msg.retrieve()[1]self.user.append((proc,_user))self.user_count+=1ifself.user_count>=self.max_user:self.get_result()os._exit(0)ifport=="drop":drop_user_list=msg.retrieve()[0]for_userindrop_user_list:self.drop_user.append(_user)self.drop_user_count+=1