def __init__(self):
        self.sepwin = []
        super().__init__()
        self.setupUi(self)

        self.tabWidget.addTab(Process(), "进程")
        self.tabWidget.addTab(Performance(), "性能")
        self.tabWidget.addTab(StartItem(), "启动项")
        self.tabWidget.customContextMenuRequested.connect(
            self.tabWidget_showrightmenu)

        if (os.path.exists('.computerhousekeeper\\img\\taskmanager.jpg')):
            self.setWindowIcon(
                QIcon('.computerhousekeeper\\img\\taskmanager.jpg'))
        else:
            self.setWindowIcon(
                QIcon('..\\.computerhousekeeper\\img\\taskmanager.jpg'))
Exemple #2
0
def startAnalysis():
    arr_performance_obj = []

    # str_path = input('Insira o path para o arquivo .asm: ')
    # str_path = "./simpleExpression/simple_expression.asm"
    str_path = input('Informe o arquivo .asm (informe o path):')
    data(str_path)

    labels_dict, total_execution_lines = getLabelsDict(str_path)
    total_text_lines = getTotalTextLine(str_path)
    arr_bin_machine = []
    line_pos = 0
    fake_line = 0

    #print('--------------')
    #print(labels_dict)
    #print('--------------')
    for i in range(total_text_lines):

        line = progamCounter(str_path, i)
        fake_line += 1

        if line.isspace():
            continue

        #simplifica a instrução removendo partes inutilizadas segundo nossa lógica
        line_regex = re.sub("[$,() ]"," ", line)
        line_regex = re.sub("   "," ",line_regex) #debug
        line_regex = re.sub("  "," ",line_regex) #debug
        instruction = line_regex.split()

        if instruction[0][-1] == ':' or instruction[0][0] == '.':
            continue

        if instruction[0] == 'lw' or instruction[0] == 'sw':
            ## instrução para conseguir performance
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            opcode = TypeI.getOpcode(instruction[0])
            rs, rt = TypeI.getIRegisters(instruction)
            address = TypeI.getAddress(instruction[2])

            ## instrução para conseguir performance
            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] in ('add','sub','and','or','nor','xor', 'slt'):
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            rs, rt, rd = TypeR.getRRegisters(instruction)
            funct = TypeR.getFunct(instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '000000', rs, rt, rd, '00000', funct, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'sll' or instruction[0] == 'srl' or instruction[0] == 'sra':
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            rs, rt, rd = TypeR.getRRegisters(instruction)
            funct = TypeR.getFunct(instruction[0])
            shamt = '{0:05b}'.format(int(instruction[3]))

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '000000', rs, rt, rd, shamt, funct, fake_line)
            arr_bin_machine.append(bm)
        
        elif instruction[0] == 'mult' or instruction[0] == 'div':
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            rs, rt, rd = TypeR.getRRegisters(instruction)
            funct = TypeR.getFunct(instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '000000', rs, rt, rd, '00000', funct, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'mfhi' or instruction[0] == 'mflo':
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            rs = '00000'
            rt = '00000'
            rd = Registers.getReg(instruction[1][0],instruction[1][1])
            funct = TypeR.getFunct(instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '000000', rs, rt, rd, '00000', funct, fake_line)
            arr_bin_machine.append(bm)
        
        elif instruction[0] == 'srav':
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            rt, rs, rd = TypeR.getRRegisters(instruction)
            funct = TypeR.getFunct(instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '000000', rs, rt, rd, '00000', funct, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'madd' or instruction[0] == 'msubu':
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            rs, rt, rd = TypeR.getRRegisters(instruction)
            funct = TypeR.getFunct(instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '011100', rs, rt, rd, '00000', funct)
            arr_bin_machine.append(bm)            

        elif instruction[0] == 'beq' or instruction[0] == 'bne' or\
                    instruction[0] == 'bgez' or instruction[0] == 'bgezal':
            
            performance = Performance(instruction[0], 'type I', datetime.datetime.now())

            opcode = TypeI.getOpcode(instruction[0])
            rs, rt = TypeI.getIRegisters(instruction)
            address = TypeI.getAddress(instruction, line_pos, labels_dict)

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'j' or instruction[0] == 'jal':
            performance = Performance(instruction[0], 'type J', datetime.datetime.now())

            opcode = TypeJ.getOpcode(instruction[0])
            address = TypeJ.getAddress(instruction, line_pos, labels_dict)

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineJ(line, str(line_pos), opcode, address, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'jr':
            performance = Performance(instruction[0], 'type J', datetime.datetime.now())

            opcode = TypeJ.getOpcode(instruction[0])
            address = TypeJ.getAddress(instruction, line_pos, labels_dict, instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineJ(line, str(line_pos), opcode, address, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'jalr':
            performance = Performance(instruction[0], 'type R', datetime.datetime.now())

            rs, rt, rd = TypeR.getRRegisters(instruction)
            funct = TypeR.getFunct(instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '000000', rs, rt, rd, '00000', funct, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'lui':
            performance = Performance(instruction[0], 'type I', datetime.datetime.now())

            opcode = TypeI.getOpcode(instruction[0])
            rs, rt = TypeI.getIRegisters(instruction)
            address = TypeI.getAddress(instruction)

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
            arr_bin_machine.append(bm)

        elif instruction[0] == 'li':

            performance = Performance(instruction[0], 'type I', datetime.datetime.now())

            num = int(instruction[2], 0)
            if num/65536.0 > 1:
                # PSEUDO INSTRUÇÃO
                num_lui = '0x'
                num_hex = hex(num)[6:]
                for i in range(8 - len(num_hex)):
                    num_lui += '0'
                num_lui += num_hex
                first_inst = ['lui', '1', num_lui]
                opcode = TypeI.getOpcode(first_inst[0])
                rs, rt = TypeI.getIRegisters(first_inst)
                address = TypeI.getAddress(first_inst)
                

                # Criar o objeto e salva-lo em uma list para acesso posteriormente
                bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
                arr_bin_machine.append(bm)

                #### incrementar linha pseudo instrução
                line_pos += 1 

                num_lui = '0x'
                num_hex = hex(num)[:6]
                for i in range(8 - len(num_hex)):
                    num_lui += '0'
                num_lui += num_hex[2:]
                second_inst = ['ori', instruction[1], '1', num_lui]
                opcode = TypeI.getOpcode(second_inst[0])
                rs, rt = TypeI.getIRegisters(second_inst)
                address = TypeI.getAddress(second_inst)

                performance.setTime2(datetime.datetime.now())
                arr_performance_obj.append(performance)
                # Criar o objeto e salva-lo em uma list para acesso posteriormente
                bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
                bm.setIsPseudo(True)
                arr_bin_machine.append(bm)

            else:
                analogo_inst = ['addiu', instruction[1], '0', instruction[2]]
                opcode = TypeI.getOpcode(analogo_inst[0])
                rs, rt = TypeI.getIRegisters(analogo_inst)
                address = TypeI.getAddress(analogo_inst)

                performance.setTime2(datetime.datetime.now())
                arr_performance_obj.append(performance)
                # Criar o objeto e salva-lo em uma list para acesso posteriormente
                bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
                arr_bin_machine.append(bm)


            

        elif instruction[0] == 'addi' or instruction[0] == 'andi' or\
                instruction[0] == 'ori' or instruction[0] == 'xori':
            
            performance = Performance(instruction[0], 'type I', datetime.datetime.now())

            imidiate_int = int(instruction[3], 0)
            if imidiate_int < 0 and (instruction[0] == 'andi' or\
                        instruction[0] == 'ori' or instruction[0] == 'xori'):
                first_pseudo_inst = ['lui', '1', '0xffff']
                opcode = TypeI.getOpcode(first_pseudo_inst[0])
                rs, rt = TypeI.getIRegisters(first_pseudo_inst)
                address = TypeI.getAddress(first_pseudo_inst)

                # Criar o objeto e salva-lo em uma list para acesso posteriormente
                bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
                bm.setIsPseudo(True)
                arr_bin_machine.append(bm)
                
                #### incrementar linha pseudo instrução
                line_pos += 1 

                ### Como temos uma pseudo intrução, será necessário salvar mais objetos
                second_pseudo_inst = ['ori', '1', '1', instruction[3]]
                opcode = TypeI.getOpcode(second_pseudo_inst[0])
                rs, rt = TypeI.getIRegisters(second_pseudo_inst)
                address = TypeI.getAddress(second_pseudo_inst)

                # Criar o objeto e salva-lo em uma list para acesso posteriormente
                bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
                bm.setIsPseudo(True)
                arr_bin_machine.append(bm)

                #### incrementar linha pseudo instrução
                line_pos += 1 

                if(instruction[0] == 'andi'):
                    third_pseudo_inst = ['and', instruction[1], instruction[2], '1']
                    rs, rt, rd = TypeR.getRRegisters(third_pseudo_inst)
                    funct = TypeR.getFunct(third_pseudo_inst[0])
                elif(instruction[0] == 'ori'):
                    third_pseudo_inst = ['or', instruction[1], instruction[2], '1']
                    rs, rt, rd = TypeR.getRRegisters(third_pseudo_inst)
                    funct = TypeR.getFunct(third_pseudo_inst[0])
                elif(instruction[0] == 'xori'):
                    third_pseudo_inst = ['xor', instruction[1], instruction[2], '1']
                    rs, rt, rd = TypeR.getRRegisters(third_pseudo_inst)
                    funct = TypeR.getFunct(third_pseudo_inst[0])

                # Criar o objeto e salva-lo em uma list para acesso posteriormente
                bm = BinaryMachineR(line, str(line_pos), '000000', rs, rt, rd, '00000', funct, fake_line)
                arr_bin_machine.append(bm)

            else: 
                opcode = TypeI.getOpcode(instruction[0])
                rs, rt = TypeI.getIRegisters(instruction)
                address = TypeI.getAddress(instruction)

                performance.setTime2(datetime.datetime.now())
                arr_performance_obj.append(performance)

                # Criar o objeto e salva-lo em uma list para acesso posteriormente
                bm = BinaryMachineI(line, str(line_pos), opcode, rs, rt, address, fake_line)
                arr_bin_machine.append(bm)
        
        elif instruction[0] == 'clo':
            performance = Performance(instruction[0], 'type I', datetime.datetime.now())

            rs, rt, rd = TypeR.getRRegisters(instruction)
            funct = TypeR.getFunct(instruction[0])

            performance.setTime2(datetime.datetime.now())
            arr_performance_obj.append(performance)

            # Criar o objeto e salva-lo em uma list para acesso posteriormente
            bm = BinaryMachineR(line, str(line_pos), '011100', rs, rt, rd, '00000', funct, fake_line)
            arr_bin_machine.append(bm)

        else:
            print("ERROR - INSTRUCTION NOT RECOGNIZED")
            print('------------------')
            print(instruction)
            print('------------------')

        line_pos += 1

    ## Salvar arquivo .mif
    Saida.saveFileText(arr_bin_machine, 'saida_text')

    return arr_bin_machine, arr_performance_obj
Exemple #3
0
import Performance as Pfce 

name_Workwook = 'FLOW Operation and support report ASAP 7.0.2 JAMU66%2c WASS133 2018-09-10.xlsx'
name_Sheet = 'WASS WEEK '

'''instancia'''
object1 = Pfce.Performance(name_Workwook, name_Sheet)


'''obtencion de datos, function Text to Columns'''
wos_host_data = object1.text_To_Columns('A2009', 'A2072')
completed_data = object1.text_To_Columns('A1961', 'A2003')
failed_data = object1.text_To_Columns('A1908', 'A1955')
timeout_data = object1.text_To_Columns('A28', 'A43')


'''conversion a diccionarios'''
wos_host_dic = object1.convert_to_directory(wos_host_data[:,1], wos_host_data[:,0])
completed_dic = object1.convert_to_directory(completed_data[:,1], completed_data[:,0])
failed_dic = object1.convert_to_directory(failed_data[:,1], failed_data[:,0])
timout_dic = object1.convert_to_directory(timeout_data[:,1], timeout_data[:,0])

'''--------generate the failed and timeout details section -------'''

object1.write_xlsx_Document(object1.dictionary_to_pyMatrix(failed_dic), 'WASS-FailedDetails.xlsx')
object1.write_xlsx_Document(object1.dictionary_to_pyMatrix(timout_dic), 'WASS-TimeoutDetails.xlsx')



'''------------------ALINEAMIENTO------------------------'''
wos_host_listA, completed_listA = object1.alignment(wos_host_data[:,1], completed_data[:,1])
Exemple #4
0
        # show current holdings and orders record
        print("\nCurrent Holdings:")
        #print("symbol \t\t num \t\t price \t\t avg_cost \t\t date")
        print("{:10}\t{:10}\t{:10}\t{:10}\t{:10}".format('symbol', 'num', 'price', 'avg_cost', 'date'))
        cur.execute('select * from current_holdings')
        temp_records = cur.fetchall()
        for stock in temp_records:
            #print(stock[0], '\t\t', stock[1], '\t\t', str.format('{0:.2f}', stock[2]), '\t\t', str.format('{0:.2f}', stock[3]), '\t\t', stock[4])
            print("{:10}\t{:10}\t{:10}\t{:10}\t{:10}".format(stock[0], stock[1], str.format('{0:.2f}', stock[2]), str.format('{0:.2f}', stock[3]), stock[4]))
        # update asset values and holdings record
        holdings.update_tables()
        
        # simulate another day
        opt.date = available_dates[1+i]

    cur.execute('select * from asset_values_record')
    print("\n-----------Asset Values Record-----------")
    #print("date \t\t asset_value \t orders \t\t diversity")
    print("{:10}\t{:10}\t\t{:10}\t{:10}".format('date', 'asset_value', 'orders', 'diversity'))
    temp_records = cur.fetchall()
    for av_record in temp_records:
        #print(av_record[0], '\t', str.format('{0:.2f}', av_record[1]), '\t', av_record[2], '\t\t', av_record[3])
        print("{:10}\t{:10}\t{:10}\t{:10}".format(av_record[0], str.format('{0:.2f}', av_record[1]), av_record[2], av_record[3]))
    
    # performance
    print("\n-----------Performance Indicators-----------")
    perf = Performance.Performance(opt, holdings, stock_price.stock_mat, available_dates[:test_days], 2.6, 0.05)
    perf.get_performance()
    
    # close database connection
    holdings.conn.close()