Exemplo n.º 1
0
 def simulationSettings(self, enable=False, values=None):
     if enable:
         self.simulationEnabled = True
         self.simulator = simulator.Simulator(values, settings.getInterval())
     if not enable:
         self.simulator = None
         self.simulationEnabled = False
Exemplo n.º 2
0
    def __init__(self, parent, mainWindow, **kwargs):
        tk.Frame.__init__(self, parent, **kwargs)
        self.mainWindow = mainWindow

        self.columnconfigure(0, weight=1)
        self.columnconfigure(4, weight=1)
        self.configure(pady=10)
        tk.Frame(self, height="0", width="1").grid(row="0", column="0")
        tk.Frame(self, height="0", width="1").grid(row="0", column="4")
        self.counter = 0

        checkboxValue = tk.BooleanVar()
        checkboxValue.set(settings.getGraphDisabled())
        self.graphDisabled = tk.Checkbutton(self,
                                            text="完全禁用图象",
                                            variable=checkboxValue)
        self.graphDisabled.var = checkboxValue
        self.graphDisabled.grid(row=self.counter, column="1", columnspan="2")
        descriptor = tk.Label(self, text="数据标签将仍被显示")
        font = tkFont.Font(font=descriptor['font'])
        font.config(slant='italic')
        descriptor['font'] = font
        descriptor.grid(row=self.counter + 1, column="1", columnspan="2")
        tk.Frame(self, height="20", width="10").grid(row=self.counter + 2,
                                                     column="1",
                                                     columnspan="5")
        self.counter += 3

        self.secondsVar = tk.StringVar()
        self.secondsVar.set(settings.getSeconds())
        self.addSetting(self.secondsVar, "每求一次数据平均值的时间间隔(秒):",
                        "建议将此值设定为高于你武器射速的数值。")

        self.intervalVar = tk.StringVar()
        self.intervalVar.set(settings.getInterval())
        self.addSetting(self.intervalVar, "更新图象与数据标签的时间间隔(毫秒):",
                        "该值越低,电脑CPU的占用越高。")

        self.transparencyVar = tk.StringVar()
        self.transparencyVar.set(settings.getCompactTransparency())
        self.addSetting(self.transparencyVar, "紧凑模式下的窗口透明度:",
                        "100为完全可见,0为完全不可见。")
Exemplo n.º 3
0
 def __init__(self, parent, mainWindow, **kwargs):
     tk.Frame.__init__(self, parent, **kwargs)
     self.mainWindow = mainWindow
     
     self.columnconfigure(0, weight=1)
     self.columnconfigure(4, weight=1)
     self.configure(pady=10)
     tk.Frame(self, height="0", width="1").grid(row="0", column="0")
     tk.Frame(self, height="0", width="1").grid(row="0", column="4")
     self.counter = 0
     
     checkboxValue = tk.BooleanVar()
     checkboxValue.set(settings.getGraphDisabled())
     self.graphDisabled = tk.Checkbutton(self, text="禁用统计图", variable=checkboxValue)
     self.graphDisabled.var = checkboxValue
     self.graphDisabled.grid(row=self.counter, column="1", columnspan="2")
     descriptor = tk.Label(self, text="标签仍然会显示")
     font = tkFont.Font(font=descriptor['font'])
     font.config(slant='italic')
     descriptor['font'] = font
     descriptor.grid(row=self.counter+1, column="1", columnspan="2")
     tk.Frame(self, height="20", width="10").grid(row=self.counter+2, column="1", columnspan="5")
     self.counter += 3
     
     self.secondsVar = tk.StringVar()
     self.secondsVar.set(settings.getSeconds())
     self.addSetting(self.secondsVar, "DPS计算周期(秒):", 
                     "建议将此条设置为比你武器循环时间高一点的整数")
     
     self.intervalVar = tk.StringVar()
     self.intervalVar.set(settings.getInterval())
     self.addSetting(self.intervalVar, "图形绘制周期(毫秒):", 
                     "数值越低CPU负担越大")
     
     self.transparencyVar = tk.StringVar()
     self.transparencyVar.set(settings.getCompactTransparency())
     self.addSetting(self.transparencyVar, "Compat模式的透明度:", 
                     "100为不透明,0为全透明")
Exemplo n.º 4
0
 def __init__(self, parent, mainWindow, **kwargs):
     tk.Frame.__init__(self, parent, **kwargs)
     self.mainWindow = mainWindow
     
     self.columnconfigure(0, weight=1)
     self.columnconfigure(4, weight=1)
     self.configure(pady=10)
     tk.Frame(self, height="0", width="1").grid(row="0", column="0")
     tk.Frame(self, height="0", width="1").grid(row="0", column="4")
     self.counter = 0
     
     checkboxValue = tk.BooleanVar()
     checkboxValue.set(settings.getGraphDisabled())
     self.graphDisabled = tk.Checkbutton(self, text="Disable graph entirely", variable=checkboxValue)
     self.graphDisabled.var = checkboxValue
     self.graphDisabled.grid(row=self.counter, column="1", columnspan="2")
     descriptor = tk.Label(self, text="Labels will still be shown")
     font = tkFont.Font(font=descriptor['font'])
     font.config(slant='italic')
     descriptor['font'] = font
     descriptor.grid(row=self.counter+1, column="1", columnspan="2")
     tk.Frame(self, height="20", width="10").grid(row=self.counter+2, column="1", columnspan="5")
     self.counter += 3
     
     self.secondsVar = tk.StringVar()
     self.secondsVar.set(settings.getSeconds())
     self.addSetting(self.secondsVar, "Number of seconds to average values:", 
                     "Recommended to set this value higher than your weapon cycle time")
     
     self.intervalVar = tk.StringVar()
     self.intervalVar.set(settings.getInterval())
     self.addSetting(self.intervalVar, "How often to update graph/labels in milliseconds:", 
                     "The lower you set this value, the higher your CPU usage will be")
     
     self.transparencyVar = tk.StringVar()
     self.transparencyVar.set(settings.getCompactTransparency())
     self.addSetting(self.transparencyVar, "Window transparency percentage in compact mode:", 
                     "100 is fully visible, 0 is invisible")
Exemplo n.º 5
0
    def animate(self):
        """ this function gets called every 'interval', and handles all the tracking data """
        try:
            # data points are retrieved from either the simulator or the EVE logs
            if self.simulationEnabled:
                newEntries = self.simulator.simulate()
            else:
                newEntries = self.characterDetector.readLog()

            # insert all the new values into the categories entries
            self.categories["dpsOut"]["newEntry"] = newEntries[0]
            self.categories["dpsIn"]["newEntry"] = newEntries[1]
            self.categories["logiOut"]["newEntry"] = newEntries[2]
            self.categories["logiIn"]["newEntry"] = newEntries[3]
            self.categories["capTransfered"]["newEntry"] = newEntries[4]
            self.categories["capRecieved"]["newEntry"] = newEntries[5]
            self.categories["capDamageOut"]["newEntry"] = newEntries[6]
            self.categories["capDamageIn"]["newEntry"] = newEntries[7]
            self.categories["mining"]["newEntry"] = newEntries[8]
            self.interval = settings.getInterval()

            # pops old values, adds new values, and passes those to the graph and other handlers
            for category, items in self.categories.items():
                if self.fleetMode and category != 'mining':
                    for entry in items["newEntry"]:
                        self.dataQueue.put({
                            "category": category,
                            "entry": entry
                        })
                # if items["settings"] is empty, this isn't a category that is being tracked
                if items["settings"]:
                    # remove old values
                    items["historical"].pop(0)
                    items["historicalDetails"].pop(0)
                    # as values are broken up by weapon, add them together for the non-details views
                    amountSum = sum(
                        [entry['amount'] for entry in items["newEntry"]])
                    items["historical"].append(amountSum)
                    items["historicalDetails"].append(items["newEntry"])
                    # update totals if necessary
                    if items["settings"][0].get("showTotal",
                                                False) and amountSum > 0:
                        self.labelHandler.updateTotal(category, amountSum)
                    # 'yValues' is for the actual DPS at that point in time, as opposed to raw values
                    items["yValues"] = items["yValues"][1:]
                    average = (np.sum(items["historical"]) *
                               (1000 / self.interval)) / self.arrayLength
                    items["yValues"] = np.append(items["yValues"], average)
                    # pass the values to the graph and other handlers
                    if not items["labelOnly"] and not self.graphDisabled:
                        self.graph.animateLine(items["yValues"],
                                               items["settings"],
                                               items["lines"],
                                               zorder=items["zorder"])
                    color = self.findColor(category, average)
                    self.labelHandler.updateLabel(category, average, color)
                    self.detailsHandler.updateDetails(
                        category, items["historicalDetails"])

            # Find highest average for the y-axis scaling
            # We need to track graph avg and label avg separately, since graph avg is used for y-axis scaling
            #  and label average is needed for detecting when to slow down the animation
            self.highestAverage = 0
            self.highestLabelAverage = 0
            for category, items in self.categories.items():
                if items["settings"] and not items["labelOnly"]:
                    highest = max(items["yValues"])
                    if highest > self.highestAverage:
                        self.highestAverage = highest
                elif items["settings"]:
                    highest = max(items["yValues"])
                    if highest > self.highestLabelAverage:
                        self.highestLabelAverage = highest

            if not self.graphDisabled:
                self.graph.readjust(self.highestAverage)

            # if there are no values coming in to the graph, enable 'slowDown' mode to save CPU
            if self.highestAverage == 0 and self.highestLabelAverage == 0 and not self.fleetMode:
                if not self.slowDown:
                    self.slowDown = True
                    self.interval = 500
            else:
                if self.slowDown:
                    self.slowDown = False
                    self.interval = settings.getInterval()

            # display of pilot details is handled after all values are updated, for sorting and such
            self.detailsHandler.cleanupAndDisplay(
                self.interval, self.arrayLength,
                lambda x, y: self.findColor(x, y))

            if self.fleetMode:
                self.updateFleetWindow(self.mainWindow.fleetWindow)

        except Exception as e:
            logging.exception(e)
Exemplo n.º 6
0
    def changeSettings(self):
        """This function is called when a user changes settings after the settings are verified"""
        if self.is_alive():
            self.paused = True
            self.mainWindow.after_cancel(self.animate)
            self.graph.subplot.clear()
        if self.simulationEnabled:
            self.simulationSettings(enable=False)
            self.mainWindow.mainMenu.menu.delete(7)
            self.mainWindow.mainMenu.menu.insert_command(
                7,
                label="Simulate Input",
                command=lambda: simulationWindow.SimulationWindow(self.
                                                                  mainWindow))
            self.mainWindow.topLabel.grid_remove()
            self.mainWindow.mainMenu.menu.entryconfig(5, state="normal")

        self.slowDown = False
        self.seconds = settings.getSeconds()
        self.interval = settings.getInterval()
        self.categories["dpsOut"]["settings"] = settings.getDpsOutSettings()
        self.categories["dpsIn"]["settings"] = settings.getDpsInSettings()
        self.categories["logiOut"]["settings"] = settings.getLogiOutSettings()
        self.categories["logiIn"]["settings"] = settings.getLogiInSettings()
        self.categories["capTransfered"][
            "settings"] = settings.getCapTransferedSettings()
        self.categories["capRecieved"][
            "settings"] = settings.getCapRecievedSettings()
        self.categories["capDamageOut"][
            "settings"] = settings.getCapDamageOutSettings()
        self.categories["capDamageIn"][
            "settings"] = settings.getCapDamageInSettings()
        self.categories["mining"]["settings"] = settings.getMiningSettings()
        self.graphDisabled = settings.getGraphDisabled()

        if self.graphDisabled:
            self.graph.grid_remove()
        else:
            self.graph.grid()

        self.labelHandler.redoLabels()
        self.mainWindow.makeAllChildrenDraggable(self.labelHandler)

        if settings.detailsWindowShow:
            self.mainWindow.detailsWindow.deiconify()
        else:
            self.mainWindow.detailsWindow.withdraw()

        if self.fleetMode and settings.fleetWindowShow:
            self.mainWindow.fleetWindow.deiconify()
        else:
            self.mainWindow.fleetWindow.withdraw()

        self.arrayLength = int((self.seconds * 1000) / self.interval)
        historicalTemplate = [0] * self.arrayLength
        yValuesTemplate = np.array([0] * self.arrayLength)
        ySmooth = self.graph.smoothListGaussian(yValuesTemplate, 5)
        # resets all the arrays to contain no values
        showAnyPeakOrTotal = False
        for category, items in self.categories.items():
            if items["settings"]:
                self.labelHandler.enableLabel(category, True)
                showPeak = items["settings"][0].get("showPeak", False)
                self.labelHandler.enablePeak(category, showPeak)
                showTotal = items["settings"][0].get("showTotal", False)
                findColor = lambda x, category=category: self.findColor(
                    category, x)
                showAnyPeakOrTotal = showAnyPeakOrTotal or showPeak or showTotal
                self.labelHandler.enableTotal(category, findColor, showTotal)
                self.detailsHandler.enableLabel(category, True)
                items["historical"] = historicalTemplate.copy()
                items["historicalDetails"] = [[]] * self.arrayLength
                items["yValues"] = yValuesTemplate.copy()
                items["labelOnly"] = items["settings"][0].get(
                    "labelOnly", False)
                if not items["labelOnly"]:
                    plotLine, = self.graph.subplot.plot(ySmooth,
                                                        zorder=items["zorder"])
                    items["lines"] = [plotLine]
            else:
                self.labelHandler.enableLabel(category, False)
                self.labelHandler.enablePeak(category, False)
                self.detailsHandler.enableLabel(category, False)

        self.mainWindow.showClearMenuOption(
            showAnyPeakOrTotal,
            lambda: self.labelHandler.clearValues(self.findColor))

        if not self.graphDisabled:
            self.graph.subplot.margins(0, 0)
            self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100)
            self.graph.graphFigure.canvas.draw()

        # reset fleet data
        characterName = self.mainWindow.fleetWindow.characterName
        if self.dataQueue:
            self.fleetData = {
                'aggregate': {
                    'dpsOut': {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    },
                    'dpsIn': {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    },
                    'logiOut': {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                },
                'dpsOut': {
                    characterName: {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                },
                'dpsIn': {
                    characterName: {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                },
                'logiOut': {
                    characterName: {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                }
            }
        self.mainWindow.fleetWindow.resetGraphs(ySmooth)
        self.mainWindow.fleetWindow.changeSettings()

        self.paused = False
Exemplo n.º 7
0
 def animate(self):
     """ this function gets called every 'interval', and handles all the tracking data """
     try:
         # data points are retrieved from either the simulator or the EVE logs
         if self.simulationEnabled:
             newEntries = self.simulator.simulate()
         else:
             newEntries = self.characterDetector.readLog()
         
         # insert all the new values into the categories entries
         self.categories["dpsOut"]["newEntry"] = newEntries[0]
         self.categories["dpsIn"]["newEntry"] = newEntries[1]
         self.categories["logiOut"]["newEntry"] = newEntries[2]
         self.categories["logiIn"]["newEntry"] = newEntries[3]
         self.categories["capTransfered"]["newEntry"] = newEntries[4]
         self.categories["capRecieved"]["newEntry"] = newEntries[5]
         self.categories["capDamageOut"]["newEntry"] = newEntries[6]
         self.categories["capDamageIn"]["newEntry"] = newEntries[7]
         self.categories["mining"]["newEntry"] = newEntries[8]
         interval = settings.getInterval()
         
         # pops old values, adds new values, and passes those to the graph and other handlers
         for category, items in self.categories.items():
             if self.queue and category != 'mining':
                 for entry in items["newEntry"]:
                     self.queue.put({"category": category, "entry": entry})
             # if items["settings"] is empty, this isn't a category that is being tracked
             if items["settings"]:
                 # remove old values
                 items["historical"].pop(0)
                 items["historicalDetails"].pop(0)
                 # as values are broken up by weapon, add them together for the non-details views
                 amountSum = sum([entry['amount'] for entry in items["newEntry"]])
                 items["historical"].insert(len(items["historical"]), amountSum)
                 items["historicalDetails"].insert(len(items["historicalDetails"]), items["newEntry"])
                 # 'yValues' is for the actual DPS at that point in time, as opposed to raw values
                 items["yValues"] = items["yValues"][1:]
                 average = (np.sum(items["historical"])*(1000/interval))/len(items["historical"])
                 items["yValues"] = np.append(items["yValues"], average)
                 # pass the values to the graph and other handlers
                 if not items["labelOnly"] and not self.graphDisabled:
                     self.graph.animateLine(items["yValues"], items["settings"], items["lines"], zorder=items["zorder"])
                     self.labelHandler.updateLabel(category, average, matplotlib.colors.to_hex(items["lines"][-1].get_color()))
                 else:
                     color = self.findColor(category, average)
                     self.labelHandler.updateLabel(category, average, color)
                 self.detailsHandler.updateDetails(category, items["historicalDetails"])
         
         # Find highest average for the y-axis scaling
         # We need to track graph avg and label avg separately, since graph avg is used for y-axis scaling
         #  and label average is needed for detecting when to slow down the animation
         self.highestAverage = 0
         self.highestLabelAverage = 0
         for category, items in self.categories.items():
             if items["settings"] and not items["labelOnly"]:
                 for value in items["yValues"]:
                     if (value > self.highestAverage):
                         self.highestAverage = value
             elif items["settings"]:
                 for value in items["yValues"]:
                     if (value > self.highestAverage):
                         self.highestLabelAverage = value
         
         if not self.graphDisabled:
             if (self.highestAverage < 100):
                 self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100)
             else:
                 self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=(self.highestAverage+self.highestAverage*0.1))
             self.graph.graphFigure.axes[0].get_yaxis().grid(True, linestyle="-", color="grey", alpha=0.2)
             self.graph.readjust(settings.getWindowWidth(), self.highestAverage)
         
         # if there are no values coming in to the graph, enable 'slowDown' mode to save CPU
         if (self.highestAverage == 0 and self.highestLabelAverage == 0):
             if not self.slowDown:
                 self.slowDown = True
                 self.interval = 500
         else:
             if self.slowDown:
                 self.slowDown = False
                 self.interval = settings.getInterval()
         
         # display of pilot details is handled after all values are updated, for sorting and such
         self.detailsHandler.cleanupAndDisplay(interval, int((self.seconds*1000)/self.interval), lambda x,y: self.findColor(x,y))
 
         if not self.graphDisabled:
             self.graph.graphFigure.canvas.draw()
         
     except Exception as e:
         logging.exception(e)
Exemplo n.º 8
0
 def changeSettings(self):
     """This function is called when a user changes settings after the settings are verified"""
     if self.is_alive():
         self.paused = True
         self.mainWindow.after_cancel(self.animate)
         self.graph.subplot.clear()
     if self.simulationEnabled:
         self.simulationSettings(enable=False)
         self.mainWindow.mainMenu.menu.delete(5)
         self.mainWindow.mainMenu.menu.insert_command(5, label="Simulate Input", command=lambda: simulationWindow.SimulationWindow(self.mainWindow))
         self.mainWindow.topLabel.grid_remove()
         self.mainWindow.mainMenu.menu.entryconfig(3, state="normal")
     
     self.slowDown = False
     self.seconds = settings.getSeconds()
     self.interval = settings.getInterval()
     self.categories["dpsOut"]["settings"] = settings.getDpsOutSettings()
     self.categories["dpsIn"]["settings"] = settings.getDpsInSettings()
     self.categories["logiOut"]["settings"] = settings.getLogiOutSettings()
     self.categories["logiIn"]["settings"] = settings.getLogiInSettings()
     self.categories["capTransfered"]["settings"] = settings.getCapTransferedSettings()
     self.categories["capRecieved"]["settings"] = settings.getCapRecievedSettings()
     self.categories["capDamageOut"]["settings"] = settings.getCapDamageOutSettings()
     self.categories["capDamageIn"]["settings"] = settings.getCapDamageInSettings()
     self.categories["mining"]["settings"] = settings.getMiningSettings()
     self.graphDisabled = settings.getGraphDisabled()
     
     if self.graphDisabled:
         self.graph.grid_remove()
     else:
         self.graph.grid()
     
     self.labelHandler.redoLabels()
     
     if settings.detailsWindowShow:
         self.mainWindow.detailsWindow.deiconify()
     else:
         self.mainWindow.detailsWindow.withdraw()
     
     # resets all the arrays to contain no values
     for category, items in self.categories.items():
         if items["settings"]:
             self.labelHandler.enableLabel(category, True)
             self.detailsHandler.enableLabel(category, True)
             items["historical"] = [0] * int((self.seconds*1000)/self.interval)
             items["historicalDetails"] = [[]] * int((self.seconds*1000)/self.interval)
             items["yValues"] = np.array([0] * int((self.seconds*1000)/self.interval))
             try:
                 items["labelOnly"] = items["settings"][0]["labelOnly"]
             except KeyError:
                 items["settings"][0]["labelOnly"] = False
                 items["labelOnly"] = items["settings"][0]["labelOnly"]
             if not items["labelOnly"]:
                 ySmooth = self.graph.smoothListGaussian(items["yValues"], 5)
                 plotLine, = self.graph.subplot.plot(ySmooth, zorder=items["zorder"])
                 items["lines"] = [plotLine]
         else:
             self.labelHandler.enableLabel(category, False)
             self.detailsHandler.enableLabel(category, False)
     
     if not self.graphDisabled:
         self.graph.subplot.margins(0,0)
         self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100)
         self.graph.graphFigure.canvas.draw()
     
     self.paused = False