From 6d29445153e50cbafb444cc665b9edf93d1b4fd4 Mon Sep 17 00:00:00 2001 From: MaD_CaT Date: Thu, 16 Nov 2023 14:26:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BF=D1=80=D1=8F=D0=B6=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=81=20?= =?UTF-8?q?=D0=9F=D0=9E=20=D0=9C=D0=9F-550.=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D1=83=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=BC=D0=B5=D1=85=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=B5=20?= =?UTF-8?q?=D0=BE=D1=82=20=D0=9C=D0=9F-550.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fs.gd | 9 +++++++-- interfers.gd | 27 ++++++++++++++++++++++++++- main.gd | 5 ++++- main.tscn | 26 +++++++++++++------------- threats.gd | 1 + кнопка-4.tscn | 8 ++++---- 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/fs.gd b/fs.gd index c0ab31b..3ff3e6c 100644 --- a/fs.gd +++ b/fs.gd @@ -110,6 +110,12 @@ class Fs: pow = '' width = '' interfer = null + if isg == 0: + btn.set_texture_normal(btn_txr3) + elif isg == 1: + btn.set_texture_normal(btn_txr0) + elif isg == 2: + btn.set_texture_normal(btn_txr1) func init_lbls(tab, x0, y0): @@ -177,7 +183,6 @@ func on_item_selected(item_num): g_active_fs.isg = item_num if g_active_fs.isg == 0: fs_off(g_active_fs) - g_active_fs.btn.set_texture_normal(btn_txr3) elif g_active_fs.isg == 1: g_active_fs.btn.set_texture_normal(btn_txr0) elif g_active_fs.isg == 2: @@ -244,7 +249,6 @@ func set_fs(interfer: Interfers.Interfer): g_fs_dict[fs_num].interfer = interfer if (interfer.active_fs != g_fs_dict[fs_num]) and (interfer.active_fs != null): fs_off(interfer.active_fs) - interfer.active_fs.btn.set_texture_normal(btn_txr0) interfer.active_fs = g_fs_dict[fs_num] g_fs_dict[fs_num].pow = float(interfer.options['powp']) g_fs_dict[fs_num].freq = float(freq) @@ -292,3 +296,4 @@ func on_receive_msg8(data): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): pass + diff --git a/interfers.gd b/interfers.gd index 927e169..fb03399 100644 --- a/interfers.gd +++ b/interfers.gd @@ -46,7 +46,6 @@ const SVK = ['Подготовка', 'Выполнено', 'Ошибка', 'За # Номера колонок const COLUMN_OPT = [[COLUMN_SVK, SVK]] const COLUMN_OPT_BTN = [COLUMN_SVK] -const ID_ARRAY_LEN = 100 # Размер пула номеров целей # Помеха class Interfer: @@ -184,3 +183,29 @@ func get_msg7_data(): func on_row_pressed(i_row: int, table): pass + +func off_interfer(json_data): + if not interfers.has(json_data['ispp']): return + var row_id = interfers[json_data['ispp']].row_id + if interfers[json_data['ispp']] != null: + if interfers[json_data['ispp']].active_fs != null: + fs.fs_off(interfers[json_data['ispp']].active_fs) + if g_table.get_rows_count() > row_id: + interfers.erase(json_data['ispp']) + g_table.remove_row(row_id) + for i in g_table.get_rows_count(): + var interfer = g_table.get_node_user_data(0, i) + interfer.row_id = i + + +func check_interfers_state(): + for interfer in interfers.values(): + if interfer.active_fs != null: + fs.fs_off(interfer.active_fs) + interfer.active_fs = null + for interfer in interfers.values(): + var cmd_state: int = fs.set_fs(interfer) + if interfer.svk == 3: + interfer.svk = cmd_state + var cell = g_table.get_node2(COLUMN_SVK, interfer.row_id) + cell.select(cmd_state) diff --git a/main.gd b/main.gd index 059ccf6..c493466 100644 --- a/main.gd +++ b/main.gd @@ -23,6 +23,7 @@ func _ready(): func on_timeout(): sock.put_packet(Threats.get_threats_data()) + Interfers.check_interfers_state() func on_receive(data): @@ -36,9 +37,11 @@ func on_receive(data): if json_data['ts'] == 6: if not json_data.has('ispp'): return if not ((json_data['ispp'] is int) or (json_data['ispp'] is float)): return + if not json_data.has('krp'): return if not json_data.has('ss'): return if not ((json_data['ss'] is int) or (json_data['ss'] is float)): return - if not json_data.has('krp'): return + if json_data['krp'] == 'off': + Interfers.off_interfer(json_data) if not json_data.has('powp'): return if not json_data.has('kni'): return if not json_data.has('params'): return diff --git a/main.tscn b/main.tscn index d6b745b..a5597d6 100644 --- a/main.tscn +++ b/main.tscn @@ -1,14 +1,14 @@ [gd_scene load_steps=7 format=3 uid="uid://87gtvqd7bbje"] -[ext_resource type="Script" path="res://main.gd" id="1_do14e"] -[ext_resource type="Script" path="res://table/table.gd" id="2_vhqjb"] -[ext_resource type="Texture2D" uid="uid://cex4jiu1pcj3x" path="res://edit-add-0.png" id="3_aeg5a"] -[ext_resource type="Texture2D" uid="uid://cx746np1wexnd" path="res://edit-add-1.png" id="4_vmaqo"] -[ext_resource type="Texture2D" uid="uid://blpkoi7s8qugp" path="res://document-save-0.png" id="5_ysafc"] -[ext_resource type="Texture2D" uid="uid://wh7p3t4frxf" path="res://disconnect.png" id="6_8jprr"] +[ext_resource type="Script" path="res://main.gd" id="1_jt2ds"] +[ext_resource type="Script" path="res://table/table.gd" id="2_61iss"] +[ext_resource type="Texture2D" uid="uid://cex4jiu1pcj3x" path="res://edit-add-0.png" id="3_0aqi0"] +[ext_resource type="Texture2D" uid="uid://cx746np1wexnd" path="res://edit-add-1.png" id="4_s8cxp"] +[ext_resource type="Texture2D" uid="uid://blpkoi7s8qugp" path="res://document-save-0.png" id="5_8l4uh"] +[ext_resource type="Texture2D" uid="uid://wh7p3t4frxf" path="res://disconnect.png" id="6_hj3vd"] [node name="main" type="Node2D"] -script = ExtResource("1_do14e") +script = ExtResource("1_jt2ds") [node name="tabs" type="TabContainer" parent="."] offset_right = 1594.0 @@ -28,7 +28,7 @@ offset_right = 1.0 offset_bottom = 10.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("2_vhqjb") +script = ExtResource("2_61iss") node_type_file = "res://ячейка-1.tscn" [node name="btn_add" type="TextureButton" parent="tabs/threats"] @@ -37,8 +37,8 @@ offset_left = 1533.0 offset_top = -2.0 offset_right = 1581.0 offset_bottom = 46.0 -texture_normal = ExtResource("3_aeg5a") -texture_pressed = ExtResource("4_vmaqo") +texture_normal = ExtResource("3_0aqi0") +texture_pressed = ExtResource("4_s8cxp") [node name="btn_save" type="TextureButton" parent="tabs/threats"] layout_mode = 0 @@ -46,7 +46,7 @@ offset_left = 1442.0 offset_top = -1.0 offset_right = 1490.0 offset_bottom = 47.0 -texture_normal = ExtResource("5_ysafc") +texture_normal = ExtResource("5_8l4uh") [node name="btn_del" type="TextureButton" parent="tabs/threats"] layout_mode = 0 @@ -55,7 +55,7 @@ offset_top = 1.0 offset_right = 1547.0 offset_bottom = 67.0 scale = Vector2(0.62, 0.62) -texture_normal = ExtResource("6_8jprr") +texture_normal = ExtResource("6_hj3vd") [node name="pomehi" type="Panel" parent="tabs"] visible = false @@ -66,7 +66,7 @@ layout_mode = 0 offset_top = 30.0 offset_right = 1587.0 offset_bottom = 886.0 -script = ExtResource("2_vhqjb") +script = ExtResource("2_61iss") node_type_file = "res://ячейка-1.tscn" [node name="fs_rect" type="ReferenceRect" parent="tabs/pomehi"] diff --git a/threats.gd b/threats.gd index 2847ac1..7aa2d55 100644 --- a/threats.gd +++ b/threats.gd @@ -6,6 +6,7 @@ var msg_counter : int = 0 # Счётчик отправленных п var g_table: GridContainer + const TableCellType1 = preload('res://ячейка-1.tscn') const TableCellType2 = preload('res://кнопка-3.tscn') const TableCellType3 = preload('res://кнопка-4.tscn') diff --git a/кнопка-4.tscn b/кнопка-4.tscn index 40e132c..d2ba6e5 100644 --- a/кнопка-4.tscn +++ b/кнопка-4.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://ccxre8mwhndjk"] -[ext_resource type="Texture2D" uid="uid://dag8n0gknjwak" path="res://индикатор-1-0.png" id="1_stfie"] -[ext_resource type="Texture2D" uid="uid://b3ext3w4ftgg2" path="res://индикатор-1-1.png" id="2_xepyc"] +[ext_resource type="Texture2D" uid="uid://dag8n0gknjwak" path="res://индикатор-1-0.png" id="1_vc7pt"] +[ext_resource type="Texture2D" uid="uid://b3ext3w4ftgg2" path="res://индикатор-1-1.png" id="2_tp80w"] [node name="indicator_1" type="TextureButton"] modulate = Color(1, 0.596078, 0.4, 1) @@ -9,5 +9,5 @@ offset_right = 35.0 offset_bottom = 29.0 toggle_mode = true button_mask = 0 -texture_normal = ExtResource("1_stfie") -texture_pressed = ExtResource("2_xepyc") +texture_normal = ExtResource("1_vc7pt") +texture_pressed = ExtResource("2_tp80w")