diff --git a/__pycache__/device_commands.cpython-312.pyc b/__pycache__/device_commands.cpython-312.pyc index 160d46c..32f0409 100644 Binary files a/__pycache__/device_commands.cpython-312.pyc and b/__pycache__/device_commands.cpython-312.pyc differ diff --git a/__pycache__/device_conversion.cpython-312.pyc b/__pycache__/device_conversion.cpython-312.pyc index 045b873..0780389 100644 Binary files a/__pycache__/device_conversion.cpython-312.pyc and b/__pycache__/device_conversion.cpython-312.pyc differ diff --git a/__pycache__/device_interaction.cpython-312.pyc b/__pycache__/device_interaction.cpython-312.pyc index f77ecac..b45b308 100644 Binary files a/__pycache__/device_interaction.cpython-312.pyc and b/__pycache__/device_interaction.cpython-312.pyc differ diff --git a/__pycache__/gui.cpython-312.pyc b/__pycache__/gui.cpython-312.pyc index 358baf7..e8e9f4b 100644 Binary files a/__pycache__/gui.cpython-312.pyc and b/__pycache__/gui.cpython-312.pyc differ diff --git a/_device_main.py b/_device_main.py index 5e12a07..a1e5f47 100644 --- a/_device_main.py +++ b/_device_main.py @@ -1,4 +1,4 @@ -from FreeSimpleGUI import TIMEOUT_KEY, WIN_CLOSED +from FreeSimpleGUI import TIMEOUT_KEY, WIN_CLOSED import json import math import socket @@ -18,10 +18,10 @@ GUI_TIMEOUT_INTERVAL = 5#505 - dev.WAIT_AFTER_SEND*1000 # GUI refresh time in mi SAVE_POINTS_NUMBER = 1000 # Number of most recent data points kept in memory -INITIAL_TEMPERATURE_1 = 22.40 # Set initial temperature for Laser 1 in Celsius: from -1 to 45 C ?? -INITIAL_TEMPERATURE_2 = 16.70 # Set initial temperature for Laser 2 in Celsius: from -1 to 45 C ?? -INITIAL_CURRENT_1 = 32.0 # 64.0879 max # Set initial current for Laser 1, in mA -INITIAL_CURRENT_2 = 32.0 # 64.0879 max # Set initial current for Laser 2, in mA +INITIAL_TEMPERATURE_1 = 28 # Set initial temperature for Laser 1 in Celsius: from -1 to 45 C ?? +INITIAL_TEMPERATURE_2 = 28.9 # Set initial temperature for Laser 2 in Celsius: from -1 to 45 C ?? +INITIAL_CURRENT_1 = 33 # 64.0879 max # Set initial current for Laser 1, in mA +INITIAL_CURRENT_2 = 35 # 64.0879 max # Set initial current for Laser 2, in mA #### ---- Functions @@ -62,17 +62,17 @@ def set_initial_params(): params['Min_Temp_1'] = INITIAL_TEMPERATURE_1 params['Max_Temp_1'] = 28 params['Min_Current_1'] = INITIAL_CURRENT_1 - params['Max_Current_1'] = 50.0 + params['Max_Current_1'] = 70.0 #50 params['Delta_Temp_1'] = 0.05 params['Delta_Current_1'] = 0.05 params['Min_Temp_2'] = INITIAL_TEMPERATURE_2 params['Max_Temp_2'] = 28 params['Min_Current_2'] = INITIAL_CURRENT_2 - params['Max_Current_2'] = 50.0 + params['Max_Current_2'] = 60 # 50 params['Delta_Temp_2'] = 0.05 params['Delta_Current_2'] = 0.05 params['Delta_Time'] = 50 - params['Tau'] = 3 + params['Tau'] = 10 return params def update_data_lists(): diff --git a/device_commands.py b/device_commands.py index e839576..741743a 100644 --- a/device_commands.py +++ b/device_commands.py @@ -173,6 +173,7 @@ def get_DATA(prt): print("Received "+str(prt.inWaiting())+" bytes.\n") if prt.inWaiting()!=GET_DATA_TOTAL_LENGTH: print("Error. Couldn't get DATA data.") + print("receiven data len:", prt.inWaiting()) return None out_bytes = prt.read(GET_DATA_TOTAL_LENGTH) @@ -324,18 +325,18 @@ def decode_DATA(dh): data = {} data['datetime'] = datetime.now() data['Header'] = get_word(dh, 0) - data['I1'] = cnv.conv_I_N_to_mA(get_int_word(dh, 1)) - data['I2'] = cnv.conv_I_N_to_mA(get_int_word(dh, 2)) - data['TO_LSB'] = get_int_word(dh, 3) - data['TO_MSB'] = get_int_word(dh, 4) - data['Temp_1'] = cnv.conv_T_N_to_C(get_int_word(dh, 5)) - data['Temp_2'] = cnv.conv_T_N_to_C(get_int_word(dh, 6)) - data['Temp_Ext_1'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 7)) - data['Temp_Ext_2'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 8)) - data['MON_3V3'] = cnv.conv_U3V3_N_to_V(get_int_word(dh, 9)) - data['MON_5V1'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 10)) - data['MON_5V2'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 11)) - data['MON_7V0'] = cnv.conv_U7V_N_to_V(get_int_word(dh, 12)) + data['I1'] = cnv.conv_I_N_to_mA(get_int_word(dh, 1)) #LD1_param.POWER + data['I2'] = cnv.conv_I_N_to_mA(get_int_word(dh, 2)) #LD2_param.POWER + data['TO_LSB'] = get_int_word(dh, 3) #TO6_counter_LSB + data['TO_MSB'] = get_int_word(dh, 4) #TO6_counter_MSB + data['Temp_1'] = cnv.conv_T_N_to_C(get_int_word(dh, 5)) #LD1_param.LD_CURR_TEMP + data['Temp_2'] = cnv.conv_T_N_to_C(get_int_word(dh, 6)) #LD2_param.LD_CURR_TEMP + data['Temp_Ext_1'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 7)) #U_Rt1_ext_Gain + data['Temp_Ext_2'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 8)) #U_Rt2_ext_Gain + data['MON_3V3'] = cnv.conv_U3V3_N_to_V(get_int_word(dh, 9)) #3V_monitor + data['MON_5V1'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 10)) #5V1_monitor + data['MON_5V2'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 11)) #5V2_monitor + data['MON_7V0'] = cnv.conv_U7V_N_to_V(get_int_word(dh, 12)) #7V_monitor data['Message_ID'] = get_word(dh, 13) # Last received command data['CRC'] = get_word(dh, 14) diff --git a/device_conversion.py b/device_conversion.py index 25e582b..947b5a9 100644 --- a/device_conversion.py +++ b/device_conversion.py @@ -13,7 +13,7 @@ R4 = 30000 # Ohm R5 = 27000 # Ohm R6 = 56000 # Ohm -RREF = 28.7 # Ohm (current-setting resistor) @1550 nm - 28.7 Ohm; @840 nm - 10 Ohm +RREF = 10 # Ohm (current-setting resistor) @1550 nm - 28.7 Ohm; @840 nm - 10 Ohm R7 = 22000 # Ohm R8 = 22000 # Ohm diff --git a/device_interaction.py b/device_interaction.py index 92084c6..6e2cb78 100644 --- a/device_interaction.py +++ b/device_interaction.py @@ -12,7 +12,20 @@ WAIT_AFTER_SEND = 0.15 # Wait after sending command, before requesting input (in #### ---- High-level port commands - +''' +def create_port_connection(): + prt = None + for port, _, _ in sorted(cmd.list_ports.comports()): + try: + prt = cmd.setup_port_connection(port=port, baudrate=115200, timeout_sec=1) + cmd.open_port(prt) + reset_port_settings(prt) + except: + prt.close() + continue + break + return prt +''' def create_port_connection(): prt = None print() @@ -44,6 +57,9 @@ def create_port_connection(): break return prt + + + # def setup_connection(): # prt = cmd.setup_port_connection() # cmd.open_port(prt) diff --git a/gui.py b/gui.py index df3084c..119ba16 100644 --- a/gui.py +++ b/gui.py @@ -1,4 +1,6 @@ +#from Tools.scripts.highlight import default_html +#default_html import FreeSimpleGUI as sg #### ---- GUI Constants @@ -28,7 +30,7 @@ SET_DELTA_TEMPERATURE_TEXT_2 = 'Шаг дискретизации темпера SET_MIN_CURRENT_TEXT_2 = 'Мнимальный ток лазера 2 (мА):' SET_MAX_CURRENT_TEXT_2 = 'Максимальный ток лазера 2 (мА):' SET_DELTA_CURRENT_TEXT_2 = 'Шаг дискретизации тока лазера 2 (0.002-0.5 мА):' -SET_DELTA_T_TEXT = 'Шаг дискретизации времени (1-100 мкс):' +SET_DELTA_T_TEXT = 'Шаг дискретизации времени (20-100 мкс, шаг 10 мкс):' SET_TAU_T_TEXT = 'Время задержки (3-10мс):' SET_TEXT_WIDTH_NEW = 40