Отладка индикации подключения

This commit is contained in:
2024-10-09 13:47:01 +03:00
parent b7359c5fab
commit 5aacc4f2dc
3 changed files with 32 additions and 26 deletions

35
Main.gd
View File

@@ -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()

View File

@@ -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"]

View File

@@ -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
@@ -16,4 +18,3 @@ enum STATE {
READ, # Чтение из ИСА
WRITE, # ЗАпись в ИСА
}