예제 #1
0
    def __init__(self):
        self.slot_0 = Slot()
        self.slot_1 = Slot()
        self.slot_2 = Slot()
        self.slot_3 = Slot()

        self.foundation_0 = Foundation()
        self.foundation_1 = Foundation()
        self.foundation_2 = Foundation()
        self.foundation_3 = Foundation()

        self.cascade_deck_0 = Cascade_deck()
        self.cascade_deck_1 = Cascade_deck()
        self.cascade_deck_2 = Cascade_deck()
        self.cascade_deck_3 = Cascade_deck()
        self.cascade_deck_4 = Cascade_deck()
        self.cascade_deck_5 = Cascade_deck()
        self.cascade_deck_6 = Cascade_deck()
        self.cascade_deck_7 = Cascade_deck()

        self.deck = Deck(1, 13, 4)

        # lists that contain the all objects from the same class
        self.list_slot = [self.slot_0, self.slot_1, self.slot_2, self.slot_3]

        self.list_foundation = [
            self.foundation_0, self.foundation_1, self.foundation_2,
            self.foundation_3
        ]

        self.list_cascade_deck = [
            self.cascade_deck_0, self.cascade_deck_1, self.cascade_deck_2,
            self.cascade_deck_3, self.cascade_deck_4, self.cascade_deck_5,
            self.cascade_deck_6, self.cascade_deck_7
        ]
예제 #2
0
    def __init__(self, cmt):
        """Accumulator(cmt)

        cmt is the comment flag
        """
        self._cmt = cmt
        self._fileset: Set[str] = set()
        self._filelist: List[str] = []
        self.slots: Dict[int, Any] = {}
        self.slots[SLOT_INITIAL] = Slot(SLOT_INITIAL)
        self.slots[SLOT_FINAL] = Slot(SLOT_FINAL)
        self._disableprivslots: bool = False
        self.repeater_ctrl_type = 'Unknown'
예제 #3
0
    def __init__(self, parent=None):
        super().__init__(parent)

        # Initialize the main widget
        self.gameWidget = SlotGame()
        self.setCentralWidget(self.gameWidget)

        # Window title & status bar
        self.setWindowTitle('ADProject Slotmachine')
        self.statusBar = QStatusBar(self)
        self.setStatusBar(self.statusBar)

        # Connect button callbacks
        self.gameWidget.betButton.clicked.connect(self.buttonClicked)
        self.gameWidget.newGameButton.clicked.connect(self.buttonClicked)

        self.currentMoney = 1000
        self.gameWidget.currentMoney.setText(str(self.currentMoney))

        #실행횟수를 5회로 제한
        self.currentTrial = 5
        self.gameWidget.count.setText("Left trials: " + str(self.currentTrial))

        # 게임이 시작될때 슬롯값을 비우는 기능
        self.game = Slot()
        self.slotValue = [None, None, None]
예제 #4
0
 def SwitchMobileqq(self, d, z, slotId):
     z.toast("开始切换到普通QQ")
     z.generate_serial("com.tencent.mobileqq")  # 随机生成手机特征码
     z.toast("随机生成手机特征码")
     serial = d.server.adb.device_serial()
     self.slot = Slot(serial, self.type)
     d.server.adb.cmd("shell",
                      "pm clear com.tencent.tim").communicate()  # 清除缓存
     self.slot.restore(slotId,
                       "com.tencent.mobileqq")  # 有time_limit分钟没用过的卡槽情况,切换卡槽
     z.server.adb.run_cmd(
         "shell",
         "am start -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity"
     )
     z.sleep(3)
     z.toast("判断是否成功切换到普通QQ")
     loginStatusList = z.qq_getLoginStatus(d)
     if loginStatusList is None:
         z.toast("登陆新页面,现无法判断登陆状态")
         return None
     loginStatus = loginStatusList['success']
     if loginStatus:
         z.toast("成功切换到普通QQ,继续执行")
     else:
         z.toast("切换到普通QQ失败,重新切换")
         return "gg"
예제 #5
0
    def new_slot(self, data):
        """ Créé un nouveau slot"""
        slot_id = data["slot"] = str(len(self.slots_list) + 1)

        self.slots_list[data['ip']] = Slot(**data)

        return slot_id
예제 #6
0
    def action(self, d, z, args):
        z.toast(u"开始:ping网络是否通畅")
        i = 0
        while i < 200:
            i += 1
            ping = d.server.adb.cmd("shell",
                                    "ping -c 3 baidu.com").communicate()
            print(ping)
            if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                z.toast(u"网络通畅。开始执行:QQ安全中心登陆备份模块")
                break
            z.sleep(2)

        if i > 200:
            z.toast(u"网络不通,请检查网络状态")
            return

        while True:
            z.heartbeat()
            z.generate_serial("com.tencent.token")  # 随机生成手机特征码
            z.toast(u"随机生成手机特征码")

            serial = d.server.adb.device_serial()
            self.slot = Slot(serial, self.type)
            self.slot.backupToDisk("132132132")  # 设备信息,卡槽号,QQ号
            print "ok"
            break
예제 #7
0
파일: main.py 프로젝트: mehgcap/FAH-Access
def showSummary():
    queues = {}
    slots = {}

    #get the slot info
    slotsData = session.getSlotInfo()
    #add all the slots to our dictionary
    for slotData in slotsData:
        slot = Slot(slotData)
        slots[slot.id] = slot

    #now the queue info
    queuesData = session.getQueueInfo()
    for queueData in queuesData:
        queue = Queue(queueData)
        queues[queue.id] = queue
        #add this queue to it's parent slot's list of queues
        slotID = int(queue.slot)
        slots[slotID].queues.append(queue)

    #get basic details
    teamInfo = eval(session.getPreparedResponse("options user team"), {}, {})

    print("User {user} is folding for team {team}".format(
        user=teamInfo["user"], team=teamInfo["team"]))
    for slot in slots.values():
        print(slot.__str__())
    for queue in queues.values():
        print(queue.__str__())
예제 #8
0
    def build_interface(self):

        self.mainlayout = FloatLayout()
        self.buttonlayout = GridLayout(
            cols=1,
            size_hint=(0.75, 0.5),
            pos_hint={"x": 0.125,
                      "y": 0.25}
        )

        for i in range(1, 6):
            self.buttonlayout.add_widget(Slot(i, self.switchto_main))

        self.mainlayout.add_widget(self.buttonlayout)

        self.menubutton = RealButton(
            './media/icons/arrowleft.png',
            './media/icons/arrowleft_pressed.png',
            self.switchto_menu,
            size_hint=(None, None),
            size=(self.iconsize, self.iconsize),
            pos_hint={'x': 0, 'y': 0},
            source='./media/icons/arrowleft.png',
            always_release=True
        )

        self.mainlayout.add_widget(self.menubutton)
        self.add_widget(self.mainlayout)
예제 #9
0
 def __init__(self, viewport, gpfile, card):
     self.card = card
     self.viewport = viewport
     self.gpfile = gpfile
     self.canvas = viewport.canvas
     self.draw()
     self.editing = False
     self.moving = False
     self.moving_edgescroll_id = None
     self.resize_state = None
     self.resize_edgescroll_id = None
     # slot triggered when geometry (pos/size) changes
     # fn args: (self, x, y, w, h)
     self.geom_slot = Slot()
     self.deletion_slot = Slot()
     self.new_edge = None
예제 #10
0
파일: zapi.py 프로젝트: wszg5/studyGit
def slotService():
    reqs = request.json

    action = request.json['action']
    if 'id' in request.json:
        id = request.json['id']

    serial = request.json['serial']
    type = request.json['type']

    if 'remark' in request.json:
        remark = request.json['remark']
    else:
        remark = "Backed";

    if 'page' in reqs:
        page = reqs['page']
    else:
        page = 1;

    if not action:
        return jsonify({'success': False, 'msg': u'paramter action is missed'})

    if not serial:
        return jsonify({'success': False, 'msg': u'paramter serial is missed'})

    slot = Slot(serial, type)
    if action == "save":
        if remark == "":
            remark = "BackUp"
        slot.backup(id, remark)
        return jsonify({'success': True, 'msg': u'Save slot success'})

    if action == "restore":
        slot.restore(id)
        return jsonify({'success': True, 'msg': u'Restore slot success'})

    if action == "clear":
        slot.clear(id)
        return jsonify({'success': True, 'msg': u'Clear slot success'})

    if action == "list":
        result = []
        slots = slot.getSlots()
        if not slots:
            slots = {};
        idFrom = (page - 1)*20 + 1
        idTo = (page-1) * 20 + 20
        for index in range(idFrom, idTo + 1):
            if slots.has_key(str(index)) :
                obj = slots[str(index)]
                obj['empty'] = False;
                obj['id'] = index
            else:
                obj = {'id':index, 'empty': True}
            result.append(obj)

        return jsonify({'slots': result })

    return "-"
예제 #11
0
    def __init__(self, taskDag, processorDag):
        super(Schedule, self).__init__()
        self.taskDag = taskDag
        self.processorDag = processorDag
        # self.isScheduled = False
        # store execution slot of each task for easy retrieving
        self.taskExecutionSlot = []
        # store all execution slots of each processor
        self.processorCoreExecutionSlots = []

        schedulePositionId = 0
        for i in range(0, len(processorDag.processors)):
            currentProcessor = processorDag.processors[i]

            for j in range(0, currentProcessor.noOfCores):
                self.processorCoreExecutionSlots.append([
                    Slot(None, ProcessorCore(currentProcessor, j, schedulePositionId), 0, sys.maxint)
                ])
                schedulePositionId += 1

        for i in range(0, len(taskDag.tasks)):
            self.taskExecutionSlot.append(None)

        # actual finish time of schedule
        self.aft = 0
예제 #12
0
    def getFirstFitSlotForTaskOnProcessorCore(self, processorCore, task):
        # the ready time of the task at which
        # all required input data has arrived at the current processor
        readyTime = -1

        # loop through all predecessors of the current task
        # to calculate readyTime
        for i in range(0, len(task.predecessors)):
            # get predecessor task in the tuple of (task, dependency)
            predTask = task.predecessors[i][0]
            # get dependency of current predecessor
            predTaskConstraint = task.predecessors[i][1]
            # get processor which processes the current predecessor task
            predProcessorCore = self.taskExecutionSlot[predTask.id].processorCore

            # calculate communication time to transmit data dependency from 
            # processor which is assigned to process the predecessor task to 
            # the processor which is being considered to use to process the current task
            communicationTime = self.processorDag.getCommunicationTimeBetweenCores(predProcessorCore, 
                processorCore, predTaskConstraint)

            predecessorSlotEnd = self.taskExecutionSlot[predTask.id].end
            currentReadyTime = predecessorSlotEnd + communicationTime

            if currentReadyTime > readyTime:
                readyTime = currentReadyTime

        processingTime = task.computationRequired / processorCore.processor.processingRate

        currentProcessorCoreSlots = self.processorCoreExecutionSlots[processorCore.schedulePositionId]

        # find the earliest slot
        for i in range(0, len(currentProcessorCoreSlots)):
            currentSlot = currentProcessorCoreSlots[i]

            if currentSlot.task == None:
                actualStart = max(currentSlot.start, readyTime)
                actualEnd = actualStart + processingTime

                if actualEnd <= currentSlot.end:
                    # return the first fit slot for the task on the current processor
                    return Slot(task, processorCore, actualStart, actualEnd)
            else:
                continue

        print("nothing")
        return Slot(task, processorCore, -1, -1)
예제 #13
0
 def add_slot(self, slot_name, slot_duration):
     self.session_slots.append(
         Slot(self.next_slot_time, slot_name, slot_duration))
     self.next_slot_time = datetime.datetime.combine(
         datetime.date(1, 1, 1),
         self.next_slot_time) + datetime.timedelta(minutes=slot_duration)
     self.session_filled = self.session_filled + slot_duration
     self.next_slot_time = self.next_slot_time.time()
예제 #14
0
    def test_park_vehicle(self):
        slot_number = 1
        slot = Slot(slot_number)
        slot.park_vehicle('KA-03-BB-1234', 'White')

        assert slot.occupied_status == True
        assert slot.vehicle_number == 'KA-03-BB-1234'
        assert slot.vehicle_color == 'White'
예제 #15
0
 def schedule(self, talk_list):
     """Schedule events for a list of events
     This method takes list of talks as input"""
     totaltime = self.totaltime(talk_list)
     possibledays = int(totaltime / self.perday) + 1
     talk_list.sort(key=operator.attrgetter('duration'))
     m = self.combinations(talk_list, possibledays,
                           Slot(3 * 60))  #morning slot
     self.clear(m)  #clearing scheduled talks
     evening_slot = Slot(4 * 60, 3 * 60)
     e = self.combinations(talk_list, possibledays,
                           evening_slot)  #morning slot
     self.clear(e)  #clearing scheduled talks
     if (self.talk_list):
         raise Exception("Unable to schedule all task for conferencing")
     self.morning = m
     self.evening = e
예제 #16
0
    def action(self, d, z, args):
        while True:
            z.toast("正在ping网络是否通畅")
            i = 0
            # while i < 200:
            #     i += 1
            #     ping = d.server.adb.cmd("shell", "ping -c 3 baidu.com").communicate()
            #     print(ping)
            #     if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
            #         z.toast(u"网络通畅。开始执行:国际版QQ登录  有卡槽")
            #         break
            #     z.sleep(2)
            # if i > 200 :
            #     z.toast(u"网络不通,请检查网络状态")
            #     if (args["time_delay"]):
            #         z.sleep(int(args["time_delay"]))
            #     return
            #
            # z.heartbeat()
            # z.generate_serial("com.tencent.mobileqqi") # 随机生成手机特征码
            cate_id = args["repo_cate_id"]

            time_limit1 = args['time_limit1']
            numbers = self.repo.GetAccount(cate_id, time_limit1, 1)
            if len(numbers) == 0:
                d.server.adb.cmd("shell", "am broadcast -a com.zunyun.zime.toast --es msg \"QQ帐号库%s号仓库无%s分钟未用,开始切换卡槽\"" % (cate_id, time_limit1)).communicate()

            serial = d.server.adb.device_serial()
            self.slot = Slot(serial, self.type)
            slotnum = self.slot.getEmpty()  # 取空卡槽
            if slotnum == 0 or len(numbers) == 0:    #没有空卡槽的话
               if self.qiehuan(d, z, args):
                   break

            else:  # 有空卡槽的情况
                # d.server.adb.cmd("shell", "settings put global airplane_mode_on 1").communicate()
                # d.server.adb.cmd("shell", "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true").communicate()
                # z.sleep(6)
                # d.server.adb.cmd("shell", "settings put global airplane_mode_on 0").communicate()
                # d.server.adb.cmd("shell", "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false").communicate()
                z.heartbeat()
                while True:
                    ping = d.server.adb.cmd("shell", "ping -c 3 baidu.com").communicate()
                    print(ping)
                    if 'icmp_seq'and 'bytes from'and'time' in ping[0]:
                        break
                    z.sleep(2)

                z.heartbeat()
                if self.login(d, args, z, numbers):
                    z.heartbeat()
                    featureCodeInfo = z.get_serial("com.tencent.mobileqq")
                    self.slot.backup(slotnum, str(slotnum) + '_' + numbers[0]['number'] + '_' + cate_id)  # 设备信息,卡槽号,QQ号
                    self.repo.BackupInfo(cate_id, 'using', numbers[0]['number'], featureCodeInfo, '%s_%s_%s' % (d.server.adb.device_serial(), self.type, slotnum))  # 仓库号,使用中,QQ号,设备号_卡槽号
                    break

        if args["time_delay"]:
            z.sleep(int(args["time_delay"]))
예제 #17
0
 def addSlots(self, new_slots):
     self.slotsList += [
         Slot(i)
         for i in range(self.totalslots, self.totalslots + new_slots)
     ]
     self.free_slots_queue += [
         i for i in range(self.totalslots, self.totalslots + new_slots)
     ]
     self.totalslots += new_slots
예제 #18
0
    def __init__(self, number_of_slots):
        self.number_of_slots = int(number_of_slots)
        self.car_slots = []
        self.bike_slots = []

        n = 1
        while n <= self.number_of_slots:
            slot = Slot(n)
            self.car_slots.append(slot)
            n += 1
        
        n = 1
        while n <= self.number_of_slots:
            slot = Slot(n)
            self.bike_slots.append(slot)
            n += 1

        print "Created a parking lot with " + str(self.number_of_slots) + " car and bike slots each"
예제 #19
0
    def test_exit_vehicle(self):
        slot_number = 1
        slot = Slot(slot_number)
        slot.park_vehicle('KA-03-BB-1234', 'White')
        slot.exit_vehicle()

        assert slot.vehicle_color == 'None'
        assert slot.vehicle_number == 'None'
        assert slot.occupied_status == False
예제 #20
0
 def __init__(self):
     unitSize = settings.UNIT_SIZE
     self.coords = (-unitSize, unitSize * 11, unitSize * 12, unitSize * 12)
     self.slots = [[
         Slot(coords=(self.coords[0] + self.coords[2] *
                      (7 / 36 * (5 - i) + 1 / 36), self.coords[1] +
                      self.coords[3] * (7 / 36 * j - 6 / 36),
                      self.coords[2] * 6 / 36, self.coords[2] * 6 / 36))
         for i in range(j)
     ] for j in range(1, 6)]
예제 #21
0
    def action(self, d, z, args):
        z.generate_serial("com.tencent.tim")  # 随机生成手机特征码
        z.toast("随机生成手机特征码")

        serial = d.server.adb.device_serial()
        cate_id = args["repo_cate_id"]
        self.slot = Slot(serial, self.type)
        slotnum = self.slot.getEmpty()  # 取空卡槽

        if slotnum == 0:
            QieHuanSolt_Result = self.QieHuanSolt(d, z, args)
            if QieHuanSolt_Result == "fail":
                obj = self.slot.getSlotInfo(slotnum)
                remark = obj['remark']
                remarkArr = remark.split("_")
                QQnumber = remarkArr[1]
                self.repo.BackupInfo(cate_id, 'frozen', QQnumber, '',
                                     '')  # 仓库号,使用中,QQ号,设备号_卡槽号QQNumber
                self.slot.clear(slotnum)  # 清空改卡槽,并补登
                z.toast("卡槽恢复失败,进行补登")
                self.action(d, z, args)

            else:
                z.toast("卡槽恢复成功,帐号正常")

        else:
            Login_Result = self.Login(d, z, args)
            if Login_Result == "again":
                self.action(d, z, args)

            elif Login_Result == "none":  # 有空卡槽,单仓库无帐号可登,继续继续切换卡槽
                QieHuanSolt_Result = self.QieHuanSolt(d, z, args)
                if QieHuanSolt_Result == "fail":
                    obj = self.slot.getSlotInfo(slotnum)
                    remark = obj['remark']
                    remarkArr = remark.split("_")
                    QQnumber = remarkArr[1]
                    self.repo.BackupInfo(cate_id, 'frozen', QQnumber, '',
                                         '')  # 仓库号,使用中,QQ号,设备号_卡槽号QQNumber
                    self.slot.clear(slotnum)  # 清空改卡槽,并补登
                    z.toast("卡槽恢复失败,进行补登")
                    self.action(d, z, args)

                else:
                    z.toast("卡槽恢复成功,帐号正常")

            else:
                QQnumber = Login_Result
                self.slot.backup(slotnum,
                                 str(slotnum) + '_' + QQnumber)  # 设备信息,卡槽号,QQ号
                self.repo.BackupInfo(cate_id, 'using', QQnumber, serial,
                                     '%s_%s_%s' %
                                     (d.server.adb.device_serial(), self.type,
                                      slotnum))  # 仓库号,使用中,QQ号,设备号_卡槽号
예제 #22
0
 def __init__(self):
     self.coords = (settings.UNIT_SIZE * 2, settings.UNIT_SIZE * 23.5,
                    settings.UNIT_SIZE * 100 / 6,
                    settings.UNIT_SIZE * 16 / 6)
     self.slots = [
         Slot(coords=(self.coords[0] + settings.UNIT_SIZE * 2 / 6 +
                      settings.UNIT_SIZE * 14 / 6 * i,
                      self.coords[1] + settings.UNIT_SIZE * 2 / 6,
                      settings.UNIT_SIZE * 2, settings.UNIT_SIZE * 2))
         for i in range(7)
     ]
예제 #23
0
 def __init__(self):
     self.coords = (settings.UNIT_SIZE * 27, settings.UNIT_SIZE * 6,
                    settings.UNIT_SIZE * 7, settings.UNIT_SIZE * 10)
     self.borderThickness = settings.UNIT_SIZE * 2 / 6
     self.slots = [[
         Slot(coords=(self.coords[0] + self.borderThickness * 2 +
                      settings.UNIT_SIZE * 1.5 * i,
                      self.coords[1] + self.borderThickness * 2 +
                      settings.UNIT_SIZE * 1.5 * j,
                      settings.UNIT_SIZE * 1.3, settings.UNIT_SIZE * 1.3),
              isVisible=False) for i in range(4)
     ] for j in range(6)]
예제 #24
0
 def __init__(self, xpos, ypos, radius, id):
     self.id = id
     self.coords = (int(xpos), int(ypos))
     self.radius = int(radius)
     self.slots = [
         Slot(coords=(self.coords[0] + settings.UNIT_SIZE * 1.5 *
                      (((0, 0, 1, 1)[i]) - 0.9), self.coords[1] +
                      settings.UNIT_SIZE * 1.5 * (((0, 1, 0, 1)[i]) - 0.9),
                      settings.UNIT_SIZE * 1.3, settings.UNIT_SIZE * 1.3),
              isVisible=False) for i in range(4)
     ]
     self.colors = (settings.COLORS['black'], settings.COLORS['lightblue'])
예제 #25
0
 def test_1append(self):
     a:Slot = Slot(9)
     a.append('this is a test\n')
     l = 'this is test 1\n'
     ll = ['this is test 2\n']
     a.append(l)
     a.append(ll)
     self.assertEqual(3, len(a.data))
     tst = a.data[:]
     self.assertTrue('test\n' in tst[0])
     self.assertTrue('test 1\n' in tst[1])
     self.assertTrue('test 2\n' in tst[2])
예제 #26
0
    def __init__(self, date):
        '''Set up inital values. Date is the date for which this schedule applies.'''
        self.slots = []
        self.date = date

        # Fill self.slots with 32 instances of Slots, starting from 9:00 AM
        # In order to use timedelta, we need the full datetime object,
        # including the date, not just the time.
        curr_time = datetime.combine(self.date, time(9, 0))
        interval = timedelta(minutes=15)
        for i in range(0, 32):
            self.slots.append(Slot(curr_time.time()))
            curr_time = curr_time + interval
예제 #27
0
    def test_2get_lines(self):
        acc: Accumulator = Accumulator('#')
        s5: Slot = Slot(5)
        s5.append("l1,s5\n")
        acc.add_slot(s5)
        s5a: Slot = Slot(5)
        s5a.append('l2,s5\n')
        acc.add_slot(s5a)
        st = acc.slots[5]
        s0: Slot = Slot(0)
        s0.append('l1,s0\n')
        acc.add_slot(s0)
        s99: Slot = Slot(99)
        s99.append('l1,s99\n')
        acc.add_slot(s99)
        acc.slots[5].data.append('l3,s5\n')
        result = acc.get_lines()

        expected = ['# result from processing !UNSPECIFIED!\n',
                    '\n', '#lines from Slot 0\n',
                    '\n', 'l1,s0\n',
                    '\n', '#lines from Slot 5\n',
                    '\n', 'l1,s5\n',
                    'l2,s5\n',
                    'l3,s5\n',
                    '\n',
                    '#lines from Slot 99\n',
                    '\n',
                    'l1,s99\n',
                    '\n']
        for a, b in zip(expected, result[2:]):
            self.assertEqual(a, b)
        acc.add_file('file1')
        acc.add_file('file2')
        result = acc.get_lines()
        fileinfo = result[3:6]
        self.assertEqual(
            ['# Files included by reference:\n', '#\tfile1\n', '#\tfile2\n'],
            fileinfo)
예제 #28
0
    def addNewSlot(self, processorCore, task, startTime):
        currentProcessorCoreSlots = self.processorCoreExecutionSlots[processorCore.schedulePositionId]

        computationTime = task.computationRequired / processorCore.processor.processingRate
        endTime = startTime + computationTime

        for i in range(0, len(currentProcessorCoreSlots)):
            currentSlot = currentProcessorCoreSlots[i]
            # find the first slot on the processor that fits the startTime and endTime
            if currentSlot.task == None and currentSlot.start <= startTime and currentSlot.end >= endTime:
                newSlot = Slot(task, processorCore, startTime, endTime)
                currentProcessorCoreSlots.append(newSlot)

                if startTime != currentSlot.start and endTime != currentSlot.end:
                    slotBefore = Slot(None, processorCore, currentSlot.start, startTime)
                    slotAfter = Slot(None, processorCore, endTime, currentSlot.end)

                    currentProcessorCoreSlots.append(slotBefore)
                    currentProcessorCoreSlots.append(slotAfter)
                elif startTime == currentSlot.start and endTime != currentSlot.end:
                    slotAfter = Slot(None, processorCore, endTime, currentSlot.end)

                    currentProcessorCoreSlots.append(slotAfter)
                elif startTime != currentSlot.start and endTime == currentSlot.end:
                    slotBefore = Slot(None, processorCore, currentSlot.start, startTime)

                    currentProcessorCoreSlots.append(slotBefore)

                del currentProcessorCoreSlots[i]

                # sort all the slots in an increasing order based on start time
                currentProcessorCoreSlots.sort(key = lambda el: el.start, reverse = False)
                # store execution slot of task for easy retrieving
                self.taskExecutionSlot[task.id] = newSlot
                # print("Task " + str(task.id) + 
                #     ", processor " + str(processor.id) + 
                #     ", processingTime " + str(computationTime) + ": start " + str(start) + ", end " + str(end))

                break
예제 #29
0
    def test_1add_slot(self):
        acc: Accumulator = Accumulator('#')
        s5: Slot = Slot(5)
        s5.append("l1,s5")
        acc.add_slot(s5)
        self.assertEqual(set([0, 5, 99]),  acc.slots.keys())
        s5a: Slot = Slot(5)
        s5a.append('l2,s5')
        acc.add_slot(s5a)
        self.assertEqual(set([0, 5, 99]),  acc.slots.keys())
        st = acc.slots[5]
        aa = str(st)
        self.assertEqual('[id:5, len:2, d:(l1,s5, l2,s5)]', str(st))
        s0: Slot = Slot(0)
        s0.append('s0,l1\n')
        acc.add_slot(s0)
        s99: Slot = Slot(99)
        s99.append('s99,l1\n')
        acc.add_slot(s99)

        self.assertEqual(3, len(acc.slots))
        s0 = acc.slots[0]
        self.assertEqual(1, len(s0.data))
        s5 = acc.slots[5]
        self.assertEqual(2, len(s5.data))
        s99 = acc.slots[99]
        self.assertEqual(1, len(s99.data))
        self.assertTrue(5 in acc.slots)
        self.assertFalse(3 in acc.slots)
        acc.add_slot(s99)
        acc.add_slot(s0)
        self.assertEqual(2, len(s99.data))
        self.assertEqual(2, len(s0.data))
        acc.disable_priv_slots()
        acc.add_slot(s99)
        self.assertEqual(2, len(s99.data))
        acc.add_slot(s0)
        self.assertEqual(2, len(s0.data))
예제 #30
0
 def __init__(self):
     self.coords = (settings.UNIT_SIZE * 14, settings.UNIT_SIZE * 11,
                    settings.UNIT_SIZE * 12, settings.UNIT_SIZE * 12)
     self.acceptColors = [[["red", "blue", "green", "white",
                            "yellow"][(i - j) % 5] for i in range(5)]
                          for j in range(5)]
     self.slots = [[
         Slot(coords=(self.coords[0] + self.coords[2] / 36 +
                      i * self.coords[2] * 7 / 36, self.coords[1] +
                      self.coords[3] / 36 + j * self.coords[3] * 7 / 36,
                      self.coords[2] / 6, self.coords[3] / 6),
              color=self.acceptColors[j][i],
              isDark=True) for i in range(5)
     ] for j in range(5)]