diff --git a/project.godot b/project.godot index ee894e9..83ff45a 100644 --- a/project.godot +++ b/project.godot @@ -57,7 +57,6 @@ threats="*res://scripts/threats.gd" yemsdevs="*res://scenes/эмс/yems-devs.gd" yemsboards="*res://scenes/эмс/yems-boards.gd" yemsconsts="*res://scenes/эмс/yems-consts.gd" -yemsg="*res://scenes/эмс/yems-g.gd" interfer="*res://scripts/interfer.gd" hotkeys="*res://scripts/hotkeys.gd" tcp5p28="*res://scripts/tcp5p28.gd" diff --git a/scenes/bip/bip.gd b/scenes/bip/bip.gd index d8ea82f..b4594e0 100644 --- a/scenes/bip/bip.gd +++ b/scenes/bip/bip.gd @@ -10,7 +10,7 @@ func set_track_visible(value: bool): $track.visible = value func set_ecm_visible(value: bool): $ecm_done.visible = value -func update(tick_ms: int = 0): pass +func update(_tick_ms: int = 0): pass ## Задаёт цвет diff --git a/scenes/frame-ecm-params/scroll-ecm-params.gd b/scenes/frame-ecm-params/scroll-ecm-params.gd index 2ed2ba8..0245a76 100644 --- a/scenes/frame-ecm-params/scroll-ecm-params.gd +++ b/scenes/frame-ecm-params/scroll-ecm-params.gd @@ -4,7 +4,7 @@ class_name scroll_ecm_params extends ScrollContainer const CellLineEdit = preload('res://table/ячейка-2.tscn') ## Ячейка таблицы. const TableHeader = preload('res://table/header.tscn') ## Ячейка заголовок таблицы. -const CellTaggleBtn = preload('res://table/settings-toggle.tscn') +const CellTaggleBtn = preload('res://table/set-toggle.tscn') const TABLE_HEADER = [ TableHeader, TableHeader ] ## Описание ряда заголовка. const TABLE_ROW = [ CellLineEdit, CellLineEdit ] ## Описание ряда. @@ -38,13 +38,6 @@ func init_table(): $table.set_node_alligment(0, MOD_ROW_INDEX, HORIZONTAL_ALIGNMENT_LEFT) $table.set_node_editable(0, MOD_ROW_INDEX, false) var taggle_node = $table.get_node2(1, MOD_ROW_INDEX) - #for item in taggle_node.get_children(): - #item.size.x = 85 - #item.size.y = 25 - #item.position.x = 0 - #item.position.y = 0 - #taggle_node.size.x = 85 - #taggle_node.size.y = 25 var taggle_btn = taggle_node.get_children()[1] taggle_btn.connect('pressed', on_taggle_btn.bind(taggle_btn)) taggle_btn.disabled = true diff --git a/scenes/pribor-prd-v/pribor_prd_v.gd b/scenes/pribor-prd-v/pribor_prd_v.gd index 46cd360..5fcc0fd 100644 --- a/scenes/pribor-prd-v/pribor_prd_v.gd +++ b/scenes/pribor-prd-v/pribor_prd_v.gd @@ -7,7 +7,7 @@ enum STATE_VAL { # Called when the node enters the scene tree for the first time. func _ready() -> void: - var unit_key = settings.get_unit_key(get_meta('unit_name')) + var unit_key = settings.get_unit_key(get_meta('unit_name')[0]) var unit_prd = network.units[unit_key] unit_prd.connect('data_received', Callable(self, 'on_data_received')) unit_prd.connect('line_changed', Callable(self, 'on_line_changed')) diff --git a/scenes/контроль/connect_pribor.gd b/scenes/контроль/connect_pribor.gd new file mode 100644 index 0000000..4f1cf51 --- /dev/null +++ b/scenes/контроль/connect_pribor.gd @@ -0,0 +1,7 @@ +extends AnimatedSprite2D + +## Изменяет состояние значка "прибор на связи" +func set_val(val: bool): + set_frame(val) + if val: modulate = Color(0.3, 1.0, 0.3, 1) + else: modulate = Color(0.5, 0.5, 0.5, 1) diff --git a/scenes/контроль/кассета_у_5.gd b/scenes/контроль/кассета_у_5.gd index a8a76d8..bf45fa1 100644 --- a/scenes/контроль/кассета_у_5.gd +++ b/scenes/контроль/кассета_у_5.gd @@ -7,7 +7,7 @@ enum STATE_VAL { # Called when the node enters the scene tree for the first time. func _ready() -> void: - var unit_key = settings.get_unit_key(get_parent().get_meta('unit_name')) + var unit_key = settings.get_unit_key(get_parent().get_meta('unit_name')[0]) var unit_prd = network.units[unit_key] unit_prd.connect('data_received', Callable(self, 'on_data_received')) unit_prd.connect('line_changed', Callable(self, 'on_line_changed')) diff --git a/scenes/контроль/контроль.gd b/scenes/контроль/контроль.gd index 6a9d815..e2db211 100644 --- a/scenes/контроль/контроль.gd +++ b/scenes/контроль/контроль.gd @@ -35,9 +35,32 @@ func _ready(): var header_text = PRIBORS_RES[k][1] pribor_node.set_button_group(group) pribor_node.connect('button_down', Callable(self, 'on_pribor_press').bind(pribor_path, header_text, pribor_node)) + var conn_node = pribor_node.get_node("connect_pribor") + var pribor_meta = pribor_node.get_meta('unit_name', []) + var pribor_proc = pribor_node.get_meta('online_proc', '') + if pribor_proc == '': + continue + if pribor_meta.size(): + for i in pribor_meta.size(): + var unit_key = settings.get_unit_key(pribor_meta[i]) + var unit_pribor = network.units[unit_key] + unit_pribor.connect('line_changed', Callable(self, pribor_proc).bind(conn_node, pribor_meta)) log.info('Модуль контроля работы готов') +func on_line_changed(u, conn_node, _pribor_meta): conn_node.set_val(u.online) + + +func online_change_arr(u, conn_node, pribor_meta): + var state_online = true + for i in pribor_meta.size(): + var unit_key = settings.get_unit_key(pribor_meta[i]) + var unit_pribor = network.units[unit_key] + if not unit_pribor.online: + state_online = false + break + conn_node.set_val(state_online) + func on_pribor_press(pribor_path, header_text, pribor_node): var items = get_tree().get_nodes_in_group('pribor_items') for item in items: diff --git a/scenes/контроль/контроль.tscn b/scenes/контроль/контроль.tscn index 76b424a..34ff75d 100644 --- a/scenes/контроль/контроль.tscn +++ b/scenes/контроль/контроль.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://lwmw4egynmd1"] +[gd_scene load_steps=16 format=3 uid="uid://lwmw4egynmd1"] [ext_resource type="Script" path="res://scenes/контроль/контроль.gd" id="1_x5d6w"] [ext_resource type="Texture2D" uid="uid://bar8k5qef7kch" path="res://data/УФ.png" id="2_0nvm1"] @@ -13,6 +13,7 @@ [ext_resource type="Texture2D" uid="uid://u3tnejvpm8it" path="res://data/disconnect_1.png" id="8_gs2be"] [ext_resource type="Texture2D" uid="uid://dnreyfh3cd1k2" path="res://data/состояние-исправности-1.png" id="8_isjua"] [ext_resource type="Texture2D" uid="uid://c6booa8753u5t" path="res://data/состояние-исправности-2.png" id="9_ll0vs"] +[ext_resource type="Script" path="res://scenes/контроль/connect_pribor.gd" id="11_u7tym"] [sub_resource type="SpriteFrames" id="SpriteFrames_foasq"] animations = [{ @@ -52,6 +53,8 @@ texture_normal = ExtResource("2_0nvm1") stretch_mode = 0 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.74, 0.37, 1), Color(0.854902, 0.0705882, 0.0705882, 1)] +metadata/unit_name = ["уарэп-эмс"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_uf"] layout_mode = 0 @@ -85,6 +88,7 @@ position = Vector2(52, -6) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_rtr" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -134,6 +138,7 @@ position = Vector2(49, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_afsp_l" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -186,6 +191,7 @@ position = Vector2(410, -30) scale = Vector2(3.23077, 3.28125) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_afsp_r" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -238,6 +244,7 @@ position = Vector2(410, -30) scale = Vector2(3.23077, 3.28125) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_uyep" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -254,6 +261,8 @@ texture_normal = ExtResource("5_kvnex") stretch_mode = 0 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] +metadata/unit_name = ["уарэп-щ3", "уарэп-спт25-1", "уарэп-спт25-2"] +metadata/online_proc = "online_change_arr" [node name="label" type="Label" parent="pribor_uyep"] layout_mode = 0 @@ -287,6 +296,7 @@ position = Vector2(45, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.872305 +script = ExtResource("11_u7tym") [node name="pribor_prd_v_2" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -303,7 +313,8 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-2в" +metadata/unit_name = ["уарэп-яу07-2в"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_2"] layout_mode = 0 @@ -337,6 +348,7 @@ position = Vector2(40, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_n_2" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -353,7 +365,8 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-2н" +metadata/unit_name = ["уарэп-яу07-2н"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_n_2"] layout_mode = 0 @@ -389,6 +402,7 @@ position = Vector2(40, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_k_2" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -405,7 +419,8 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-2к" +metadata/unit_name = ["уарэп-яу07-2к"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_2"] layout_mode = 0 @@ -439,6 +454,7 @@ position = Vector2(43, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_v_3" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -456,7 +472,8 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-3в" +metadata/unit_name = ["уарэп-яу07-3в"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_3"] layout_mode = 0 @@ -490,6 +507,7 @@ position = Vector2(34, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_n_3" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -507,7 +525,8 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-3н" +metadata/unit_name = ["уарэп-яу07-3н"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_n_3"] layout_mode = 0 @@ -541,6 +560,7 @@ position = Vector2(33, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_k_3" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -558,7 +578,8 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-3к" +metadata/unit_name = ["уарэп-яу07-3к"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_3"] layout_mode = 0 @@ -592,6 +613,7 @@ position = Vector2(35, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_v_1" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -609,7 +631,8 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-1в" +metadata/unit_name = ["уарэп-яу07-1в"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_1"] layout_mode = 0 @@ -643,6 +666,7 @@ position = Vector2(34, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_n_1" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -660,7 +684,8 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-1н" +metadata/online_proc = "on_line_changed" +metadata/unit_name = ["уарэп-яу07-1н"] [node name="label" type="Label" parent="pribor_prd_n_1"] layout_mode = 0 @@ -694,6 +719,7 @@ position = Vector2(35, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_k_1" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -711,7 +737,8 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-1к" +metadata/unit_name = ["уарэп-яу07-1к"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_1"] layout_mode = 0 @@ -745,6 +772,7 @@ position = Vector2(35, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_v_4" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -761,7 +789,8 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-4в" +metadata/unit_name = ["уарэп-яу07-4в"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_4"] layout_mode = 0 @@ -795,6 +824,7 @@ position = Vector2(41, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_n_4" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -811,7 +841,8 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-4н" +metadata/unit_name = ["уарэп-яу07-4н"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_n_4"] layout_mode = 0 @@ -845,6 +876,7 @@ position = Vector2(40, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="pribor_prd_k_4" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." @@ -861,7 +893,8 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -metadata/unit_name = "уарэп-яу07-4к" +metadata/unit_name = ["уарэп-яу07-4к"] +metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_4"] layout_mode = 0 @@ -895,6 +928,7 @@ position = Vector2(42, -10) scale = Vector2(0.615385, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 +script = ExtResource("11_u7tym") [node name="mnemo_container" type="Panel" parent="."] layout_mode = 0 diff --git a/scenes/работа/работа.gd b/scenes/работа/работа.gd index 5bef2f7..42067e4 100644 --- a/scenes/работа/работа.gd +++ b/scenes/работа/работа.gd @@ -40,7 +40,7 @@ signal drag_end ## Вызывается в момент завершени const map_sizes = [ Rect2i(360, 360, 400, 400), Rect2i(82, 82, 955, 955)] -var fs_band = prd.fs_band_rto ## Текущий режим блоков ФС по частоте +var fs_band = prd.FS_BAND_RTO ## Текущий режим блоков ФС по частоте var fs_selected: Dictionary ## Словарь выбранных секторов var fs_active: Dictionary ## Словарь секторов назначенных на подавление @@ -74,7 +74,7 @@ func on_enter_tree() -> void: call_deferred('on_button_strobe_pressed') ## Обработчик нажатия на кнопку вид. func on_button_view_toggled(toggled: bool): signaller.emit_signal('map_mode_changed', int(toggled)) - fs_band = prd.fs_band_rls if toggled else prd.fs_band_rto + fs_band = prd.FS_BAND_RLS if toggled else prd.FS_BAND_RTO var s = map_sizes[int(toggled)] $tilemap.size = s.size $tilemap.position = s.position @@ -138,17 +138,17 @@ func map_threat_to_bip(th: threats.Threat, bip: Control): var freq = th.freq var sector_key = null var sector_width = 50.0 - for key in prd.fs_freq: - var freq_range = prd.fs_freq[key] + for key in prd.FS_FREQ: + var freq_range = prd.FS_FREQ[key] var _num_values = (freq_range[1]- freq_range[0]) / sector_width if freq_range[0] <= freq and freq <= freq_range[1]: sector_key = key break if sector_key!= null: - radius_internal = prd.fs_freq[sector_key][2] - radius_outter = prd.fs_freq[sector_key][3] - freq_low = prd.fs_freq[sector_key][0] - freq_high = prd.fs_freq[sector_key][1] + radius_internal = prd.FS_FREQ[sector_key][2] + radius_outter = prd.FS_FREQ[sector_key][3] + freq_low = prd.FS_FREQ[sector_key][0] + freq_high = prd.FS_FREQ[sector_key][1] bip.position = tools.pos_calc( th.freq, th.aoa, @@ -372,9 +372,9 @@ func sel_fs_sector(event): var sector: int var band: int var has_band: bool = false - for sec in prd.fs_sectors.values(): + for sec in prd.FS_SECTORS.values(): if angle >= sec[0] and angle <= sec[1]: - sector = prd.fs_sectors.find_key(sec) + sector = prd.FS_SECTORS.find_key(sec) for diap in fs_band.values(): if distance >= diap[0] and distance <= diap[1]: band = fs_band.find_key(diap) @@ -430,11 +430,11 @@ func set_ecm_btns_state(value: bool): func get_fs_param(index: int) -> Array: - var freq = (prd.fs_freq[index / 4][4]) - var sector = (prd.fs_sectors[index % 4][0] + prd.fs_sectors[index % 4][1])/2 - 45.0 + var freq = (prd.FS_FREQ[index / 4][4]) + var sector = (prd.FS_SECTORS[index % 4][0] + prd.FS_SECTORS[index % 4][1])/2 - 45.0 if sector < 0: sector += 360.0 - var width = prd.fs_freq[index / 4][1] - prd.fs_freq[index / 4][0] + var width = prd.FS_FREQ[index / 4][1] - prd.FS_FREQ[index / 4][0] return [sector, freq, width, index] diff --git a/scenes/эмс/yems-boards.gd b/scenes/эмс/yems-boards.gd index d0c27bc..9c184cf 100644 --- a/scenes/эмс/yems-boards.gd +++ b/scenes/эмс/yems-boards.gd @@ -2,7 +2,9 @@ class_name yems_boards extends Node class EmsBoard: enum {WAIT, WR_DEV_NUM_W, WRITE, WR_DEV_NUM_R, READ, READ_FLASH, WRITE_FLASH, - WRITE_FLASH_BEGIN, LOAD_KEMS, WRITE_FLASH_END, LOAD_FAIL} ## Состояния платы + WRITE_FLASH_BEGIN, WRITE_FLASH_END, LOADING} ## Состояния платы + + enum LoadState {NOT_LOAD, DONE, IN_PROCESS, FAIL, NOT_DEFINED} const modulation_dev: Dictionary = { ## Словарь соответствия диапазона номеру устройства 0 : 50, @@ -13,33 +15,32 @@ class EmsBoard: 5 : 51, 6 : 52, } - var id_board: int ## id платы - var in_devs: Dictionary ## Словарь с входными устройствами. - var out_devs: Dictionary ## Словарь с выходными устройствами. - var base_addr_isa: int ## Базовый адрес ячейки isa. - var ports_to_wr: Array ## Порты для записи + var id_board: int ## id платы + var in_devs: Dictionary ## Словарь с входными устройствами. + var out_devs: Dictionary ## Словарь с выходными устройствами. + var base_addr_isa: int ## Базовый адрес ячейки isa. + var ports_to_wr: Array ## Порты для записи var in_tbl: Array var out_tbl: Array - var online: bool ## статус платы - var ems_load: bool ## флаг загрузки платы - var state_cmd = WAIT ## текущее состояние платы ЭМС - var state_board = WAIT ## текущее состояние платы ЭМС - var cur_dev ## Текущее устройство - var cur_dev_num: = 0 ## Номер текущего устройства - var cur_dev_index: = 0 ## Индекс текущего устройства в списке - var dev_num_list: = Array() ## Список всех устройств - var need_next_dev: bool = false ## Нужно ли переходить к следующему устройству - var unit_ems ## Юнит эмс - var read_done: bool = false ## Флаг, что данные из ячейки прочитанны - var need_flash_rd: bool = false ## Флаг, что надо прочитать флеш - var need_flash_wr: bool = false ## Флаг, что надо записать данные в флеш - var need_write: bool = false ## Флаг, что надо записать данные в ячейку ЭМС - var ems_g_fn: String = '' ## Имя файла настроек ЭМС-Г - var cmd_array: Array ## Очередь выполнения команд + var online: bool ## статус платы + var ems_load: int = LoadState.NOT_DEFINED ## состояние загрузки платы + var state_cmd = WAIT ## текущее состояние платы ЭМС + var state_board = WAIT ## текущее состояние платы ЭМС + var cur_dev ## Текущее устройство + var cur_dev_num: = 0 ## Номер текущего устройства + var cur_dev_index: = 0 ## Индекс текущего устройства в списке + var dev_num_list: = Array() ## Список всех устройств + var need_next_dev: bool = false ## Нужно ли переходить к следующему устройству + var unit_ems ## Юнит эмс + var read_done: bool = false ## Флаг, что данные из ячейки прочитанны + var need_flash_rd: bool = false ## Флаг, что надо прочитать флеш + var need_flash_wr: bool = false ## Флаг, что надо записать данные в флеш + var need_write: bool = false ## Флаг, что надо записать данные в ячейку ЭМС + var ems_g_fn: String = '' ## Имя файла настроек ЭМС-Г + var cmd_array: Array ## Очередь выполнения команд - signal upd_delay_offset(board, cur_dev) ## Сигнал о обновлении данных задержек - signal upd_o_state(board, cur_dev) ## Сигнал о обновлении данных режима выходов - signal load_done(board) ## Сигнал о окончании загрузки данных в ячейку + signal upd_delay_offset(board, cur_dev) ## Сигнал о обновлении данных задержек + signal upd_o_state(board, cur_dev) ## Сигнал о обновлении данных режима выходов func _init(id, base_addr, in_table, out_table, u): id_board = id @@ -59,13 +60,18 @@ class EmsBoard: var bit_online = 0 + id_board var bit_load = 3 + id_board online = (status[0] >> bit_online) & 1 - ems_load = (status[0] >> bit_load) & 1 + ems_load = LoadState.DONE if ((status[0] >> bit_load) & 1) else LoadState.NOT_LOAD else: online = status[0] & 1 var bit_load = 4 - ems_load = (status[0] >> bit_load) & 1 - if not online: - need_write = true + if online: + if (ems_load != LoadState.IN_PROCESS) and (ems_load != LoadState.FAIL): + ems_load = LoadState.DONE if ((status[0] >> bit_load) & 1) else LoadState.NOT_LOAD + elif ((status[0] >> bit_load) & 1): + ems_load = LoadState.DONE + else: + ems_load = LoadState.NOT_DEFINED + set_wait() var in_blank = int(status[1 + offset] | (status[2 + offset] << 8) | (status[3 + offset] << 16) | \ (status[4 + offset] << 24) | (status[5 + offset] << 32)) var in_imp = int(status[7 + offset] | (status[8 + offset] << 8) | (status[9 + offset] << 16) | \ @@ -117,22 +123,23 @@ class EmsBoard: ports.append(port) unit_ems.send_isa(unit_ems.CmdCode.READ_ISA, ports) + ## Проверяет правильность выполнения команды записи номера устройства + func check_set_dev(cmd_s): + if unit_ems.isa_ports.has(base_addr_isa + 2): + cur_dev_num = unit_ems.isa_ports[base_addr_isa + 2] + state_cmd = cmd_s + if not check_dev_number(): + return + on_wr_device(cur_dev_num) + ## Обработчик сообщения, о том, что команда выполнена (машина состояний) func on_command_done(_yau_07): if not check_dev_number(): return if (unit_ems.cmd_code_rx == 1) and state_cmd == WR_DEV_NUM_W: - state_cmd = WRITE - cur_dev_num = unit_ems.isa_ports[base_addr_isa + 2] - if not check_dev_number(): - return - on_wr_device(cur_dev_num) + check_set_dev(WRITE) elif (unit_ems.cmd_code_rx == 1) and state_cmd == WR_DEV_NUM_R: - state_cmd = READ - cur_dev_num = unit_ems.isa_ports[base_addr_isa + 2] - if not check_dev_number(): - return - on_wr_device(cur_dev_num) + check_set_dev(READ) elif (state_cmd == READ) or (state_cmd == WRITE) \ and ((unit_ems.cmd_code_rx == 1) or (unit_ems.cmd_code_rx == 0)): for key in unit_ems.isa_ports.keys(): @@ -155,19 +162,22 @@ class EmsBoard: state_cmd = WR_DEV_NUM_W on_wr_device(cur_dev_num) else: # Пробег закончен, выбираем последнее устройство - state_cmd = WAIT - state_board = WAIT + set_wait() read_done = true cur_dev_index -= 1 need_next_dev = false else: - state_cmd = WAIT + if cmd_array.size(): + execute_cmd() + else: + set_wait() elif (state_cmd == READ_FLASH) and (unit_ems.cmd_code_rx == unit_ems.CmdCode.READ_FLASH_MP550): on_read_flash() elif (state_cmd == WRITE_FLASH) and (unit_ems.cmd_code_rx == unit_ems.CmdCode.WRITE_FLASH_MP550): - state_board = WAIT - state_cmd = WAIT + set_wait() + elif state_board == LOADING: + set_wait() ## Выбор текущего устройства и проверка правильности его номера func check_dev_number(): @@ -293,10 +303,12 @@ class EmsBoard: cur_dev.ports_data[base_addr_isa + 10] = int(ports['%d'%(base_addr_isa + 10)]) func set_load_done(): + state_board = LOADING unit_ems.send_load_ems_done(unit_ems.CmdCode.LOAD_EMS_DONE) func execute_cmd(): if len(cmd_array): + state_board = WRITE var cmd: Array = cmd_array.pop_front() change_mode(cmd[0], cmd[1]) @@ -308,3 +320,7 @@ class EmsBoard: func get_dev_mode(fs_index): return out_devs[modulation_dev[fs_index/4]].mode + + func set_wait(): + state_cmd = WAIT + state_board = WAIT diff --git a/scenes/эмс/yems-consts.gd b/scenes/эмс/yems-consts.gd index e37934b..dd27c0e 100644 --- a/scenes/эмс/yems-consts.gd +++ b/scenes/эмс/yems-consts.gd @@ -16,6 +16,7 @@ const STATUS_OFFSET = { ## Смещение статуса, ключ 1: 26, 2: 52 } +const EMG_G_ID = 4 const STATUS_OUT_OFFSET = 47 ## Смещение индекса выходных устройств относитель входных const KEMS_BOARD_NAME = 'КЭМС-Б1' ## Название платы КЭМС @@ -36,19 +37,19 @@ const FILES_NAME = ['Вариант 1', ] ## Первый элемент - имя юнита, второй - имя файла настроек -const EMS_G_BOARDS = [ - ['уарэп-яу07-2в','ЭМС-Г-В2'], - ['уарэп-яу07-2н','ЭМС-Г-Н2'], - ['уарэп-яу07-2к','ЭМС-Г-К2'], - ['уарэп-яу07-4в','ЭМС-Г-В4'], - ['уарэп-яу07-4н','ЭМС-Г-Н4'], - ['уарэп-яу07-4к','ЭМС-Г-К4'], - ['уарэп-яу07-1в','ЭМС-Г-В1'], - ['уарэп-яу07-1н','ЭМС-Г-Н1'], - ['уарэп-яу07-1к','ЭМС-Г-К1'], - ['уарэп-яу07-3в','ЭМС-Г-В3'], - ['уарэп-яу07-3н','ЭМС-Г-Н3'], - ['уарэп-яу07-3к','ЭМС-Г-К4'],] +const EMS_G_BOARDS = { + 'уарэп-яу07-2в':'ЭМС-Г-В2', + 'уарэп-яу07-2н':'ЭМС-Г-Н2', + 'уарэп-яу07-2к':'ЭМС-Г-К2', + 'уарэп-яу07-4в':'ЭМС-Г-В4', + 'уарэп-яу07-4н':'ЭМС-Г-Н4', + 'уарэп-яу07-4к':'ЭМС-Г-К4', + 'уарэп-яу07-1в':'ЭМС-Г-В1', + 'уарэп-яу07-1н':'ЭМС-Г-Н1', + 'уарэп-яу07-1к':'ЭМС-Г-К1', + 'уарэп-яу07-3в':'ЭМС-Г-В3', + 'уарэп-яу07-3н':'ЭМС-Г-Н3', + 'уарэп-яу07-3к':'ЭМС-Г-К3',} ## Таблица с данными для входов, первое значение - индекс устройства в ячейке КЭМС. diff --git a/scenes/эмс/yems-g.gd b/scenes/эмс/yems-g.gd deleted file mode 100644 index 4dead05..0000000 --- a/scenes/эмс/yems-g.gd +++ /dev/null @@ -1,81 +0,0 @@ -extends Node - -var ems_board: Dictionary = {} - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - check_dir() - var in_tbl: Array = [] - var out_tbl: Array = [] - for j in yemsconsts.NUM_INPUT_G: - in_tbl.append([j+1]) - out_tbl.append([j+yemsconsts.STATUS_OUT_OFFSET]) - for i in len(yemsconsts.EMS_G_BOARDS): - var unit_key = settings.get_unit_key(yemsconsts.EMS_G_BOARDS[i][0]) - var unit_ems = network.units[unit_key] - var ems_g: yemsboards.EmsBoard = yemsboards.EmsBoard.new(i+3, 0x120, in_tbl, out_tbl, unit_ems) - ems_board[i+3] = [ems_g, unit_ems] - ems_g.ems_g_fn = yemsconsts.EMS_G_BOARDS[i][1] - var params = ['','',0.0, 0,0] - for item in ems_g.in_tbl: - var in_dev: yemsdevs.InDev = yemsdevs.InDev.new(item[0], params, 0, 0x120) - ems_g.in_devs[in_dev.id] = in_dev - for item in ems_g.out_tbl: - var out_dev = yemsdevs.OutDev.new(item[0], params, 0, 0x120) - ems_g.out_devs[out_dev.id] = out_dev - ems_g.need_write = true - unit_ems.connect('data_received', Callable(self, 'on_data_ems_received').bind(ems_g)) - unit_ems.connect('command_done', Callable(self, 'on_command_done').bind(ems_g)) - unit_ems.connect('line_changed', Callable(self, 'on_line_changed').bind(ems_g)) - - -func on_line_changed(unit_ems, board): - if not unit_ems.online: - board.ems_load = false - board.state_board = board.WAIT - board.state_cmd = board.WAIT - board.need_write = true - - -func on_data_ems_received(unit_ems, board): - board.set_status(unit_ems.status) - if board.state_board == board.WAIT and board.state_cmd == board.WAIT: - if board.online: - if board.need_write and (not board.ems_load): - start_load(board) - elif not board.ems_load: - board.set_load_done() - elif board.ems_load and len(board.cmd_array): - board.execute_cmd() - else: - board.need_write = true - - -func on_command_done(unit_ems, board): - board.on_command_done(unit_ems) - - -func start_load(board): - var file = FileAccess.open(yemsconsts.emsg_files_folder + board.ems_g_fn, FileAccess.READ) - if file == null: - board.state_board = board.LOAD_FAIL - return - var read = file.get_as_text() - file.close() - var json_conv: = JSON.new() - if Error.OK == json_conv.parse(read): - var json_data = json_conv.get_data() - board.btn_load(json_data) - board.state_board = board.WRITE - board.start_rw_kems(false) - else: - board.state_board = board.LOAD_FAIL - - -## Проверяет ниличие директории, если их нет, создаёт -func check_dir(): - var dir = DirAccess.open(yemsconsts.emsg_files_folder) - if dir: - return - else: - DirAccess.make_dir_absolute(yemsconsts.emsg_files_folder) diff --git a/scripts/interfer.gd b/scripts/interfer.gd index e298d40..b6814fd 100644 --- a/scripts/interfer.gd +++ b/scripts/interfer.gd @@ -52,6 +52,7 @@ class Interfer: var tick_tx: int ## Тик время обновления цели, мс. var source_interfer: String = '' ## Тип объекта по которой поставлена помеха. var modulation: bool ## Модуляция для включения усилителей + var um: float ## Угол места для помехи. func _to_string() -> String: return 'номер: %d название: %s частота: %0.1f МГц пеленг: %0.1f гр.' % [ispp, ITERFER_MODE[krp][0], params['freq'], kni] @@ -258,14 +259,15 @@ func interfer_create(interfer_name, ecms, param, kni, id, dict, source_interfer) ecm = Interfer.new() ecm.ispp = ispp ecms[ispp] = ecm - ecm.svk = STATE_TSMT # Подготовка к передаче сообщения + ecm.svk = STATE_TSMT # Подготовка к передаче сообщения ecm.ss = msg_ss ecm.kni = kni ecm.krp = interfer_name ecm.params = param - ecm.powp = 100.0 # Необходимо добавить управление мощностью + ecm.powp = 100.0 ecm.source_interfer = source_interfer ecm.modulation = emit_enable + ecm.um = 15.0 # Значение по умолчанию signaller.emit_signal('interfer_new', ecm) if interfer_name == 'off': signaller.emit_signal('interfer_off', ecm, ecms, thrs) diff --git a/scripts/prd.gd b/scripts/prd.gd index 657e6cb..d09a66f 100644 --- a/scripts/prd.gd +++ b/scripts/prd.gd @@ -1,8 +1,9 @@ extends Node +enum PrdState {WORK, CONTROL} ## Границы секторов блоков ФС по частоте в режиме РТО. -const fs_band_rto: Dictionary = { +const FS_BAND_RTO: Dictionary = { 0: [200.0, 250.0], 1: [250.0, 300.0], 2: [300.0, 350.0], @@ -12,7 +13,7 @@ const fs_band_rto: Dictionary = { 6: [500.0, 550.0] } ## Границы секторов блоков ФС по частоте в режиме РЛС. -const fs_band_rls: Dictionary = { +const FS_BAND_RLS: Dictionary = { 0: [480.0, 490.0], 1: [490.0, 500.0], 2: [500.0, 510.0], @@ -22,13 +23,13 @@ const fs_band_rls: Dictionary = { 6: [540.0, 550.0] } ## Границы секторов блоков ФС по пеленгу. -const fs_sectors: Dictionary = { +const FS_SECTORS: Dictionary = { 0: [0.0, 90.0], 3: [90.0, 180.0], 2: [180.0, 270.0], 1: [270.0, 360.0] } -const fs_freq: Dictionary = { +const FS_FREQ: Dictionary = { 0: [390.0, 800.0, 200.0, 250.0, 433.0], 1: [800.0, 1065.0, 250.0, 300.0, 860.0], 2: [1065.0, 1210.0, 300.0, 350.0, 1137.0], @@ -38,7 +39,7 @@ const fs_freq: Dictionary = { 6: [3500.0, 6000.0, 500.0, 550.0, 5800.0] } ## Названия приборов ПРД -const prd_names: Array = [ +const PRD_NAMES: Array = [ 'уарэп-яу07-1н', 'уарэп-яу07-1в', 'уарэп-яу07-1к', @@ -53,7 +54,7 @@ const prd_names: Array = [ 'уарэп-яу07-4к', ] ## Соответствие модулей ФС их нахождуению в приборе ПРД -const fs_prd: Dictionary = { +const FS_PRD: Dictionary = { 0: ['уарэп-яу07-1к'], 1: ['уарэп-яу07-4к'], 2: ['уарэп-яу07-3к'], @@ -87,60 +88,181 @@ var fs_dict: Dictionary ## Словарь с модулями ФС var prd_dict: Dictionary ## Словарь с приборами ПРД class Fs: - const um_ports: Dictionary = { - 1 : 0x6, - 2 : 0xA, - 3 : 0x6, - 4 : 0xA, - 5 : 0x6, - 6 : 0xA } + const UM_PORTS: Dictionary = { + 1 : 0x106, + 2 : 0x10A, + 3 : 0x106, + 4 : 0x10A, + 5 : 0x106, + 6 : 0x10A } + + const CODE_UM: Array = [ + [-5, 0], + [0 , 10], + [10, 20], + [20, 30], + [30, 40], + [40, 50], + [50, 55]] var index ## Индекс блока усилителей var modulation: bool ## Состояние модуляции var prd_name: String ## Ипя прибора ПРД в котором стоит модуль var um_port: int = 0 ## Порт для угла места - var um: int = 0 ## Код угла места + var um_code_tx: int = 0 ## Код угла места для отправки в прибор + var um_code_rx: int = 0 ## Текущий код угла места signal update_modulation(index) func _init(i, p_name): prd_name = p_name index = i - if um_ports.has(index/4): - um_port = um_ports[index/4] + if UM_PORTS.has(index/4): + um_port = UM_PORTS[index/4] func set_modulation(val): modulation = val + func set_um_code(um: float): + if um < CODE_UM[0][0]: + um_code_tx = 0 + elif um > CODE_UM[len(CODE_UM) - 1][1]: + um_code_tx = len(CODE_UM) - 1 + else: + for i in CODE_UM.size(): + if (um >= CODE_UM[i][0]) and (um < CODE_UM[i][1]): + um_code_tx = i + + func set_um_data(data_arr, u): + if UM_PORTS.has(index/4): + var val = um_code_tx + if u.isa_ports.has(um_port): + val = tools.set_bits(u.isa_ports[um_port], um_code_tx, 0x0003) + data_arr.append(um_port) + data_arr.append(val) + class PRD: - const ug_addr: int = 0x100 ## адрес ячейки УГ + var prd_name: String ## Имя прибора + var unit_yau07 ## Юнит эмс + var fs_dic: Dictionary ## Массив блоков ФС + var yemsg_board: yemsboards.EmsBoard ## Плата ЭМС-Г + var state = PrdState.WORK + var cmd_array: Array ## Очередь команд + var ug_online: bool = false ## Состояние ячейки УГ + var set_ug_state: bool = true ## Необходимо ли записать в УГ настройки - var prd_name: String ## Имя прибора - var unit_yau07 ## Юнит эмс - var fs_dic: Dictionary ## Массив блоков ФС - var yemsg_board ## Плата ЭМС-Г - - func _init(u_name ,u, yems_board): + func _init(u_name ,u): prd_name = u_name unit_yau07 = u - yemsg_board = yems_board + init_ems_g() + + func init_ems_g(): + var in_tbl: Array = [] + var out_tbl: Array = [] + for j in yemsconsts.NUM_INPUT_G: + in_tbl.append([j+1]) + out_tbl.append([j+yemsconsts.STATUS_OUT_OFFSET]) + yemsg_board = yemsboards.EmsBoard.new(yemsconsts.EMG_G_ID, 0x120, in_tbl, out_tbl, unit_yau07) + yemsg_board.ems_g_fn = yemsconsts.EMS_G_BOARDS[prd_name] + var params = ['','',0.0, 0,0] + for item in yemsg_board.in_tbl: + var in_dev: yemsdevs.InDev = yemsdevs.InDev.new(item[0], params, 0, 0x120) + yemsg_board.in_devs[in_dev.id] = in_dev + for item in yemsg_board.out_tbl: + var out_dev = yemsdevs.OutDev.new(item[0], params, 0, 0x120) + yemsg_board.out_devs[out_dev.id] = out_dev + yemsg_board.need_write = true + unit_yau07.connect('data_received', Callable(self, 'on_data_received').bind()) + unit_yau07.connect('command_done', Callable(self, 'on_command_done').bind()) + unit_yau07.connect('line_changed', Callable(self, 'on_line_changed').bind()) + + func on_command_done(u): + if yemsg_board.state_board != yemsg_board.WAIT or yemsg_board.state_cmd != yemsg_board.WAIT: + yemsg_board.on_command_done(u) + return + for fs in fs_dic.values(): + for port in u.isa_ports.keys(): + if port == fs.um_port: + fs.um_code_rx = u.isa_ports[port] & 0x7 + + + + func on_line_changed(unit_ems): + if not unit_ems.online: + yemsg_board.ems_load = yemsg_board.LoadState.NOT_DEFINED + yemsg_board.set_wait() + set_ug_state = true + + func on_data_received(_u): + set_prd_status() + if state != PrdState.WORK: + return + if yemsg_board.state_board != yemsg_board.WAIT or yemsg_board.state_cmd != yemsg_board.WAIT: + return + if yemsg_board.online: + if yemsg_board.ems_load == yemsg_board.LoadState.NOT_LOAD: + start_load() + elif yemsg_board.ems_load == yemsg_board.LoadState.IN_PROCESS: + yemsg_board.set_load_done() + elif (yemsg_board.ems_load == yemsg_board.LoadState.DONE) and len(yemsg_board.cmd_array): + yemsg_board.execute_cmd() + else: + execute_cmd() + return + execute_cmd() + + func set_prd_status(): + yemsg_board.set_status(unit_yau07.status) + ug_online = (unit_yau07.status[0] >> 1) & 1 + if not ug_online: + set_ug_state = true + + func execute_cmd(): + if not len(cmd_array): return + var cmd: Array = cmd_array.pop_front() + unit_yau07.send_isa(cmd[0], cmd[1]) + + func start_load(): + var file = FileAccess.open(yemsconsts.emsg_files_folder + yemsg_board.ems_g_fn, FileAccess.READ) + var abs_dir = ProjectSettings.globalize_path(yemsconsts.emsg_files_folder + yemsg_board.ems_g_fn) + if file == null: + yemsg_board.ems_load = yemsg_board.LoadState.FAIL + yemsg_board.set_wait() + log.error('Не удалось прочитать файл настроек ячейки ЭМС-Г %s' %abs_dir) + return + var read = file.get_as_text() + file.close() + var json_conv: = JSON.new() + if Error.OK == json_conv.parse(read): + var json_data = json_conv.get_data() + yemsg_board.need_write = true + yemsg_board.ems_load = yemsg_board.LoadState.IN_PROCESS + yemsg_board.btn_load(json_data) + yemsg_board.state_board = yemsg_board.WRITE + yemsg_board.start_rw_kems(false) + else: + yemsg_board.ems_load = yemsg_board.LoadState.FAIL + yemsg_board.set_wait() + log.error('Не удалось прочитать файл настроек ячейки ЭМС-Г %s' %abs_dir) + func on_update_modulation(index): yemsg_board.add_cmd(index/4, fs_dic[index].modulation) + func set_um(data_arr): + cmd_array.append([unit_yau07.CmdCode.WRITE_ISA, data_arr]) + func _ready() -> void: - for prd_name in prd_names: + check_dir() + for prd_name in PRD_NAMES: var unit_key = settings.get_unit_key(prd_name) var unit_prd = network.units[unit_key] - for yemsg_board in yemsg.ems_board.values(): - if yemsg_board[1] == unit_prd: - var yemsg_b = yemsg_board[0] - var new_prd = PRD.new(prd_name, unit_prd, yemsg_b) - prd_dict[prd_name] = new_prd - for key in fs_prd.keys(): - var fs = Fs.new(key, fs_prd[key][0]) + var new_prd = PRD.new(prd_name, unit_prd) + prd_dict[prd_name] = new_prd + for key in FS_PRD.keys(): + var fs = Fs.new(key, FS_PRD[key][0]) fs_dict[key] = fs if prd_dict.has(fs.prd_name): prd_dict[fs.prd_name].fs_dic[key] = fs @@ -154,13 +276,13 @@ func get_fs_index(ecm, fs_index_arr): var angle: float = ecm.kni + 45.0 if angle > 360.0: angle -= 360.0 - for sec in fs_sectors.values(): + for sec in FS_SECTORS.values(): if float(angle) >= sec[0] and float(angle) <= sec[1]: - sector = fs_sectors.find_key(sec) - for diap in fs_freq.values(): + sector = FS_SECTORS.find_key(sec) + for diap in FS_FREQ.values(): if ecm.params.has('freq'): if ecm.params['freq'] >= diap[0] and ecm.params['freq'] <= diap[1]: - band.append(fs_freq.find_key(diap)) + band.append(FS_FREQ.find_key(diap)) for item in band: fs_index_arr.append(item * 4 + sector) @@ -175,8 +297,11 @@ func update_fs_state(ecms): for fs_index in fs_ids: var fs = fs_dict[fs_index] fs.set_modulation(ecm.modulation) + fs.set_um_code(ecm.um) for prd_module in prd_dict.values(): ## Отправка команды на исполнение в ПРД + if prd_module.state != PrdState.WORK: return if not prd_module.unit_yau07.online: continue + var um_data_array: Array = [] for fs in prd_module.fs_dic.values(): var dev_mode = prd_module.yemsg_board.get_dev_mode(fs.index) var fs_state = 2 @@ -184,3 +309,19 @@ func update_fs_state(ecms): fs_state = 3 if (dev_mode != fs_state) or (fs_state == 3): fs.emit_signal('update_modulation') + if not prd_module.ug_online: continue + if prd_module.set_ug_state: + fs.set_um_data(um_data_array, prd_module.unit_yau07) + else: + if fs.um_code_tx != fs.um_code_rx: + fs.set_um_data(um_data_array, prd_module.unit_yau07) + if um_data_array.size(): + prd_module.set_ug_state = false + prd_module.set_um(um_data_array) + + +## Проверяет ниличие директории, если их нет, создаёт +func check_dir(): + var dir = DirAccess.open(yemsconsts.emsg_files_folder) + if dir: return + else: DirAccess.make_dir_absolute(yemsconsts.emsg_files_folder) diff --git a/scripts/threats.gd b/scripts/threats.gd index 676a024..da3036e 100644 --- a/scripts/threats.gd +++ b/scripts/threats.gd @@ -59,8 +59,10 @@ func _ready() -> void: unit_5p28.connect('get_threats', Callable(self, 'on_get_threats').bind(unit_5p28, threats)) timer_check_lost.connect('timeout', Callable(self, 'on_timer_check_lost').bind(settings.ThreatParams.time_lost, threats)) timer_check_lost.start(settings.ThreatParams.time_lost / 1000.0) - timer_aoa_update.connect('timeout', Callable(self, 'on_timer_aoa_update').bind(threats)) - timer_aoa_update.start(1.00) + timer_aoa_update.connect('timeout', Callable(self, 'on_timer_aoa_update').bind(threats, timer_aoa_update)) + timer_aoa_update.start(3.0) + timer_aoa_update.one_shot = true + signaller.connect('rto_threat_sel', Callable(self, 'on_rto_threat_sel').bind(threats)) signaller.connect('rto_threat_unsel', Callable(self, 'on_rto_threat_unsel').bind(threats)) signaller.connect('rto_threat_unsel_all', Callable(self, 'on_rto_threat_unsel_all').bind(threats)) @@ -80,8 +82,9 @@ func on_timer_check_lost(time_lost: int, threats: Dictionary): call_deferred('emit_signal', 'threats_resized', threats) -func on_timer_aoa_update(threats:Dictionary): +func on_timer_aoa_update(threats:Dictionary, tmr): signaller.emit_signal('th_aoa_update', threats) + tmr.start(1.0) ## отправляет словарь целей в юнит, для запаковки и отправки в 5П28. func on_get_threats(unit, threats): unit.pack_threats(threats) diff --git a/scripts/yau07.gd b/scripts/yau07.gd index 97990dc..7a2e0f8 100644 --- a/scripts/yau07.gd +++ b/scripts/yau07.gd @@ -216,6 +216,8 @@ class YaU07 extends unit.Unit: var i: = 0 while i < ports_count: var shift: = i * 4 + if rx_data.size() < (data_pos + shift): + return false var isa_addr = rx_data.decode_u16(addr_pos + shift) # Адрес порта ISA яу-07 var isa_data = rx_data.decode_u16(data_pos + shift) # Данные порта ISA яу-07 isa_ports[isa_addr] = isa_data @@ -227,9 +229,13 @@ class YaU07 extends unit.Unit: var ports_count_pos = status_len + 7 # Положение в приёмном буфере количества портов if rx_data.size() < ports_count_pos: return false + if rx_data.size() < (ports_count_pos + 5): + return false var block_len = rx_data.decode_u16(ports_count_pos + 3) var block_adr = rx_data.decode_u16(ports_count_pos + 5) var block_data = [] + if rx_data.size() < (ports_count_pos + 7 + (block_len - 1) * 2): + return false for i in block_len: var shift: int = i * 2 block_data.append(rx_data.decode_u16(ports_count_pos + 7 + shift)) @@ -238,9 +244,13 @@ class YaU07 extends unit.Unit: func parse_flash(rx_data: PackedByteArray, status_len, cmd_code) -> bool: if cmd_code == CmdCode.READ_FLASH: + if rx_data.size() < (status_len + 14): + return false flash_len = rx_data.decode_u16(status_len + 12) flash_data = rx_data.slice(status_len + 14) if cmd_code == CmdCode.READ_FLASH_MP550: + if rx_data.size() < (status_len + 15): + return false flash_len = rx_data.decode_u16(status_len + 13) flash_data = rx_data.slice(status_len + 15) return true diff --git a/table/set_taggle.tscn b/table/set-toggle.tscn similarity index 100% rename from table/set_taggle.tscn rename to table/set-toggle.tscn