Jelajahi Sumber

split files

subDesTagesMitExtraKaese 4 tahun lalu
induk
melakukan
8b1de4b9f9

+ 2 - 2
software/analogPressure/sdpArray.py

@@ -1,7 +1,7 @@
-from mcp3008 import MCP3008
+from .mcp3008 import MCP3008
 import time
 
-class SdpArray():
+class SdpArray:
   def __init__(self):
     self.adcs = (
       MCP3008(0, 0), 

+ 68 - 16
software/appWindow.py

@@ -1,23 +1,75 @@
-#!/usr/bin/python3
-# -*- coding: utf-8 -*-
+# The code for changing pages was derived from: http://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter
+# License: http://creativecommons.org/licenses/by-sa/3.0/	
 
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import (QSettings, QThread, pyqtSignal, pyqtSlot)
+from analogPressure.sdpArray import SdpArray
+from digitalPressure.spd610Array import Spd610Array
+from wirelessLoadCell.loadCells import LoadCells
+from ui import *
 
-from ui.windkanal import Ui_Form
-from ui.main_ui import Ui_MainWindow
+import matplotlib
+from matplotlib.backends.backend_tkagg import (
+    FigureCanvasTkAgg, NavigationToolbar2Tk)
+from matplotlib.figure import Figure
+import matplotlib.animation as animation
+from matplotlib import style
 
-class AppWindow(QMainWindow):
+import tkinter as tk
+import tk_tools
+from time import *
 
-  def __init__(self):
-    super().__init__()
-    self.ui = Ui_MainWindow()
-    self.ui.setupUi(self)
-    self.ui.saveButton.clicked.connect(self.save_pressed)
+LARGE_FONT= ("Verdana", 12)
+style.use("ggplot")
+       
 
-    self.show()
+class Main(tk.Tk):
+  def __init__(self, *args, **kwargs):
+    tk.Tk.__init__(self, *args, **kwargs)
+    tk.Tk.wm_title(self, "Windkanal-Tool")
+    
+    
+    container = tk.Frame(self)
+    container.pack(side="top", fill="both", expand = True)
+    container.grid_rowconfigure(0, weight=1)
+    container.grid_columnconfigure(0, weight=1)
 
-  def save_pressed(self):
-    self.ui.lcdNumber_pressure.intValue(123)
-    print(dir(self.ui.lcdNumber_pressure))
 
+    menubar = tk.Menu(container)
+    filemenu = tk.Menu(menubar, tearoff=0)
+    filemenu.add_command(label="Save settings", command = lambda: self.popupmsg("Not supported just yet!"))
+    filemenu.add_separator()
+    filemenu.add_command(label="Exit", command=quit)
+    menubar.add_cascade(label="File", menu=filemenu)
+
+    tk.Tk.config(self, menu=menubar)
+
+    self.frames = {}
+
+    for F in (Page_1, Page_2, Page_3, Page_4):
+
+      frame = F(container, self)
+
+      self.frames[F] = frame
+
+      frame.grid(row=0, column=0, sticky="nsew")
+
+    self.show_frame(Page_1)
+
+  def show_frame(self, cont):
+    frame = self.frames[cont]
+    frame.tkraise()
+
+  def popupmsg(self, msg=""):
+      popup = tk.Toplevel(self.master)
+      popup.wm_title("Error!")
+      label = tk.Label(popup, text=msg, font=LARGE_FONT)
+      label.pack(side="top", fill="x", pady=10)
+      b1 = tk.Button(popup, text="Okay", command=popup.destroy)
+      b1.pack()
+  def interval(self):
+    
+    for frame in self.frames:
+      frame.update()
+
+    self.after(300,self.interval)
+
+          

+ 4 - 8
software/main.py

@@ -2,16 +2,12 @@
 # -*- coding: utf-8 -*-
 
 import sys
+from appWindow import Main
 
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import (QThread, pyqtSignal, pyqtSlot)
 
-from appWindow import AppWindow
+app = Main()
+app.geometry("1280x720")
+app.mainloop()
 
 
-
-qApp = QApplication(sys.argv)
-w = AppWindow()
-ret = qApp.exec_()
-
 sys.exit(ret)

+ 56 - 0
software/ui/Page_1.py

@@ -0,0 +1,56 @@
+import tkinter as tk
+import tk_tools
+
+class Page_1(tk.Frame):
+  def __init__(self, parent, controller):
+    tk.Frame.__init__(self, parent)
+    self.t = 0
+    label = tk.Label(self, text="Bedienelemente", font=LARGE_FONT)
+    label.pack(pady=10,padx=10)
+    # top menu
+    top = tk.Frame(self, borderwidth=2, relief="solid")
+    button1 = tk.Button(top, text="Bedienelemente", command=lambda: controller.show_frame(Page_0))
+    button1.pack(side=tk.LEFT)
+
+    button2 = tk.Button(top, text="Kräfte", command=lambda: controller.show_frame(Page_2))
+    button2.pack(side=tk.LEFT)
+
+    button3 = tk.Button(top, text="Druck", command=lambda: controller.show_frame(Page_2))
+    button3.pack(side=tk.LEFT)
+
+    button4 = tk.Button(top,text="Einstellungen",command=lambda: controller.show_frame(Page_2))
+    button4.pack(side=tk.LEFT)
+
+    button5 = tk.Button(top, text="QUIT", fg="red",command=quit)
+    button5.pack(side=tk.LEFT)
+    top.pack(side="top", expand=True, fill="both")
+    # graph
+    self.serialPlot = Plot()
+    canvas = FigureCanvasTkAgg(self.serialPlot.fig, self)
+    canvas.draw()
+    canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
+    canvas._tkcanvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
+    # right menu
+    left = tk.Frame(self, borderwidth=2, relief="solid")
+    container = tk.Frame(left, borderwidth=2, relief="solid")
+    label1 = tk.Label(container, text="I could be a canvas, but I'm a label right now")
+
+    self.label4 = tk.Label(self,font=("Arial","30"),fg="red")
+    self.label4.pack()
+    self.label4.config(text=str(self.t))
+
+    SendButton = tk.Button(left, text='Quit', command=quit)
+    label2 = tk.Label(left, text="I could be a button")
+    label3 = tk.Label(left, text="So could I")
+
+    left.pack(side="left", expand=True, fill="both")
+    container.pack(expand=True, fill="both", padx=7, pady=5)
+    SendButton.pack()
+
+    label1.pack()
+    label2.pack()
+    label3.pack()
+
+  def update(self):
+    self.serialPlot.update(3)
+    self.label4.config(text="{:3d} Nm".format(3))

+ 12 - 0
software/ui/Page_2.py

@@ -0,0 +1,12 @@
+import tkinter as tk
+import tk_tools
+
+class Page_2(tk.Frame):
+  def __init__(self, parent, controller):
+    tk.Frame.__init__(self, parent)
+    label = tk.Label(self, text="Kräfte", font=LARGE_FONT)
+    label.pack(pady=10,padx=10)
+    button1 = tk.Button(self, text="Page_0", command=lambda: controller.show_frame(Page_0))
+    button1.pack()
+    button2 = tk.Button(self, text="Page_1", command=lambda: controller.show_frame(Page_1))
+    button2.pack()

+ 12 - 0
software/ui/Page_3.py

@@ -0,0 +1,12 @@
+import tkinter as tk
+import tk_tools
+
+class Page_3(tk.Frame):
+  def __init__(self, parent, controller):
+    tk.Frame.__init__(self, parent)
+    label = tk.Label(self, text="Druck", font=LARGE_FONT)
+    label.pack(pady=10,padx=10)
+    button1 = tk.Button(self, text="Page_0", command=lambda: controller.show_frame(Page_0))
+    button1.pack()
+    button2 = tk.Button(self, text="Page_1", command=lambda: controller.show_frame(Page_1))
+    button2.pack()

+ 12 - 0
software/ui/Page_4.py

@@ -0,0 +1,12 @@
+import tkinter as tk
+import tk_tools
+
+class Page_4(tk.Frame):
+  def __init__(self, parent, controller):
+    tk.Frame.__init__(self, parent)
+    label = tk.Label(self, text="Einstellungen", font=LARGE_FONT)
+    label.pack(pady=10,padx=10)
+    button1 = tk.Button(self, text="Page_0", command=lambda: controller.show_frame(Page_0))
+    button1.pack()
+    button2 = tk.Button(self, text="Page_1", command=lambda: controller.show_frame(Page_1))
+    button2.pack()

+ 24 - 0
software/ui/Plot.py

@@ -0,0 +1,24 @@
+import matplotlib
+from matplotlib.figure import Figure
+from matplotlib import style
+
+
+class Plot():
+  def __init__(self, n):
+    self.fig = Figure()
+    self.ax = self.fig.add_subplot(111)
+    self.xs = range(n)
+    self.ys = [0] * n
+    self.i = 0
+    self.n = n
+
+  def update(self, y):
+    # Add x and y to lists
+    ys[i] = y
+    i = i+1 if i+1 < self.n else 0
+
+
+    ax.clear()
+    ax.plot(xs, ys, "#00A3E0", label="1. Graph")
+    ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)
+    ax.set_title('Windkanal')

+ 7 - 0
software/ui/__init__.py

@@ -0,0 +1,7 @@
+from Page_1 import Page_1
+from Page_2 import Page_2
+from Page_3 import Page_3
+from Page_4 import Page_4
+from Plot import Plot
+
+__all__ = ["Page_1", "Page_2", "Page_3", "Page_4", "Plot"]

+ 0 - 187
software/ui/tkinter_windkanal.py

@@ -1,187 +0,0 @@
-# The code for changing pages was derived from: http://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter
-# License: http://creativecommons.org/licenses/by-sa/3.0/	
-
-import matplotlib
-from matplotlib.backends.backend_tkagg import (
-    FigureCanvasTkAgg, NavigationToolbar2Tk)
-from matplotlib.figure import Figure
-import matplotlib.animation as animation
-from matplotlib import style
-
-import tkinter as tk
-import tk_tools
-from time import *
-
-LARGE_FONT= ("Verdana", 12)
-style.use("ggplot")
-
-class Plot():
-    def __init__(self, n):
-        self.fig = Figure()
-        self.ax = self.fig.add_subplot(111)
-        self.xs = range(n)
-        self.ys = [0] * n
-        self.i = 0
-        self.n = n
-
-    def update(self, y):
-        # Add x and y to lists
-        ys[i] = y
-        i = i+1 if i+1 < self.n else 0
-
-
-        ax.clear()
-        ax.plot(xs, ys, "#00A3E0", label="1. Graph")
-        ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)
-        ax.set_title('Windkanal')
-
-        return self.fig
-       
-
-class Main(tk.Tk):
-    def __init__(self, *args, **kwargs):
-        tk.Tk.__init__(self, *args, **kwargs)
-        tk.Tk.wm_title(self, "Windkanal-Tool")
-        
-        
-        container = tk.Frame(self)
-        container.pack(side="top", fill="both", expand = True)
-        container.grid_rowconfigure(0, weight=1)
-        container.grid_columnconfigure(0, weight=1)
-
-
-        menubar = tk.Menu(container)
-        filemenu = tk.Menu(menubar, tearoff=0)
-        filemenu.add_command(label="Save settings", command = lambda: self.popupmsg("Not supported just yet!"))
-        filemenu.add_separator()
-        filemenu.add_command(label="Exit", command=quit)
-        menubar.add_cascade(label="File", menu=filemenu)
-
-        tk.Tk.config(self, menu=menubar)
-
-        self.frames = {}
-
-        for F in (Page_1, Page_2, Page_3, Page_4):
-
-            frame = F(container, self)
-
-            self.frames[F] = frame
-
-            frame.grid(row=0, column=0, sticky="nsew")
-
-        self.show_frame(Page_1)
-
-    def show_frame(self, cont):
-        frame = self.frames[cont]
-        frame.tkraise()
-
-    def popupmsg(self, msg=""):
-        popup = tk.Toplevel(self.master)
-        popup.wm_title("Error!")
-        label = tk.Label(popup, text=msg, font=LARGE_FONT)
-        label.pack(side="top", fill="x", pady=10)
-        b1 = tk.Button(popup, text="Okay", command=popup.destroy)
-        b1.pack()
-
-class Page_4(tk.Frame):
-    def __init__(self, parent, controller):
-        tk.Frame.__init__(self, parent)
-        label = tk.Label(self, text="Einstellungen", font=LARGE_FONT)
-        label.pack(pady=10,padx=10)
-        button1 = tk.Button(self, text="Page_0", command=lambda: controller.show_frame(Page_0))
-        button1.pack()
-        button2 = tk.Button(self, text="Page_1", command=lambda: controller.show_frame(Page_1))
-        button2.pack()
-
-class Page_3(tk.Frame):
-    def __init__(self, parent, controller):
-        tk.Frame.__init__(self, parent)
-        label = tk.Label(self, text="Druck", font=LARGE_FONT)
-        label.pack(pady=10,padx=10)
-        button1 = tk.Button(self, text="Page_0", command=lambda: controller.show_frame(Page_0))
-        button1.pack()
-        button2 = tk.Button(self, text="Page_1", command=lambda: controller.show_frame(Page_1))
-        button2.pack()
-
-class Page_2(tk.Frame):
-    def __init__(self, parent, controller):
-        tk.Frame.__init__(self, parent)
-        label = tk.Label(self, text="Kräfte", font=LARGE_FONT)
-        label.pack(pady=10,padx=10)
-        button1 = tk.Button(self, text="Page_0", command=lambda: controller.show_frame(Page_0))
-        button1.pack()
-        button2 = tk.Button(self, text="Page_1", command=lambda: controller.show_frame(Page_1))
-        button2.pack()
-
-
-
-class Page_1(tk.Frame):
-    def __init__(self, parent, controller):
-        tk.Frame.__init__(self, parent)
-        self.t = 0
-        label = tk.Label(self, text="Bedienelemente", font=LARGE_FONT)
-        label.pack(pady=10,padx=10)
-        # top menu
-        top = tk.Frame(self, borderwidth=2, relief="solid")
-        button1 = tk.Button(top, text="Bedienelemente", command=lambda: controller.show_frame(Page_0))
-        button1.pack(side=tk.LEFT)
-
-        button2 = tk.Button(top, text="Kräfte", command=lambda: controller.show_frame(Page_2))
-        button2.pack(side=tk.LEFT)
-
-        button3 = tk.Button(top, text="Druck", command=lambda: controller.show_frame(Page_2))
-        button3.pack(side=tk.LEFT)
-
-        button4 = tk.Button(top,text="Einstellungen",command=lambda: controller.show_frame(Page_2))
-        button4.pack(side=tk.LEFT)
-
-        button5 = tk.Button(top, text="QUIT", fg="red",command=quit)
-        button5.pack(side=tk.LEFT)
-        top.pack(side="top", expand=True, fill="both")
-        # graph
-        self.serialPlot = Plot()
-        canvas = FigureCanvasTkAgg(self.serialPlot.fig, self)
-        canvas.draw()
-        canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
-        canvas._tkcanvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
-        # right menu
-        left = tk.Frame(self, borderwidth=2, relief="solid")
-        container = tk.Frame(left, borderwidth=2, relief="solid")
-        label1 = tk.Label(container, text="I could be a canvas, but I'm a label right now")
-
-        self.label4 = tk.Label(self,font=("Arial","30"),fg="red")
-        self.label4.pack()
-        self.label4.config(text=str(self.t))
-
-        SendButton = tk.Button(left, text='Quit', command=quit)
-        label2 = tk.Label(left, text="I could be a button")
-        label3 = tk.Label(left, text="So could I")
-
-        left.pack(side="left", expand=True, fill="both")
-        container.pack(expand=True, fill="both", padx=7, pady=5)
-        SendButton.pack()
-
-        label1.pack()
-        label2.pack()
-        label3.pack()
-
-        self.after(100,self.interval)
-
-    def interval(self):
-        
-
-
-        self.serialPlot.update(3)
-
-        self.label4.config(text="{:3d} Nm".format(3))
-            
-        self.after(100,self.interval)
-
-
-    def sendFactorToMCU(self):
-        self.serialReference.sendSerialData(self.entry.get() + '%')
-
-
-app = Main()
-app.geometry("1280x720")
-app.mainloop()