Доработка. WIP Отображение конфликтов на матрице

This commit is contained in:
sasha80
2026-03-23 14:20:06 +03:00
parent 528566e949
commit c5da181fb7
3 changed files with 233 additions and 101 deletions

View File

@@ -33,8 +33,8 @@ extends Panel
#endregion
#region Заполняется автоматически при запуске
var name_to_index: Dictionary[StringName, int] ## Имя устройства -> Индекс
var name_to_scale: Dictionary[StringName, Control] ## Имя устройства -> Шкала
var name_to_index: Dictionary[StringName, int] ## Имя устройства -> Индекс
var name_to_scale: Dictionary[StringName, GridContainer] ## Имя устройства -> Шкала
var table_cell_row: Array
#endregion
@@ -65,11 +65,6 @@ func _ready() -> void:
for node in claster_scales:
var nm: = node.get_meta('unit_name') as StringName
name_to_scale[nm] = node
var header_row: = []
for cell_scn in table_headers:
header_row.append(load(cell_scn))
for cell_scn in table_cells:
table_cell_row.append(load(cell_scn))
# Расскрасить чётные-нечётные
for node in get_tree().get_nodes_in_group('нечётные'):
@@ -79,7 +74,17 @@ func _ready() -> void:
node.get_node('panel_rx').back_color = color_even
node.get_node('panel_tx').back_color = color_even
# Подключить обработчик для приёма данных
for nm in yems_data_info:
var yems_unit = network.get_unit_instance(nm)
yems_unit.connect('data_received', on_data_received.bind(nm))
# Настроить таблицу
var header_row: = []
for cell_scn in table_headers:
header_row.append(load(cell_scn))
for cell_scn in table_cells:
table_cell_row.append(load(cell_scn))
var ctable: = $'таблица/сетка'
ctable.set_header(header_row)
ctable.set_header_text(table_header_text)
@@ -91,27 +96,37 @@ func _ready() -> void:
ctable.set_header_min_hight(table_rows_hight)
ctable.pin_header2()
# Подключить обработчик для приёма данных
for nm in yems_data_info:
var yems_unit = network.get_unit_instance(nm)
yems_unit.connect('data_received', on_data_received.bind(nm))
## Обрабатывает событие [b]data_received[/b]
func on_data_received(data: Dictionary, nm: StringName):
yems_data_info[nm].merge(data, true)
var unit_data: = yems_data_info[nm]
unit_data.merge(data, true)
if not unit_data:
return
var ctable: GDTable = $'таблица/сетка'
var claster_scale: = name_to_scale[nm] as GridContainer
var unit_data = yems_data_info.get(nm)
if unit_data:
var indexes: = cnames_table[nm] # Идексы строк в таблице
map_yems_data_to_table(ctable, unit_data, indexes)
map_yems_data_to_scale(claster_scale, unit_data)
var indexes: = cnames_table[nm] # Идексы строк в таблице
map_yems_data_to_table(unit_data, ctable, indexes)
map_yems_data_to_scale(unit_data, claster_scale)
var inters: = find_inters(yems_data_info)
map_inters_to_matrix(inters, $'матрица')
func map_inters_to_matrix(inters: Array, matrix: GridContainer) -> void:
var nodes = matrix.get_children()
for item in inters:
var tx_unit_name = item[0]
var rx_unit_name = item[1]
var i_col = 1 + name_to_index[tx_unit_name] # (1 +) - одна колонка для значков приёмников
var i_row = 1 + name_to_index[rx_unit_name] # (1 +) - один ряд для значков передатчиков
var idx = i_col + i_row * matrix.columns # последовательный индекс в GridContainer
var node = nodes[idx] # Искомый элемент
node.button_pressed = true
## Отображает кластеры в таблицу
## [param nm] - имя устройства
func map_yems_data_to_table(ctable: GDTable, unit_data: Dictionary, indexes: Dictionary):
func map_yems_data_to_table(unit_data: Dictionary, ctable: GDTable, indexes: Dictionary):
# Обойти все кластеры устройства
for cls in unit_data.mcls:
# Строки для заполнения ряда
@@ -120,7 +135,7 @@ func map_yems_data_to_table(ctable: GDTable, unit_data: Dictionary, indexes: Dic
if cls.cname in indexes:
# Получить индекс строки кластера в таблице
var i_row = indexes[cls.cname]
ctable.set_row_text(0, row_text)
ctable.set_row_text(i_row, row_text)
# Если такого кластера нет, создать его строку в таблице
else:
# Создать новый ряд
@@ -132,9 +147,40 @@ func map_yems_data_to_table(ctable: GDTable, unit_data: Dictionary, indexes: Dic
ctable.set_row_min_hight(i_row, table_rows_hight)
func find_inters(info: Dictionary) -> Array:
# info - словарь, его структура
# {
# "устройство": # имя устройства ("эмс-ор63")
# [
# {
# cname, # имя кластера ("Кластер-0")
# wfb, # ширина диапазона, МГЦ (800.0)
# cfb, # центр диапазона, МГЦ (2000.0)
# txe, # передатчик включен
# rxe # передатчик выключен
# },
# {
# cname, # имя кластера ("Кластер-1")
# wfb, # ширина диапазона, МГЦ (200.0)
# cfb, # центр диапазона, МГЦ (1000.0)
# txe, # передатчик включен
# rxe # передатчик выключен
# },
# ]
# }
for nm in info:
# nm - имя устройства
var unit_data = info[nm]
if not unit_data: continue
for cls in unit_data.mcls:
# cls - один кластер
print_debug([cls.cname, cls.wfb, cls.cfb, cls.txe, cls.rxe])
return [['эмс-ор63', 'эмс-ор63', 'Кластер-0', 'Кластер-0', 1500.0, 2500.0]]
## Отображает кластеры на шкале
## [param nm] - имя устройства
func map_yems_data_to_scale(claster_scale: GridContainer, unit_data: Dictionary):
func map_yems_data_to_scale(unit_data: Dictionary, claster_scale: GridContainer):
# Обойти все кластеры устройства
for cls in unit_data.mcls:
var c: = remap(cls.cfb, freq_min, freq_max, 0.0, 1.0)

View File

@@ -343,8 +343,10 @@ back_color = Color(0.31863, 0.32773, 0.327729, 1)
[node name="фон-матрицы" type="Polygon2D" parent="."]
self_modulate = Color(0.498039, 0.498039, 0.498039, 0.498039)
position = Vector2(400, 0)
position = Vector2(1830, 1020)
offset = Vector2(-1430, -1020)
polygon = PackedVector2Array(800, 765, 1200, 765, 1200, 1165, 800, 1165)
uv = PackedVector2Array(800, 765, 1200, 765, 1200, 1165, 800, 1165)
[node name="матрица" type="GridContainer" parent="."]
layout_mode = 0
@@ -361,194 +363,278 @@ texture = ExtResource("6_a0vpj")
[node name="прд-0" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("7_xr3ub")
metadata/unit_name = &""
[node name="прд-1" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("8_saoyo")
metadata/unit_name = &""
[node name="прд-2" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("9_bqil1")
metadata/unit_name = &""
[node name="прд-3" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("10_ggqgc")
metadata/unit_name = &""
[node name="прд-4" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("11_xothm")
metadata/unit_name = &""
[node name="прд-5" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("12_4rjt3")
metadata/unit_name = &""
[node name="прм-0" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("13_g0j2q")
metadata/unit_name = &"эмс-ор63"
[node name="матрица-0-0" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-0-0" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-0-1" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-0-1" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-0-2" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-0-2" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-0-3" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-0-3" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-0-4" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-0-4" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-0-5" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-0-5" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="прм-1" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("14_crrpm")
metadata/unit_name = &""
[node name="матрица-1-0" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-1-0" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-1-1" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-1-1" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-1-2" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-1-2" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-1-3" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-1-3" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-1-4" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-1-4" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-1-5" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-1-5" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="прм-2" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("15_0dspi")
metadata/unit_name = &""
[node name="матрица-2-0" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-2-0" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-2-1" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-2-1" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-2-2" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-2-5" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-2-3" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-2-2" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-2-4" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-2-3" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-2-5" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-2-4" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="прм-3" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("16_6042y")
metadata/unit_name = &""
[node name="матрица-3-0" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-3-0" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-3-1" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-3-1" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-3-2" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-3-2" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-3-3" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-3-3" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-3-4" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-3-4" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-3-5" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-3-5" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="прм-4" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("17_gvsi1")
metadata/unit_name = &""
[node name="матрица-4-0" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-4-0" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-4-1" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-4-1" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-4-2" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-4-2" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-4-3" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-4-3" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-4-4" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-4-4" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-4-5" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-4-5" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="прм-5" type="TextureRect" parent="матрица"]
layout_mode = 2
texture = ExtResource("18_p3gp1")
metadata/unit_name = &""
[node name="матрица-5-0" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-5-0" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-5-1" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-5-1" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-5-2" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-5-2" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-5-3" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-5-3" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-5-5" type="TextureRect" parent="матрица" groups=["матрица-к"]]
[node name="матрица-5-5" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="матрица-5-6" type="TextureRect" parent="матрица"]
[node name="матрица-5-6" type="TextureButton" parent="матрица" groups=["матрица-к"]]
layout_mode = 2
texture = ExtResource("2_s28jr")
toggle_mode = true
texture_normal = ExtResource("2_s28jr")
texture_pressed = ExtResource("3_its7t")
[node name="ор-63" type="TextureRect" parent="."]
layout_mode = 0