コード例 #1
0
    def _print_memory_usage(self, term, lock, start_x, start_y):
        XBUtil.print_section_heading(term, lock, "Device Memory Usage", start_y)
        table_offset = 1

        if self._df == None:
            XBUtil.print_warning(term, lock, start_y + table_offset, "Data unavailable. Acceleration image not loaded")
            return table_offset + 1

        try:
            memories = self._df['board']['memory']['memories']
        except:
            XBUtil.print_warning(term, lock, start_y + table_offset, "Data unavailable. Acceleration image not loaded")
            return table_offset + 1

        mem_usage = []
        for memory in memories:
            size = int(memory['range_bytes'], 16)
            if size == 0 or memory['enabled'] == "false":
                continue
            name = memory['tag']
            usage = int(memory['extended_info']['usage']['allocated_bytes'], 0)
            mem_usage.append("%-16s %s" % (name, XBUtil.progress_bar(usage * 100 / size)))

        XBUtil.indented_print(term, lock, mem_usage, 3, start_y + table_offset)
        table_offset += len(mem_usage)
        return table_offset
コード例 #2
0
    def _print_memory_usage(self, term, lock, start_x, start_y, page):
        XBUtil.print_section_heading(term, lock, "Device Memory Usage",
                                     start_y)
        offset = 1

        if self._df == None:
            XBUtil.print_warning(
                term, lock, start_y + offset,
                "Data unavailable. Acceleration image not loaded")
            return offset + 1

        data = []
        memories = []
        try:
            memories = self._df['board']['memory']['memories']
        except:
            XBUtil.print_warning(
                term, lock, start_y + offset,
                "Data unavailable. Acceleration image not loaded")
            return offset + 1

        for i in range(self.report_length):
            # The current element to be parsed depends on what page has been requested
            index = i + (page * self.report_length)
            # Ensure that our index does not exceed the input data size. This may happen on the last page
            if (index < len(memories)):
                memory = memories[index]
                size = int(memory['range_bytes'], self.hexadecimal_converion)
                if size == 0 or memory['enabled'] == "false":
                    continue
                name = memory['tag']
                usage = int(
                    memory['extended_info']['usage']['allocated_bytes'], 0)
                data.append("%-16s %s" %
                            (name, XBUtil.progress_bar(usage * 100 / size)))
            # If the index exceeds the input data size leave the for loop as everything is populated on the
            # last page
            else:
                break

        if (not data):
            XBUtil.print_warning(term, lock, start_y + offset,
                                 "Data unavailable")
            return offset + 1

        XBUtil.indented_print(term, lock, data, 3, start_y + offset)
        offset += len(data)
        return offset