From 1982125fc74cadfad2018fdb84ee78ae0d6ee339 Mon Sep 17 00:00:00 2001 From: Maxim Date: Wed, 28 May 2025 16:23:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B8=D0=B5=D0=BD=D1=82=20=D0=BE=D1=82=20=D0=A4=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/FS.gd | 6 +- scripts/PRD.gd | 195 +++++++++++++++++++++++++------------------------ 2 files changed, 103 insertions(+), 98 deletions(-) diff --git a/scripts/FS.gd b/scripts/FS.gd index bda9e99..9ecc459 100644 --- a/scripts/FS.gd +++ b/scripts/FS.gd @@ -178,7 +178,7 @@ class ClientFs extends Node: func send_fs_data() -> bool: if _status != _stream.STATUS_CONNECTED: - print("Error: Stream is not currently connected.") + print("Send_fs_data Error: Stream is not currently connected.") return false var error: int = _stream.put_data(command_stack.pop_front()) @@ -208,7 +208,7 @@ class ClientFs extends Node: send_packet_to(packet) ## Constant модуляция - func set_configure_state_msk_const_1(): + func set_configure_state_msk_const(): var index_size = 0x20 var packet = _form_packet(GROUP.GENERATOR, CmdCode.SET_CONFIGURE, index_size, counter) packet.encode_u8(0x3, 0x09) @@ -244,7 +244,7 @@ class ClientFs extends Node: packet.encode_float(0x18, attenuation) send_packet_to(packet) - func set_base_can_macro(installation_can_frequency: int, ): + func set_base_can_macro(installation_can_frequency: int): var index_size = 0x34 var packet = _form_packet(GROUP.BASE, CmdCode.BASE_CAN_MACRO_WRITE, index_size, counter) packet.encode_u16(0x08, 0x28) diff --git a/scripts/PRD.gd b/scripts/PRD.gd index 9a5c6ee..5381f55 100644 --- a/scripts/PRD.gd +++ b/scripts/PRD.gd @@ -199,19 +199,19 @@ func _ready() -> void: node_select_yau_07b_3.get_node2(1, 4).connect('item_selected', Callable(self, '_on_attenuator_3')) ## FS 1 - node_select_fs_1.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_1')) - node_select_fs_1.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_1')) - node_select_fs_1.get_node2(1, 4).connect('item_selected', Callable(self, '_on_modul_fs_1')) + node_select_fs_1.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq').bind(Network.unit_fs_1)) + node_select_fs_1.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att').bind(Network.unit_fs_1)) + node_select_fs_1.get_node2(1, 4).connect('item_selected', Callable(self, '_on_modul_fs').bind(Network.unit_fs_1)) node_select_fs_1.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_get_status').bind(Network.unit_fs_1)) - node_select_fs_1.get_node2(1, 7).connect('text_submitted', Callable(self, '_on_set_base_can_macro')) - node_select_fs_1.get_node2(1, 8).get_child(1, false).connect('toggled', Callable(self, '_on_status_can_macro_1')) + node_select_fs_1.get_node2(1, 7).connect('text_submitted', Callable(self, '_on_set_base_can_macro').bind(Network.unit_fs_1)) + node_select_fs_1.get_node2(1, 8).get_child(1, false).connect('toggled', Callable(self, '_on_status_can_macro').bind(Network.unit_fs_1)) ## FS 2 - node_select_fs_2.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_2')) - node_select_fs_2.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_2')) - node_select_fs_2.get_node2(1, 4).connect('item_selected', Callable(self, '_on_modul_fs_2')) + node_select_fs_2.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq').bind(Network.unit_fs_2)) + node_select_fs_2.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att').bind(Network.unit_fs_2)) + node_select_fs_2.get_node2(1, 4).connect('item_selected', Callable(self, '_on_modul_fs').bind(Network.unit_fs_2)) node_select_fs_2.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_get_status').bind(Network.unit_fs_2)) - node_select_fs_2.get_node2(1, 7).connect('text_submitted', Callable(self, '_on_set_base_can_macro_2')) - node_select_fs_2.get_node2(1, 8).get_child(1, false).connect('toggled', Callable(self, '_on_status_can_macro_2')) + node_select_fs_2.get_node2(1, 7).connect('text_submitted', Callable(self, '_on_set_base_can_macro').bind(Network.unit_fs_2)) + node_select_fs_2.get_node2(1, 8).get_child(1, false).connect('toggled', Callable(self, '_on_status_can_macro').bind(Network.unit_fs_2)) ## FS 3 node_select_fs_3.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_3')) node_select_fs_3.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_3')) @@ -230,14 +230,14 @@ func _ready() -> void: #Network.connect('data_from_fs_3', _on_data_fs_3) - Network.unit_fs_1.connect("connected", Callable(self, "_on_port_changed").bind(Network.unit_fs_1, true)) - Network.unit_fs_1.connect("disconnected", Callable(self, "_on_port_changed").bind(Network.unit_fs_1, false)) - Network.unit_fs_1.connect("error_connect", Callable(self, "_on_port_changed").bind(Network.unit_fs_1, false)) + Network.unit_fs_1.connect("connected", Callable(self, "_on_port_changed").bind(Network.unit_fs_1, Constants.STATE_VAL.GOOD)) + Network.unit_fs_1.connect("disconnected", Callable(self, "_on_port_changed").bind(Network.unit_fs_1, Constants.STATE_VAL.NONE)) + Network.unit_fs_1.connect("error_connect", Callable(self, "_on_port_changed").bind(Network.unit_fs_1, Constants.STATE_VAL.ERROR)) Network.unit_fs_1.connect("data_fs", Callable(self, "_on_data_fs").bind(Network.unit_fs_1)) - Network.unit_fs_2.connect("connected", Callable(self, "_on_port_changed").bind(Network.unit_fs_2, true)) - Network.unit_fs_2.connect("disconnected", Callable(self, "_on_port_changed").bind(Network.unit_fs_2, false)) - Network.unit_fs_2.connect("error_connect", Callable(self, "_on_port_changed").bind(Network.unit_fs_2, false)) + Network.unit_fs_2.connect("connected", Callable(self, "_on_port_changed").bind(Network.unit_fs_2, Constants.STATE_VAL.GOOD)) + Network.unit_fs_2.connect("disconnected", Callable(self, "_on_port_changed").bind(Network.unit_fs_2, Constants.STATE_VAL.NONE)) + Network.unit_fs_2.connect("error_connect", Callable(self, "_on_port_changed").bind(Network.unit_fs_2, Constants.STATE_VAL.ERROR)) Network.unit_fs_2.connect("data_fs", Callable(self, "_on_data_fs").bind(Network.unit_fs_2)) @@ -340,8 +340,6 @@ func _on_yau_status(addr: String): var status_yau_list = $TabContainer/PRD/status_yau_list.get_children() var status_label = $TabContainer/PRD/status_yau if addr.is_empty(): - if Network.unit.online: - return # Сброс состояния, если адрес пуст (нет связи) for label in status_yau_list: label.text = '' @@ -906,25 +904,30 @@ func set_bits(v, a, m): ## ФС Connect close -func _on_port_changed(client_addr: String, unit_fs_client: Node, status_online:bool) -> void: +func _on_port_changed(client_addr: String, unit_fs_client: Node, status) -> void: + var loging = 'Соединение ...' if status == Constants.STATE_VAL.NONE else 'Подключено!' if status == Constants.STATE_VAL.GOOD else 'Ошибка' + var color = Color.AQUAMARINE if status == Constants.STATE_VAL.GOOD else Color.DARK_GRAY if status == Constants.STATE_VAL.NONE else Color.CRIMSON if unit_fs_client == Network.unit_fs_1: $TabContainer/PRD/body_grid/litera_2_4_6/fs_control.set_node_text(1, 1, client_addr) - $TabContainer/PRD/body_grid/litera_2_4_6/fs_control.get_node2(1,1).modulate = Color.AQUAMARINE if status_online else Color.DARK_GRAY + $TabContainer/PRD/body_grid/litera_2_4_6/fs_control.set_node_text(2, 1, loging) + $TabContainer/PRD/body_grid/litera_2_4_6/fs_control.get_node2(1,1).modulate = color elif unit_fs_client == Network.unit_fs_2: $TabContainer/PRD/body_grid/litera_3_5_7/fs_control.set_node_text(1, 1, client_addr) - $TabContainer/PRD/body_grid/litera_3_5_7/fs_control.get_node2(1,1).modulate = Color.AQUAMARINE if status_online else Color.DARK_GRAY + $TabContainer/PRD/body_grid/litera_3_5_7/fs_control.set_node_text(2, 1, loging) + $TabContainer/PRD/body_grid/litera_3_5_7/fs_control.get_node2(1,1).modulate = color elif unit_fs_client == Network.unit_fs_3: $TabContainer/PRD/body_grid/litera_1/fs_control.set_node_text(1, 1, client_addr) - $TabContainer/PRD/body_grid/litera_1/fs_control.get_node2(1,1).modulate = Color.AQUAMARINE if status_online else Color.DARK_GRAY + $TabContainer/PRD/body_grid/litera_1/fs_control.set_node_text(2, 1, loging) + $TabContainer/PRD/body_grid/litera_1/fs_control.get_node2(1,1).modulate = color # Установка формы сигнала (модуляция константа или msk) -func _on_modul_fs_1(modulation_select_1) -> void: +func _on_modul_fs(modulation_select_1: int, unit_fs_client: Node) -> void: if modulation_select_1 == 0: - Network.set_configure_gen_const_1() + unit_fs_client.set_configure_state_msk_const() elif modulation_select_1 == 1: - Network.set_configure_gen_msk_1() + unit_fs_client.set_configure_state_msk_modul_1() # Установка и получение статуса генератора фс @@ -933,6 +936,7 @@ func _on_get_status(toggled_btn: bool, unit_fs_client: Node): var inverted_state = not toggled_btn unit_fs_client.set_gen_state(inverted_state) unit_fs_client.get_gen_state() + unit_fs_client.get_base_current_temp() func _on_set_ferq(freq: String, unit_fs_client: Node): @@ -954,18 +958,19 @@ func _on_set_ferq(freq: String, unit_fs_client: Node): unit_fs_client.get_carrier() -func _on_set_att_1(att: String): - Network.unit_fs_1.set_att_batch(float(att)) +func _on_set_att(att: String, unit_fs_client: Node): + unit_fs_client.set_att_batch(float(att)) save_settings(float(att), 0) - Network.unit_fs_1.get_att_batch() + unit_fs_client.get_att_batch() -func _on_set_base_can_macro(can_freq: String): - Network.set_can_macro(int(can_freq)) +func _on_set_base_can_macro(can_freq: String, unit_fs_client: Node): + unit_fs_client.set_base_can_macro(int(can_freq)) + unit_fs_client.get_base_can_macro() -func _on_status_can_macro_1(toggled_btn: bool): - Network.status_can_macro_1(toggled_btn) +func _on_status_can_macro(toggled_btn: bool, unit_fs_client: Node): + unit_fs_client.status_can_macro_exec(toggled_btn) ### 2 ФС @@ -991,71 +996,71 @@ func _on_status_can_macro_1(toggled_btn: bool): #print_debug('Некорректная частота') #return #Network.set_fs_ferq_carrier_2(freq_int) +# +# +#func _on_set_att_2(att: String): + #Network.set_fs_attenuation_2(float(att)) + #save_settings(float(att), 1) +# +# +#func _on_set_base_can_macro_2(can_freq: String): + #Network.set_can_macro_2(int(can_freq)) +# +# +#func _on_status_can_macro_2(toggled_btn: bool): + #Network.status_can_macro_2(toggled_btn) +# +# +#func _on_modul_fs_2(modulation_select_2) -> void: + #if modulation_select_2 == 0: + #Network.set_configure_gen_const_2() + #elif modulation_select_2 == 1: + #Network.set_configure_gen_msk_2() -func _on_set_att_2(att: String): - Network.set_fs_attenuation_2(float(att)) - save_settings(float(att), 1) - - -func _on_set_base_can_macro_2(can_freq: String): - Network.set_can_macro_2(int(can_freq)) - - -func _on_status_can_macro_2(toggled_btn: bool): - Network.status_can_macro_2(toggled_btn) - - -func _on_modul_fs_2(modulation_select_2) -> void: - if modulation_select_2 == 0: - Network.set_configure_gen_const_2() - elif modulation_select_2 == 1: - Network.set_configure_gen_msk_2() - - -## ФС 3 -func _on_get_status_3(toggled_btn): - if $Background/switch_panel/select_prd.is_pressed() or $Background/switch_panel/texture_prd.is_pressed(): - var inverted_state = not toggled_btn - Network.set_fs_gen_status_3(inverted_state) - Network.get_gen_state_3() - - -func _on_set_ferq_3(freq: String): - # Проверка на наличие символов в строке freq - var regex = RegEx.new() - regex.compile("^[0-9]+$") - if not regex.search(freq): - print_debug('Ошибка: частота должна быть числом без букв') - return - # Преобразование строки в число - var freq_int = int(freq) * 1_000_000 - - # Проверка на диапазон - if freq_int < 370 * 1_000_000 or freq_int > 6100 * 1_000_000: - print_debug('Некорректная частота') - return - Network.set_fs_ferq_carrier_3(freq_int) - - -func _on_set_att_3(att: String): - Network.set_fs_attenuation_3(float(att)) - save_settings(float(att), 2) - - -func _on_set_base_can_macro_3(can_freq: String): - Network.set_can_macro_3(int(can_freq)) - - -func _on_status_can_macro_3(toggled_btn: bool): - Network.status_can_macro_3(toggled_btn) - - -func _on_modul_fs_3(modulation_select_3) -> void: - if modulation_select_3 == 0: - Network.set_configure_gen_const_3() - elif modulation_select_3 == 1: - Network.set_configure_gen_msk_3() +### ФС 3 +#func _on_get_status_3(toggled_btn): + #if $Background/switch_panel/select_prd.is_pressed() or $Background/switch_panel/texture_prd.is_pressed(): + #var inverted_state = not toggled_btn + #Network.set_fs_gen_status_3(inverted_state) + #Network.get_gen_state_3() +# +# +#func _on_set_ferq_3(freq: String): + ## Проверка на наличие символов в строке freq + #var regex = RegEx.new() + #regex.compile("^[0-9]+$") + #if not regex.search(freq): + #print_debug('Ошибка: частота должна быть числом без букв') + #return + ## Преобразование строки в число + #var freq_int = int(freq) * 1_000_000 +# + ## Проверка на диапазон + #if freq_int < 370 * 1_000_000 or freq_int > 6100 * 1_000_000: + #print_debug('Некорректная частота') + #return + #Network.set_fs_ferq_carrier_3(freq_int) +# +# +#func _on_set_att_3(att: String): + #Network.set_fs_attenuation_3(float(att)) + #save_settings(float(att), 2) +# +# +#func _on_set_base_can_macro_3(can_freq: String): + #Network.set_can_macro_3(int(can_freq)) +# +# +#func _on_status_can_macro_3(toggled_btn: bool): + #Network.status_can_macro_3(toggled_btn) +# +# +#func _on_modul_fs_3(modulation_select_3) -> void: + #if modulation_select_3 == 0: + #Network.set_configure_gen_const_3() + #elif modulation_select_3 == 1: + #Network.set_configure_gen_msk_3() ## Switch panel