|
@@ -1,17 +1,18 @@
|
|
|
from idlelib.colorizer import color_config
|
|
|
from logging import disable
|
|
|
-from tkinter import *
|
|
|
-import tkinter as tk
|
|
|
+from tkinter import Tk, Label, Entry, Button, Spinbox, StringVar, BOTTOM, LEFT, SOLID, EW, END
|
|
|
from tkinter import ttk
|
|
|
from tkinter import filedialog
|
|
|
from tkinter.ttk import Combobox
|
|
|
from matplotlib.figure import Figure
|
|
|
-from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)
|
|
|
+from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
|
|
+from matplotlib.backends._backend_tk import NavigationToolbar2Tk
|
|
|
from random import choice
|
|
|
import matplotlib.pyplot as plt
|
|
|
import matplotlib
|
|
|
import matplotlib.animation as animation
|
|
|
import numpy as np
|
|
|
+import time
|
|
|
import os
|
|
|
from matplotlib.animation import FuncAnimation
|
|
|
import tkinter as tk
|
|
@@ -28,19 +29,20 @@ class Interface():
|
|
|
Interface.window.geometry('500x250+100+100')
|
|
|
photo = tk.PhotoImage(file='iconka.png')
|
|
|
Interface.window.iconphoto(False, photo)
|
|
|
- self.f_top = ttk.LabelFrame(Interface.window, text="Виртуальный COM порт", relief=SOLID, padding=[8, 10])
|
|
|
+ self.f_top = ttk.LabelFrame(Interface.window, text="Виртуальный COM порт", relief=SOLID, padding=(8, 10))
|
|
|
self.combo = Combobox(self.f_top)
|
|
|
self.combo['values'] = (1, 2, 3, 4, 5)
|
|
|
self.combo.current(4)
|
|
|
self.f_top.grid(column=0, row=0)
|
|
|
self.combo.pack(side=BOTTOM)
|
|
|
- self.f_file = ttk.LabelFrame(Interface.window, text="Выбрать файл txt для записи", relief=SOLID, padding=[8, 10])
|
|
|
+ self.f_file = ttk.LabelFrame(Interface.window, text="Выбрать файл txt для записи", relief=SOLID,
|
|
|
+ padding=(8, 10))
|
|
|
self.f_file.grid(column=1, row=0)
|
|
|
self.txt = Entry(self.f_file, width=40)
|
|
|
self.txt.pack(side=LEFT)
|
|
|
self.btn = Button(self.f_file, height=1, text='Файл', bg="gray", fg="red", command=self.clicked_file)
|
|
|
self.btn.pack(side=LEFT)
|
|
|
- self.f_start = ttk.Frame(Interface.window, relief=SOLID, padding=[8, 10])
|
|
|
+ self.f_start = ttk.Frame(Interface.window, relief=SOLID, padding=(8, 10))
|
|
|
self.t1 = Label(self.f_start, text="Состояние работы", fg="black")
|
|
|
self.t2 = Label(self.f_start, text="Начать сбор данных", fg="black")
|
|
|
self.t3 = Label(self.f_start, text="Остановить сбор данных", fg="black")
|
|
@@ -48,9 +50,9 @@ class Interface():
|
|
|
self.button_start = Button(self.f_start, text="Пуск", bg="lightgray", fg="black", command=self.clicked_start1)
|
|
|
self.button_startoff = Button(self.f_start, text="Стоп", bg="lightgray", fg="red",
|
|
|
command=self.clicked_start2,
|
|
|
- state=['disabled'])
|
|
|
- self.f_start1= ttk.LabelFrame(Interface.window, text='Принятые символы', relief=SOLID, padding=[8, 10])
|
|
|
- self.t_entry = Entry(self.f_start1, width=40)
|
|
|
+ state='disabled')
|
|
|
+ self.f_start1 = ttk.LabelFrame(Interface.window, text='Принятые символы', relief=SOLID, padding=(8, 10))
|
|
|
+ self.t_entry = Entry(self.f_start1, width=40, state=['disable'])
|
|
|
self.f_start.grid(column=2, row=0)
|
|
|
self.f_start1.grid(column=3, row=0)
|
|
|
self.t1.grid(column=0, row=0)
|
|
@@ -62,32 +64,32 @@ class Interface():
|
|
|
self.button_startoff.grid(column=2, row=1)
|
|
|
|
|
|
def create_widgets_W(self):
|
|
|
- self.f_W = ttk.Frame(Interface.window, relief=SOLID, padding=[8, 10])
|
|
|
+ self.f_W = ttk.Frame(Interface.window, relief=SOLID, padding=(8, 10))
|
|
|
self.f_W.grid(column=0, row=1)
|
|
|
self.tspin1 = Label(self.f_W, text="Время экспозиции, с", fg="black")
|
|
|
self.tspin2 = Label(self.f_W, text="Макс. время сбора данных, с", fg="black")
|
|
|
self.tspin3 = Label(self.f_W, text="Прошло времени, с", fg="black")
|
|
|
self.spin1 = Spinbox(self.f_W, from_=0, to=100, width=7)
|
|
|
self.spin2 = Spinbox(self.f_W, from_=0, to=10000000, increment=500, width=11)
|
|
|
- self.t_entry = Entry(self.f_W, width=20, state=['disabled'])
|
|
|
+ self.t_entry = Entry(self.f_W, width=20, state='disabled')
|
|
|
self.tspin1.grid(column=0, row=0, ipadx=10)
|
|
|
self.spin1.grid(column=0, row=1, pady=10)
|
|
|
self.tspin2.grid(column=0, row=2, ipadx=10)
|
|
|
self.spin2.grid(column=0, row=3, pady=10)
|
|
|
self.tspin3.grid(column=0, row=4, pady=10)
|
|
|
self.t_entry.grid(column=0, row=5)
|
|
|
- self.f_W1 = ttk.Frame(Interface.window, relief=SOLID, padding=[8, 10])
|
|
|
+ self.f_W1 = ttk.Frame(Interface.window, relief=SOLID, padding=(8, 10))
|
|
|
self.f_W1.grid(column=0, row=2)
|
|
|
self.tspin_0 = Label(self.f_W1, text="Коэффициент делителя", fg="black")
|
|
|
self.spin_0 = Spinbox(self.f_W1, from_=0, to=100, width=7)
|
|
|
self.tspin_0.grid(column=0, row=0, ipadx=10)
|
|
|
self.spin_0.grid(column=0, row=1, pady=10)
|
|
|
- self.f_W2 = ttk.Frame(Interface.window, relief=SOLID, padding=[8, 10])
|
|
|
+ self.f_W2 = ttk.Frame(Interface.window, relief=SOLID, padding=(8, 10))
|
|
|
self.f_W2.grid(column=0, row=3)
|
|
|
self.spin1_zap = Spinbox(self.f_W2, from_=0.0, to=50.0, increment=0.1, width=6)
|
|
|
self.spin2_zap = Spinbox(self.f_W2, from_=0, to=100, increment=1, width=6)
|
|
|
self.spin3_zap = Spinbox(self.f_W2, from_=0, to=500, width=6)
|
|
|
- self.spin4_zap = Spinbox(self.f_W2, from_=0, to=500 , width=6)
|
|
|
+ self.spin4_zap = Spinbox(self.f_W2, from_=0, to=500, width=6)
|
|
|
self.tspin1_zap = Label(self.f_W2, text="ЦАП канал 1.0...3.29В", fg="black")
|
|
|
self.tspin2_zap = Label(self.f_W2, text="ЦАП канал 2.0...3.29В", fg="black")
|
|
|
self.tspin3_zap = Label(self.f_W2, text="ЦАП канал 3.1...256", fg="black")
|
|
@@ -96,7 +98,7 @@ class Interface():
|
|
|
каналов DAC''', fg="black")
|
|
|
self.tbut2_zap = Label(self.f_W2, text='''Прочесть текущее
|
|
|
значение каналов DAC''', fg="black")
|
|
|
- self.button1_zap= Button(self.f_W2, text="Обновить", bg="lightgray", fg="black")
|
|
|
+ self.button1_zap = Button(self.f_W2, text="Обновить", bg="lightgray", fg="black")
|
|
|
self.button2_zap = Button(self.f_W2, text="Прочесть", bg="lightgray", fg="black")
|
|
|
self.tspin1_zap.grid(column=0, row=0, ipadx=10)
|
|
|
self.spin1_zap.grid(column=0, row=1, pady=10)
|
|
@@ -110,7 +112,7 @@ class Interface():
|
|
|
self.button1_zap.grid(column=0, row=9)
|
|
|
self.tbut2_zap.grid(column=0, row=10)
|
|
|
self.button2_zap.grid(column=0, row=11)
|
|
|
- self.f_W3 = ttk.Frame(Interface.window, relief=SOLID, padding=[8, 10])
|
|
|
+ self.f_W3 = ttk.Frame(Interface.window, relief=SOLID, padding=(8, 10))
|
|
|
self.txt0_fw3 = Label(self.f_W3, text="Порт В1 напряжения", fg="black")
|
|
|
self.txt1_fw3 = Label(self.f_W3, text=" 0 B ", fg="black", bg="pink")
|
|
|
self.m = ' 0 B '
|
|
@@ -123,8 +125,6 @@ class Interface():
|
|
|
self.txt2_fw3.grid(column=0, row=2)
|
|
|
self.but_fw3.grid(column=0, row=3)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
def create_Figure(self):
|
|
|
self.file1 = open('coordinates.txt', 'r')
|
|
|
with self.file1 as f:
|
|
@@ -155,11 +155,10 @@ class Interface():
|
|
|
return self.line,
|
|
|
|
|
|
self.ani = FuncAnimation(self.fig, update, frames=len(self.xdata),
|
|
|
- init_func=init, blit=True, interval=5, repeat=False)
|
|
|
+ init_func=init, blit=True, interval=5, repeat=False)
|
|
|
|
|
|
-
|
|
|
- Interface.window.after(100, None)
|
|
|
- self.f_grafbtn = ttk.LabelFrame(self.f_graf, text='Время отоброжения', padding=[8, 10])
|
|
|
+ Interface.window.after(100, lambda: None)
|
|
|
+ self.f_grafbtn = ttk.LabelFrame(self.f_graf, text='Время отоброжения', padding=(8, 10))
|
|
|
self.f_grafbtn.grid(column=1, row=0)
|
|
|
self.tgrafsp = Label(self.f_grafbtn, text="Начало времени, с", fg="black")
|
|
|
self.tgrafsp.grid(column=0, row=0)
|
|
@@ -167,17 +166,15 @@ class Interface():
|
|
|
self.grafspin.grid(column=0, row=1)
|
|
|
self.t1grafbtn = Label(self.f_grafbtn, text="Выбор конца времени", fg="black")
|
|
|
self.t1grafbtn.grid(column=0, row=2)
|
|
|
- self.button_time1 = Button(self.f_grafbtn, text="start",
|
|
|
- bg="lightgray", fg="black", command=self.clicked_time, state=['disabled'])
|
|
|
+ self.button_time1 = Button(self.f_grafbtn, text="Текущее время",
|
|
|
+ bg="lightgray", fg="black", command=self.clicked_time, state=['disable'])
|
|
|
self.button_time1.grid(column=0, row=3, sticky=EW)
|
|
|
self.tgrafsp1 = Label(self.f_grafbtn, text="Конец времени, с", fg="black")
|
|
|
self.tgrafsp1.grid(column=0, row=4)
|
|
|
self.Time_flag = 'disabled'
|
|
|
- self.spinbox_varTime = StringVar(value=100)
|
|
|
- self.grafspin1 = Spinbox(self.f_grafbtn, from_=100, to=50000, increment=100, width=7,
|
|
|
- textvariable=self.spinbox_varTime, state=[self.Time_flag])
|
|
|
+ self.grafspin1 = Entry(self.f_grafbtn, width=7,state=self.Time_flag)
|
|
|
self.grafspin1.grid(column=0, row=5)
|
|
|
- self.spinbox_var1 = StringVar(value=0)
|
|
|
+ self.spinbox_var1 = StringVar(value=str(0))
|
|
|
self.tgrafspTmin = Label(self.f_grafbtn, text="Нижняя граница, имп/с", fg="black")
|
|
|
self.tgrafspTmin.grid(column=0, row=6)
|
|
|
self.grafspinTmin = Spinbox(self.f_grafbtn, from_=0, to=5000,
|
|
@@ -185,7 +182,7 @@ class Interface():
|
|
|
self.grafspinTmin.grid(column=0, row=7)
|
|
|
self.tgrafspTmax = Label(self.f_grafbtn, text="Верхняя граница, имп/с", fg="black")
|
|
|
self.tgrafspTmax.grid(column=0, row=8)
|
|
|
- self.spinbox_var2 = StringVar(value=10000)
|
|
|
+ self.spinbox_var2 = StringVar(value=str(10000))
|
|
|
self.grafspinTmax = Spinbox(self.f_grafbtn, from_=5000, to=10000, increment=500,
|
|
|
textvariable=self.spinbox_var2, width=7)
|
|
|
self.grafspinTmax.grid(column=0, row=9)
|
|
@@ -197,7 +194,7 @@ class Interface():
|
|
|
self.ADC_data = [line.strip().split() for line in self.ADC_lines]
|
|
|
self.ADC_xdata, self.ADC_ydata = zip(*[(float(x), float(y)) for x, y in self.ADC_data])
|
|
|
self.f_graf_ADC = ttk.LabelFrame(Interface.window,
|
|
|
- text='АЦП канал 1, В', relief=SOLID)
|
|
|
+ text='АЦП канал 1, В', relief=SOLID)
|
|
|
self.f_graf_ADC.grid(column=3, row=1, columnspan=2, rowspan=2)
|
|
|
self.fig_ADC = Figure(figsize=(7, 4), dpi=80)
|
|
|
self.ax_ADC = self.fig_ADC.add_subplot(111)
|
|
@@ -220,11 +217,10 @@ class Interface():
|
|
|
return self.ADC_line,
|
|
|
|
|
|
self.ADC_ani = FuncAnimation(self.fig_ADC, update, frames=len(self.ADC_xdata),
|
|
|
- init_func=init, blit=True, interval=5, repeat=False)
|
|
|
-
|
|
|
+ init_func=init, blit=True, interval=5, repeat=False)
|
|
|
|
|
|
- Interface.window.after(100, None)
|
|
|
- self.f_grafbtnADC = ttk.LabelFrame(self.f_graf_ADC, text='Время отоброжения', padding=[8, 10])
|
|
|
+ Interface.window.after(100, lambda: None)
|
|
|
+ self.f_grafbtnADC = ttk.LabelFrame(self.f_graf_ADC, text='Время отоброжения', padding=(8, 10))
|
|
|
self.f_grafbtnADC.grid(column=1, row=0)
|
|
|
self.tgrafspADC = Label(self.f_grafbtnADC, text="Начало времени, с", fg="black")
|
|
|
self.tgrafspADC.grid(column=0, row=0)
|
|
@@ -232,27 +228,25 @@ class Interface():
|
|
|
self.grafspinADC.grid(column=0, row=1)
|
|
|
self.t1grafbtnADC = Label(self.f_grafbtnADC, text="Выбор конца времени", fg="black")
|
|
|
self.t1grafbtnADC.grid(column=0, row=2)
|
|
|
- self.button_time1ADC = Button(self.f_grafbtnADC, text="start",
|
|
|
- bg="lightgray", fg="black", command=self.clicked_timeADC, state=['disabled'])
|
|
|
+ self.button_time1ADC = Button(self.f_grafbtnADC, text="Текущее время",
|
|
|
+ bg="lightgray", fg="black", command=self.clicked_timeADC, state=['disable'])
|
|
|
self.button_time1ADC.grid(column=0, row=3, sticky=EW)
|
|
|
self.tgrafsp1ADC = Label(self.f_grafbtnADC, text="Конец времени, с", fg="black")
|
|
|
self.tgrafsp1ADC.grid(column=0, row=4)
|
|
|
self.Time_flagADC = 'disabled'
|
|
|
- self.spinbox_varTimeADC = StringVar(value=100)
|
|
|
- self.grafspin1ADC = Spinbox(self.f_grafbtnADC, from_=100, to=50000, increment=100, width=7,
|
|
|
- textvariable=self.spinbox_varTimeADC, state=[self.Time_flagADC])
|
|
|
+ self.grafspin1ADC = Entry(self.f_grafbtnADC, width=7, state=self.Time_flagADC)
|
|
|
self.grafspin1ADC.grid(column=0, row=5)
|
|
|
- self.spinbox_var1ADC = StringVar(value=0)
|
|
|
+ self.spinbox_var1ADC = StringVar(value=str(0))
|
|
|
self.tgrafspTminADC = Label(self.f_grafbtnADC, text="Нижняя граница, В", fg="black")
|
|
|
self.tgrafspTminADC.grid(column=0, row=6)
|
|
|
self.grafspinTminADC = Spinbox(self.f_grafbtnADC, from_=0, to=5000,
|
|
|
- textvariable=self.spinbox_var1ADC, increment=500, width=7)
|
|
|
+ textvariable=self.spinbox_var1ADC, increment=500, width=7)
|
|
|
self.grafspinTminADC.grid(column=0, row=7)
|
|
|
self.tgrafspTmaxADC = Label(self.f_grafbtnADC, text="Верхняя граница, В", fg="black")
|
|
|
self.tgrafspTmaxADC.grid(column=0, row=8)
|
|
|
- self.spinbox_var2ADC = StringVar(value=10000)
|
|
|
+ self.spinbox_var2ADC = StringVar(value=str(10000))
|
|
|
self.grafspinTmaxADC = Spinbox(self.f_grafbtnADC, from_=5000, to=10000, increment=500,
|
|
|
- textvariable=self.spinbox_var2ADC, width=7)
|
|
|
+ textvariable=self.spinbox_var2ADC, width=7)
|
|
|
self.grafspinTmaxADC.grid(column=0, row=9)
|
|
|
|
|
|
def TEM_create_Figure(self):
|
|
@@ -262,7 +256,7 @@ class Interface():
|
|
|
self.TEM_data = [line.strip().split() for line in self.TEM_lines]
|
|
|
self.TEM_xdata, self.TEM_ydata = zip(*[(float(x), float(y)) for x, y in self.TEM_data])
|
|
|
self.f_graf_TEM = ttk.LabelFrame(Interface.window,
|
|
|
- text='Температура, С', relief=SOLID)
|
|
|
+ text='Температура, С', relief=SOLID)
|
|
|
self.f_graf_TEM.grid(column=1, row=3, columnspan=2, rowspan=2)
|
|
|
self.fig_TEM = Figure(figsize=(7, 4), dpi=80)
|
|
|
self.ax_TEM = self.fig_TEM.add_subplot(111)
|
|
@@ -285,11 +279,10 @@ class Interface():
|
|
|
return self.TEM_line,
|
|
|
|
|
|
self.TEM_ani = FuncAnimation(self.fig_TEM, update, frames=len(self.TEM_xdata),
|
|
|
- init_func=init, blit=True, interval=5, repeat=False)
|
|
|
-
|
|
|
+ init_func=init, blit=True, interval=5, repeat=False)
|
|
|
|
|
|
- Interface.window.after(100, None)
|
|
|
- self.f_grafbtnTEM = ttk.LabelFrame(self.f_graf_TEM, text='Время отоброжения', padding=[8, 10])
|
|
|
+ Interface.window.after(100, lambda: None)
|
|
|
+ self.f_grafbtnTEM = ttk.LabelFrame(self.f_graf_TEM, text='Время отоброжения', padding=(8, 10))
|
|
|
self.f_grafbtnTEM.grid(column=1, row=0)
|
|
|
self.tgrafspTEM = Label(self.f_grafbtnTEM, text="Начало времени, с", fg="black")
|
|
|
self.tgrafspTEM.grid(column=0, row=0)
|
|
@@ -297,27 +290,25 @@ class Interface():
|
|
|
self.grafspinTEM.grid(column=0, row=1)
|
|
|
self.t1grafbtnTEM = Label(self.f_grafbtnTEM, text="Выбор конца времени", fg="black")
|
|
|
self.t1grafbtnTEM.grid(column=0, row=2)
|
|
|
- self.button_time1TEM = Button(self.f_grafbtnTEM, text="start",
|
|
|
- bg="lightgray", fg="black", command=self.clicked_timeTEM, state=['disabled'])
|
|
|
+ self.button_time1TEM = Button(self.f_grafbtnTEM, text="Текущее время",
|
|
|
+ bg="lightgray", fg="black", command=self.clicked_timeTEM, state=['disable'])
|
|
|
self.button_time1TEM.grid(column=0, row=3, sticky=EW)
|
|
|
self.tgrafsp1TEM = Label(self.f_grafbtnTEM, text="Конец времени, с", fg="black")
|
|
|
self.tgrafsp1TEM.grid(column=0, row=4)
|
|
|
self.Time_flagTEM = 'disabled'
|
|
|
- self.spinbox_varTimeTEM = StringVar(value=100)
|
|
|
- self.grafspin1TEM = Spinbox(self.f_grafbtnTEM, from_=100, to=50000, increment=100, width=7,
|
|
|
- textvariable=self.spinbox_varTimeTEM, state=[self.Time_flagTEM])
|
|
|
+ self.grafspin1TEM = Entry(self.f_grafbtnTEM, width=7, state=self.Time_flagTEM)
|
|
|
self.grafspin1TEM.grid(column=0, row=5)
|
|
|
- self.spinbox_var1TEM = StringVar(value=0)
|
|
|
+ self.spinbox_var1TEM = StringVar(value=str(0))
|
|
|
self.tgrafspTminTEM = Label(self.f_grafbtnTEM, text="Нижняя граница, С", fg="black")
|
|
|
self.tgrafspTminTEM.grid(column=0, row=6)
|
|
|
self.grafspinTminTEM = Spinbox(self.f_grafbtnTEM, from_=0, to=5000,
|
|
|
- textvariable=self.spinbox_var1TEM, increment=500, width=7)
|
|
|
+ textvariable=self.spinbox_var1TEM, increment=500, width=7)
|
|
|
self.grafspinTminTEM.grid(column=0, row=7)
|
|
|
self.tgrafspTmaxTEM = Label(self.f_grafbtnTEM, text="Верхняя граница, С", fg="black")
|
|
|
self.tgrafspTmaxTEM.grid(column=0, row=8)
|
|
|
- self.spinbox_var2TEM = StringVar(value=10000)
|
|
|
+ self.spinbox_var2TEM = StringVar(value=str(10000))
|
|
|
self.grafspinTmaxTEM = Spinbox(self.f_grafbtnTEM, from_=5000, to=10000, increment=500,
|
|
|
- textvariable=self.spinbox_var2TEM, width=7)
|
|
|
+ textvariable=self.spinbox_var2TEM, width=7)
|
|
|
self.grafspinTmaxTEM.grid(column=0, row=9)
|
|
|
|
|
|
def start(self):
|
|
@@ -328,26 +319,84 @@ class Interface():
|
|
|
self.ADC_create_Figure()
|
|
|
self.TEM_create_Figure()
|
|
|
self.block_control()
|
|
|
+ #scrollbar = ttk.Scrollbar(Interface.window, orient='vertical')
|
|
|
+ #scrollbar.grid(column=5, row=0, rowspan=3, padx=50)
|
|
|
Interface.window.mainloop()
|
|
|
|
|
|
def clicked_file(self):
|
|
|
- self.file1 = filedialog.askopenfile(filetypes=(("Text files","*.txt"),("all files","*.*")))
|
|
|
+ self.file1 = filedialog.askopenfile(filetypes=(("Text files", "*.txt"), ("all files", "*.*")))
|
|
|
+ assert self.file1 is not None
|
|
|
+
|
|
|
self.file = os.path.abspath(self.file1.name)
|
|
|
self.txt.delete(0, END)
|
|
|
self.txt.insert(0, self.file)
|
|
|
|
|
|
def clicked_start1(self):
|
|
|
- self.button_start.configure(state=["disabled"])
|
|
|
+ self.button_start.configure(state="disabled")
|
|
|
self.t4.configure(text="Включено", bg="black", fg="green")
|
|
|
- self.button_startoff.configure(state=["active"])
|
|
|
+ self.button_startoff.configure(state="active")
|
|
|
+ self.seconds1 = time.time()
|
|
|
+ self.clicked_time()
|
|
|
+ self.clicked_timeADC()
|
|
|
+ self.clicked_timeTEM()
|
|
|
+
|
|
|
+
|
|
|
|
|
|
def clicked_start2(self):
|
|
|
- self.button_start.configure(state=["active"])
|
|
|
+ self.seconds2 = time.time()
|
|
|
+ self.button_start.configure(state="active")
|
|
|
self.t4.configure(text="Выключено", bg="black", fg="white")
|
|
|
- self.button_startoff.configure(state=['disabled'])
|
|
|
+ self.button_startoff.configure(state='disabled')
|
|
|
+ self.grafspin1.configure(state="normal")
|
|
|
+ self.grafspin1ADC.configure(state="normal")
|
|
|
+ self.grafspin1TEM.configure(state="normal")
|
|
|
+ self.IMP_entry.configure(state="normal")
|
|
|
+ self.ADC_entry.configure(state="normal")
|
|
|
+ self.TEM_entry.configure(state="normal")
|
|
|
+ if self.ani is not None:
|
|
|
+ self.ani.event_source.stop()
|
|
|
+ self.ani = None
|
|
|
+ if self.ADC_ani is not None:
|
|
|
+ self.ADC_ani.event_source.stop()
|
|
|
+ self.ADC_ani = None
|
|
|
+ if self.TEM_ani is not None:
|
|
|
+ self.TEM_ani.event_source.stop()
|
|
|
+ self.TEM_ani = None
|
|
|
+ if self.ani1 is not None:
|
|
|
+ self.ani1.event_source.stop()
|
|
|
+ self.ani1 = None
|
|
|
+ if self.ADC_ani1 is not None:
|
|
|
+ self.ADC_ani1.event_source.stop()
|
|
|
+ self.ADC_ani1 = None
|
|
|
+ if self.TEM_ani1 is not None:
|
|
|
+ self.TEM_ani1.event_source.stop()
|
|
|
+ self.TEM_ani1 = None
|
|
|
+
|
|
|
+ self.indexxx = (self.seconds2 - self.seconds1)
|
|
|
+ self.grafspin1.delete(0, last=END)
|
|
|
+ self.grafspin1.insert(0, str(self.xdata[round(self.indexxx * 5)]))
|
|
|
+ self.grafspin1ADC.delete(0, last=END)
|
|
|
+ self.grafspin1ADC.insert(0, str(self.ADC_xdata[round(self.indexxx * 5)]))
|
|
|
+ self.grafspin1TEM.delete(0, last=END)
|
|
|
+ self.grafspin1TEM.insert(0, str(self.TEM_xdata[round(self.indexxx * 5)]))
|
|
|
+
|
|
|
+ self.IMP_entry.delete(0, last=END)
|
|
|
+ self.IMP_entry.insert(0, str(round(self.ydata[round(self.indexxx * 5)])))
|
|
|
+ self.ADC_entry.delete(0, last=END)
|
|
|
+ self.ADC_entry.insert(0, str(round(self.ADC_ydata[round(self.indexxx * 5)])))
|
|
|
+ self.TEM_entry.delete(0, last=END)
|
|
|
+ self.TEM_entry.insert(0, str(round(self.TEM_ydata[round(self.indexxx * 5)])))
|
|
|
+
|
|
|
+ self.grafspin1.configure(state="disabled")
|
|
|
+ self.grafspin1ADC.configure(state="disabled")
|
|
|
+ self.grafspin1TEM.configure(state="disabled")
|
|
|
+ self.IMP_entry.configure(state="disabled")
|
|
|
+ self.ADC_entry.configure(state="disabled")
|
|
|
+ self.TEM_entry.configure(state="disabled")
|
|
|
+
|
|
|
|
|
|
def clicked_V(self):
|
|
|
- if self.m == " 0 B ":
|
|
|
+ if self.m == " 0 B ":
|
|
|
self.m = ' 3.3 B '
|
|
|
self.txt1_fw3.configure(text=' 3.3 B ')
|
|
|
self.but_fw3.configure(text="--->")
|
|
@@ -360,149 +409,142 @@ class Interface():
|
|
|
if self.ani is not None:
|
|
|
self.ani.event_source.stop()
|
|
|
self.ani = None
|
|
|
- if self.Time_flag == 'disabled':
|
|
|
- self.Time_flag = 'normal'
|
|
|
- self.grafspin1.configure(state=[self.Time_flag])
|
|
|
- else:
|
|
|
- self.file1 = open(self.file, 'r')
|
|
|
- self.Time_flag = 'disabled'
|
|
|
- self.grafspin1.configure(state=[self.Time_flag])
|
|
|
- with self.file1 as f:
|
|
|
- self.lines = f.readlines()
|
|
|
-
|
|
|
- self.data = [line.strip().split() for line in self.lines]
|
|
|
- self.xdata, self.ydata = zip(*[(float(x), float(y)) for x, y in self.data])
|
|
|
- max_time = self.grafspin1.get()
|
|
|
- min_time = self.grafspin.get()
|
|
|
- self.xdata = list(filter(lambda x: x <= int(max_time), self.xdata))
|
|
|
- self.xdata = list(filter(lambda x: x >= int(min_time), self.xdata))
|
|
|
- self.ax.clear()
|
|
|
- self.ax.set_xlabel('Время, с')
|
|
|
- self.ax.set_ylabel('Импульсы')
|
|
|
- self.ax.grid(color='black', linewidth=1.0)
|
|
|
- self.ax.set_xlim(min(self.xdata), 3000)
|
|
|
- self.ax.set_ylim(int(self.spinbox_var1.get()),
|
|
|
- int(self.spinbox_var2.get()))
|
|
|
- self.line, = self.ax.plot([], [], 'ro-')
|
|
|
-
|
|
|
- def init1():
|
|
|
- self.line.set_data([], [])
|
|
|
- return self.line,
|
|
|
-
|
|
|
- def update1(frame):
|
|
|
- self.line.set_data(self.xdata[:frame], self.ydata[:frame])
|
|
|
- return self.line,
|
|
|
-
|
|
|
- self.ani1 = FuncAnimation(self.fig, update1, frames=len(self.xdata),
|
|
|
- init_func=init1, blit=True, interval=5, repeat=False)
|
|
|
-
|
|
|
- self.canvas.draw()
|
|
|
- Interface.window.after(10, None)
|
|
|
+
|
|
|
+ self.file1 = open(self.file, 'r')
|
|
|
+ with self.file1 as f:
|
|
|
+ self.lines = f.readlines()
|
|
|
+
|
|
|
+ self.data = [line.strip().split() for line in self.lines]
|
|
|
+ self.xdata, self.ydata = zip(*[(float(x), float(y) + 100 * (-1) ** (round(float(y)) % 2)) for x, y in self.data])
|
|
|
+ min_time = self.grafspin.get()
|
|
|
+ self.xdata = list(filter(lambda x: x >= int(min_time), self.xdata))
|
|
|
+ self.ax.clear()
|
|
|
+ self.ax.set_xlabel('Время, с')
|
|
|
+ self.ax.set_ylabel('Импульсы')
|
|
|
+ self.ax.grid(color='black', linewidth=1.0)
|
|
|
+ self.ax.set_xlim(min(self.xdata), 3000)
|
|
|
+ self.ax.set_ylim(int(self.spinbox_var1.get()),
|
|
|
+ int(self.spinbox_var2.get()))
|
|
|
+ self.line, = self.ax.plot([], [], 'ro-')
|
|
|
+
|
|
|
+ def init1():
|
|
|
+ self.line.set_data([], [])
|
|
|
+ return self.line,
|
|
|
+
|
|
|
+ def update1(frame):
|
|
|
+ self.line.set_data(self.xdata[:frame], self.ydata[:frame])
|
|
|
+ return self.line,
|
|
|
+
|
|
|
+ self.ani1 = FuncAnimation(self.fig, update1, frames=len(self.xdata),
|
|
|
+ init_func=init1, blit=True, interval=200, repeat=False)
|
|
|
+
|
|
|
+ self.canvas.draw()
|
|
|
+ Interface.window.after(10, lambda: None)
|
|
|
+
|
|
|
|
|
|
def clicked_timeADC(self):
|
|
|
if self.ADC_ani is not None:
|
|
|
self.ADC_ani.event_source.stop()
|
|
|
self.ADC_ani = None
|
|
|
- if self.Time_flagADC == 'disabled':
|
|
|
- self.Time_flagADC = 'normal'
|
|
|
- self.grafspin1ADC.configure(state=[self.Time_flagADC])
|
|
|
- else:
|
|
|
- self.ADC_file1 = open(self.file, 'r')
|
|
|
- self.Time_flagADC = 'disabled'
|
|
|
- self.grafspin1.configure(state=[self.Time_flagADC])
|
|
|
- with self.ADC_file1 as f:
|
|
|
- self.ADC_lines = f.readlines()
|
|
|
-
|
|
|
- self.ADC_data = [line.strip().split() for line in self.ADC_lines]
|
|
|
- self.ADC_xdata, self.ADC_ydata = zip(*[(float(x), float(y)) for x, y in self.ADC_data])
|
|
|
- max_time = self.grafspin1ADC.get()
|
|
|
- min_time = self.grafspinADC.get()
|
|
|
- self.ADC_xdata = list(filter(lambda x: x <= int(max_time), self.ADC_xdata))
|
|
|
- self.ADC_xdata = list(filter(lambda x: x >= int(min_time), self.ADC_xdata))
|
|
|
- self.ax_ADC.clear()
|
|
|
- self.ax_ADC.set_xlabel('Время, с')
|
|
|
- self.ax_ADC.set_ylabel('Напряжение, В')
|
|
|
- self.ax_ADC.grid(color='black', linewidth=1.0)
|
|
|
- self.ax_ADC.set_xlim(min(self.ADC_xdata), 3000)
|
|
|
- self.ax_ADC.set_ylim(int(self.spinbox_var1ADC.get()),
|
|
|
- int(self.spinbox_var2ADC.get()))
|
|
|
- self.ADC_line, = self.ax_ADC.plot([], [], 'ro-')
|
|
|
-
|
|
|
- def init1():
|
|
|
- self.ADC_line.set_data([], [])
|
|
|
- return self.ADC_line,
|
|
|
-
|
|
|
- def update1(frame):
|
|
|
- self.ADC_line.set_data(self.ADC_xdata[:frame], self.ADC_ydata[:frame])
|
|
|
- return self.ADC_line,
|
|
|
-
|
|
|
- self.ADC_ani1 = FuncAnimation(self.fig_ADC, update1, frames=len(self.ADC_xdata),
|
|
|
- init_func=init1, blit=True, interval=5, repeat=False)
|
|
|
-
|
|
|
- self.canvas_ADC.draw()
|
|
|
- Interface.window.after(10, None)
|
|
|
+
|
|
|
+ self.ADC_file1 = open(self.file, 'r')
|
|
|
+ self.Time_flagADC = 'disabled'
|
|
|
+ self.grafspin1.configure(state=self.Time_flagADC)
|
|
|
+ with self.ADC_file1 as f:
|
|
|
+ self.ADC_lines = f.readlines()
|
|
|
+
|
|
|
+ self.ADC_data = [line.strip().split() for line in self.ADC_lines]
|
|
|
+ self.ADC_xdata, self.ADC_ydata = zip(*[(float(x), float(y)) for x, y in self.ADC_data])
|
|
|
+ max_time = self.grafspin1ADC.get()
|
|
|
+ min_time = self.grafspinADC.get()
|
|
|
+ self.ADC_xdata = list(filter(lambda x: x >= int(min_time), self.ADC_xdata))
|
|
|
+ self.ax_ADC.clear()
|
|
|
+ self.ax_ADC.set_xlabel('Время, с')
|
|
|
+ self.ax_ADC.set_ylabel('Напряжение, В')
|
|
|
+ self.ax_ADC.grid(color='black', linewidth=1.0)
|
|
|
+ self.ax_ADC.set_xlim(min(self.ADC_xdata), 3000)
|
|
|
+ self.ax_ADC.set_ylim(int(self.spinbox_var1ADC.get()),
|
|
|
+ int(self.spinbox_var2ADC.get()))
|
|
|
+ self.ADC_line, = self.ax_ADC.plot([], [], 'ro-')
|
|
|
+
|
|
|
+ def init1():
|
|
|
+ self.ADC_line.set_data([], [])
|
|
|
+ return self.ADC_line,
|
|
|
+
|
|
|
+ def update1(frame):
|
|
|
+ self.ADC_line.set_data(self.ADC_xdata[:frame], self.ADC_ydata[:frame])
|
|
|
+ return self.ADC_line,
|
|
|
+
|
|
|
+ self.ADC_ani1 = FuncAnimation(self.fig_ADC, update1, frames=len(self.ADC_xdata),
|
|
|
+ init_func=init1, blit=True, interval=200, repeat=False)
|
|
|
+
|
|
|
+ self.canvas_ADC.draw()
|
|
|
+ Interface.window.after(10, lambda: None)
|
|
|
+
|
|
|
|
|
|
def clicked_timeTEM(self):
|
|
|
if self.TEM_ani is not None:
|
|
|
self.TEM_ani.event_source.stop()
|
|
|
self.TEM_ani = None
|
|
|
- if self.Time_flagTEM == 'disabled':
|
|
|
- self.Time_flagTEM = 'normal'
|
|
|
- self.grafspin1TEM.configure(state=[self.Time_flagTEM])
|
|
|
- else:
|
|
|
- self.TEM_file1 = open(self.file, 'r')
|
|
|
- self.Time_flagTEM = 'disabled'
|
|
|
- self.grafspin1TEM.configure(state=[self.Time_flagTEM])
|
|
|
- with self.TEM_file1 as f:
|
|
|
- self.TEM_lines = f.readlines()
|
|
|
-
|
|
|
- self.TEM_data = [line.strip().split() for line in self.ADC_lines]
|
|
|
- self.TEM_xdata, self.TEM_ydata = zip(*[(float(x), float(y)) for x, y in self.TEM_data])
|
|
|
- max_time = self.grafspin1TEM.get()
|
|
|
- min_time = self.grafspinTEM.get()
|
|
|
- self.TEM_xdata = list(filter(lambda x: x <= int(max_time), self.TEM_xdata))
|
|
|
- self.TEM_xdata = list(filter(lambda x: x >= int(min_time), self.TEM_xdata))
|
|
|
- self.ax_TEM.clear()
|
|
|
- self.ax_TEM.set_xlabel('Время, с')
|
|
|
- self.ax_TEM.set_ylabel('Температура, С')
|
|
|
- self.ax_TEM.grid(color='black', linewidth=1.0)
|
|
|
- self.ax_TEM.set_xlim(min(self.TEM_xdata), 3000)
|
|
|
- self.ax_TEM.set_ylim(int(self.spinbox_var1TEM.get()),
|
|
|
- int(self.spinbox_var2TEM.get()))
|
|
|
- self.TEM_line, = self.ax_TEM.plot([], [], 'ro-')
|
|
|
-
|
|
|
- def init1():
|
|
|
- self.TEM_line.set_data([], [])
|
|
|
- return self.TEM_line,
|
|
|
-
|
|
|
- def update1(frame):
|
|
|
- self.TEM_line.set_data(self.TEM_xdata[:frame], self.TEM_ydata[:frame])
|
|
|
- return self.TEM_line,
|
|
|
-
|
|
|
- self.TEM_ani1 = FuncAnimation(self.fig_TEM, update1, frames=len(self.TEM_xdata),
|
|
|
- init_func=init1, blit=True, interval=5, repeat=False)
|
|
|
-
|
|
|
- self.canvas_TEM.draw()
|
|
|
- Interface.window.after(10, None)
|
|
|
+
|
|
|
+ self.TEM_file1 = open(self.file, 'r')
|
|
|
+ self.Time_flagTEM = 'disabled'
|
|
|
+ self.grafspin1TEM.configure(state=self.Time_flagTEM)
|
|
|
+ with self.TEM_file1 as f:
|
|
|
+ self.TEM_lines = f.readlines()
|
|
|
+
|
|
|
+ self.TEM_data = [line.strip().split() for line in self.ADC_lines]
|
|
|
+ self.TEM_xdata, self.TEM_ydata = zip(*[(float(x), float(y)) for x, y in self.TEM_data])
|
|
|
+ max_time = self.grafspin1TEM.get()
|
|
|
+ min_time = self.grafspinTEM.get()
|
|
|
+ self.TEM_xdata = list(filter(lambda x: x >= int(min_time), self.TEM_xdata))
|
|
|
+ self.ax_TEM.clear()
|
|
|
+ self.ax_TEM.set_xlabel('Время, с')
|
|
|
+ self.ax_TEM.set_ylabel('Температура, С')
|
|
|
+ self.ax_TEM.grid(color='black', linewidth=1.0)
|
|
|
+ self.ax_TEM.set_xlim(min(self.TEM_xdata), 3000)
|
|
|
+ self.ax_TEM.set_ylim(int(self.spinbox_var1TEM.get()),
|
|
|
+ int(self.spinbox_var2TEM.get()))
|
|
|
+ self.TEM_line, = self.ax_TEM.plot([], [], 'ro-')
|
|
|
+
|
|
|
+ def init1():
|
|
|
+ self.TEM_line.set_data([], [])
|
|
|
+ return self.TEM_line,
|
|
|
+
|
|
|
+ def update1(frame):
|
|
|
+ self.TEM_line.set_data(self.TEM_xdata[:frame], self.TEM_ydata[:frame])
|
|
|
+ return self.TEM_line,
|
|
|
+
|
|
|
+ self.TEM_ani1 = FuncAnimation(self.fig_TEM, update1, frames=len(self.TEM_xdata),
|
|
|
+ init_func=init1, blit=True, interval=200, repeat=False)
|
|
|
+
|
|
|
+ self.canvas_TEM.draw()
|
|
|
+ Interface.window.after(10, lambda: None)
|
|
|
+
|
|
|
|
|
|
def block_control(self):
|
|
|
self.f_BC = ttk.LabelFrame(Interface.window, text='Текущее значение данных:', relief=SOLID)
|
|
|
self.f_BC.grid(column=3, row=3, columnspan=2, rowspan=2)
|
|
|
self.text_BC = Label(self.f_BC, text="Кол-во импульсов", fg="black")
|
|
|
- self.text_BC.grid(column=0, row=0, ipady=10)
|
|
|
+ self.text_BC.grid(column=0, row=0, pady=10)
|
|
|
self.text_BC_ADC = Label(self.f_BC, text="АЦП канал 1, В", fg="black")
|
|
|
- self.text_BC_ADC.grid(column=1, row=0, ipadx=15, ipady=10)
|
|
|
+ self.text_BC_ADC.grid(column=1, row=0, ipadx=15, pady=10)
|
|
|
self.text_BC_TEM = Label(self.f_BC, text="Температура, С", fg="black")
|
|
|
self.text_BC_TEM.grid(column=2, row=0, ipady=10)
|
|
|
- self.impSV = StringVar(value=round(self.ydata[-1]))
|
|
|
- self.adcSV = StringVar(value=round(self.ADC_ydata[-1]))
|
|
|
- self.temSV = StringVar(value=round(self.TEM_ydata[-1]))
|
|
|
- self.IMP_entry = Entry(self.f_BC, width=15, state=['disable'], textvariable=self.impSV)
|
|
|
+ self.impSV = StringVar(value=round(self.ydata[0]))
|
|
|
+ self.adcSV = StringVar(value=round(self.ADC_ydata[0]))
|
|
|
+ self.temSV = StringVar(value=round(self.TEM_ydata[0]))
|
|
|
+ self.IMP_entry = Entry(self.f_BC, width=15, state='disabled', textvariable=self.impSV)
|
|
|
self.IMP_entry.grid(column=0, row=1)
|
|
|
- self.ADC_entry = Entry(self.f_BC, width=15, state=['disable'], textvariable=self.adcSV)
|
|
|
- self.ADC_entry.grid(column=1, row=1, ipadx=15)
|
|
|
- self.TEM_entry = Entry(self.f_BC, width=15, state=['disable'], textvariable=self.temSV)
|
|
|
+ self.ADC_entry = Entry(self.f_BC, width=15, state='disabled', textvariable=self.adcSV)
|
|
|
+ self.ADC_entry.grid(column=1, row=1, padx=15)
|
|
|
+ self.TEM_entry = Entry(self.f_BC, width=15, state='disabled', textvariable=self.temSV)
|
|
|
self.TEM_entry.grid(column=2, row=1)
|
|
|
+ self.SDT = Label(self.f_BC, text="Работает", fg="black", bg="green")
|
|
|
+ self.SDT.grid(column=0, row=2, pady=10, sticky='NSEW')
|
|
|
+ self.SVadc = Label(self.f_BC, text="Работает", fg="black", bg="green")
|
|
|
+ self.SVadc.grid(column=2, row=2, pady=10, sticky='NSEW')
|
|
|
+
|
|
|
|
|
|
def mennuB(self):
|
|
|
menubar1 = tk.Menu(self.window)
|
|
@@ -526,5 +568,6 @@ class Interface():
|
|
|
setting_menu6.add_command(label='-----')
|
|
|
menubar1.add_cascade(label='Help', menu=setting_menu6)
|
|
|
|
|
|
+
|
|
|
interface = Interface()
|
|
|
-interface.start()
|
|
|
+interface.start()
|