little changes

This commit is contained in:
nazarchuk.as 2022-11-14 21:49:40 +03:00
parent 6846b95748
commit 8e36d3d3f3
13 changed files with 111 additions and 55 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

62
Automation/ChartWindow.py Normal file
View File

@ -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)

View File

@ -112,4 +112,9 @@ class GraduationWindow(AbstractWindow):
bytesToRead = self.parent.ser.inWaiting() bytesToRead = self.parent.ser.inWaiting()
I_M = self.parent.ser.read(bytesToRead) I_M = self.parent.ser.read(bytesToRead)
self.volt += 5 self.volt += 5
self.save_data([b, self.volt, I_M, t]) 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'))

View File

@ -14,8 +14,8 @@ from PyQt6.QtWidgets import (QApplication,
QLabel QLabel
) )
from Abstract_window import AbstractWindow from Abstract_window import AbstractWindow
from Main_experiment_window import (MainExperimentDataWindow, from Main_experiment_window import MainWindow
MainExperimentChartWindow) from ChartWindow import ChartWindow
from GraduationWindow import GraduationWindow from GraduationWindow import GraduationWindow
from SignWindow import SignWindow from SignWindow import SignWindow
from ResistanceWindow import ResistanceWindow from ResistanceWindow import ResistanceWindow
@ -31,9 +31,7 @@ class Start:
self.app = QApplication.instance() self.app = QApplication.instance()
self.window = StartWindow(self) self.window = StartWindow(self)
# self.add_ser() # self.add_equip()
# 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()
@ -50,19 +48,19 @@ class Start:
self.window = GraduationWindow(self) self.window = GraduationWindow(self)
if self.number == 20: if self.number == 20:
self.window.close() self.window.close()
self.window = MainExperimentDataWindow(self) self.window = MainWindow(self)
if self.number == 21:
self.window.close()
self.window = MainExperimentChartWindow(self)
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: if self.number == 40:
self.window.close() self.window.close()
self.window = ResistanceWindow(self) self.window = ResistanceWindow(self)
if self.number == 50:
self.window.close()
self.window = ChartWindow(self)
self.draw() self.draw()
def add_ser(self): def add_equip(self):
self.ser = serial.Serial( self.ser = serial.Serial(
port='/dev/ttyUSB2', port='/dev/ttyUSB2',
baudrate=9600, baudrate=9600,
@ -71,6 +69,9 @@ class Start:
self.ser.isOpen() self.ser.isOpen()
msg = 'OUTput on\n' msg = 'OUTput on\n'
self.ser.write(msg.encode('ascii')) 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): class StartWindow(AbstractWindow):
@ -102,6 +103,11 @@ class StartWindow(AbstractWindow):
self.res.clicked.connect(self.res_click) self.res.clicked.connect(self.res_click)
if not self.parent.foldername: if not self.parent.foldername:
self.res.setEnabled(False) 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 = QPushButton('Основной эксперимент')
self.main.clicked.connect(self.main_click) 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.sign, 3, 0)
self.hbox_layout.addWidget(self.res, 3, 1) self.hbox_layout.addWidget(self.res, 3, 1)
self.hbox_layout.addWidget(self.main, 2, 1) self.hbox_layout.addWidget(self.main, 2, 1)
self.hbox_layout.addWidget(self.chart, 4, 0, 1, -1)
def flow_click(self): def flow_click(self):
self.parent.number = 10 self.parent.number = 10
self.parent.change_number() self.parent.change_number()
def chart_click(self):
self.parent.number = 50
self.parent.change_number()
def main_click(self): def main_click(self):
self.parent.number = 20 self.parent.number = 20
@ -145,6 +156,7 @@ class StartWindow(AbstractWindow):
self.main.setEnabled(True) self.main.setEnabled(True)
self.sign.setEnabled(True) self.sign.setEnabled(True)
self.res.setEnabled(True) self.res.setEnabled(True)
self.chart.setEnabled(True)
self.lineEdit.setReadOnly(True) self.lineEdit.setReadOnly(True)

View File

@ -40,7 +40,7 @@ class ThreadData(QtCore.QThread):
self.sleep(1) self.sleep(1)
class MainExperimentDataWindow(AbstractWindow): class MainWindow(AbstractWindow):
def __init__(self, parent): def __init__(self, parent):
super().__init__() super().__init__()
@ -75,9 +75,9 @@ class MainExperimentDataWindow(AbstractWindow):
self.new.clicked.connect(self.new_clicked) self.new.clicked.connect(self.new_clicked)
self.new.setEnabled(False) self.new.setEnabled(False)
self.chart = QPushButton('График') self.menu = QPushButton('Меню')
self.chart.setEnabled(False) self.menu.setEnabled(False)
self.chart.clicked.connect(self.chart_clicked) self.menu.clicked.connect(self.menu_clicked)
self.lineEdit = QLineEdit(placeholderText='Введите a, мм') self.lineEdit = QLineEdit(placeholderText='Введите a, мм')
self.lineEdit.returnPressed.connect(self.enter_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.start, 1, 2)
self.grid_layout.addWidget(self.stop, 1, 3) self.grid_layout.addWidget(self.stop, 1, 3)
self.grid_layout.addWidget(self.new, 2, 2, 1, -1) 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): def enter_a(self):
# TODO # TODO
@ -119,7 +119,7 @@ class MainExperimentDataWindow(AbstractWindow):
self.data_thread.running = False self.data_thread.running = False
self.stop.setEnabled(False) self.stop.setEnabled(False)
self.start.setEnabled(True) self.start.setEnabled(True)
self.chart.setEnabled(True) self.menu.setEnabled(True)
def new_clicked(self): def new_clicked(self):
self.number_iteration += 1 self.number_iteration += 1
@ -130,8 +130,8 @@ class MainExperimentDataWindow(AbstractWindow):
self.new.setEnabled(True) self.new.setEnabled(True)
self.stop.setEnabled(True) self.stop.setEnabled(True)
def chart_clicked(self): def menu_clicked(self):
self.parent.number = 21 self.parent.number = 0
self.parent.change_number() self.parent.change_number()
def no_data(self): def no_data(self):
@ -199,41 +199,8 @@ class MainExperimentDataWindow(AbstractWindow):
def closeEvent(self, event): def closeEvent(self, event):
self.data_thread.running = False 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)

View File

@ -75,4 +75,9 @@ class SignWindow(AbstractWindow):
def get_values(self): def get_values(self):
without_field = self.measure(0) without_field = self.measure(0)
with_field = self.measure(10) with_field = self.measure(10)
return without_field, with_field return without_field, with_field
def closeEvent(self, event):
pass
# msg = 'VOLTage '+str(0)+'\n'
# self.parent.ser.write(msg.encode('ascii'))

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 147 KiB

View File

@ -1 +1,6 @@
"U_34,mV","I_M,mA","U_0,mV","I_0,mA","E, mV",N,"t,ms" "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

1 U_34,mV I_M,mA U_0,mV I_0,mA E, mV N t,ms
2 0.016666666666666666 0.016666666666666666 0.016666666666666666 0.00016666666666666666 0 1 1
3 16.7 16.7 0.016666666666666666 0.16699999999999998 5.0 1 1002
4 33.38333333333333 33.38333333333333 0.016666666666666666 0.3338333333333333 10.0 1 2003
5 50.06666666666667 50.06666666666667 0.016666666666666666 0.5006666666666667 15.0 1 3004
6 66.75 66.75 0.016666666666666666 0.6675 20.0 1 4005