Exemplo n.º 1
0
    def process_log_line(self, log_line, lineno, last_lineno):
        packet_type = log_line[logger.LOG_LINE_PACKET]
        if packet_type is packets.Resettle:
            axis = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "axis")
            position = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "position")
            if axis == AXIS_X:
                self.path.moveTo(self.path.currentPosition().x(), position * 1000.0)
            else:
                self.path.moveTo(position * 1000.0, self.path.currentPosition().y())
        if packet_type is packets.MoveLine or packet_type is packets.MoveCurve:
            for p in logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "points"):
                x = logtools.get_value(p, "x")
                y = logtools.get_value(p, "y")
                self.path.lineTo(y * 1000.0, x * 1000.0)
        elif packet_type is packets.MoveArc:
            content = log_line[logger.LOG_LINE_CONTENT]
            center = logtools.get_value(content, "center")
            center_x = logtools.get_value(center, 'x')
            center_y = logtools.get_value(center, 'y')
            radius = logtools.get_value(content, "radius")
            points = logtools.get_value(content, "points")
            for p in points:
                x = center_x + radius * math.cos(p)
                y = center_y + radius * math.cos(p)
                self.path.lineTo(y * 1000.0, x * 1000.0)

        if lineno == last_lineno:
            path_item = QGraphicsPathItem(self)
            path_item.setPen(QPen(QColor(self.color), 10))
            path_item.setPath(self.path)
Exemplo n.º 2
0
    def process_log_line(self, log_line, lineno, last_lineno):
        packet_type = log_line[logger.LOG_LINE_PACKET]
        if packet_type is packets.Resettle:
            axis = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "axis")
            position = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "position")
            if axis == AXIS_X:
                self.path.moveTo(self.path.currentPosition().x(), position * 1000.0)
            else:
                self.path.moveTo(position * 1000.0, self.path.currentPosition().y())
        if packet_type is packets.MoveLine or packet_type is packets.MoveCurve:
            for p in logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "points"):
                x = logtools.get_value(p, "x")
                y = logtools.get_value(p, "y")
                self.path.lineTo(y * 1000.0, x * 1000.0)
        elif packet_type is packets.MoveArc:
            content = log_line[logger.LOG_LINE_CONTENT]
            center = logtools.get_value(content, "center")
            center_x = logtools.get_value(center, 'x')
            center_y = logtools.get_value(center, 'y')
            radius = logtools.get_value(content, "radius")
            points = logtools.get_value(content, "points")
            for p in points:
                x = center_x + radius * math.cos(p)
                y = center_y + radius * math.cos(p)
                self.path.lineTo(y * 1000.0, x * 1000.0)

        if lineno == last_lineno:
            path_item = QGraphicsPathItem(self)
            path_item.setPen(QPen(QColor(self.color), 10))
            path_item.setPath(self.path)
Exemplo n.º 3
0
 def process_log_line(self, log_line, lineno, last_lineno):
     packet_type = log_line[logger.LOG_LINE_PACKET]
     if packet_type is packets.TurretDetect:
         angle = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "angle")
         if logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "robot") == OPPONENT_ROBOT_MAIN:
             if logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "distance") == 0:
                 self.main_opponent_short_distance[angle] += 1
             else:
                 self.main_opponent_long_distance[angle] += 1
         else:
             if logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "distance") == 0:
                 self.secondary_opponent_short_distance[angle] += 1
             else:
                 self.secondary_opponent_long_distance[angle] += 1
Exemplo n.º 4
0
 def process_log_line(self, log_line, lineno, last_lineno):
     packet_type = log_line[logger.LOG_LINE_PACKET]
     sender = log_line[logger.LOG_LINE_SENDER]
     if packet_type is packets.KeepAlive and sender == "PIC":
         pose = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "current_pose")
         angle = logtools.get_value(pose, "angle")
         if len(self.angles) > 0:
             speed = abs(self.angles[-1] - angle)
             self.speeds.append(speed)
             if speed > self.max_speed:
                 self.max_speed = speed
             if speed > 0.01:
                 self.average_speed += speed
                 self.average_speed_count += 1
         self.angles.append(angle)
Exemplo n.º 5
0
    def load_log(self):
        log = imp.load_source("logcontent", self.log_file).log
        lineno = 1
        last_lineno = len(log)
        for log_line in log:
            content = log_line[logger.LOG_LINE_CONTENT]
            packet_type = log_line[logger.LOG_LINE_PACKET]
            if type(packet_type) != str:
                try :
                    log_line[logger.LOG_LINE_CONTENT] = eval(content)
                except Exception as e :
                    print(e)

            log_line.append(content)
            for view in self.views:
                if packet_type is packets.KeepAlive:
                    match_time = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "match_time")
                    if match_time <= 0 or match_time > 90000:
                        continue
                view.process_log_line(log_line, lineno, last_lineno)
            lineno += 1
        dir_name, log_name = os.path.split(self.log_file)
        if len(dir_name) == 0:
            dir_name = "."
        svg_list = self.find_svg_images(log_name, os.listdir(dir_name))
        cwd = os.getcwd()
        os.chdir(dir_name)
        for svg in svg_list:
            lbl = QLabel()
            lbl.setPixmap(QPixmap(svg))
            self.ui.tabWidget.addTab(lbl, svg)
        os.chdir(cwd)
        for view in self.views:
            view.log_loaded()
Exemplo n.º 6
0
    def load_log(self):
        log = imp.load_source("logcontent", self.log_file).log
        lineno = 1
        last_lineno = len(log)
        for log_line in log:
            content = log_line[logger.LOG_LINE_CONTENT]
            packet_type = log_line[logger.LOG_LINE_PACKET]
            if type(packet_type) != str:
                try:
                    log_line[logger.LOG_LINE_CONTENT] = eval(content)
                except Exception as e:
                    print(e)

            log_line.append(content)
            for view in self.views:
                if packet_type is packets.KeepAlive:
                    match_time = logtools.get_value(
                        log_line[logger.LOG_LINE_CONTENT], "match_time")
                    if match_time <= 0 or match_time > 90000:
                        continue
                view.process_log_line(log_line, lineno, last_lineno)
            lineno += 1
        dir_name, log_name = os.path.split(self.log_file)
        if len(dir_name) == 0:
            dir_name = "."
        svg_list = self.find_svg_images(log_name, os.listdir(dir_name))
        cwd = os.getcwd()
        os.chdir(dir_name)
        for svg in svg_list:
            lbl = QLabel()
            lbl.setPixmap(QPixmap(svg))
            self.ui.tabWidget.addTab(lbl, svg)
        os.chdir(cwd)
        for view in self.views:
            view.log_loaded()
Exemplo n.º 7
0
 def process_log_line(self, log_line, lineno, last_lineno):
     packet_type = log_line[logger.LOG_LINE_PACKET]
     sender = log_line[logger.LOG_LINE_SENDER]
     if packet_type is packets.KeepAlive and sender == "PIC":
         pose = logtools.get_value(log_line[logger.LOG_LINE_CONTENT],
                                   "current_pose")
         angle = logtools.get_value(pose, "angle")
         if len(self.angles) > 0:
             speed = abs(self.angles[-1] - angle)
             self.speeds.append(speed)
             if speed > self.max_speed:
                 self.max_speed = speed
             if speed > 0.01:
                 self.average_speed += speed
                 self.average_speed_count += 1
         self.angles.append(angle)
Exemplo n.º 8
0
    def process_log_line(self, log_line, lineno, last_lineno):
        packet_type = log_line[logger.LOG_LINE_PACKET]
        if packet_type is packets.KeepAlive:
            pose = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "current_pose")
            x = logtools.get_value(pose, "x")
            y = logtools.get_value(pose, "y")
            if not self.has_first_goto:
                self.path.moveTo(y * 1000.0, x * 1000.0)
            else:
                self.path.lineTo(y * 1000.0, x * 1000.0)
        if packet_type is packets.MoveLine or packet_type is packets.MoveCurve or packet_type is packets.MoveArc:
            self.has_first_goto = True

        if lineno == last_lineno:
            path_item = QGraphicsPathItem(self)
            path_item.setPen(QPen(QColor(self.color), 10))
            path_item.setPath(self.path)
Exemplo n.º 9
0
    def process_log_line(self, log_line, lineno, last_lineno):
        packet_type = log_line[logger.LOG_LINE_PACKET]
        if packet_type is packets.KeepAlive:
            pose = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "current_pose")
            x = logtools.get_value(pose, "x")
            y = logtools.get_value(pose, "y")
            if not self.has_first_goto:
                self.path.moveTo(y * 1000.0, x * 1000.0)
            else:
                self.path.lineTo(y * 1000.0, x * 1000.0)
        if packet_type is packets.MoveLine or packet_type is packets.MoveCurve or packet_type is packets.MoveArc:
            self.has_first_goto = True

        if lineno == last_lineno:
            path_item = QGraphicsPathItem(self)
            path_item.setPen(QPen(QColor(self.color), 10))
            path_item.setPath(self.path)
Exemplo n.º 10
0
 def process_log_line(self, log_line, lineno, last_lineno):
     packet_type = log_line[logger.LOG_LINE_PACKET]
     sender = log_line[logger.LOG_LINE_SENDER]
     if packet_type is packets.KeepAlive and sender == "PIC":
         pose = logtools.get_value(log_line[logger.LOG_LINE_CONTENT], "current_pose")
         x = logtools.get_value(pose, "x")
         y = logtools.get_value(pose, "y")
         if len(self.points) > 0:
             oldx, oldy = self.points[-1]
             speed = math.sqrt((x - oldx) ** 2 + (y - oldy) ** 2) / (KEEP_ALIVE_DELAY_MS / 1000.0)
             self.speeds.append(speed)
             if speed > self.max_speed:
                 self.max_speed = speed
             if speed > 0.001:
                 self.average_speed += speed
                 self.average_speed_count += 1
         self.points.append((x, y))
 def process_log_line(self, log_line, lineno, last_lineno):
     packet_type = log_line[logger.LOG_LINE_PACKET]
     if packet_type is packets.TurretDetect:
         angle = logtools.get_value(log_line[logger.LOG_LINE_CONTENT],
                                    "angle")
         if logtools.get_value(log_line[logger.LOG_LINE_CONTENT],
                               "robot") == OPPONENT_ROBOT_MAIN:
             if logtools.get_value(log_line[logger.LOG_LINE_CONTENT],
                                   "distance") == 0:
                 self.main_opponent_short_distance[angle] += 1
             else:
                 self.main_opponent_long_distance[angle] += 1
         else:
             if logtools.get_value(log_line[logger.LOG_LINE_CONTENT],
                                   "distance") == 0:
                 self.secondary_opponent_short_distance[angle] += 1
             else:
                 self.secondary_opponent_long_distance[angle] += 1
Exemplo n.º 12
0
 def process_log_line(self, log_line, lineno, last_lineno):
     packet_type = log_line[logger.LOG_LINE_PACKET]
     sender = log_line[logger.LOG_LINE_SENDER]
     if packet_type is packets.KeepAlive and sender == "PIC":
         pose = logtools.get_value(log_line[logger.LOG_LINE_CONTENT],
                                   "current_pose")
         x = logtools.get_value(pose, "x")
         y = logtools.get_value(pose, "y")
         if len(self.points) > 0:
             oldx, oldy = self.points[-1]
             speed = math.sqrt((x - oldx)**2 +
                               (y - oldy)**2) / (KEEP_ALIVE_DELAY_MS /
                                                 1000.0)
             self.speeds.append(speed)
             if speed > self.max_speed:
                 self.max_speed = speed
             if speed > 0.001:
                 self.average_speed += speed
                 self.average_speed_count += 1
         self.points.append((x, y))