示例#1
0
 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)
示例#2
0
 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())
示例#3
0
 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)
示例#4
0
 def __init__(self):
     self.instName = ''
     self.courseName = ''
     self.place = ''
     self.type = ''
     self.time = Time()
     self.length = ''
     self.groupNum = ''
     self.periodType = ''
示例#5
0
    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
示例#6
0
 def __step(self):
     self.manager1.work()
     self.manager2.work()
     Time.step()
示例#7
0
 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())
示例#8
0
 def __calculate_time_for_create(self):
     return Time.get_current_time() + (-1/config.alf)*log(random())
示例#9
0
 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)
示例#10
0
 def __calculate_work_time(self):
     return Time.get_current_time() + config.lam * exp(
         int(random() * -config.lam))
示例#11
0
文件: stack.py 项目: badochov/dls-pi
         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)
示例#12
0
 def deny_buffer(self):
     self.stat.denied(self.__numOfSource)
     self.stat.add_wait_time(self.__numOfSource,
                             Time.get_current_time() - self.__time)
示例#13
0
    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)
示例#14
0
    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())
示例#15
0
 def leave_buffer(self):
     self.stat.add_wait_time(self.__numOfSource,
                             Time.get_current_time() - self.__time)