def get_request(self): if self.__time_for_create <= Time.get_current_time(): self.__time_for_create = self.__calculate_time_for_create() r = Request(self.__number, Time.get_current_time(), self.stat) r.created() Time.upd_time(self.__time_for_create) return r Time.upd_time(self.__time_for_create) return None
def __ten_steps(self): for i in range(10): self.__step() self.__fill_buffer() self.__fill_workers() self.__time.set('{:.3f}'.format(Time.get_current_time())) self.__step2.set(Time.get_current_step())
def try_to_release(self): if Time.get_current_time( ) >= self.__time_of_release and not self.is_available(): self.__current_request.leave_worker(self.__number) self.__current_request = None elif not self.is_available(): Time.upd_time(self.__time_of_release)
def __one_step(self): self.__step() self.__fill_buffer() self.__fill_workers() self.__time.set('{:.3f}'.format(Time.get_current_time())) self.__step2.set(Time.get_current_step())
def __calculate_time_for_create(self): return Time.get_current_time() + (-1/config.alf)*log(random())
def __calculate_work_time(self): return Time.get_current_time() + config.lam * exp( int(random() * -config.lam))
def deny_buffer(self): self.stat.denied(self.__numOfSource) self.stat.add_wait_time(self.__numOfSource, Time.get_current_time() - self.__time)
def leave_worker(self, num): self.stat.add_worker_time2(num, Time.get_current_time()) self.stat.completed(self.__numOfSource) self.stat.add_all_time(self.__numOfSource, Time.get_current_time() - self.__time)
def in_worker(self, num, time): self.stat.add_work_time(self.__numOfSource, time - Time.get_current_time()) self.stat.add_worker_time(num, Time.get_current_time())
def leave_buffer(self): self.stat.add_wait_time(self.__numOfSource, Time.get_current_time() - self.__time)