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 __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 __init_system(self): Time.reset_time() self.stat = StatCollector() self.buffer = Buffer(config.bufferLength) self.sources = [ Source(i, self.stat) for i in range(config.numOfSources) ] self.manager1 = Manager1(self.buffer, self.sources) self.workers = [Worker(i) for i in range(config.numOfWorkers)] self.manager2 = Manager2(self.buffer, self.workers)
def __init__(self): self.instName = '' self.courseName = '' self.place = '' self.type = '' self.time = Time() self.length = '' self.groupNum = '' self.periodType = ''
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 __step(self): self.manager1.work() self.manager2.work() Time.step()
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 add_request(self, request): self.__current_request = request self.__time_of_release = self.__calculate_work_time() self.__current_request.in_worker(self.__number, self.__time_of_release) Time.upd_time(self.__time_of_release)
def __calculate_work_time(self): return Time.get_current_time() + config.lam * exp( int(random() * -config.lam))
print(e) count = 0 print(state, stage) czy = True czy2 = 0 czy3 = True for stat in state: if stat[1] != "A": czy = False if stat[1] == "S": czy2 += 1 if stat[7] != "@": czy3 = False if stat[1] == " " and stage == 1: stage = 2 time_start = Time(round(time() * 100)) if czy: if stage == 0: stage = 1 # print(czy2)(czy2) if czy2 > len(stacks) - 2 and stage == 2: czy = True for x in range(len(state)): if state[x][2:7] != latest_state[x][2:7] or state[x][7] == "@": print(state[x]) czy = False # print('siema') if czy: stage = 3 act_time = time_start.difference_from_timestamp(time()) print(act_time)
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)