diff --git a/project.godot b/project.godot index dd994222..1bc7aa1a 100644 --- a/project.godot +++ b/project.godot @@ -122,7 +122,7 @@ astrakb="*res://scripts/astra-kb.gd" prd="*res://scripts/prd.gd" navi="*res://scripts/navigation.gd" trassa="*res://scripts/trassa.gd" -yems_info="*res://scripts/yems-info.gd" +yemstg="*res://scripts/yemstg.gd" [debug] diff --git a/scenes/button-six-state/six-state.tscn b/scenes/button-six-state/six-state.tscn index 9f9e92de..e8f7701f 100644 --- a/scenes/button-six-state/six-state.tscn +++ b/scenes/button-six-state/six-state.tscn @@ -72,5 +72,6 @@ horizontal_alignment = 1 [node name="check" type="CheckButton" parent="."] layout_mode = 2 size_flags_horizontal = 8 +action_mode = 0 [connection signal="toggled" from="check" to="." method="_on_check_toggled"] diff --git a/scenes/эмс-тг/эмс-тг.gd b/scenes/эмс-тг/эмс-тг.gd index 23b0dec4..cbe94270 100644 --- a/scenes/эмс-тг/эмс-тг.gd +++ b/scenes/эмс-тг/эмс-тг.gd @@ -10,18 +10,29 @@ extends Panel @export var freq_min: float ## Максимальная частота, МГЦ @export var freq_max: float -## Цвет диапазона передатчика на шкале -@export var color_tx: Color -## Цвет диапазона приёмника на шкале -@export var color_rx: Color +## Цвет диапазона если включен (разрешён) +@export_color_no_alpha var color_enabled: Color +## Цвет диапазона если выключен (запрещён) +@export_color_no_alpha var color_disabled: Color +## Прозрачность диапазон на шкале (диапазоны могут накладываться, что бы было видно наложения) +@export_range(0, 1.0) var color_alpha: float ## Цвет нечётных строк шкалы @export_color_no_alpha var color_odd: Color ## Цвет чётных строк шкалы @export_color_no_alpha var color_even: Color +## Индекс колонки в таблице для разрешения работы приёмника +@export var column_cmd_rx: int +## Индекс колонки в таблице для разрешения работы передатчика +@export var column_cmd_tx: int +## Максимальное количесво кластеров на одно устройство +@export var max_clasters_per_unit: int +## Сообщение пользователю +@export var msg_select_unit: String +## Сообщение пользователю +@export var msg_waiting_data: String #endregion #region Загружаемые ресурсы -@export var matrix_conf: Array[Texture] @export_file('*.tscn') var table_headers: Array[String] @export_file('*.tscn') var table_cells: Array[String] @export_file('*.png') var image_file_rx: String @@ -39,28 +50,59 @@ var table_cell_row: Array #endregion #region Заполняется во время работы -var yems_data_info: Dictionary[StringName, Dictionary] ## Доклады -var yems_data_cmd: Dictionary[StringName, Dictionary] ## Команды +var yems_info: Dictionary[StringName, Dictionary] ## Доклады +var yems_cmd: Dictionary[StringName, Dictionary] ## Команды ## Порядок следования кластеров в таблице. ## {имя_устройства: { имя_кластера: индекс_в_таблице } } var cnames_table: Dictionary[StringName, Dictionary] ## Порядок следования кластеров на шкале. ## {имя_устройства: { индекс_на_шкале } } var pnames_scale: Dictionary[StringName, int] +## Текущее выбранное оператором устройство на шкале +var selected_unit: Dictionary[StringName, bool] +## Состояния кластеров в соответствии с докладами и командами +var cmd_vs_info: Dictionary[StringName, Dictionary] #endregion +## Состояние кластера +enum ClasterStatus { + DELETED, + RUNNING +} + + +## Режим управления кластером +enum ClasterMode { + MANUAL, ## Ручной, управляется операторром + AUTO, ## Автоматический, управляется программой + IGNORE ## Игнорируемый, не управляется +} + + +## Состояние кластера. Значения должны соответствовать состояниям [b]six-state-button[/b] +enum ClasterState { + WAITING = 0, ## Ожидание даннных + DONE = 1, ## Выполнено + MISSMATCH = 2 ## Несоответствие +} + func _ready() -> void: # Инициализировать переменные + color_enabled.a = color_alpha + color_disabled.a = color_alpha for i in index_to_unit_names.size(): var nm: = index_to_unit_names[i] name_to_index[nm] = i - yems_data_info[nm] = {} + yems_info[nm] = {} + yems_cmd[nm] = {} cnames_table[nm] = {} + selected_unit[nm] = false + cmd_vs_info[nm] = {} var btns_scales = get_tree().get_nodes_in_group('кнопки-шкалы') for node in btns_scales: var nm: = node.get_meta('unit_name') as StringName - node.connect('pressed', map_yems_data_to_table.bind(nm)) + node.connect('toggled', _on_scale_selected.bind(nm)) var claster_scales = get_tree().get_nodes_in_group('шкалы-кластеров') for node in claster_scales: var nm: = node.get_meta('unit_name') as StringName @@ -75,7 +117,7 @@ func _ready() -> void: node.get_node('panel_tx').back_color = color_even # Подключить обработчик для приёма данных - for nm in yems_data_info: + for nm in yems_info: var yems_unit = network.get_unit_instance(nm) yems_unit.connect('data_received', on_data_received.bind(nm)) @@ -97,22 +139,168 @@ func _ready() -> void: ctable.pin_header2() +## Вызывается при выборе оператором устройства на шкале +## [param nm] - имя выбранного устройства +func _on_scale_selected(val: bool, nm: StringName): + selected_unit[nm] = val + if not val: + $'таблица/сетка'.clear_rows() + cnames_table[nm].clear() + $label_msg.text = msg_select_unit + $label_msg.show() + return + var unit_info = yems_info[nm] + if not unit_info: # проверить, есть ли данные + $label_msg.text = msg_waiting_data + return # данных ещё нет, ничего не далать + $label_msg.hide() + var ctable = $'таблица/сетка' + var indexes = cnames_table[nm] + var unit_cvi = cmd_vs_info[nm] + map_yems_data_to_table(unit_info, ctable, indexes) + connect_cmd_handlers(ctable, nm, indexes) + update_cmd_vs_info(nm) + map_cvi_to_table(unit_cvi, ctable, indexes) + + +func map_cvi_to_table(unit_cvi: Dictionary, ctable: GDTable, indexes: Dictionary): + for cname in indexes: + var i_row = indexes[cname] + var state_rxe: = ClasterState.WAITING + var state_txe: = ClasterState.WAITING + if unit_cvi.has(cname): + state_rxe = unit_cvi[cname]['state_rxe'] + state_txe = unit_cvi[cname]['state_txe'] + ctable.set_node_property(column_cmd_rx, i_row, 'state', int(state_rxe)) + ctable.set_node_property(column_cmd_tx, i_row, 'state', int(state_txe)) + + +func update_cmd_vs_info(nm: StringName): + if yems_info.has(nm): + return + var unit_info = yems_info[nm] + if not unit_info.has('mcls'): + return + if not yems_cmd.has(nm): + return + var unit_cvi = {} + for cls_info in unit_info.mcls: + var claster_cvi = {} + claster_cvi['state_txe'] = ClasterState.WAITING + claster_cvi['state_rxe'] = ClasterState.WAITING + var unit_cmd = yems_cmd[nm] + if not unit_cmd.has(cls_info.cname): + continue + var cls_cmd = unit_cmd[cls_info.cname] + claster_cvi['state_rxe'] = ClasterState.DONE if cls_info.rxe == cls_cmd.rxe else ClasterState.MISSMATCH + claster_cvi['state_txe'] = ClasterState.DONE if cls_info.txe == cls_cmd.txe else ClasterState.MISSMATCH + unit_cvi[cls_info.cname] = claster_cvi + cmd_vs_info[nm] = unit_cvi + + +## Подключает обработчики команд к таблице кластеров +## [param cls_table] - таблица для отображения кластеров +## [param nm] - имя устройства +func connect_cmd_handlers(cls_table: GDTable, nm: StringName, indexes: Dictionary): + var rows_count = cls_table.get_rows_count() + if indexes.size() != rows_count: + push_error('indexes.size() != rows_count') + return + for cname in indexes: + # Имя устройства и имя кластера + var i_row = indexes[cname] + # Подключить обработчки разрешения приёмников + var node = cls_table.get_node2(column_cmd_rx, i_row) + node.connect_check('toggled', _on_user_cmd.bind(nm, cname, 'rxe')) + # Подключить обработчки разрешения приёмников + node = cls_table.get_node2(column_cmd_tx, i_row) + node.connect_check('toggled', _on_user_cmd.bind(nm, cname, 'txe')) + + +func _on_user_cmd(val: bool, nm: StringName, cname: String, param_name: StringName): + var unit_cmd = yems_cmd[nm] + if cname in unit_cmd: + unit_cmd[cname][param_name] = val + else: + unit_cmd[cname] = {param_name: val} + + ## Обрабатывает событие [b]data_received[/b] func on_data_received(data: Dictionary, nm: StringName): - var unit_data: = yems_data_info[nm] + var unit_data: = yems_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 indexes: = cnames_table[nm] # Идексы строк в таблице - map_yems_data_to_table(unit_data, ctable, indexes) + var indexes: = cnames_table[nm] # Индексы строк в таблице + if selected_unit[nm]: + map_yems_data_to_table(unit_data, ctable, indexes) map_yems_data_to_scale(unit_data, claster_scale) - #var yems_data_info1 = {} - var inters: = find_inters(yems_data_info) + var inters: = find_inters(yems_info) + var unit_cvi = cmd_vs_info[nm] + reset_matrix() map_inters_to_matrix(inters, $'матрица') + set_timeouts(yems_info) + cmd_to_unit(nm) + update_cmd_vs_info(nm) + map_cvi_to_table(unit_cvi, ctable, indexes) +func cmd_to_unit(nm: StringName): + var unit_yemstg: = network.get_unit_instance(nm) + if unit_yemstg.cmd_state != unit.Unit.CmdState.DONE: + return + # Команда формируется из докладов (данных принятых из сети от устройств) + var cmd = yems_info[nm] + # Переписать новыми значениями из команды заданной оператором + cmd['mtype'] = 'cmd' + var unit_cmd = yems_cmd[nm] + for cls_info in cmd.mcls: + if unit_cmd.has(cls_info.cname): + var cmd_cls = unit_cmd[cls_info.cname] + cls_info.merge(cmd_cls, true) + unit_yemstg.cmd.merge(cmd, true) + unit_yemstg.cmd_state = unit.Unit.CmdState.SEND + + +func set_timeouts(info: Dictionary): + for nm in info: # nm - имя устройства + var unit_data = info[nm] + if not unit_data: continue + for cls in unit_data.mcls: # cls - один кластер + var timer_name = NodePath('%s_%s' % [nm, cls.cname]) + var timer = get_node_or_null(timer_name) + if not timer: + timer = Timer.new() + timer.name = timer_name + timer.one_shot = true + timer.connect('timeout', _on_timeout_ttl.bind(nm, cls.cname)) + add_child(timer) + timer.start(cls.ttl) + cls['status'] = ClasterStatus.RUNNING + + +## Обработчик истечения времени жизни кластера +func _on_timeout_ttl(nm, cname): + var timer_name = NodePath('%s_%s' % [nm, cname]) + var timer = get_node_or_null(timer_name) + if timer: + remove_child(timer) + timer.queue_free() + var unit_data = yems_info[nm] + for cls in unit_data.mcls: + if cname == cls.cname: + cls.status = ClasterStatus.DELETED + + +func reset_matrix(): + var nodes = get_tree().get_nodes_in_group('матрица-к') + for node in nodes: + node.button_pressed = false + + +## Отображает пересечения на матрице func map_inters_to_matrix(inters: Array, matrix: GridContainer) -> void: var nodes = matrix.get_children() for item in inters: @@ -131,23 +319,30 @@ func map_yems_data_to_table(unit_data: Dictionary, ctable: GDTable, indexes: Dic # Обойти все кластеры устройства for cls in unit_data.mcls: # Строки для заполнения ряда - var row_text = [cls.cname, 'Активен', '%.1f' % cls.ttl, '%.1f' % cls.daa, '%.1f' % cls.dap, '%.1f' % cls.cfb] + var row_text = [cls.cname, 'Активен', '%.1f' % cls.ttl, '%.1f' % cls.daa, '%.1f' % cls.dap, '%.1f-%.1f' % [cls.cfb - cls.wfb / 2.0, cls.cfb + cls.wfb / 2.0]] # Если такой кластер уже есть, обновить его строку в таблице if cls.cname in indexes: # Получить индекс строки кластера в таблице var i_row = indexes[cls.cname] + # Установить новый текст ctable.set_row_text(i_row, row_text) - # Если такого кластера нет, создать его строку в таблице + # Если такого кластера нет, то создать его строку в таблице else: - # Создать новый ряд + # Добавить новый ряд ctable.add_row(table_cell_row) - # Записать индекс строки в таблице для кластера + # Получить индекс нового ряда в таблице var i_row: = indexes.size() + # Записать индекс нового ряда (связать с именем кластера) indexes[cls.cname] = i_row - # Установка высоты строки + # Установить высоту ряда (можно пропустить, если нужная высота будет выставлена по умолчанию) ctable.set_row_min_hight(i_row, table_rows_hight) + # Установить новый текст + ctable.set_row_text(i_row, row_text) + ctable.set_node_property(column_cmd_rx, i_row, 'pressed', cls.rxe) + ctable.set_node_property(column_cmd_tx, i_row, 'pressed', cls.txe) +## Находит пересечения диапазонов func find_inters(info: Dictionary) -> Array: var result = [] @@ -209,17 +404,21 @@ func find_inters(info: Dictionary) -> Array: 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) var w: = remap(cls.wfb, freq_min, freq_max, 0.0, 0.5) + # Чтобы диапазон всегда был виден, даже если он слишком узкий + w = clampf(w, 0.005, 1.0) + # Отсечь значения по границам var l: = clampf(c - w, 0.0, 1.0) var h: = clampf(c + w, 0.0, 1.0) + # Получить шкалу приёмника var scale_rx: = claster_scale.get_node('panel_rx') + # Отобразить диапазон приёмника, в соответствии с разрешением + var color_rxe: = color_enabled if cls.get('rxe', false) else color_disabled + scale_rx.set_range(cls.cname, l, h, color_rxe) + # Получить шкалу передатчика var scale_tx: = claster_scale.get_node('panel_tx') - if cls.get('rxe', false): - scale_rx.set_range(cls.cname, l, h, color_rx) - else: - scale_rx.del_range(cls.cname) - if cls.get('txe', false): - scale_tx.set_range(cls.cname, l, h, color_tx) - else: - scale_tx.del_range(cls.cname) + # Отобразить диапазон передатчика, в соответсвии с разрешением + var color_txe: = color_enabled if cls.get('txe', false) else color_disabled + scale_tx.set_range(cls.cname, l, h, color_txe) diff --git a/scenes/эмс-тг/эмс-тг.tscn b/scenes/эмс-тг/эмс-тг.tscn index 96f9a9bc..2b2d5c4d 100644 --- a/scenes/эмс-тг/эмс-тг.tscn +++ b/scenes/эмс-тг/эмс-тг.tscn @@ -42,11 +42,16 @@ script = ExtResource("1_b7tfl") index_to_unit_names = Array[StringName]([&"эмс-ор63", &"эмс-454", &"эмс-го", &"эмс-рлс1", &"эмс-рлс2", &"эмс-ннвс", &"эмс-изделие7", &"эмс-изделие8"]) freq_min = 300.0 freq_max = 6000.0 -color_tx = Color(0.898367, 0.460547, 0.239949, 1) -color_rx = Color(0.498039, 0.498039, 1, 1) +color_enabled = Color(0.898039, 0.458824, 0.239216, 1) +color_disabled = Color(0.601223, 0.601223, 0.601223, 1) +color_alpha = 0.7 color_odd = Color(0.31863, 0.32773, 0.327729, 1) color_even = Color(0.258824, 0.266667, 0.266667, 1) -matrix_conf = Array[Texture]([ExtResource("2_s28jr"), ExtResource("3_its7t")]) +column_cmd_rx = 6 +column_cmd_tx = 7 +max_clasters_per_unit = 32 +msg_select_unit = "Выберите устройство" +msg_waiting_data = "Ожидание данных" table_headers = Array[String](["uid://ch14g46swx74h", "uid://ch14g46swx74h", "uid://ch14g46swx74h", "uid://ch14g46swx74h", "uid://ch14g46swx74h", "uid://ch14g46swx74h", "uid://cymcld4mjmlhj", "uid://cymcld4mjmlhj"]) table_cells = Array[String](["uid://dwphmxstaxn4v", "uid://dwphmxstaxn4v", "uid://dwphmxstaxn4v", "uid://dwphmxstaxn4v", "uid://dwphmxstaxn4v", "uid://dwphmxstaxn4v", "uid://cixwl6xi22buo", "uid://cixwl6xi22buo"]) image_file_rx = "uid://c6etralq2tvxg" @@ -98,6 +103,7 @@ columns = 2 layout_mode = 2 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "ОР-63" metadata/unit_name = &"эмс-ор63" @@ -130,6 +136,7 @@ layout_mode = 2 size_flags_horizontal = 5 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "454" metadata/unit_name = &"эмс-454" @@ -160,6 +167,7 @@ layout_mode = 2 size_flags_horizontal = 5 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "ГО" metadata/unit_name = &"эмс-го" @@ -192,6 +200,7 @@ layout_mode = 2 size_flags_horizontal = 5 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "РЛС1" metadata/unit_name = &"эмс-рлс1" @@ -222,6 +231,7 @@ layout_mode = 2 size_flags_horizontal = 5 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "РЛС2" metadata/unit_name = &"эмс-рлс2" @@ -254,6 +264,7 @@ layout_mode = 2 size_flags_horizontal = 5 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "ННВС" metadata/unit_name = &"эмс-ннвс" @@ -284,9 +295,10 @@ layout_mode = 2 size_flags_horizontal = 5 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "Изделие 7" -metadata/unit_name = &"изделие7" +metadata/unit_name = &"эмс-изделие7" [node name="sub6" type="GridContainer" parent="шкала" groups=["чётные", "шкалы-кластеров"]] self_modulate = Color(0.258824, 0.266667, 0.266667, 1) @@ -316,6 +328,7 @@ layout_mode = 2 size_flags_horizontal = 5 size_flags_vertical = 7 toggle_mode = true +action_mode = 0 button_group = SubResource("ButtonGroup_vwsbs") text = "Изделие 8" metadata/unit_name = &"эмс-изделие8" @@ -398,36 +411,43 @@ metadata/unit_name = &"эмс-ор63" [node name="матрица-0-0" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +action_mode = 0 +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-0-1" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-0-2" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-0-3" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-0-4" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-0-5" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") @@ -439,36 +459,42 @@ metadata/unit_name = &"" [node name="матрица-1-0" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-1-1" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-1-2" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-1-3" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-1-4" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-1-5" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") @@ -480,36 +506,42 @@ metadata/unit_name = &"" [node name="матрица-2-0" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-2-1" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-2-5" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-2-2" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-2-3" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-2-4" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") @@ -521,36 +553,42 @@ metadata/unit_name = &"" [node name="матрица-3-0" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-3-1" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-3-2" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-3-3" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-3-4" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-3-5" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") @@ -562,36 +600,42 @@ metadata/unit_name = &"" [node name="матрица-4-0" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-4-1" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-4-2" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-4-3" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-4-4" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-4-5" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") @@ -603,36 +647,42 @@ metadata/unit_name = &"" [node name="матрица-5-0" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-5-1" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-5-2" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-5-3" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-5-5" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") [node name="матрица-5-6" type="TextureButton" parent="матрица" groups=["матрица-к"]] layout_mode = 2 toggle_mode = true +button_mask = 0 texture_normal = ExtResource("2_s28jr") texture_pressed = ExtResource("3_its7t") @@ -901,3 +951,13 @@ offset_bottom = 65.0 size_flags_horizontal = 4 size_flags_vertical = 6 text = "ННВС" + +[node name="label_msg" type="Label" parent="."] +layout_mode = 0 +offset_left = 25.0 +offset_top = 765.0 +offset_right = 1180.0 +offset_bottom = 1155.0 +text = "Выберите устройство" +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/scripts/network.gd b/scripts/network.gd index 2a20876c..d6b07814 100644 --- a/scripts/network.gd +++ b/scripts/network.gd @@ -1,7 +1,7 @@ @tool class_name Network extends Node -const YAU07_PROTO: = {'yau07tx': yau07.YaU07, 'iyems-tx': yems_info.YeMSInfo} +const YAU07_PROTO: = {'yau07tx': yau07.YaU07, 'iyems-tx': yemstg.YeMSTG} const UDP_PROTO: = {'capsrpb': capsrpb.CapsRpb, 'trassa': trassa.Trassa} const TCP_PROTO: = {'5p28': tcp5p28.TCP5P28} const SERIAL_PROTO: = {'spt25': spt25.SPT25} @@ -355,6 +355,7 @@ func _process(_delta: float) -> void: poll_sockets.any(poll_receive_udp) +## Возвращает экземпляр уже созданного устройства ## [param unit_name] - Уникальное имя устройства[br] func get_unit_instance(unit_name: StringName) -> unit.Unit: return units.get(unit_name, null) diff --git a/scripts/unit.gd b/scripts/unit.gd index bffe7961..5a71604d 100644 --- a/scripts/unit.gd +++ b/scripts/unit.gd @@ -25,6 +25,6 @@ class Unit extends Object: var rx_tick: int = 0 ## Тик-время последнего приёма данных var online: bool = false ## Состояние подключения устройства var name: StringName = '<без имени>' ## Уникальное имя устройства - func _init(nm) -> void: self.name = nm + func _init(nm: StringName) -> void: self.name = nm func _to_string() -> String: return String('Unit(\"%s\", %s)' % [self.name, 'на связи' if online else 'отключен']) diff --git a/scripts/yems-info.gd b/scripts/yemstg.gd similarity index 68% rename from scripts/yems-info.gd rename to scripts/yemstg.gd index 572539a9..04a90130 100644 --- a/scripts/yems-info.gd +++ b/scripts/yemstg.gd @@ -1,11 +1,17 @@ extends Node -class YeMSInfo extends unit.Unit: +class YeMSTG extends unit.Unit: static var json_conv: = JSON.new() var online_timeout: float = 5000 ## Должен быть равен наибольшему времени дотоверности из всех кластеров var info: = Dictionary() ## Доклад о состоянии var cmd: = Dictionary() ## Команда + var cnt: int = 0 ## Счётчик отправленных пакетов + + func _init(unit_name) -> void: + super._init(unit_name) + cmd_state = CmdState.DONE + func parse(data: PackedByteArray, now_tick: int): self.rx_tick = now_tick if not online: @@ -23,4 +29,10 @@ class YeMSInfo extends unit.Unit: if online and ((now_tick - rx_tick) > online_timeout): online = false emit_signal('line_changed', self) - return Error.ERR_BUSY + var rc = Error.ERR_BUSY + if cmd_state == CmdState.SEND: + tx_data = JSON.stringify(cmd).to_utf8_buffer() + tx_len = tx_data.size() + cmd_state = CmdState.DONE + rc = Error.OK + return rc diff --git a/scripts/yems-info.gd.uid b/scripts/yemstg.gd.uid similarity index 100% rename from scripts/yems-info.gd.uid rename to scripts/yemstg.gd.uid diff --git a/table/lable.tscn b/table/lable.tscn index 43d2ec80..c0e03492 100644 --- a/table/lable.tscn +++ b/table/lable.tscn @@ -32,4 +32,6 @@ offset_right = 104.0 offset_bottom = 27.0 theme_override_colors/font_color = Color(1, 0.596078, 0.4, 1) theme_override_styles/normal = SubResource("StyleBoxFlat_yign5") +horizontal_alignment = 1 +vertical_alignment = 1 script = SubResource("GDScript_dhnrx") diff --git a/table/table.gd b/table/table.gd index f60f9e67..39072986 100644 --- a/table/table.gd +++ b/table/table.gd @@ -55,7 +55,7 @@ func defaultselector_color_proc(_i_row: int): return selector_color func _assert(val: bool, msg: String = '<не указано>'): if val: return - push_error('ошибка: %s\n' % msg) + push_error('%s\n' % msg) get_tree().quit(1)