add new window

This commit is contained in:
nazarchuk.as 2022-11-14 21:33:32 +03:00
parent bf75188f82
commit 6846b95748
7 changed files with 197 additions and 67 deletions

View File

@ -17,6 +17,8 @@ from Abstract_window import AbstractWindow
from Main_experiment_window import (MainExperimentDataWindow, from Main_experiment_window import (MainExperimentDataWindow,
MainExperimentChartWindow) MainExperimentChartWindow)
from GraduationWindow import GraduationWindow from GraduationWindow import GraduationWindow
from SignWindow import SignWindow
from ResistanceWindow import ResistanceWindow
class Start: class Start:
@ -28,7 +30,11 @@ class Start:
else: else:
self.app = QApplication.instance() self.app = QApplication.instance()
self.window = StartWindow(self) self.window = StartWindow(self)
# self.add_ser() # self.add_ser()
# self.parent.amp_name= os.path.join('/dev', 'usbtmc1')
# self.volt_name = os.path.join('/dev', 'usbtmc0')
self.draw() self.draw()
self.app.exec() self.app.exec()
@ -51,6 +57,9 @@ class Start:
if self.number == 30: if self.number == 30:
self.window.close() self.window.close()
self.window = SignWindow(self) self.window = SignWindow(self)
if self.number == 40:
self.window.close()
self.window = ResistanceWindow(self)
self.draw() self.draw()
def add_ser(self): def add_ser(self):
@ -89,6 +98,11 @@ class StartWindow(AbstractWindow):
if not self.parent.foldername: if not self.parent.foldername:
self.sign.setEnabled(False) self.sign.setEnabled(False)
self.res = QPushButton('Удельная проводимость')
self.res.clicked.connect(self.res_click)
if not self.parent.foldername:
self.res.setEnabled(False)
self.main = QPushButton('Основной эксперимент') self.main = QPushButton('Основной эксперимент')
self.main.clicked.connect(self.main_click) self.main.clicked.connect(self.main_click)
if not self.parent.foldername: if not self.parent.foldername:
@ -101,6 +115,7 @@ class StartWindow(AbstractWindow):
self.hbox_layout.addWidget(self.lineEdit, 1, 0, 1, 2) self.hbox_layout.addWidget(self.lineEdit, 1, 0, 1, 2)
self.hbox_layout.addWidget(self.flow, 2, 0) self.hbox_layout.addWidget(self.flow, 2, 0)
self.hbox_layout.addWidget(self.sign, 3, 0) self.hbox_layout.addWidget(self.sign, 3, 0)
self.hbox_layout.addWidget(self.res, 3, 1)
self.hbox_layout.addWidget(self.main, 2, 1) self.hbox_layout.addWidget(self.main, 2, 1)
def flow_click(self): def flow_click(self):
@ -111,6 +126,10 @@ class StartWindow(AbstractWindow):
self.parent.number = 20 self.parent.number = 20
self.parent.change_number() self.parent.change_number()
def res_click(self):
self.parent.number = 40
self.parent.change_number()
def sign_click(self): def sign_click(self):
self.parent.number = 30 self.parent.number = 30
self.parent.change_number() self.parent.change_number()
@ -125,70 +144,10 @@ class StartWindow(AbstractWindow):
self.flow.setEnabled(True) self.flow.setEnabled(True)
self.main.setEnabled(True) self.main.setEnabled(True)
self.sign.setEnabled(True) self.sign.setEnabled(True)
self.res.setEnabled(True)
self.lineEdit.setReadOnly(True) self.lineEdit.setReadOnly(True)
class SignWindow(AbstractWindow):
def __init__(self, parent):
super().__init__()
self.setWindowTitle('Определение знака носителей')
self.parent = parent
self.start = QPushButton('Старт')
self.start.clicked.connect(self.start_clicked)
self.start.setEnabled(True)
self.menu = QPushButton('Меню')
self.menu.setEnabled(False)
self.menu.clicked.connect(self.menu_clicked)
self.with_field = QLabel('С полем: ', self)
self.without_field = QLabel('С полем: ', self)
self.with_field_value = QLabel(self)
self.without_field_value = QLabel(self)
self.centralwidget = QWidget()
self.resize(1400, 800)
self.setCentralWidget(self.centralwidget)
self.grid_layout = QGridLayout(self.centralwidget)
self.grid_layout.addWidget(self.start, 0, 0, 1, -1)
self.grid_layout.addWidget(self.with_field, 1, 0)
self.grid_layout.addWidget(self.with_field_value, 1, 1)
self.grid_layout.addWidget(self.without_field, 2, 0)
self.grid_layout.addWidget(self.without_field_value, 2, 1)
self.grid_layout.addWidget(self.menu, 3, 0, 1, -1)
def menu_clicked(self):
self.parent.number = 0
self.parent.change_number()
def start_clicked(self):
self.start.setEnabled(False)
with_field=10
without_field=15
# without_field, with_field = self.get_values()
self.with_field_value.setText(str(with_field)+', mV')
self.without_field_value.setText(str(without_field)+', mV')
self.menu.setEnabled(True)
def measure(self, volt):
msg = 'VOLTage '+str(volt)+'\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
volt_name = os.path.join('/dev', 'usbtmc0')
f_volt = open(volt_name, 'w')
f_volt.write('Measure:Voltage:DC?\n')
f_volt.close()
f_volt = open(volt_name, 'r')
v = '{:.9f}'.format(float(f_volt.read(15))*10**3)
f_volt.close()
return v
def get_values(self):
without_field = self.measure(0)
with_field = self.measure(10)
return without_field, with_field

View File

@ -170,20 +170,18 @@ class MainExperimentDataWindow(AbstractWindow):
I_M = self.parent.ser.read(bytesToRead) I_M = self.parent.ser.read(bytesToRead)
self.volt += 5 self.volt += 5
volt_name = os.path.join('/dev', 'usbtmc0') f_volt = open(self.parent.volt_name, 'w')
f_volt = open(volt_name, 'w')
f_volt.write('Measure:Voltage:DC?\n') f_volt.write('Measure:Voltage:DC?\n')
f_volt.close() f_volt.close()
amp_name = os.path.join('/dev', 'usbtmc1') f_amp = open(self.parent.amp_name, 'w')
f_amp = open(amp_name, 'w')
f_amp.write('Measure:Current:DC?\n') f_amp.write('Measure:Current:DC?\n')
f_amp.close() f_amp.close()
f_volt = open(volt_name, 'r') f_volt = open(self.parent.volt_name, 'r')
v = '{:.9f}'.format(float(f_volt.read(15))*10**3) v = '{:.9f}'.format(float(f_volt.read(15))*10**3)
if self.volt == 0: if self.volt == 0:
self.u_0 = v self.u_0 = v
f_amp = open(amp_name, 'r') f_amp = open(self.parent.amp_name, 'r')
a = '{:.9f}'.format(float(f_amp.read(15))*10**3) a = '{:.9f}'.format(float(f_amp.read(15))*10**3)
print(a) print(a)
# protect of errors: # protect of errors:

View File

@ -0,0 +1,95 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 14 21:31:55 2022
@author: anna
"""
from PyQt6.QtWidgets import (QPushButton,
QWidget,
QGridLayout,
QLabel,
QLineEdit
)
from Abstract_window import AbstractWindow
class ResistanceWindow(AbstractWindow):
def __init__(self, parent):
super().__init__()
self.setWindowTitle('Определение удельной проводимости')
self.parent = parent
self.start = QPushButton('Старт')
self.start.clicked.connect(self.start_clicked)
self.start.setEnabled(False)
self.menu = QPushButton('Меню')
self.menu.setEnabled(False)
self.menu.clicked.connect(self.menu_clicked)
self.current = QLabel('Ток через образец: ', self)
self.voltage= QLabel('Напряжение на 3_5: ', self)
self.current_value = QLabel(self)
self.voltage_value = QLabel(self)
self.line_L = QLineEdit(placeholderText='Введите L_35, мм')
self.line_L.returnPressed.connect(self.enter_L)
self.line_l = QLineEdit(placeholderText='Введите l, мм')
self.line_l.returnPressed.connect(self.enter_l)
self.centralwidget = QWidget()
self.resize(1400, 800)
self.setCentralWidget(self.centralwidget)
self.grid_layout = QGridLayout(self.centralwidget)
self.grid_layout.addWidget(self.line_L, 0, 0)
self.grid_layout.addWidget(self.line_l, 0, 1)
self.grid_layout.addWidget(self.start, 1, 0, 1, -1)
self.grid_layout.addWidget(self.current, 2, 0)
self.grid_layout.addWidget(self.current_value, 2, 1)
self.grid_layout.addWidget(self.voltage, 3, 0)
self.grid_layout.addWidget(self.voltage_value, 3, 1)
self.grid_layout.addWidget(self.menu, 4, 0, 1, -1)
def menu_clicked(self):
self.parent.number = 0
self.parent.change_number()
def enter_L(self):
self.parent.L=self.line_L.text()
self.line_L.setReadOnly(True)
def enter_l(self):
self.parent.L=self.line_l.text()
self.start.setEnabled(True)
self.line_l.setReadOnly(True)
def start_clicked(self):
self.start.setEnabled(False)
current=10
voltage=15
# voltage, current = self.measure()
self.current_value.setText(str(current)+', mA')
self.voltage_value.setText(str(voltage)+', mV')
self.menu.setEnabled(True)
def measure(self):
f_amp = open(self.parent.amp_name, 'w')
f_amp.write('Measure:Current:DC?\n')
f_amp.close()
f_amp = open(self.parent.amp_name, 'r')
a = '{:.9f}'.format(float(f_amp.read(15))*10**3)
f_amp.close()
f_amp.close()
f_volt = open(self.parent.volt_name, 'w')
f_volt.write('Measure:Voltage:DC?\n')
f_volt.close()
f_volt = open(self.parent.volt_name, 'r')
v = '{:.9f}'.format(float(f_volt.read(15))*10**3)
f_volt.close()
return v, a

78
Automation/SignWindow.py Normal file
View File

@ -0,0 +1,78 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 14 21:00:36 2022
@author: anna
"""
import os
import time
from PyQt6.QtWidgets import (QPushButton,
QWidget,
QGridLayout,
QLabel
)
from Abstract_window import AbstractWindow
class SignWindow(AbstractWindow):
def __init__(self, parent):
super().__init__()
self.setWindowTitle('Определение знака носителей')
self.parent = parent
self.start = QPushButton('Старт')
self.start.clicked.connect(self.start_clicked)
self.start.setEnabled(True)
self.menu = QPushButton('Меню')
self.menu.setEnabled(False)
self.menu.clicked.connect(self.menu_clicked)
self.with_field = QLabel('С полем: ', self)
self.without_field = QLabel('С полем: ', self)
self.with_field_value = QLabel(self)
self.without_field_value = QLabel(self)
self.centralwidget = QWidget()
self.resize(1400, 800)
self.setCentralWidget(self.centralwidget)
self.grid_layout = QGridLayout(self.centralwidget)
self.grid_layout.addWidget(self.start, 0, 0, 1, -1)
self.grid_layout.addWidget(self.with_field, 1, 0)
self.grid_layout.addWidget(self.with_field_value, 1, 1)
self.grid_layout.addWidget(self.without_field, 2, 0)
self.grid_layout.addWidget(self.without_field_value, 2, 1)
self.grid_layout.addWidget(self.menu, 3, 0, 1, -1)
def menu_clicked(self):
self.parent.number = 0
self.parent.change_number()
def start_clicked(self):
self.start.setEnabled(False)
with_field=10
without_field=15
# without_field, with_field = self.get_values()
self.with_field_value.setText(str(with_field)+', mV')
self.without_field_value.setText(str(without_field)+', mV')
self.menu.setEnabled(True)
def measure(self, volt):
msg = 'VOLTage '+str(volt)+'\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
f_volt = open(self.parent.volt_name, 'w')
f_volt.write('Measure:Voltage:DC?\n')
f_volt.close()
f_volt = open(self.parent.volt_name, 'r')
v = '{:.9f}'.format(float(f_volt.read(15))*10**3)
f_volt.close()
return v
def get_values(self):
without_field = self.measure(0)
with_field = self.measure(10)
return without_field, with_field

Binary file not shown.

Binary file not shown.