Отладка согласований кнопок между приборами
This commit is contained in:
33
main.gd
33
main.gd
@@ -191,11 +191,10 @@ func _update_tab_container():
|
||||
tab_container.visible = has_visible_tabs
|
||||
|
||||
|
||||
func _on_update_isa_ports(isa_ports: Dictionary)->void:
|
||||
func _on_update_isa_ports(isa_ports: Dictionary, device_name: String)->void:
|
||||
for port_addr in isa_ports:
|
||||
var value = isa_ports[port_addr]
|
||||
|
||||
# Группы кнопок обновлять для каждого порта
|
||||
var port_configs = {
|
||||
0x106: [ # Порт 0x106
|
||||
{'group': 'dou2', 'mask': 0b111, 'shift': 0},
|
||||
@@ -210,18 +209,35 @@ func _on_update_isa_ports(isa_ports: Dictionary)->void:
|
||||
if port_configs.has(port_addr):
|
||||
for config in port_configs[port_addr]:
|
||||
var status = (value >> config.shift) & config.mask
|
||||
_update_button_group(config.group, status)
|
||||
_update_specific_device_buttons(config.group, status, device_name)
|
||||
|
||||
|
||||
func _update_button_group(group_name: String, status: int) -> void:
|
||||
"""Обновление всех кнопок в группе на основе статуса"""
|
||||
var buttons = get_tree().get_nodes_in_group(group_name)
|
||||
func _update_specific_device_buttons(group_name: String, status: int, target_device: String) -> void:
|
||||
"""Обновление кнопок только для конкретного устройства"""
|
||||
var buttons = _get_nodes_for_device(target_device, group_name)
|
||||
|
||||
for button in buttons:
|
||||
if button.has_meta('bit'):
|
||||
var bit_value = button.get_meta('bit')
|
||||
var should_be_pressed = (status == bit_value)
|
||||
button.set_pressed_no_signal(should_be_pressed)
|
||||
|
||||
if button.button_pressed != should_be_pressed:
|
||||
button.set_pressed_no_signal(should_be_pressed)
|
||||
|
||||
|
||||
func _get_nodes_for_device(device: String, group_name: String) -> Array:
|
||||
"""Получение всех нод в группе, принадлежащих указанному устройству"""
|
||||
var prd_nodes = get_tree().get_nodes_in_group('prd')
|
||||
var result = []
|
||||
|
||||
for prd in prd_nodes:
|
||||
if prd.get_meta('yau07') == device:
|
||||
for node in get_tree().get_nodes_in_group(group_name):
|
||||
if prd.is_ancestor_of(node) and node.get_meta('device') == device:
|
||||
result.append(node)
|
||||
break
|
||||
return result
|
||||
|
||||
|
||||
## Функция для установки статусов ячеек на связи (УГ, ЭМС-Г, УКП)
|
||||
func _on_modify_sockets(toggled: bool, bit: int, device: String)->void:
|
||||
@@ -248,7 +264,7 @@ func _on_modify_status(toggled: bool, bit: int, device: String, status_type: Str
|
||||
return
|
||||
|
||||
var udp_unit = dictionary_yau07[device]
|
||||
var button_group = get_tree().get_nodes_in_group(status_type)
|
||||
var button_group = _get_nodes_for_device(device, status_type)
|
||||
|
||||
if not toggled:
|
||||
# Восстанавливаем предыдущее состояние
|
||||
@@ -261,7 +277,6 @@ func _on_modify_status(toggled: bool, bit: int, device: String, status_type: Str
|
||||
for button in button_group:
|
||||
if button.has_meta('bit') and button.get_meta('bit') != bit and button.button_pressed:
|
||||
button.set_pressed_no_signal(false)
|
||||
print('button_press_bit: ', bit)
|
||||
# Устанавливаем статус через менеджер
|
||||
match status_type:
|
||||
"dou2":
|
||||
|
||||
@@ -205,7 +205,7 @@ func set_isa_port(port_addr: int, value: int) -> bool:
|
||||
return false
|
||||
|
||||
_isa_ports[port_addr] = value
|
||||
emit_signal('update_isa_ports', _isa_ports)
|
||||
emit_signal('update_isa_ports', _isa_ports, _self_name)
|
||||
return true
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user