from dis import pretty_flags from PySide6 import QtWidgets # Импорт модуля QtWidgets из библиотеки PySide6 from PySide6.QtGui import QPixmap,QFont import sys # Импорт модуля sys для работы с системными параметрами и выходом из программы import numpy as np import struct import xml.etree.ElementTree as ET from xml.dom import minidom def switch(metric): if metric == 'nS': return 10**-9 elif metric == 'uS': return 10**-6 elif metric == 'mS': return 10**-3 elif metric == 'S': return 1 def set_params(): pulse_period_metric = pulse_period_combo_box.currentText() pulse_period = (np.int32(pulse_period_line_edit.text())) * switch(pulse_period_metric) pulse_width_metric = pulse_width_combo_box.currentText() pulse_width = (np.int32(pulse_width_line_edit.text())) * switch(pulse_width_metric) delay1_metric = delay1_combo_box.currentText() delay1 = (np.int32(delay1_line_edit.text())) * switch(delay1_metric) delay2_metric = delay2_combo_box.currentText() delay2 = (np.int32(delay2_line_edit.text())) * switch(delay2_metric) sample_freq = np.int32(sample_rate_box.currentText()) pulse_number = np.int32(period_number_line_edit.text()) print(f""" Pulse parameters: pulse width - {pulse_width} S pulse period - {pulse_period} S delay 1 - {delay1} S delay 2 - {delay2} S pulse_number - {pulse_number} sample frequency {sample_freq} MHz""") #add = (pulse_width * pulse_number * sample_freq * (10**6) * 2) counter = 0 n_high = round(pulse_width * sample_freq * (10 ** 6)) print(f"high samples {n_high}") n_low = round((pulse_period - pulse_width) * sample_freq * (10 ** 6)) print(f"low samples {n_low}") size_1 =(n_low + n_high) * 2 print(f'rf array size_1 = {size_1}') size_2 = np.int32(size_1) * np.int32(pulse_number) print(f'rf array size_2 = {size_2}') rf_array = np.zeros(size_2, dtype=np.int8) for _ in range(0, pulse_number, 1): for _ in range(0, n_high, 1): rf_array[counter] = np.int8(127) rf_array[counter + 1] = np.int8(0) counter += 2 for _ in range(0, n_low, 1): rf_array[counter] = np.int8(0) rf_array[counter + 1] = np.int8(0) counter += 2 print(rf_array) f = open(f'pulse_pw_{pulse_width}_S_period_{pulse_period}_S_reps_{pulse_number}_delay1_{delay1}_delay2_{delay2}.bin', 'wb') # открываем файл на чтение # f = open(f'test_100_pulses_10Msps_1ms.bin', 'wb') # открываем файл на чтение for elem in rf_array: # берём каждую строчку из файла f f.write(struct.pack('