From 5aacc4f2dc0cfb09db6539fd9e497a57495bba16 Mon Sep 17 00:00:00 2001 From: Maxim Date: Wed, 9 Oct 2024 13:47:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BB=D0=B0=D0=B4=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B8=D0=BD=D0=B4=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Main.gd | 35 ++++++++++++++++++++--------------- Plata-check.tscn | 16 ++++++++-------- constants.gd | 7 ++++--- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Main.gd b/Main.gd index 6f0bbd5..7384579 100644 --- a/Main.gd +++ b/Main.gd @@ -58,7 +58,7 @@ func _ready(): # Поле для ввода (базовый порт) var edit_addr = node_select.get_node2(0, 2) edit_addr.editable = true - edit_addr.placeholder_text = ' 0x%x' % port_select + edit_addr.text = '%x' % port_select edit_addr.connect('text_submitted', Callable(self, '_on_written_addres')) # Поле для ввода (интервал непрерывной записи) @@ -98,13 +98,14 @@ func poll_receive(sock: Socket) -> bool: ## Приёмник $BROADCAST.text = 'BROADCAST: ' + str(rx_data) var line_yau07_control = node_select.get_node2(0, 0) line_yau07_control.text = ' ЯУ-07Б НА СВЯЗИ' - line_yau07_control.modulate = Color(0, 1, 0, 1) - else: - var line_yau07_control = node_select.get_node2(0, 0) - line_yau07_control.text = ' НЕТ СВЯЗИ С ЯУ-07' - line_yau07_control.modulate = Color(1, 0, 0, 1) - if (address == addr_receive) and (port == port_receive): + line_yau07_control.modulate = Constants.GREEN + if (address == addr_receive) and (port == port_receive) and flag_online: unit.parse(rx_data) + var line_board_control = node_select.get_node2(0, 1) + line_board_control.modulate = Constants.GREEN + else: + var line_board_control = node_select.get_node2(0, 1) + line_board_control.modulate = Constants.RED return false @@ -134,15 +135,17 @@ func on_timer() -> void: func on_line_changed(_unit) -> void: - print_debug() if unit.online: - var line_yau07_control = node_select.get_node2(0, 1) - line_yau07_control.modulate = Color(0, 1, 0, 1) + var line_yau07_control = node_select.get_node2(0, 0) + line_yau07_control.modulate = Constants.GREEN else: - var line_yau07_control = node_select.get_node2(0, 1) - line_yau07_control.modulate = Color(1, 0, 0, 1) + var line_yau07_control = node_select.get_node2(0, 0) + line_yau07_control.modulate = Constants.RED var light_interval = node_select.get_node2(1, 2) light_interval.modulate = Color(0.5, 0.5, 0.5, 1) + var line_board_control = node_select.get_node2(0, 1) + line_board_control.modulate = Constants.RED + $Turn_on.button_pressed = false flag_online = false flag_interval = false @@ -162,7 +165,7 @@ func on_command_done(_unit) -> void: $ISA.text = 'ISA: ' + str(isa) $ISA.modulate = Color(1, 1, 1, 1) else: - $ISA.modulate = Color(1, 0, 0, 1) + $ISA.modulate = Constants.RED func state_machine() -> void: @@ -209,7 +212,7 @@ func _on_written_interval(write_interval) -> void: timer.start(float(write_interval)) flag_interval = true var light_interval = node_select.get_node2(1, 2) - light_interval.modulate = Color(0, 1, 0, 1) + light_interval.modulate = Constants.GREEN ## Подключение @@ -223,6 +226,8 @@ func _on_button_pressed(turn_on) -> void: else: flag_online = false flag_interval = false + var light_interval = node_select.get_node2(1, 2) + light_interval.modulate = Color(1,1,1,1) func _on_button_read() -> void: @@ -241,5 +246,5 @@ func save_settings(): if file: file.store_line(address) # Сохранить IP-адрес file.store_line(str(port)) # Сохранить порт - file.store_line(str(port_select)) # Сохранить базовый адрес + file.store_line(str(port_select)) # Сохранить базовый адрес file.close() diff --git a/Plata-check.tscn b/Plata-check.tscn index 78a1cda..468857f 100644 --- a/Plata-check.tscn +++ b/Plata-check.tscn @@ -63,17 +63,17 @@ text = "ЗАПИСАТЬ" metadata/_edit_lock_ = true [node name="BROADCAST" type="Label" parent="."] -offset_left = 43.0 -offset_top = 178.0 -offset_right = 996.0 -offset_bottom = 201.0 +offset_left = 45.0 +offset_top = 218.0 +offset_right = 998.0 +offset_bottom = 241.0 metadata/_edit_lock_ = true [node name="ISA" type="Label" parent="."] -offset_left = 46.0 -offset_top = 211.0 -offset_right = 999.0 -offset_bottom = 234.0 +offset_left = 45.0 +offset_top = 187.0 +offset_right = 998.0 +offset_bottom = 210.0 metadata/_edit_lock_ = true [connection signal="toggled" from="Turn_on" to="." method="_on_button_pressed"] diff --git a/constants.gd b/constants.gd index 8d89341..3bc8dd9 100644 --- a/constants.gd +++ b/constants.gd @@ -2,8 +2,10 @@ extends Node const TableNode = preload("res://table/node.tscn") var file = FileAccess.open("user://constants.txt", FileAccess.READ) const UNICAST_PORT: int = 50003 -const UNICAST_ADDRESS: String = '10.1.1.14' +const UNICAST_ADDRESS: String = '10.1.1.3' const BROADCAST_PORT: int = 50000 +const RED = Color(1, 0, 0, 1) +const GREEN = Color(0, 1, 0, 1) var DEFAULT_ADDRESS: String = file.get_line() if file else '10.1.1.70' var DEFAULT_PORT: String = file.get_line() if file else '50070' var BASE_ADDR: int = int(file.get_line()) if file else 0x100 @@ -15,5 +17,4 @@ enum STATE { WAIT, # Режим ожидания команды READ, # Чтение из ИСА WRITE, # ЗАпись в ИСА -} - +}