diff --git a/Automation/Chart.png b/Automation/Chart.png deleted file mode 100644 index 63a0afa..0000000 Binary files a/Automation/Chart.png and /dev/null differ diff --git a/Automation/ChartWindow.py b/Automation/ChartWindow.py new file mode 100644 index 0000000..3bcce47 --- /dev/null +++ b/Automation/ChartWindow.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Mon Nov 14 21:44:23 2022 + +@author: anna +""" +import os +import csv +import serial +import numpy as np +import time +from PyQt6 import QtCore +from PyQt6.QtGui import QPixmap +from PyQt6.QtWidgets import (QLabel, + QLineEdit, + QPushButton, + QWidget, + QTableWidget, + QGridLayout, + QTableWidgetItem, + QHeaderView, + QTextBrowser) +from Analisis_data import Data +from Abstract_window import AbstractWindow + +class ChartWindow(AbstractWindow): + def __init__(self, parent): + super().__init__() + + self.setWindowTitle('Обработка данных') + self.parent = parent + self.parent.chartname = 'Chart' + self.parent.data = Data(data_filename=os.path.join(self.parent.folder, self.parent.dataname), + saving=os.path.join(self.parent.folder, self.parent.chartname)) + self.parent.data.read_csv() + # add B(I_M) #TODO + self.parent.data.x = np.array(self.parent.data.data['I_0,mA'])*np.array(self.parent.data.data['I_M,mA']) + self.parent.data.y = self.parent.data.data['U_34,mV'] + self.parent.data.ylabel = 'U_34,mV' + self.parent.data.xlabel = 'I$_{обр} \cdot B$, мА$\cdot $ Tл' + self.parent.data.make_grafic() + + self.setWindowTitle('Основной эксперимент. Обработка данных') + self.resize(1400, 800) + + self.centralwidget = QWidget() + self.setCentralWidget(self.centralwidget) + + pixmap = QPixmap(os.path.join( + self.parent.folder, self.parent.chartname)) + self.label = QLabel(self) + self.label.setScaledContents(True) + self.label.setFixedSize(0.7*self.width(), 0.9*self.height()) + self.label.setPixmap(pixmap) + + self.text = QTextBrowser() + self.text.setText('text') + + self.hbox_layout = QGridLayout(self.centralwidget) + self.hbox_layout.addWidget(self.label, 0, 0) + self.hbox_layout.addWidget(self.text, 0, 1) \ No newline at end of file diff --git a/Automation/GraduationWindow.py b/Automation/GraduationWindow.py index 3709284..e90273f 100644 --- a/Automation/GraduationWindow.py +++ b/Automation/GraduationWindow.py @@ -112,4 +112,9 @@ class GraduationWindow(AbstractWindow): bytesToRead = self.parent.ser.inWaiting() I_M = self.parent.ser.read(bytesToRead) self.volt += 5 - self.save_data([b, self.volt, I_M, t]) \ No newline at end of file + self.save_data([b, self.volt, I_M, t]) + + def closeEvent(self, event): + pass + # msg = 'VOLTage '+str(0)+'\n' + # self.parent.ser.write(msg.encode('ascii')) \ No newline at end of file diff --git a/Automation/Main.py b/Automation/Main.py index 702dee8..cd68195 100644 --- a/Automation/Main.py +++ b/Automation/Main.py @@ -14,8 +14,8 @@ from PyQt6.QtWidgets import (QApplication, QLabel ) from Abstract_window import AbstractWindow -from Main_experiment_window import (MainExperimentDataWindow, - MainExperimentChartWindow) +from Main_experiment_window import MainWindow +from ChartWindow import ChartWindow from GraduationWindow import GraduationWindow from SignWindow import SignWindow from ResistanceWindow import ResistanceWindow @@ -31,9 +31,7 @@ class Start: self.app = QApplication.instance() self.window = StartWindow(self) - # self.add_ser() - # self.parent.amp_name= os.path.join('/dev', 'usbtmc1') - # self.volt_name = os.path.join('/dev', 'usbtmc0') + # self.add_equip() self.draw() self.app.exec() @@ -50,19 +48,19 @@ class Start: self.window = GraduationWindow(self) if self.number == 20: self.window.close() - self.window = MainExperimentDataWindow(self) - if self.number == 21: - self.window.close() - self.window = MainExperimentChartWindow(self) + self.window = MainWindow(self) if self.number == 30: self.window.close() self.window = SignWindow(self) if self.number == 40: self.window.close() self.window = ResistanceWindow(self) + if self.number == 50: + self.window.close() + self.window = ChartWindow(self) self.draw() - def add_ser(self): + def add_equip(self): self.ser = serial.Serial( port='/dev/ttyUSB2', baudrate=9600, @@ -71,6 +69,9 @@ class Start: self.ser.isOpen() msg = 'OUTput on\n' self.ser.write(msg.encode('ascii')) + + self.parent.amp_name= os.path.join('/dev', 'usbtmc1') + self.volt_name = os.path.join('/dev', 'usbtmc0') class StartWindow(AbstractWindow): @@ -102,6 +103,11 @@ class StartWindow(AbstractWindow): self.res.clicked.connect(self.res_click) if not self.parent.foldername: self.res.setEnabled(False) + + self.chart = QPushButton('Обработка данных') + self.chart.clicked.connect(self.chart_click) + if not self.parent.foldername: + self.chart.setEnabled(False) self.main = QPushButton('Основной эксперимент') self.main.clicked.connect(self.main_click) @@ -117,10 +123,15 @@ class StartWindow(AbstractWindow): 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.chart, 4, 0, 1, -1) def flow_click(self): self.parent.number = 10 self.parent.change_number() + + def chart_click(self): + self.parent.number = 50 + self.parent.change_number() def main_click(self): self.parent.number = 20 @@ -145,6 +156,7 @@ class StartWindow(AbstractWindow): self.main.setEnabled(True) self.sign.setEnabled(True) self.res.setEnabled(True) + self.chart.setEnabled(True) self.lineEdit.setReadOnly(True) diff --git a/Automation/Main_experiment_window.py b/Automation/Main_experiment_window.py index 9de5208..19d8181 100644 --- a/Automation/Main_experiment_window.py +++ b/Automation/Main_experiment_window.py @@ -40,7 +40,7 @@ class ThreadData(QtCore.QThread): self.sleep(1) -class MainExperimentDataWindow(AbstractWindow): +class MainWindow(AbstractWindow): def __init__(self, parent): super().__init__() @@ -75,9 +75,9 @@ class MainExperimentDataWindow(AbstractWindow): self.new.clicked.connect(self.new_clicked) self.new.setEnabled(False) - self.chart = QPushButton('График') - self.chart.setEnabled(False) - self.chart.clicked.connect(self.chart_clicked) + self.menu = QPushButton('Меню') + self.menu.setEnabled(False) + self.menu.clicked.connect(self.menu_clicked) self.lineEdit = QLineEdit(placeholderText='Введите a, мм') self.lineEdit.returnPressed.connect(self.enter_a) @@ -98,7 +98,7 @@ class MainExperimentDataWindow(AbstractWindow): self.grid_layout.addWidget(self.start, 1, 2) self.grid_layout.addWidget(self.stop, 1, 3) self.grid_layout.addWidget(self.new, 2, 2, 1, -1) - self.grid_layout.addWidget(self.chart, 3, 2, 1, -1) + self.grid_layout.addWidget(self.menu, 3, 2, 1, -1) def enter_a(self): # TODO @@ -119,7 +119,7 @@ class MainExperimentDataWindow(AbstractWindow): self.data_thread.running = False self.stop.setEnabled(False) self.start.setEnabled(True) - self.chart.setEnabled(True) + self.menu.setEnabled(True) def new_clicked(self): self.number_iteration += 1 @@ -130,8 +130,8 @@ class MainExperimentDataWindow(AbstractWindow): self.new.setEnabled(True) self.stop.setEnabled(True) - def chart_clicked(self): - self.parent.number = 21 + def menu_clicked(self): + self.parent.number = 0 self.parent.change_number() def no_data(self): @@ -199,41 +199,8 @@ class MainExperimentDataWindow(AbstractWindow): def closeEvent(self, event): self.data_thread.running = False + # msg = 'VOLTage '+str(0)+'\n' + # self.parent.ser.write(msg.encode('ascii')) -class MainExperimentChartWindow(AbstractWindow): - def __init__(self, parent): - super().__init__() - self.setWindowTitle('Основной эксперимент. Обработка данных') - self.parent = parent - self.parent.chartname = 'Chart' - self.parent.data = Data(data_filename=os.path.join(self.parent.folder, self.parent.dataname), - saving=os.path.join(self.parent.folder, self.parent.chartname)) - self.parent.data.read_csv() - # add B(I_M) #TODO - self.parent.data.x = np.array(self.parent.data.data['I_0,mA'])*np.array(self.parent.data.data['I_M,mA']) - self.parent.data.y = self.parent.data.data['U_34,mV'] - self.parent.data.ylabel = 'U_34,mV' - self.parent.data.xlabel = 'I$_{обр} \cdot B$, мА$\cdot $ Tл' - self.parent.data.make_grafic() - - self.setWindowTitle('Основной эксперимент. Обработка данных') - self.resize(1400, 800) - - self.centralwidget = QWidget() - self.setCentralWidget(self.centralwidget) - - pixmap = QPixmap(os.path.join( - self.parent.folder, self.parent.chartname)) - self.label = QLabel(self) - self.label.setScaledContents(True) - self.label.setFixedSize(0.7*self.width(), 0.9*self.height()) - self.label.setPixmap(pixmap) - - self.text = QTextBrowser() - self.text.setText('text') - - self.hbox_layout = QGridLayout(self.centralwidget) - self.hbox_layout.addWidget(self.label, 0, 0) - self.hbox_layout.addWidget(self.text, 0, 1) diff --git a/Automation/SignWindow.py b/Automation/SignWindow.py index 1f0f6e0..fc489e9 100644 --- a/Automation/SignWindow.py +++ b/Automation/SignWindow.py @@ -75,4 +75,9 @@ class SignWindow(AbstractWindow): def get_values(self): without_field = self.measure(0) with_field = self.measure(10) - return without_field, with_field \ No newline at end of file + return without_field, with_field + + def closeEvent(self, event): + pass + # msg = 'VOLTage '+str(0)+'\n' + # self.parent.ser.write(msg.encode('ascii')) \ No newline at end of file diff --git a/Automation/__pycache__/Analisis_data.cpython-39.pyc b/Automation/__pycache__/Analisis_data.cpython-39.pyc index 11041af..5d8b938 100644 Binary files a/Automation/__pycache__/Analisis_data.cpython-39.pyc and b/Automation/__pycache__/Analisis_data.cpython-39.pyc differ diff --git a/Automation/__pycache__/ChartWindow.cpython-39.pyc b/Automation/__pycache__/ChartWindow.cpython-39.pyc new file mode 100644 index 0000000..40e46d1 Binary files /dev/null and b/Automation/__pycache__/ChartWindow.cpython-39.pyc differ diff --git a/Automation/__pycache__/GraduationWindow.cpython-39.pyc b/Automation/__pycache__/GraduationWindow.cpython-39.pyc index a5cc9c6..9f35dda 100644 Binary files a/Automation/__pycache__/GraduationWindow.cpython-39.pyc and b/Automation/__pycache__/GraduationWindow.cpython-39.pyc differ diff --git a/Automation/__pycache__/Main_experiment_window.cpython-39.pyc b/Automation/__pycache__/Main_experiment_window.cpython-39.pyc index 718f3da..d93147c 100644 Binary files a/Automation/__pycache__/Main_experiment_window.cpython-39.pyc and b/Automation/__pycache__/Main_experiment_window.cpython-39.pyc differ diff --git a/Automation/__pycache__/SignWindow.cpython-39.pyc b/Automation/__pycache__/SignWindow.cpython-39.pyc index 380c8c4..0bc2f2c 100644 Binary files a/Automation/__pycache__/SignWindow.cpython-39.pyc and b/Automation/__pycache__/SignWindow.cpython-39.pyc differ diff --git a/Automation/j/Chart.png b/Automation/j/Chart.png index 23e5d5c..cc0abb6 100644 Binary files a/Automation/j/Chart.png and b/Automation/j/Chart.png differ diff --git a/Automation/j/data.csv b/Automation/j/data.csv index 64726ff..307b024 100644 --- a/Automation/j/data.csv +++ b/Automation/j/data.csv @@ -1 +1,6 @@ "U_34,mV","I_M,mA","U_0,mV","I_0,mA","E, mV",N,"t,ms" +0.016666666666666666,0.016666666666666666,0.016666666666666666,0.00016666666666666666,0,1,1 +16.7,16.7,0.016666666666666666,0.16699999999999998,5.0,1,1002 +33.38333333333333,33.38333333333333,0.016666666666666666,0.3338333333333333,10.0,1,2003 +50.06666666666667,50.06666666666667,0.016666666666666666,0.5006666666666667,15.0,1,3004 +66.75,66.75,0.016666666666666666,0.6675,20.0,1,4005