Exemplo n.º 1
0
 def update(self, entity, id_to_update):
     try:
         self.__check_instance(entity)
         entity.update(self.conn, id_to_update)
         self.change_callback()
     except Exception as e:
         string = f"""Error mientras se eliminaba la entidad {type(entity).__name__} con identificador {entity.id}"""
         get_error_dialog_msg(e, string, "Error de actualizacion").exec_()
Exemplo n.º 2
0
 def append(self, entity):
     """Append to the list."""
     try:
         self.__check_instance(entity)
         entity.insert(self.conn)
         self.change_callback()
     except Exception as e:
         string = f"""Error mientras se agregaba la entidad {type(entity).__name__} con identificador {entity.id}"""
         get_error_dialog_msg(e, string, "Error de insertacion").exec_()
Exemplo n.º 3
0
    def load_graph(self, pruebas):
        test1 = []
        test2 = []
        test3 = []
        total = []
        dates = []  # X axis
        try:
            self.model.change_model_list(pruebas)
            if len(pruebas) > 0:
                self.graph.ax.clear()
                self.graph_test_1.ax.clear()
                self.graph_test_2.ax.clear()
                self.tiempo_total.setText("")
                self.tiempo_1.setText("")
                self.tiempo_2.setText("")
                self.tiempo_3.setText("")
                self.graph_test_3.ax.clear()
                self.graph_test_total.ax.clear()
                for x in range(0, len(pruebas)):
                    prueba = pruebas[x]
                    dates.append(prueba.datetime)
                    test1.append(prueba.laps[0].total_seconds())
                    test2.append(prueba.laps[1].total_seconds())
                    test3.append(prueba.laps[2].total_seconds())
                    total.append(test1[x] + test2[x] + test3[x])
                self.graph.line_lap0 = self.graph.ax.plot(date2num(dates), matplotlib.dates.num2date(test1), lw=0.75,
                                                          label=self.settings.get_lap_name(0),
                                                          color="blue",
                                                          marker="o",
                                                          markersize=2)
                self.graph.line_lap1 = self.graph.ax.plot(date2num(dates), matplotlib.dates.num2date(test2), lw=0.75,
                                                          label=self.settings.get_lap_name(1),
                                                          color="green",
                                                          marker="o",
                                                          markersize=2)
                self.graph.line_lap2 = self.graph.ax.plot(date2num(dates), matplotlib.dates.num2date(test3),
                                                          lw=0.75,
                                                          label=self.settings.get_lap_name(2),
                                                          color="brown",
                                                          marker="o",
                                                          markersize=2)
                self.graph.line_total = self.graph.ax.plot(date2num(dates), matplotlib.dates.num2date(total), lw=0.75,
                                                           label=self.settings.value(self.settings.LAP_TOTAL_NAME),
                                                           color="red",
                                                           marker="o",
                                                           markersize=2)

                self.graph.ax.xaxis.set_major_locator(Grafica.autox)
                self.graph.ax.xaxis.set_major_formatter(Grafica.formatterx)
                self.graph.ax.yaxis.set_major_formatter(Grafica.funcformatter)
                self.graph.ax.yaxis.set_label("Tiempo de prueba")
                self.graph.ax.xaxis.set_label("Fecha")
                self.graph.ax.grid(True)
                self.graph.ax.legend(frameon=False)
                self.statusChangeSlot.emit(
                    f"Mostrando {len(test2)} pruebas, entre {dates[0]} y {dates[len(dates) - 1]}", 10)
                for tick in self.graph.ax.get_xticklabels():
                    tick.set_rotation(30)
            else:
                self.graph.ax.clear()
                self.graph_test_1.ax.clear()
                self.graph_test_2.ax.clear()
                self.graph_test_3.ax.clear()
                self.graph_test_total.ax.clear()
            self.graph.draw()
            try:
                test1_lowmid_limit = self.settings.value(self.settings.LAP0_LOWMEDIUM_START).total_seconds()
                test2_lowmid_limit = self.settings.value(self.settings.LAP1_LOWMEDIUM_START).total_seconds()
                test3_lowmid_limit = self.settings.value(self.settings.LAP2_LOWMEDIUM_START).total_seconds()

                test1_midhigh_limit = self.settings.value(self.settings.LAP0_MEDIUMHARD_START).total_seconds()
                test2_midhigh_limit = self.settings.value(self.settings.LAP1_MEDIUMHARD_START).total_seconds()
                test3_midhigh_limit = self.settings.value(self.settings.LAP2_MEDIUMHARD_START).total_seconds()

                test_total_lowmid_limit = test1_lowmid_limit + test2_lowmid_limit + test3_lowmid_limit
                test_total_midhigh_limit = test3_midhigh_limit + test2_midhigh_limit + test1_midhigh_limit

                self.graph_test_1.ax.plot((0,
                                           len(test1)),
                                          (test1_lowmid_limit, test1_lowmid_limit),
                                          color="orange",
                                          markersize=1)
                self.graph_test_1.ax.plot((0, len(test1)), (test1_midhigh_limit, test1_midhigh_limit),
                                          color="red",
                                          markersize=1)

                self.graph_test_2.ax.plot((0, len(test2)), (test2_lowmid_limit, test2_lowmid_limit),
                                          color="orange",
                                          markersize=1)
                self.graph_test_2.ax.plot((0, len(test2)), (test2_midhigh_limit, test2_midhigh_limit),
                                          color="red",
                                          markersize=1)

                self.graph_test_3.ax.plot((0, len(test3)), (test3_lowmid_limit, test3_lowmid_limit),
                                          color="orange",
                                          markersize=1)
                self.graph_test_3.ax.plot((0, len(test3)), (test3_midhigh_limit, test3_midhigh_limit),
                                          color="red",
                                          markersize=1)

                self.graph_test_total.ax.plot((0, len(test3)), (test_total_lowmid_limit, test_total_lowmid_limit),
                                          color="orange",
                                          markersize=1)
                self.graph_test_total.ax.plot((0, len(test3)), (test_total_midhigh_limit, test_total_midhigh_limit),
                                          color="red",
                                          markersize=1)

                for x in range(0, len(dates)):
                    test_total = test1[x] + test2[x] + test3[x]
                    if test1[x] < test1_lowmid_limit:
                        self.graph_test_1.ax.plot(x, test1[x], color="green", marker="o", markersize=2)
                    elif test1[x] < test1_midhigh_limit:
                        self.graph_test_1.ax.plot(x, test1[x], color="orange", marker="o", markersize=2)
                    else:
                        self.graph_test_1.ax.plot(x, test1[x], color="red", marker="o", markersize=2)
                    if test2[x] < test2_lowmid_limit:
                        self.graph_test_2.ax.plot(x, test2[x], color="green", marker="o", markersize=2)
                    elif test2[x] < test2_midhigh_limit:
                        self.graph_test_2.ax.plot(x, test2[x], color="orange", marker="o", markersize=2)
                    else:
                        self.graph_test_2.ax.plot(x, test2[x], color="red", marker="o", markersize=2)
                    if test3[x] < test3_lowmid_limit:
                        self.graph_test_3.ax.plot(x, test3[x], color="green", marker="o", markersize=2)
                    elif test3[x] < test3_midhigh_limit:
                        self.graph_test_3.ax.plot(x, test3[x], color="orange", marker="o", markersize=2)
                    else:
                        self.graph_test_3.ax.plot(x, test3[x], color="red", marker="o", markersize=2)
                    if test_total < test_total_lowmid_limit:
                        self.graph_test_total.ax.plot(x, test3[x], color="green", marker="o", markersize=2)
                    elif test_total < test_total_midhigh_limit:
                        self.graph_test_total.ax.plot(x, test_total, color="orange", marker="o", markersize=2)
                    else:
                        self.graph_test_total.ax.plot(x, test_total, color="red", marker="o", markersize=2)

                self.graph_test_1.ax.yaxis.set_major_formatter(Grafica.funcformatter)
                self.graph_test_1.ax.yaxis.set_label("Tiempo de prueba")
                self.graph_test_1.ax.grid(True)
                #self.graph_test_1.ax.legend(frameon=False)

                self.graph_test_2.ax.yaxis.set_major_formatter(Grafica.funcformatter)
                self.graph_test_2.ax.yaxis.set_label("Tiempo de prueba")
                self.graph_test_2.ax.grid(True)
                #self.graph_test_2.ax.legend(frameon=False)

                self.graph_test_3.ax.yaxis.set_major_formatter(Grafica.funcformatter)
                self.graph_test_3.ax.yaxis.set_label("Tiempo de prueba")
                self.graph_test_3.ax.grid(True)
                #self.graph_test_3.ax.legend(frameon=False)
                self.graph_test_total.ax.yaxis.set_major_formatter(Grafica.funcformatter)
                self.graph_test_total.ax.yaxis.set_label("Tiempo de prueba")
                self.graph_test_total.ax.grid(True)

                self.graph_test_1.draw()
                self.graph_test_2.draw()
                self.graph_test_3.draw()
                self.graph_test_total.draw()
            except Exception as e:
                string = f"Error en la matrices secundarias. {type(e).__name__} paciente {self.pacient.dni}\n"
                string += "Valores:\n"
                string += f"{dates}\n"
                string += f"{test1}\n"
                string += f"{test2}\n"
                string += f"{test3}"
                get_error_dialog_msg(e, string, "Error de insertacion").exec_()

        except Exception as e:
            string = f"Error en la matriz {type(e).__name__} paciente {self.pacient.id}\n"
            string += "Valores:\n"
            string += f"{dates}\n"
            string += f"{test1}\n"
            string += f"{test2}\n"
            string += f"{test3}"
            get_error_dialog_msg(e, string, "Error de insertacion").exec_()