add equipment

This commit is contained in:
nazarchuk.as 2022-11-14 13:52:11 +03:00
parent d33affdf1d
commit a7155a4a6f
9 changed files with 71 additions and 20 deletions

View File

@ -119,7 +119,7 @@ class Data:
linestyle='-', color=self.color[1]) linestyle='-', color=self.color[1])
def make_grafic(self, named_by_points=True): def make_grafic(self, named_by_points=True):
plt.figure(dpi=500, figsize=(8, 5)) plt.figure(dpi=500, figsize=(4, 3))
self.make_errors() self.make_errors()
if named_by_points: if named_by_points:
self.cap_point = self.caption self.cap_point = self.caption

BIN
Automation/Chart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1,5 +1,6 @@
import os import os
import sys import sys
import serial
import csv import csv
import time import time
from PyQt6.QtGui import QIcon from PyQt6.QtGui import QIcon
@ -103,6 +104,7 @@ class FlowWindow(AbstractWindow):
self.setWindowTitle('Градуировка электромагнита') self.setWindowTitle('Градуировка электромагнита')
self.parent = parent self.parent = parent
# make csv file # make csv file
self.parent.flow_dataname = 'Induction_data.csv' self.parent.flow_dataname = 'Induction_data.csv'
head_1 = 'B,mTl' head_1 = 'B,mTl'
@ -165,6 +167,13 @@ class FlowWindow(AbstractWindow):
self.lineEdit.setReadOnly(False) self.lineEdit.setReadOnly(False)
def get_data(self): def get_data(self):
# bytesToRead=ser.inWaiting()
# data=ser.read(bytesToRead)
# print(data)
current_time = round(time.time()*1000) current_time = round(time.time()*1000)
b = self.lineEdit.text() b = self.lineEdit.text()
u = str((current_time-self.start_time)/60) u = str((current_time-self.start_time)/60)
@ -181,28 +190,30 @@ class FlowWindow(AbstractWindow):
start = Start() start = Start()
# =============================================================================
# import time # import time
# import serial # import serial
#
# ser=serial.Serial( # ser=serial.Serial(
# port='/dev/ttyUSB0', # port='/dev/ttyUSB2',
# baudrate=9600, # baudrate=9600,
# timeout=1 # timeout=1
# ) # )
# ser.isOpen() # ser.isOpen()
# # msg='Output on\n'
# msg='SYSTem:REMote\n'
# ser.write(msg.encode('ascii')) # ser.write(msg.encode('ascii'))
#
# msg='VOLTage 1\n'
# ser.write(msg.encode('ascii'))
# while 1: # while 1:
#
# msg='Read?\n' # msg='READ?\n'
# ser.write(msg.encode('ascii')) # ser.write(msg.encode('ascii'))
# time.sleep(1) # time.sleep(1)
#
# bytesToRead=ser.inWaiting() # bytesToRead=ser.inWaiting()
# data=ser.read(bytesToRead) # data=ser.read(bytesToRead)
# print(data) # print(data)
#
# =============================================================================

View File

@ -7,6 +7,7 @@ Created on Fri Nov 11 20:00:45 2022
""" """
import os import os
import csv import csv
import serial
import time import time
from PyQt6 import QtCore from PyQt6 import QtCore
from PyQt6.QtGui import QIcon, QPixmap from PyQt6.QtGui import QIcon, QPixmap
@ -34,8 +35,8 @@ class ThreadData(QtCore.QThread):
def run(self): def run(self):
self.running = True self.running = True
while self.running: while self.running:
self.parent.no_data() self.parent.take_data()
self.sleep(1) self.sleep(2)
class MainExperimentDataWindow(AbstractWindow): class MainExperimentDataWindow(AbstractWindow):
@ -44,6 +45,16 @@ class MainExperimentDataWindow(AbstractWindow):
self.setWindowTitle('Основной эксперимент. Получение данных') self.setWindowTitle('Основной эксперимент. Получение данных')
self.parent = parent self.parent = parent
self.parent.ser = serial.Serial(
port='/dev/ttyUSB2',
baudrate=9600,
timeout=1
)
self.parent.ser.isOpen()
msg = 'OUTput on\n'
self.parent.ser.write(msg.encode('ascii'))
self.data_thread = ThreadData(self) self.data_thread = ThreadData(self)
self.resize(1400, 800) self.resize(1400, 800)
@ -127,6 +138,9 @@ class MainExperimentDataWindow(AbstractWindow):
with open(os.path.join(self.parent.folder, self.parent.dataname), 'a') as file: with open(os.path.join(self.parent.folder, self.parent.dataname), 'a') as file:
wr = csv.writer(file) wr = csv.writer(file)
wr.writerow([v, a, t]) wr.writerow([v, a, t])
v = str(v)
a = str(a)
t = str(t)
self.table.insertRow(self.table.rowCount()) self.table.insertRow(self.table.rowCount())
self.table.setItem(self.table.rowCount()-1, 0, QTableWidgetItem(v)) self.table.setItem(self.table.rowCount()-1, 0, QTableWidgetItem(v))
self.table.setItem(self.table.rowCount()-1, 1, QTableWidgetItem(a)) self.table.setItem(self.table.rowCount()-1, 1, QTableWidgetItem(a))
@ -134,19 +148,34 @@ class MainExperimentDataWindow(AbstractWindow):
def take_data(self): def take_data(self):
# measure voltage and current # measure voltage and current
volt_name = os.path.join('/dev', 'usbtmc1') volt = 1.5 * (1+(time.time()-self.start_time/1000)/20)
# print(volt)
msg = 'VOLTage '+str(volt)+'\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
msg = 'MEASure:VOLTage?\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
bytesToRead = self.parent.ser.inWaiting()
data = self.parent.ser.read(bytesToRead)
print(float(data))
volt_name = os.path.join('/dev', 'usbtmc0')
f_volt = open(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', 'usbtmc2') amp_name = os.path.join('/dev', 'usbtmc1')
f_amp = open(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(volt_name, 'r')
v = f_volt.read(15) v = '{:.9f}'.format(float(f_volt.read(15))*10**3)
f_amp = open(amp_name, 'r') f_amp = open(amp_name, 'r')
a = f_amp.read(15) a = '{:.9f}'.format(float(f_amp.read(15))*10**3)
f_volt.close() f_volt.close()
f_amp.close() f_amp.close()
@ -154,6 +183,9 @@ class MainExperimentDataWindow(AbstractWindow):
t = str(current_time-self.start_time) t = str(current_time-self.start_time)
self.save_data(v, a, t) self.save_data(v, a, t)
def closeEvent(self, event):
self.data_thread.running = False
class MainExperimentChartWindow(AbstractWindow): class MainExperimentChartWindow(AbstractWindow):
def __init__(self, parent): def __init__(self, parent):
@ -178,12 +210,13 @@ class MainExperimentChartWindow(AbstractWindow):
pixmap = QPixmap(os.path.join( pixmap = QPixmap(os.path.join(
self.parent.folder, self.parent.chartname)) self.parent.folder, self.parent.chartname))
self.label = QLabel(self) self.label = QLabel(self)
pixmap.scaled(0.5, 0.3)
self.label.setPixmap(pixmap) self.label.setPixmap(pixmap)
self.label.resize(pixmap.width(), pixmap.height())
self.text = QTextBrowser() self.text = QTextBrowser()
self.text.setText('text') self.text.setText('text')
self.resize(1400, 800)
self.hbox_layout = QGridLayout(self.centralwidget) self.hbox_layout = QGridLayout(self.centralwidget)
self.hbox_layout.addWidget(self.label, 0, 0) self.hbox_layout.addWidget(self.label, 0, 0)
self.hbox_layout.addWidget(self.text, 0, 1) self.hbox_layout.addWidget(self.text, 0, 1)

5
Automation/data.csv Normal file
View File

@ -0,0 +1,5 @@
"I_0,mA","U_34,mV","t,ms"
-118.631224000,-0.000002364,3961
-13.393977600,-0.000002660,9926
-12.964528800,-0.000002364,15875
-119.215280000,-0.000002069,21888
1 I_0,mA U_34,mV t,ms
2 -118.631224000 -0.000002364 3961
3 -13.393977600 -0.000002660 9926
4 -12.964528800 -0.000002364 15875
5 -119.215280000 -0.000002069 21888

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -1,2 +1,4 @@
"I_0,mA","U_34,mV","t,ms" "I_0,mA","U_34,mV","t,ms"
0.0,0.0,0 5.721514880,-0.000002069,3963
4.002560960,0.000000000,9913
-88.817369600,-0.000000886,15850

1 I_0,mA U_34,mV t,ms
2 0.0 5.721514880 0.0 -0.000002069 0 3963
3 4.002560960 0.000000000 9913
4 -88.817369600 -0.000000886 15850