diff --git a/.gitignore b/.gitignore index 4762b6c1..a6146d7f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .import/ .dev/ export.cfg -export_presets.cfg # Imported translations (automatically generated from CSV files) *.translation diff --git a/build.sh b/build.sh index f5eab3b0..c97b0faf 100644 --- a/build.sh +++ b/build.sh @@ -12,6 +12,8 @@ TARGET_BIN="uarep-ctl.linux.x86_64" # Путь к папке в которой будет расположен исполняемый файл (загружаемый модуль) TARGET_PATH="./bin" +mkdir "${TARGET_PATH}" + # Путь к исполняемому файлу редактора Godot EDITOR="/opt/godot/godot.linuxbsd.editor.x86_64" diff --git a/config/setting_prd_control.json b/config/setting_prd_control.json new file mode 100644 index 00000000..c1534d4a --- /dev/null +++ b/config/setting_prd_control.json @@ -0,0 +1,223 @@ +{ + "config_version": "1.0.0", + "device_constants": { + "PRD_N": { + "constants": { + "POWER_UKP_1": 31, + "POWER_UKP_2": 63, + "DKM_BIT_2": 1, + "DKM_BIT_3": 2, + "BASE_ADDR_EMS_G": 288, + "ADDR_UG_LITERA_1": 262, + "ADDR_UG_LITERA_2": 264, + "ADDR_UG_LITERA_3": 266, + "TEMP_THRESHOLD": 70, + "POWER_THRESHOLD": 40, + "RAY_DOU_NUM": 3, + "ATT_UM_2": 2, + "ATT_UM_3": 3, + "POWER_UM": 100, + "TIMER_DELAY": 15.0, + "STATE_MASHINE_TIMER": 0.2 + }, + "pribor_config": { + "1н": {"angle": 0.0, "sectors": [4, 8]}, + "2н": {"angle": 90.0, "sectors": [7, 11]}, + "3н": {"angle": 180.0, "sectors": [6, 10]}, + "4н": {"angle": 270.0, "sectors": [5, 9]} + }, + "fs_params": { + "2": {"freq": 932.0, "width": 100.0}, + "3": {"freq": 1157.0, "width": 100.0} + }, + "start_litera": 2 + }, + "PRD_V": { + "constants": { + "POWER_UKP_1": 31, + "POWER_UKP_2": 63, + "DKM_BIT_4": 3, + "DKM_BIT_5": 4, + "BASE_ADDR_EMS_G": 288, + "ADDR_UG_LITERA_1": 262, + "ADDR_UG_LITERA_2": 264, + "ADDR_UG_LITERA_3": 266, + "TEMP_THRESHOLD": 70, + "POWER_THRESHOLD": 40, + "RAY_DOU_NUM": 3, + "ATT_UM_4": 2, + "ATT_UM_5": 3, + "POWER_UM": 100, + "TIMER_DELAY": 15.0, + "STATE_MASHINE_TIMER": 0.2 + }, + "pribor_config": { + "1в": {"angle": 0.0, "sectors": [12, 16]}, + "2в": {"angle": 90.0, "sectors": [15, 19]}, + "3в": {"angle": 180.0, "sectors": [14, 18]}, + "4в": {"angle": 270.0, "sectors": [13, 17]} + }, + "fs_params": { + "4": {"freq": 1227.0, "width": 100.0}, + "5": {"freq": 1575.0, "width": 110.0} + }, + "start_litera": 4 + }, + "PRD_K": { + "constants": { + "POWER_UKP_1": 31, + "POWER_UKP_2": 63, + "DKM_BIT_1": 0, + "DKM_BIT_6": 5, + "DKM_BIT_7": 6, + "BASE_ADDR_EMS_G": 288, + "ADDR_UG_LITERA_1": 262, + "ADDR_UG_LITERA_2": 264, + "ADDR_UG_LITERA_3": 266, + "TEMP_THRESHOLD": 40, + "POWER_THRESHOLD": 40, + "RAY_DOU_NUM": 3, + "ATT_UM_1": 0, + "ATT_UM_6": 3, + "ATT_UM_7": 2, + "POWER_UM": 100, + "TIMER_DELAY": 15.0, + "STATE_MASHINE_TIMER": 0.2 + }, + "pribor_config": { + "1к": {"angle": 0.0, "sectors": [0, 20, 24]}, + "2к": {"angle": 90.0, "sectors": [3, 23, 27]}, + "3к": {"angle": 180.0, "sectors": [2, 22, 26]}, + "4к": {"angle": 270.0, "sectors": [1, 21, 25]} + }, + "fs_params": { + "1": {"freq": 450.0, "width": 80.0}, + "6": {"freq": 2450.0, "width": 110.0}, + "7": {"freq": 4750.0, "width": 110.0} + }, + "start_litera": 1 + } + }, + "base_configs": { + "block_ip": { + "maa2000_1": [0, false], + "maa2000_2": [1, false], + "ip9_50_1": [2, false], + "ip9_50_2": [3, false], + "ip12_50_1": [4, false], + "ip5_25": [7, false] + }, + "block_kasseta": { + "yau07": false, + "ems": false, + "ug": false, + "ukp1": false, + "ukp2": false + } + }, + "device_configs": { + "PRD_N": { + "block_ip": "base", + "block_kasseta": "base", + "control_results": { + "block_kasseta":false, + "block_ip": false, + "temperature": true, + "dkm_2": false, + "dkm_3": false, + "dou_2": false, + "dou_3": false, + "fs_2": false, + "fs_3": false, + "is_over_control": false + } + }, + "PRD_V": { + "block_ip": "base", + "block_kasseta": "base", + "control_results": { + "block_kasseta":false, + "block_ip": false, + "temperature": true, + "dkm_4": false, + "dkm_5": false, + "dou_4": false, + "dou_5": false, + "fs_4": false, + "fs_5": false, + "is_over_control": false + } + }, + "PRD_K": { + "block_ip": { + "maa2000_1": [0, false], + "maa2000_2": [1, false], + "ip9_50_1": [2, false], + "ip9_50_2": [3, false], + "ip12_50_1": [4, false], + "ip9_50_3": [5, false], + "ip12_50_2": [6, false], + "ip5_25": [7, false] + }, + "block_kasseta": "base", + "control_results": { + "block_kasseta":false, + "block_ip": false, + "temperature": true, + "dkm_1": false, + "dkm_6": false, + "dkm_7": false, + "dou_6": false, + "dou_7": false, + "fs_1": false, + "fs_6": false, + "fs_7": false, + "is_over_control": false + } + } + }, + "ray_types": ["RAY_m5", "RAY_5", "RAY_15", "RAY_25", "RAY_35", "RAY_45"], + "data_indices": { + "STATUS_BOARD": 0, + "IN_BLANK_PRD": 1, + "IN_IMPULS_PRD": 7, + "OUT_BLANK_PRD": 13, + "OUT_IMPULS_PRD": 19, + "DRY_CONTACT": 27, + "DKM": 28, + "POWER_UKP_1": 31, + "TEMPERATURE_UKP_1": 47, + "POWER_UKP_2": 63, + "TEMPERATURE_UKP_2": 79 + }, + "fs_keys": { + "1": "fs_1", + "2": "fs_2", + "3": "fs_3", + "4": "fs_4", + "5": "fs_5", + "6": "fs_6", + "7": "fs_7" + }, + "temperature_constants": { + "CONST_MIN_TEMP": -25, + "MAXIMUM_CODE_ADC": 3796, + "MINIMUM_CODE_AD": 2660, + "TEMPERATURE_UKP_1": 47, + "TEMPERATURE_UKP_2": 79 + }, + "ems_input_bits_config": { + "PRD_N": {"bit1": 9, "bit2": 10}, + "PRD_V": {"bit1": 11, "bit2": 12}, + "PRD_K": {"bit1": 13, "bit2": 14, "bit_lit": 8} + }, + "fs_rules":[ + {"key": "fs_1", "min": 0, "max": 4}, + {"key": "fs_2", "min": 4, "max": 8}, + {"key": "fs_3", "min": 8, "max": 12}, + {"key": "fs_4", "min": 12, "max": 16}, + {"key": "fs_5", "min": 16, "max": 20}, + {"key": "fs_6", "min": 20, "max": 24}, + {"key": "fs_7", "min": 24, "max": 28} + ] +} diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 00000000..dc12e8f0 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,112 @@ +[preset.0] + +name="Linux-X11" +platform="Linux" +runnable=true +advanced_options=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="bin/uarep-ctl.linux.x86_64" +patches=PackedStringArray() +encryption_include_filters="" +encryption_exclude_filters="" +seed=0 +encrypt_pck=false +encrypt_directory=false +script_export_mode=0 + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=2 +binary_format/embed_pck=true +texture_format/s3tc_bptc=true +texture_format/etc2_astc=false +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=true +ssh_remote_deploy/host="user@192.168.11.105" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" +texture_format/bptc=true +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false + +[preset.1] + +name="Windows Desktop" +platform="Windows Desktop" +runnable=true +advanced_options=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="bin/uarep-ctl.exe" +patches=PackedStringArray() +encryption_include_filters="" +encryption_exclude_filters="" +seed=0 +encrypt_pck=false +encrypt_directory=false +script_export_mode=0 + +[preset.1.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=true +texture_format/s3tc_bptc=true +texture_format/etc2_astc=false +binary_format/architecture="x86_64" +codesign/enable=false +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PackedStringArray() +application/modify_resources=true +application/icon="" +application/console_wrapper_icon="" +application/icon_interpolation=4 +application/file_version="" +application/product_version="" +application/company_name="" +application/product_name="" +application/file_description="" +application/copyright="" +application/trademarks="" +application/export_angle=0 +application/export_d3d12=0 +application/d3d12_agility_sdk_multiarch=true +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}' +$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}' +$trigger = New-ScheduledTaskTrigger -Once -At 00:00 +$settings = New-ScheduledTaskSettingsSet +$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings +Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true +Start-ScheduledTask -TaskName godot_remote_debug +while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 } +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue" +ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue +Remove-Item -Recurse -Force '{temp_dir}'" diff --git a/scenes/diagram/diagram.gd b/scenes/diagram/diagram.gd index d1ad627f..d33a1599 100644 --- a/scenes/diagram/diagram.gd +++ b/scenes/diagram/diagram.gd @@ -35,8 +35,8 @@ func get_radius_outter() -> float: return material.get('shader_parameter/radius func get_radius_inner_0() -> float: return material.get('shader_parameter/radius_inner_0') func get_radius_inner_1() -> float: return material.get('shader_parameter/radius_inner_1') -func get_band_colors(val: Array): return material.get('shader_parameter/ant_band_c') -func get_band_failures(val: Array): return material.get('shader_parameter/ant_band_m') +func get_band_colors(_val: Array): return material.get('shader_parameter/ant_band_c') +func get_band_failures(_val: Array): return material.get('shader_parameter/ant_band_m') func set_band_colors(val: Array): material.set('shader_parameter/ant_band_c', val) func set_band_failures(val: Array): material.set('shader_parameter/ant_band_m', val) diff --git a/scenes/frame-ecm-list/frm-ecm-list.tscn b/scenes/frame-ecm-list/frm-ecm-list.tscn index e0086614..db6c658e 100644 --- a/scenes/frame-ecm-list/frm-ecm-list.tscn +++ b/scenes/frame-ecm-list/frm-ecm-list.tscn @@ -65,7 +65,7 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 strips_rotation = 15.0 -text = "СПРС" +text = "JTIDS" metadata/rfi_name = "sprs" [node name="btn_kupd" parent="grd_forced" groups=["группа-принудительно"] instance=ExtResource("4_7ys3c")] diff --git a/scenes/frame-threats/scroll-threats.gd b/scenes/frame-threats/scroll-threats.gd index d20ef2da..be9dc979 100644 --- a/scenes/frame-threats/scroll-threats.gd +++ b/scenes/frame-threats/scroll-threats.gd @@ -75,7 +75,7 @@ func on_threat_update(th, table_index: Dictionary): elif th.emit_state == 2: emit_txr.visible = true emit_txr.self_modulate = Color.RED - + ## Обрабатывает сигнал [b]threat_lost[/b]. diff --git a/scenes/grid-buttons-ecm/grid-buttons-ecm.tscn b/scenes/grid-buttons-ecm/grid-buttons-ecm.tscn index a1b2522a..d9384518 100644 --- a/scenes/grid-buttons-ecm/grid-buttons-ecm.tscn +++ b/scenes/grid-buttons-ecm/grid-buttons-ecm.tscn @@ -147,6 +147,6 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 strips_rotation = 30.0 -text = "ЕПРЛС" +text = "ЕРЛС" disabled = true metadata/rfi_name = "eprls" diff --git a/scenes/pribor-afsp/pribor-afsp-1.tscn b/scenes/pribor-afsp/pribor-afsp-1.tscn index 867517f0..1e3e72c0 100644 --- a/scenes/pribor-afsp/pribor-afsp-1.tscn +++ b/scenes/pribor-afsp/pribor-afsp-1.tscn @@ -30,7 +30,9 @@ autostart = true [node name="bort" parent="." instance=ExtResource("3_d7iti")] layout_mode = 0 +offset_left = 24.0 offset_top = 27.7778 +offset_right = 604.0 offset_bottom = 1216.78 metadata/DeviceName = &"Устройство РР левого борта" diff --git a/scenes/pribor-afsp/pribor-afsp-2.tscn b/scenes/pribor-afsp/pribor-afsp-2.tscn index 51ff32da..687a5730 100644 --- a/scenes/pribor-afsp/pribor-afsp-2.tscn +++ b/scenes/pribor-afsp/pribor-afsp-2.tscn @@ -7,9 +7,9 @@ [node name="pribor_afsp" type="Control"] layout_mode = 3 anchors_preset = 0 -offset_left = 81.0 +offset_left = 82.0 offset_top = 108.0 -offset_right = 81.0 +offset_right = 82.0 offset_bottom = 108.0 scale = Vector2(1, 0.9) script = ExtResource("1_tfses") @@ -30,9 +30,9 @@ autostart = true [node name="bort" parent="." instance=ExtResource("3_xpxb5")] layout_mode = 0 -offset_left = -11.0 +offset_left = 12.0 offset_top = -59.0 -offset_right = 569.0 +offset_right = 592.0 offset_bottom = 1130.0 metadata/DeviceName = &"Устройство РР правого борта" diff --git a/scenes/pribor-afsp/pribor-afsp.gd b/scenes/pribor-afsp/pribor-afsp.gd index 67a150ba..7437ff94 100644 --- a/scenes/pribor-afsp/pribor-afsp.gd +++ b/scenes/pribor-afsp/pribor-afsp.gd @@ -99,4 +99,4 @@ func _on_request_completed(result, _response_code, headers, body: PackedByteArra func _on_item_pressed(block_a: Control): var metas = block_a.get_meta_list() for n in metas: - var v = block_a.get_meta(n) + var _v = block_a.get_meta(n) diff --git a/scenes/pribor-afsp/pribor-bpo.tscn b/scenes/pribor-afsp/pribor-bpo.tscn index 36d5db08..06d13c79 100644 --- a/scenes/pribor-afsp/pribor-bpo.tscn +++ b/scenes/pribor-afsp/pribor-bpo.tscn @@ -9,9 +9,9 @@ layout_mode = 3 anchors_preset = 0 offset_left = 115.0 -offset_top = 150.0 +offset_top = 148.0 offset_right = 115.0 -offset_bottom = 150.0 +offset_bottom = 148.0 script = ExtResource("1_bhc4e") prefix_path = "DeviceDescription[DeviceName]" this_bpo1_name = "Устройство БПО левого борта" @@ -24,10 +24,10 @@ settings_path_to_wait_time = "Период опроса состояния БП [node name="mod_pit_g1" parent="." instance=ExtResource("2_jp6m0")] layout_mode = 2 -offset_left = 40.0 -offset_top = 535.0 -offset_right = 560.0 -offset_bottom = 605.0 +offset_left = 9.0 +offset_top = 377.0 +offset_right = 529.0 +offset_bottom = 447.0 size_flags_horizontal = 7 size_flags_vertical = 7 fname = "Модуль электропитания" @@ -35,20 +35,20 @@ rname = "G1" [node name="blok_bpo_a1" parent="." instance=ExtResource("2_jp6m0")] layout_mode = 0 -offset_left = 40.0 -offset_top = 135.0 -offset_right = 560.0 -offset_bottom = 330.0 +offset_left = 9.0 +offset_top = -23.0 +offset_right = 529.0 +offset_bottom = 172.0 show_state = false fname = "Блок БПО левого борта" rname = "А1" [node name="grid_bpo_a1" type="GridContainer" parent="."] layout_mode = 0 -offset_left = 50.0 -offset_top = 175.0 -offset_right = 498.0 -offset_bottom = 320.0 +offset_left = 19.0 +offset_top = 17.0 +offset_right = 467.0 +offset_bottom = 162.0 columns = 4 [node name="kanal1" parent="grid_bpo_a1" groups=["потребитель-питания"] instance=ExtResource("2_jp6m0")] @@ -108,30 +108,30 @@ fname = "Канал 8" metadata/state = "SelfTest[0].SystemList[0].DevList[7]['TestPassed']" [node name="yas_bpo_a1" parent="." groups=["потребитель-питания"] instance=ExtResource("3_jcpjs")] -offset_left = 500.0 -offset_top = 175.0 -offset_right = 550.0 -offset_bottom = 320.0 +offset_left = 469.0 +offset_top = 17.0 +offset_right = 519.0 +offset_bottom = 162.0 show_rname = false self_size = Vector2i(50, 145) fname = "Яч. связи" [node name="blok_bpo_a2" parent="." instance=ExtResource("2_jp6m0")] layout_mode = 0 -offset_left = 40.0 -offset_top = 335.0 -offset_right = 560.0 -offset_bottom = 530.0 +offset_left = 9.0 +offset_top = 177.0 +offset_right = 529.0 +offset_bottom = 372.0 show_state = false fname = "Блок БПО правого борта" rname = "А2" [node name="grid_bpo_a2" type="GridContainer" parent="."] layout_mode = 0 -offset_left = 50.0 -offset_top = 375.0 -offset_right = 498.0 -offset_bottom = 520.0 +offset_left = 19.0 +offset_top = 217.0 +offset_right = 467.0 +offset_bottom = 362.0 columns = 4 [node name="kanal1" parent="grid_bpo_a2" groups=["потребитель-питания", "управляется-по-шине-2"] instance=ExtResource("2_jp6m0")] @@ -191,10 +191,10 @@ fname = "Канал 8" metadata/state = "SelfTest[0].SystemList[0].DevList[7]['TestPassed']" [node name="yas_bpo_a2" parent="." groups=["потребитель-питания"] instance=ExtResource("3_jcpjs")] -offset_left = 500.0 -offset_top = 375.0 -offset_right = 550.0 -offset_bottom = 520.0 +offset_left = 469.0 +offset_top = 217.0 +offset_right = 519.0 +offset_bottom = 362.0 show_rname = false self_size = Vector2i(50, 145) fname = "Яч. связи" diff --git a/scenes/pribor-prd-k/kasseta-fs-kd.tscn b/scenes/pribor-prd-k/kasseta-fs-kd.tscn index ac2d952b..3fcc635c 100644 --- a/scenes/pribor-prd-k/kasseta-fs-kd.tscn +++ b/scenes/pribor-prd-k/kasseta-fs-kd.tscn @@ -49,7 +49,7 @@ offset_top = 33.0 offset_right = 155.0 offset_bottom = 183.0 fname = "Блок ФС-2" -rname = "A2" +rname = "A6" [node name="ref_A6" parent="." groups=["default_reset", "fs_group"] instance=ExtResource("3_kqnvt")] offset_left = 155.0 @@ -57,7 +57,7 @@ offset_top = 33.0 offset_right = 205.0 offset_bottom = 183.0 fname = "Модуль ФС" -rname = "A5" +rname = "A3" metadata/fs = "fs_6" [node name="ref_A5" parent="." groups=["default_reset", "fs_group"] instance=ExtResource("3_kqnvt")] @@ -66,7 +66,7 @@ offset_top = 33.0 offset_right = 255.0 offset_bottom = 183.0 fname = "Модуль ФС" -rname = "A3" +rname = "A2" metadata/fs = "fs_7" [node name="ref_A7" parent="." groups=["default_reset"] instance=ExtResource("3_kqnvt")] @@ -75,4 +75,4 @@ offset_top = 33.0 offset_right = 305.0 offset_bottom = 183.0 fname = "Блок ФС-6" -rname = "A6" +rname = "A5" diff --git a/scenes/pribor-prd-k/pribor-prd-k.gd b/scenes/pribor-prd-k/pribor-prd-k.gd index 12be8885..04da31fb 100644 --- a/scenes/pribor-prd-k/pribor-prd-k.gd +++ b/scenes/pribor-prd-k/pribor-prd-k.gd @@ -1,252 +1,197 @@ @tool extends 'res://scenes/контроль/прибор.gd' -const constants_k: Dictionary = { - 'POWER_UKP_1': 31, - 'POWER_UKP_2': 63, - 'DKM_BIT_1': 0, - 'DKM_BIT_6': 5, - 'DKM_BIT_7': 6, - 'BASE_ADDR_EMS_G': 0x120, - 'ADDR_UG_LITERA_1': 0x106, - 'ADDR_UG_LITERA_2': 0x108, - 'ADDR_UG_LITERA_3': 0x10A, - 'TEMP_THRESHOLD': 40, - 'POWER_THRESHOLD': 40, - 'RAY_DOU_NUM': 0x3, - 'ATT_UM_1': 0x0, - 'ATT_UM_6': 0x3, - 'ATT_UM_7': 0x2, - 'POWER_UM': 100, - 'TIMER_DELAY': 10.0, - 'STATE_MASHINE_TIMER': 0.3, -} -# Конфигурация параметров для каждого прибора -const PRIBOR_CONFIG := { - '1к': {'angle': 0.0, 'sectors': [0, 20, 24]}, - '2к': {'angle': 90.0, 'sectors': [3, 23, 27]}, - '3к': {'angle': 180.0, 'sectors': [2, 22, 26]}, - '4к': {'angle': 270.0, 'sectors': [1, 21, 25]}, -} -# Конфигурация частот и ширин для каждого ФС -const FS_PARAMS := { - 1: {'freq': 450.0, 'width': 80.0}, - 6: {'freq': 2450.0, 'width': 110.0}, - 7: {'freq': 4750.0, 'width': 110.0} -} enum STATE_VAL { NONE = 0, GOOD = 1, ERROR = 2 } -var block_ip_config_k := { - 'maa2000_1': [0, false], - 'maa2000_2': [1, false], - 'ip9_50_1': [2, false], - 'ip9_50_2': [3, false], - 'ip12_50_1': [4, false], - 'ip9_50_3': [5, false], - 'ip12_50_2': [6, false], - 'ip5_25': [7, false], -} -var block_kasseta_y5_prd_config_k: = { - 'yau07': false, - 'ems': false, - 'ug': false, - 'ukp1': false, - 'ukp2': false, -} # Основные переменные -var start_litera: int = 1 -var ug_work_1: int = 3 ## Аттенюация усилителей мощности -var ug_work_2: int = 2 ## Аттенюация усилителей мощности -var ug_work_3: int = 0 ## Аттенюация усилителей мощности -var mashine_timer: Timer = Timer.new() -var prd_k_module: Object var unit_prd_k: Object -var control_prd_k: Object -# Результаты контроля -var control_results_k: Dictionary = { - 'block_ip': false, # Проверка касет П1 и ИП МА2000 - 'temperature': true, - 'dkm_1': false, - 'dkm_6': false, - 'dkm_7': false, - 'dou_6': false, - 'dou_7': false, - 'fs_1': 2, - 'fs_6': 2, - 'fs_7': 2, -} - -var test_control_k = preload('res://scripts/pribor-prd.gd') var ctrl_pos = 30 func _ready() -> void: if Engine.is_editor_hint(): return - - initialize_connections() - setup_timer() - set_default_state() - find_labels(self) - - -func on_state_mashine() -> void: - control_prd_k.state_control_machine() - - -func initialize_connections() -> void: var unit_name = get_meta('unit_name')[0] - prd_k_module = prd.prd_dict[unit_name] - unit_prd_k = prd_k_module.unit_yau07 - - unit_prd_k.connect('line_changed', Callable(self, 'on_line_changed')) - var power_amplifiers: Array = get_tree().get_nodes_in_group('power_amplifier') - var init_data: Dictionary = { - 'control_label': $control_result, - 'power_amplifiers': power_amplifiers, - 'unit_prd': unit_prd_k, - 'module_prd' : prd_k_module, - 'constants': constants_k, - 'prd_config': PRIBOR_CONFIG, - 'fs_params': FS_PARAMS, - 'block_ip_prd_config': block_ip_config_k, - 'block_kasseta_y5_prd_config': block_kasseta_y5_prd_config_k, - 'control_results': control_results_k, - 'current_litera': start_litera, - } - control_prd_k = test_control_k.TestPRD.new(init_data) - add_child(control_prd_k) - control_prd_k.connect('control_is_over', Callable(self, 'on_control_result')) + var prd_k_module = prd.prd_dict[unit_name] + unit_prd_k = prd_k_module.unit_control + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + for temp in power_amplifier: + temp.value1 = -70 + # Подписываемся на сигналы + signaller.conn(signaller.start_contol_device, Callable(self, '_on_start_control')) + unit_prd_k.connect('control_is_over', Callable(self, 'on_press_device')) + unit_prd_k.connect('status_updated', Callable(self, '_on_status_updated')) + # Устанавливаем начальный статус + _update_status_text(unit_prd_k.get_current_status()) + on_press_device(unit_prd_k.self_name) -func setup_timer() -> void: - add_child(mashine_timer) - mashine_timer.connect('timeout', Callable(self, 'on_state_mashine')) - mashine_timer.wait_time = constants_k.STATE_MASHINE_TIMER - mashine_timer.start() +func _process(_delta: float) -> void: + if Engine.is_editor_hint(): + return + set_frame($input_0, unit_prd_k.ems_g_sock_dic.ems_input_1) + set_frame($input_1, unit_prd_k.ems_g_sock_dic.ems_input_2) + set_frame($input_2, unit_prd_k.ems_g_sock_dic.ems_input_lit_1) + set_frame($output_0, unit_prd_k.ems_g_sock_dic.ems_output_1) + set_frame($output_1, unit_prd_k.ems_g_sock_dic.ems_output_2) + set_frame($output_2, unit_prd_k.ems_g_sock_dic.ems_output_lit_1) -func set_default_state() -> void: - for group in get_tree().get_nodes_in_group('default_reset'): - group.state = STATE_VAL.NONE +func set_frame(node_frame: Node, val: int): node_frame.set_frame(val) - for group in get_tree().get_nodes_in_group('power_amplifier'): + +func _on_start_control() -> void: + set_default_state(get_tree().get_nodes_in_group('default_reset')) + set_default_state(get_tree().get_nodes_in_group('power_amplifier')) + find_labels(self) + await get_tree().create_timer(1.0).timeout + on_press_device(unit_prd_k.self_name) + + +static func set_default_state(default_reset_array_node: Array) -> void: + for group in default_reset_array_node: group.state = STATE_VAL.NONE func _enter_tree() -> void: if Engine.is_editor_hint(): return - $control_result.text = 'Выполняется ...' - $control_result.add_theme_color_override('font_color', Color.ALICE_BLUE) - signaller.connect('режим_работа', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_журнал', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_эмс', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_настройки', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_контроль', Callable(self, 'on_mode_changed').bind(true)) + if unit_prd_k: + _update_status_text(unit_prd_k.get_current_status()) func _exit_tree() -> void: if Engine.is_editor_hint(): return - prd_k_module.cmd_array.append([unit_prd_k.CmdCode.WRITE_ISA, [constants_k.ADDR_UG_LITERA_1, ug_work_1, constants_k.ADDR_UG_LITERA_2, ug_work_2, constants_k.ADDR_UG_LITERA_3, ug_work_3]]) + #prd_k_module.cmd_array.append([unit_prd_k.CmdCode.WRITE_ISA, [constants_k.ADDR_UG_LITERA_1, ug_work_1, constants_k.ADDR_UG_LITERA_2, ug_work_2, constants_k.ADDR_UG_LITERA_3, ug_work_3]]) -func on_line_changed(unit_pribor: Object) -> void: - if not unit_pribor.online: - set_default_state() +static func temperature_fill(temperature_arr_node: Array, temperature_dic: Dictionary)->void: + for i_node_temperature in temperature_arr_node: + var temperature_meta: String = i_node_temperature.get_meta('um') + if not temperature_dic.has(temperature_meta): return + i_node_temperature.value1 = temperature_dic[temperature_meta] if temperature_dic[temperature_meta] < 361 else -40 -func on_mode_changed(in_tree: bool) -> void: - if not in_tree: - mashine_timer.stop() - prd_k_module.cmd_array.append([unit_prd_k.CmdCode.WRITE_ISA, [constants_k.ADDR_UG_LITERA_1, ug_work_1, constants_k.ADDR_UG_LITERA_2, ug_work_2, constants_k.ADDR_UG_LITERA_3, ug_work_3]]) - signaller.emit_signal('interfer_off_all') - else: - set_default_state() - control_prd_k.state = control_prd_k.STATE_MASHINE.INIT - mashine_timer.start() - - -func power_fill(pow_dic: Dictionary, fs_result: Dictionary) -> void: - #if not control_prd_k.block_kasseta_y5_config.yau07 or not control_prd_k.block_kasseta_y5_config.ukp1 or not control_prd_k.block_kasseta_y5_config.ukp2: - #return - var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') - for i_powapm in power_amplifier: - var powamp_meta: String = i_powapm.get_meta('um') +static func power_fill(pow_dic: Dictionary, fs_result: Dictionary, power_amplifier_arr_node: Array, POWER_THRESHOLD: int) -> void: + for i_node_temperature in power_amplifier_arr_node: + var powamp_meta: String = i_node_temperature.get_meta('um') var status = STATE_VAL.GOOD if pow_dic else STATE_VAL.NONE - if pow_dic: - if not pow_dic.has(powamp_meta): - break - if pow_dic[powamp_meta].size() < 6: - status = STATE_VAL.ERROR + if not pow_dic.has(powamp_meta): continue + # Проверки fs_result + if powamp_meta == 'um_8' and not fs_result.fs_1: continue + if powamp_meta in ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'] and not fs_result.fs_6: continue + if powamp_meta in ['um_9', 'um_10', 'um_11', 'um_12', 'um_13', 'um_14'] and not fs_result.fs_7: continue + if powamp_meta == 'um_8': + var power_value = pow_dic[powamp_meta][5] + i_node_temperature.value0 = [power_value] + # Проверка для um_8: если значение < 1 → STATE_VAL.NONE + if power_value < 1: + status = STATE_VAL.NONE else: - if powamp_meta == 'um_7' and not fs_result.fs_1: return - if powamp_meta in ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'] and not fs_result.fs_6: return - if powamp_meta in ['um_8', 'um_9', 'um_10', 'um_11', 'um_12', 'um_13'] and not fs_result.fs_7: return - i_powapm.value0 = pow_dic[powamp_meta] - for i_p in pow_dic[powamp_meta]: - if i_p < constants_k.POWER_THRESHOLD: - status = STATE_VAL.ERROR - i_powapm.state = status + status = STATE_VAL.ERROR if power_value < POWER_THRESHOLD else STATE_VAL.GOOD + else: + var power_array: Array = pow_dic[powamp_meta] + i_node_temperature.value0 = power_array + # Проверка: если ВСЕ значения в массиве < 1 → STATE_VAL.NONE + var all_below_one: bool = true + for i_p in power_array: + if i_p >= 1: + all_below_one = false + break + + if all_below_one: + status = STATE_VAL.NONE + else: + var count_above_threshold = 0 + for i_p in power_array: + if i_p >= POWER_THRESHOLD: + count_above_threshold += 1 + status = STATE_VAL.GOOD if count_above_threshold >= 3 else STATE_VAL.ERROR + i_node_temperature.state = status -func on_control_result(result_dic: Dictionary, power_dic: Dictionary) -> void: - mashine_timer.stop() - block_kasseta_y5_prd_config_k = control_prd_k.block_kasseta_y5_config +func on_press_device(_name_davice: String) -> void: var nodes_y5: Array = get_tree().get_nodes_in_group('y-5') + var node_ip_power_arr: Array = get_tree().get_nodes_in_group('power_supply') + var fs_nodes: Array = get_tree().get_nodes_in_group('fs_group') + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + var default_reset_array_node: Array = get_tree().get_nodes_in_group('default_reset') + var module_fs_1: Node = $kasseta_fs_kd/ref_A2 + var module_fs_6: Node = $kasseta_fs_kd/ref_A4 + var dou_6: Node = $dou6_A7 + var module_fs_7: Node = $kasseta_fs_kd/ref_A7 + var dou_7: Node = $dou7_A8 + var control_data: Dictionary = unit_prd_k.get_control_results() + var for_control_result: Dictionary = { + 'nodes_y5': nodes_y5, + 'node_ip_power_arr': node_ip_power_arr, + 'fs_nodes': fs_nodes, + 'power_amplifier': power_amplifier, + 'default_reset_array_node': default_reset_array_node, + 'module_fs_1': module_fs_1, + 'module_fs_6': module_fs_6, + 'dou_6': dou_6, + 'module_fs_7': module_fs_7, + 'dou_7': dou_7, + } + for_control_result.merge(control_data, true) + on_control_result(for_control_result) + + +static func on_control_result(for_result_dic: Dictionary) -> void: + temperature_fill(for_result_dic.power_amplifier, for_result_dic.temperature_um) + var all_y5_good: bool = true + var block_kasseta_y5_prd_config_k: Dictionary = for_result_dic.block_kasseta_y5_config + var nodes_y5: Array = for_result_dic.nodes_y5 for node_y5 in nodes_y5: var meta_y5 = node_y5.get_meta('y5') if block_kasseta_y5_prd_config_k.has(meta_y5): - if block_kasseta_y5_prd_config_k['yau07'] == false: + if not block_kasseta_y5_prd_config_k['yau07']: node_y5.state = STATE_VAL.ERROR if meta_y5 == 'yau07' else STATE_VAL.NONE - break - node_y5.state = STATE_VAL.GOOD if block_kasseta_y5_prd_config_k[meta_y5] else STATE_VAL.ERROR - - block_ip_config_k = control_prd_k.block_ip_config - var node_ip_power_arr: Array = get_tree().get_nodes_in_group('power_supply') - for power_supply in node_ip_power_arr: + else: + node_y5.state = STATE_VAL.GOOD if block_kasseta_y5_prd_config_k[meta_y5] else STATE_VAL.ERROR + # Проверяем состояние после установки + if node_y5.state == STATE_VAL.ERROR: + all_y5_good = false + var block_ip_config_k: Dictionary = for_result_dic.block_ip_config + for power_supply in for_result_dic.node_ip_power_arr: var meta_ip = power_supply.get_meta('ip') - if block_ip_config_k.has(meta_ip) and block_kasseta_y5_prd_config_k.ug: + if block_ip_config_k.has(meta_ip) and block_kasseta_y5_prd_config_k.ug and block_kasseta_y5_prd_config_k.yau07: power_supply.state = STATE_VAL.GOOD if block_ip_config_k[meta_ip][1] else STATE_VAL.ERROR + else: + power_supply.state = STATE_VAL.NONE + # Проверяем состояние после установки + if power_supply.state == STATE_VAL.ERROR: + all_y5_good = false - var fs_nodes: Array = get_tree().get_nodes_in_group('fs_group') - for f in fs_nodes: + if not for_result_dic.control_is_over: + set_default_state(for_result_dic.default_reset_array_node) + set_default_state(for_result_dic.power_amplifier) + return + var result_dic: Dictionary = for_result_dic.result_dic + for f in for_result_dic.fs_nodes: var fs_meta: String = f.get_meta('fs') if result_dic.has(fs_meta): - var new_state = result_dic[fs_meta] - f.state = new_state - result_dic[fs_meta] = new_state + f.state = result_dic[fs_meta] - if result_dic.fs_1 == 1: - $kasseta_fs_kd/ref_A2.state = STATE_VAL.GOOD if result_dic.dkm_1 else STATE_VAL.ERROR - else: - result_dic.fs_1 = false - if result_dic.fs_6 == 1: - $kasseta_fs_kd/ref_A4.state = STATE_VAL.GOOD if result_dic.dkm_6 else STATE_VAL.ERROR - $dou6_A7.state = STATE_VAL.GOOD if result_dic.dou_6 else STATE_VAL.ERROR - else: - result_dic.fs_6 = false - if result_dic.fs_7 == 1: - $kasseta_fs_kd/ref_A7.state = STATE_VAL.GOOD if result_dic.dkm_7 else STATE_VAL.ERROR - $dou7_A8.state = STATE_VAL.GOOD if result_dic.dou_7 else STATE_VAL.ERROR - else: - result_dic.fs_7 = false + if not all_y5_good: return + var fs_1 = true if int(result_dic.fs_1) == 1 else false + if fs_1 and block_kasseta_y5_prd_config_k['yau07']: + for_result_dic.module_fs_1.state = STATE_VAL.GOOD if result_dic.dkm_1 else STATE_VAL.ERROR - power_fill(power_dic, result_dic) + var fs_6 = true if int(result_dic.fs_6) == 1 else false + if fs_6 and block_kasseta_y5_prd_config_k['yau07']: + for_result_dic.module_fs_6.state = STATE_VAL.GOOD if result_dic.dkm_6 else STATE_VAL.ERROR + for_result_dic.dou_6.state = STATE_VAL.GOOD if result_dic.dou_6 else STATE_VAL.ERROR - var result = true - for device in result_dic.values(): - if not device: - result = false + var fs_7 = true if int(result_dic.fs_7) == 1 else false + if fs_7 and block_kasseta_y5_prd_config_k['yau07']: + for_result_dic.module_fs_7.state = STATE_VAL.GOOD if result_dic.dkm_7 else STATE_VAL.ERROR + for_result_dic.dou_7.state = STATE_VAL.GOOD if result_dic.dou_7 else STATE_VAL.ERROR - var name_prd = control_prd_k.self_name - if result: - $control_result.text = 'Прибор ПРД-%s исправен' % name_prd - $control_result.add_theme_color_override('font_color', Color.GREEN) - else: - $control_result.text = 'Прибор ПРД-%s неисправен' % name_prd - $control_result.add_theme_color_override('font_color', Color.RED) + if block_kasseta_y5_prd_config_k['yau07']: + power_fill(for_result_dic.power_dic, for_result_dic.result_dic, for_result_dic.power_amplifier, for_result_dic.POWER_THRESHOLD) func find_labels(node1: Node): @@ -263,3 +208,22 @@ func find_labels(node1: Node): node1.set_meta("tooltip_set", true) for child in node1.get_children(): find_labels(child) + + +func _on_status_updated(status_text: String) -> void: + _update_status_text(status_text) + + +func _update_status_text(text: String) -> void: + $control_result.text = text + # Можно добавить смену цвета в зависимости от статуса + if "Ошибка" in text or "неисправен" in text: + $control_result.add_theme_color_override('font_color', Color.RED) + log.message(Logger.INFO, 'Прибор ПРД-%s неисправен' % [unit_prd_k.self_name]) + elif "Ограничена" in text or "Предупреждение" in text: + $control_result.add_theme_color_override('font_color', Color.YELLOW) + elif "исправен" in text or "завершён" in text: + $control_result.add_theme_color_override('font_color', Color.GREEN) + log.message(Logger.INFO, 'Прибор ПРД-%s исправен' % [unit_prd_k.self_name]) + else: + $control_result.add_theme_color_override('font_color', Color.WHITE) diff --git a/scenes/pribor-prd-k/pribor-prd-k.tscn b/scenes/pribor-prd-k/pribor-prd-k.tscn index b56036d2..50670978 100644 --- a/scenes/pribor-prd-k/pribor-prd-k.tscn +++ b/scenes/pribor-prd-k/pribor-prd-k.tscn @@ -1,14 +1,39 @@ -[gd_scene load_steps=10 format=3 uid="uid://m5s87q7m66lj"] +[gd_scene load_steps=16 format=3 uid="uid://m5s87q7m66lj"] [ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="1_8dmgr"] [ext_resource type="Script" uid="uid://cwvikiygf8b1m" path="res://scenes/pribor-prd-k/pribor-prd-k.gd" id="1_tpdyp"] [ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="2_14h25"] [ext_resource type="PackedScene" uid="uid://cm5jd4gjrrpba" path="res://scenes/контроль/кассета-у-5-к.tscn" id="2_tb85r"] [ext_resource type="PackedScene" uid="uid://bcyxqni7gxvtq" path="res://scenes/контроль/блок-в.tscn" id="5_c7lv8"] +[ext_resource type="PackedScene" uid="uid://ffi1njkjceb5" path="res://scenes/контроль/блок-к.tscn" id="6_wd1vi"] [ext_resource type="PackedScene" uid="uid://bmagw8nd0ulhj" path="res://scenes/pribor-prd-k/kasseta-fs-kd.tscn" id="7_ia27q"] [ext_resource type="Script" uid="uid://crpedygm3gohi" path="res://scenes/контроль/кассета.gd" id="7_xpa2n"] [ext_resource type="PackedScene" uid="uid://dq31j24gv5vi4" path="res://scenes/контроль/кассета-п-2.tscn" id="8_6fdp7"] [ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="8_la5yt"] +[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="10_c7lv8"] +[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="11_wd1vi"] +[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="12_bjebg"] +[ext_resource type="Texture2D" uid="uid://dvl3sq036gn75" path="res://data/эмс-бланк-замыкание.png" id="13_kc77u"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_di0aa"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("10_c7lv8") +}, { +"duration": 1.0, +"texture": ExtResource("11_wd1vi") +}, { +"duration": 1.0, +"texture": ExtResource("12_bjebg") +}, { +"duration": 1.0, +"texture": ExtResource("13_kc77u") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] [node name="pribor_prd_k" type="Control"] layout_mode = 3 @@ -21,55 +46,55 @@ script = ExtResource("1_tpdyp") [node name="kasseta_u5" parent="." instance=ExtResource("2_tb85r")] layout_mode = 0 -offset_left = 175.0 -offset_top = 242.0 -offset_right = 485.0 -offset_bottom = 432.0 +offset_left = 214.0 +offset_top = 96.0 +offset_right = 524.0 +offset_bottom = 286.0 -[node name="maa2000_A22" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("1_8dmgr")] +[node name="maa2000_A22" parent="." groups=["power_supply"] instance=ExtResource("1_8dmgr")] layout_mode = 0 -offset_left = 485.0 -offset_top = 907.0 -offset_right = 652.0 -offset_bottom = 949.0 +offset_left = 524.0 +offset_top = 761.0 +offset_right = 691.0 +offset_bottom = 803.0 fname = "MAA2000" rname = "A28" metadata/ip = "maa2000_1" [node name="dou6_A7" parent="." groups=["default_reset"] instance=ExtResource("1_8dmgr")] layout_mode = 0 -offset_left = 8.0 -offset_top = 862.0 -offset_right = 175.0 -offset_bottom = 907.0 +offset_left = 47.0 +offset_top = 716.0 +offset_right = 214.0 +offset_bottom = 761.0 fname = "ДОУ-6" rname = "A7" -[node name="maa2000_A23" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("1_8dmgr")] +[node name="maa2000_A23" parent="." groups=["power_supply"] instance=ExtResource("1_8dmgr")] layout_mode = 0 -offset_left = 8.0 -offset_top = 907.0 -offset_right = 175.0 -offset_bottom = 949.0 +offset_left = 47.0 +offset_top = 761.0 +offset_right = 214.0 +offset_bottom = 803.0 fname = "MAA2000" rname = "A27" metadata/ip = "maa2000_2" [node name="dou7_A8" parent="." groups=["default_reset"] instance=ExtResource("1_8dmgr")] layout_mode = 0 -offset_left = 8.0 -offset_top = 812.0 -offset_right = 175.0 -offset_bottom = 860.0 +offset_left = 47.0 +offset_top = 666.0 +offset_right = 214.0 +offset_bottom = 714.0 fname = "ДОУ-7" rname = "A8" [node name="ref_ZZ3" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 812.0 -offset_right = 485.0 -offset_bottom = 949.0 +offset_left = 214.0 +offset_top = 666.0 +offset_right = 524.0 +offset_bottom = 803.0 texture = ExtResource("2_14h25") patch_margin_left = 16 patch_margin_top = 16 @@ -90,175 +115,175 @@ vertical_alignment = 1 [node name="um1535_A10" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 485.0 -offset_top = 242.0 -offset_right = 652.0 -offset_bottom = 337.0 +offset_left = 524.0 +offset_top = 96.0 +offset_right = 691.0 +offset_bottom = 191.0 value0 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] fname = "УМ1535Б" rname = "A10" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_1" [node name="um1535_A11" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 485.0 -offset_top = 337.0 -offset_right = 652.0 -offset_bottom = 432.0 +offset_left = 524.0 +offset_top = 191.0 +offset_right = 691.0 +offset_bottom = 286.0 fname = "УМ1535Б" rname = "A11" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_2" [node name="um1535_A12" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 485.0 -offset_top = 432.0 -offset_right = 652.0 -offset_bottom = 527.0 +offset_left = 524.0 +offset_top = 286.0 +offset_right = 691.0 +offset_bottom = 381.0 fname = "УМ1535Б" rname = "A12" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_3" [node name="um1535_A13" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 485.0 -offset_top = 527.0 -offset_right = 652.0 -offset_bottom = 622.0 +offset_left = 524.0 +offset_top = 381.0 +offset_right = 691.0 +offset_bottom = 476.0 fname = "УМ1535Б" rname = "A13" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_4" [node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 485.0 -offset_top = 622.0 -offset_right = 652.0 -offset_bottom = 717.0 +offset_left = 524.0 +offset_top = 476.0 +offset_right = 691.0 +offset_bottom = 571.0 fname = "УМ1535Б" rname = "A14" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_5" [node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 485.0 -offset_top = 717.0 -offset_right = 652.0 -offset_bottom = 812.0 +offset_left = 524.0 +offset_top = 571.0 +offset_right = 691.0 +offset_bottom = 666.0 fname = "УМ1535Б" rname = "A15" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_6" -[node name="utm80_A9" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] +[node name="блок-к" parent="." groups=["power_amplifier"] instance=ExtResource("6_wd1vi")] layout_mode = 0 -offset_left = 485.0 -offset_top = 812.0 -offset_right = 652.0 -offset_bottom = 907.0 +offset_left = 524.0 +offset_top = 666.0 +offset_right = 691.0 +offset_bottom = 761.0 fname = "УТМ80" rname = "A9" -value0_info = "Мощность, Вт" -value1_info = "Температура,°C" -metadata/um = "um_7" - -[node name="rm1620m_A16" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] -layout_mode = 0 -offset_left = 8.0 -offset_top = 242.0 -offset_right = 175.0 -offset_bottom = 337.0 -fname = "УМ1535Б" -rname = "A16" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_8" -[node name="rm1620m_A17" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] +[node name="rm1620m_A16" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 8.0 -offset_top = 337.0 -offset_right = 173.0 -offset_bottom = 432.0 -fname = "УМ1535Б" -rname = "A17" -value0_info = "Мощность, Вт" +offset_left = 47.0 +offset_top = 96.0 +offset_right = 214.0 +offset_bottom = 191.0 +fname = "РМ16-20М" +rname = "A16" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_9" -[node name="rm1620m_A18" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] +[node name="rm1620m_A17" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 8.0 -offset_top = 432.0 -offset_right = 175.0 -offset_bottom = 527.0 -fname = "УМ1535Б" -rname = "A18" -value0_info = "Мощность, Вт" +offset_left = 47.0 +offset_top = 191.0 +offset_right = 212.0 +offset_bottom = 286.0 +fname = "РМ16-20М" +rname = "A17" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_10" -[node name="rm1620m_A19" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] +[node name="rm1620m_A18" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 8.0 -offset_top = 527.0 -offset_right = 175.0 -offset_bottom = 622.0 -fname = "УМ1535Б" -rname = "A19" -value0_info = "Мощность, Вт" +offset_left = 47.0 +offset_top = 286.0 +offset_right = 214.0 +offset_bottom = 381.0 +fname = "РМ16-20М" +rname = "A18" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_11" -[node name="rm1620m_A20" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] +[node name="rm1620m_A19" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 8.0 -offset_top = 622.0 -offset_right = 175.0 -offset_bottom = 717.0 -fname = "УМ1535Б" -rname = "A20" -value0_info = "Мощность, Вт" +offset_left = 47.0 +offset_top = 381.0 +offset_right = 214.0 +offset_bottom = 476.0 +fname = "РМ16-20М" +rname = "A19" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_12" -[node name="rm1620m_A21" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] +[node name="rm1620m_A20" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] layout_mode = 0 -offset_left = 8.0 -offset_top = 717.0 -offset_right = 175.0 -offset_bottom = 812.0 -fname = "УМ1535Б" -rname = "A21" -value0_info = "Мощность, Вт" +offset_left = 47.0 +offset_top = 476.0 +offset_right = 214.0 +offset_bottom = 571.0 +fname = "РМ16-20М" +rname = "A20" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_13" +[node name="rm1620m_A21" parent="." groups=["power_amplifier"] instance=ExtResource("5_c7lv8")] +layout_mode = 0 +offset_left = 47.0 +offset_top = 571.0 +offset_right = 214.0 +offset_bottom = 666.0 +fname = "РМ16-20М" +rname = "A21" +value0_info = "Мощность" +value1_info = "Температура,°C" +metadata/um = "um_14" + [node name="kasseta_fs_kd" parent="." instance=ExtResource("7_ia27q")] layout_mode = 0 -offset_left = 175.0 -offset_top = 432.0 -offset_right = 485.0 -offset_bottom = 622.0 +offset_left = 214.0 +offset_top = 286.0 +offset_right = 524.0 +offset_bottom = 476.0 fname = "Кассета ФС-КД" [node name="kasseta_p_1" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 622.0 -offset_right = 340.0 -offset_bottom = 812.0 +offset_left = 214.0 +offset_top = 476.0 +offset_right = 379.0 +offset_bottom = 666.0 texture = ExtResource("2_14h25") patch_margin_left = 16 patch_margin_top = 16 @@ -267,7 +292,7 @@ patch_margin_bottom = 16 script = ExtResource("7_xpa2n") fname = "Кассета П-1" -[node name="ref_A26" parent="kasseta_p_1" groups=["default_reset", "power_supply"] instance=ExtResource("8_la5yt")] +[node name="ref_A26" parent="kasseta_p_1" groups=["power_supply"] instance=ExtResource("8_la5yt")] offset_left = 9.0 offset_top = 33.0 offset_right = 59.0 @@ -276,7 +301,7 @@ fname = "ИП9-50" rname = "A23" metadata/ip = "ip9_50_1" -[node name="ref_A23" parent="kasseta_p_1" groups=["default_reset", "power_supply"] instance=ExtResource("8_la5yt")] +[node name="ref_A23" parent="kasseta_p_1" groups=["power_supply"] instance=ExtResource("8_la5yt")] offset_left = 59.0 offset_top = 33.0 offset_right = 109.0 @@ -285,7 +310,7 @@ fname = "ИП9-50" rname = "A24" metadata/ip = "ip9_50_2" -[node name="ref_A24" parent="kasseta_p_1" groups=["default_reset", "power_supply"] instance=ExtResource("8_la5yt")] +[node name="ref_A24" parent="kasseta_p_1" groups=["power_supply"] instance=ExtResource("8_la5yt")] offset_left = 109.0 offset_top = 33.0 offset_right = 159.0 @@ -297,9 +322,9 @@ metadata/ip = "ip12_50_1" [node name="lbl_fname" type="Label" parent="kasseta_p_1"] self_modulate = Color(1, 1, 1, 0.62) layout_mode = 0 -offset_left = 7.0 +offset_left = 2.0 offset_top = 8.0 -offset_right = 159.0 +offset_right = 162.0 offset_bottom = 33.0 text = "Кассета П-1" horizontal_alignment = 1 @@ -307,18 +332,50 @@ vertical_alignment = 1 [node name="kasseta_p_2" parent="." instance=ExtResource("8_6fdp7")] layout_mode = 0 -offset_left = 365.0 -offset_top = 622.0 -offset_right = 485.0 -offset_bottom = 812.0 +offset_left = 404.0 +offset_top = 476.0 +offset_right = 524.0 +offset_bottom = 666.0 fname = "Кассета П-2" +[node name="input_0" type="AnimatedSprite2D" parent="."] +position = Vector2(392, 472) +sprite_frames = SubResource("SpriteFrames_di0aa") + +[node name="input_1" type="AnimatedSprite2D" parent="."] +position = Vector2(444, 472) +sprite_frames = SubResource("SpriteFrames_di0aa") + +[node name="input_2" type="AnimatedSprite2D" parent="."] +position = Vector2(294, 473) +sprite_frames = SubResource("SpriteFrames_di0aa") + +[node name="output_0" type="AnimatedSprite2D" parent="."] +position = Vector2(394, 318) +sprite_frames = SubResource("SpriteFrames_di0aa") + +[node name="output_1" type="AnimatedSprite2D" parent="."] +position = Vector2(444, 318) +sprite_frames = SubResource("SpriteFrames_di0aa") + +[node name="output_2" type="AnimatedSprite2D" parent="."] +position = Vector2(294, 318) +sprite_frames = SubResource("SpriteFrames_di0aa") + [node name="control_result" type="Label" parent="."] layout_mode = 0 -offset_left = 9.0 -offset_top = 960.0 -offset_right = 649.0 -offset_bottom = 1003.0 -text = "Прибор ПРД- неисправен" +offset_left = 49.0 +offset_top = 993.0 +offset_right = 689.0 +offset_bottom = 1036.0 +theme_override_font_sizes/font_size = 22 horizontal_alignment = 1 metadata/_edit_lock_ = true + +[node name="line" type="Line2D" parent="."] +position = Vector2(59, 920) +scale = Vector2(1.03548, 1) +points = PackedVector2Array(-8, 0, 61.8069, 0, 608, 0) +width = 2.0 +default_color = Color(1, 1, 1, 0.352941) +metadata/_edit_lock_ = true diff --git a/scenes/pribor-prd-n/pribor-prd-n.gd b/scenes/pribor-prd-n/pribor-prd-n.gd index c69b5530..8b16452a 100644 --- a/scenes/pribor-prd-n/pribor-prd-n.gd +++ b/scenes/pribor-prd-n/pribor-prd-n.gd @@ -1,235 +1,183 @@ @tool extends 'res://scenes/контроль/прибор.gd' -const constants_n = { - 'POWER_UKP_1': 31, - 'POWER_UKP_2': 63, - 'DKM_BIT_2': 1, - 'DKM_BIT_3': 2, - 'BASE_ADDR_EMS_G': 0x120, - 'ADDR_UG_LITERA_1': 0x106, - 'ADDR_UG_LITERA_2': 0x108, - 'ADDR_UG_LITERA_3': 0x10A, - 'TEMP_THRESHOLD': 70, - 'POWER_THRESHOLD': 40, - 'RAY_DOU_NUM': 0x3, - 'ATT_UM_2': 0x2, - 'ATT_UM_3': 0x3, - 'POWER_UM': 100, - 'TIMER_DELAY': 10.0, - 'STATE_MASHINE_TIMER': 0.3, -} -# Конфигурация параметров для каждого прибора -const PRIBOR_CONFIG_N := { - '1н': {'angle': 0.0, 'sectors': [4, 8]}, - '2н': {'angle': 90.0, 'sectors': [7, 11]}, - '3н': {'angle': 180.0, 'sectors': [6, 10]}, - '4н': {'angle': 270.0, 'sectors': [5, 9]}, -} -# Конфигурация частот и ширин для каждого ФС -const FS_PARAMS_N := { - 2: {'freq': 932.0, 'width': 100.0}, - 3: {'freq': 1157.0, 'width': 100.0} -} enum STATE_VAL { NONE = 0, GOOD = 1, ERROR = 2 } -var block_ip_config_n:= { - 'maa2000_1': [0, false], - 'maa2000_2': [1, false], - 'ip9_50_1': [2, false], - 'ip9_50_2': [3, false], - 'ip12_50_1': [4, false], - 'ip5_25': [7, false], -} -var block_kasseta_y5_prd_config_n: = { - 'yau07': false, - 'ems': false, - 'ug': false, - 'ukp1': false, - 'ukp2': false, -} # Основные переменные -var start_litera: int = 2 -var ug_work_1: int = 2 ## Аттенюация усилителей мощности -var ug_work_2: int = 3 ## Аттенюация усилителей мощности -# Флаги и таймеры -var mashine_timer: Timer = Timer.new() -var prd_n_module: Object var unit_prd_n: Object -var control_prd_n: Object -# Результаты контроля -var control_results_n: Dictionary = { - 'block_ip': false, # Проверка касет П1 и ИП МА2000 - 'temperature': true, # Проверка температур УМ - 'dkm_2': false, - 'dkm_3': false, - 'dou_2': false, - 'dou_3': false, - 'fs_2': 2, - 'fs_3': 2, -} -var test_control_n = preload('res://scripts/pribor-prd.gd') var ctrl_pos = 0 -################################ -func on_state_mashine() -> void: - control_prd_n.state_control_machine() func _ready() -> void: if Engine.is_editor_hint(): return - - initialize_connections() - setup_timer() - set_default_state() - find_labels(self) - - -func initialize_connections() -> void: var unit_name = get_meta('unit_name')[0] - prd_n_module = prd.prd_dict[unit_name] - unit_prd_n = prd_n_module.unit_yau07 - - unit_prd_n.connect('line_changed', Callable(self, 'on_line_changed')) - var power_amplifiers: Array = get_tree().get_nodes_in_group('power_amplifier') - var init_data: Dictionary = { - 'control_label': $control_result, - 'power_amplifiers': power_amplifiers, - 'unit_prd': unit_prd_n, - 'module_prd' : prd_n_module, - 'constants': constants_n, - 'prd_config': PRIBOR_CONFIG_N, - 'fs_params': FS_PARAMS_N, - 'block_ip_prd_config': block_ip_config_n, - 'block_kasseta_y5_prd_config': block_kasseta_y5_prd_config_n, - 'control_results': control_results_n, - 'current_litera': start_litera, - } - control_prd_n = test_control_n.TestPRD.new(init_data) - add_child(control_prd_n) - control_prd_n.connect('control_is_over', Callable(self, 'on_control_result')) + var prd_n_module = prd.prd_dict[unit_name] + unit_prd_n = prd_n_module.unit_control + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + for temp in power_amplifier: + temp.value1 = -70 + # Подписываемся на сигналы + signaller.conn(signaller.start_contol_device, Callable(self, '_on_start_control')) + unit_prd_n.connect('control_is_over', Callable(self, 'on_press_device')) + unit_prd_n.connect('status_updated', Callable(self, '_on_status_updated')) + # Устанавливаем начальный статус + _update_status_text(unit_prd_n.get_current_status()) + on_press_device(unit_prd_n.self_name) -func setup_timer() -> void: - add_child(mashine_timer) - mashine_timer.connect('timeout', Callable(self, 'on_state_mashine')) - mashine_timer.wait_time = constants_n.STATE_MASHINE_TIMER - mashine_timer.start() +func _process(_delta: float) -> void: + if Engine.is_editor_hint(): + return + set_frame($input_0, unit_prd_n.ems_g_sock_dic.ems_input_1) + set_frame($input_1, unit_prd_n.ems_g_sock_dic.ems_input_2) + set_frame($output_0, unit_prd_n.ems_g_sock_dic.ems_output_1) + set_frame($output_1, unit_prd_n.ems_g_sock_dic.ems_output_2) -func set_default_state() -> void: - for group in get_tree().get_nodes_in_group('default_reset'): - group.state = STATE_VAL.NONE +func set_frame(node_frame: Node, val: int): node_frame.set_frame(val) - for group in get_tree().get_nodes_in_group('power_amplifier'): + +func _on_start_control() -> void: + set_default_state(get_tree().get_nodes_in_group('default_reset')) + set_default_state(get_tree().get_nodes_in_group('power_amplifier')) + for um in get_tree().get_nodes_in_group('power_amplifier'): + um.value0 = [0, 0, 0, 0, 0, 0] + find_labels(self) + await get_tree().create_timer(1.0).timeout + on_press_device(unit_prd_n.self_name) + + +static func set_default_state(default_reset_array_node: Array) -> void: + for group in default_reset_array_node: group.state = STATE_VAL.NONE func _enter_tree() -> void: if Engine.is_editor_hint(): return - $control_result.text = 'Выполняется ...' - $control_result.add_theme_color_override('font_color', Color.ALICE_BLUE) - signaller.connect('режим_работа', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_журнал', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_эмс', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_настройки', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_контроль', Callable(self, 'on_mode_changed').bind(true)) + if unit_prd_n: + _update_status_text(unit_prd_n.get_current_status()) func _exit_tree() -> void: if Engine.is_editor_hint(): return - prd_n_module.cmd_array.append([unit_prd_n.CmdCode.WRITE_ISA, [constants_n.ADDR_UG_LITERA_1, ug_work_1, constants_n.ADDR_UG_LITERA_2, ug_work_2]]) + #prd_n_module.cmd_array.append([unit_prd_n.CmdCode.WRITE_ISA, [constants_n.ADDR_UG_LITERA_1, ug_work_1, constants_n.ADDR_UG_LITERA_2, ug_work_2]]) -func on_line_changed(unit_pribor: Object) -> void: - if not unit_pribor.online: - set_default_state() +static func temperature_fill(temperature_arr_node: Array, temperature_dic: Dictionary)->void: + for i_node_temperature in temperature_arr_node: + var temperature_meta: String = i_node_temperature.get_meta('um') + if not temperature_dic.has(temperature_meta): return + i_node_temperature.value1 = temperature_dic[temperature_meta] if temperature_dic[temperature_meta] < 361 else -40 -func on_mode_changed(in_tree: bool) -> void: - if not in_tree: - mashine_timer.stop() - signaller.emit_signal('interfer_off_all') - prd_n_module.cmd_array.append([unit_prd_n.CmdCode.WRITE_ISA, [constants_n.ADDR_UG_LITERA_1, ug_work_1, constants_n.ADDR_UG_LITERA_2, ug_work_2]]) - else: - set_default_state() - control_prd_n.state = control_prd_n.STATE_MASHINE.INIT - mashine_timer.start() - - -func power_fill(pow_dic: Dictionary, fs_result: Dictionary) -> void: - #if not control_prd_n.block_kasseta_y5_config.yau07 or not control_prd_n.block_kasseta_y5_config.ukp1 or not control_prd_n.block_kasseta_y5_config.ukp2: - #return - var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') - for i_powapm in power_amplifier: - var powamp_meta: String = i_powapm.get_meta('um') +static func power_fill(pow_dic: Dictionary, fs_result: Dictionary, power_amplifier_arr_node: Array, POWER_THRESHOLD: int) -> void: + for i_node_powapm in power_amplifier_arr_node: + var powamp_meta: String = i_node_powapm.get_meta('um') var status = STATE_VAL.GOOD if pow_dic else STATE_VAL.NONE - if pow_dic[powamp_meta].size() < 6: - status = STATE_VAL.ERROR - else: - if powamp_meta in ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'] and not fs_result.fs_2: return - if powamp_meta in ['um_7', 'um_8', 'um_9', 'um_10', 'um_11', 'um_12'] and not fs_result.fs_3: return - i_powapm.value0 = pow_dic[powamp_meta] - for i_p in pow_dic[powamp_meta]: - if i_p < constants_n.POWER_THRESHOLD: - status = STATE_VAL.ERROR - i_powapm.state = status + if not pow_dic.has(powamp_meta): return + if powamp_meta in ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'] and not fs_result.fs_2: return + if powamp_meta in ['um_9', 'um_10', 'um_11', 'um_12', 'um_13', 'um_14'] and not fs_result.fs_3: return + i_node_powapm.value0 = pow_dic[powamp_meta] + # Проверка: если ВСЕ значения в массиве < 1 → STATE_VAL.NONE + var power_array: Array = pow_dic[powamp_meta] + var all_below_one: bool = true + for i_p in power_array: + if i_p >= 1: + all_below_one = false + break + + if all_below_one: + i_node_powapm.state = STATE_VAL.NONE + continue + + var count_above_threshold = 0 + for i_p in pow_dic[powamp_meta]: + if i_p >= POWER_THRESHOLD: + count_above_threshold += 1 + + status = STATE_VAL.GOOD if count_above_threshold >= 3 else STATE_VAL.ERROR + i_node_powapm.state = status -func on_control_result(result_dic: Dictionary, power_dic: Dictionary) -> void: - mashine_timer.stop() - block_kasseta_y5_prd_config_n = control_prd_n.block_kasseta_y5_config +func on_press_device(_device_name: String) -> void: var nodes_y5: Array = get_tree().get_nodes_in_group('y-5') + var node_ip_power_arr: Array = get_tree().get_nodes_in_group('power_supply') + var fs_nodes: Array = get_tree().get_nodes_in_group('fs_group') + var power_amplifier_arr_node: Array = get_tree().get_nodes_in_group('power_amplifier') + var default_reset_array_node = get_tree().get_nodes_in_group('default_reset') + var module_fs_2: Node = $kasseta_FS_ND/ref_A4 + var dou_2: Node = $dou2_A5 + var module_fs_3: Node = $kasseta_FS_ND/ref_A3 + var dou_3: Node = $dou3_A6 + var control_data: Dictionary = unit_prd_n.get_control_results() + var for_control_result: Dictionary = { + 'nodes_y5': nodes_y5, + 'node_ip_power_arr': node_ip_power_arr, + 'fs_nodes': fs_nodes, + 'power_amplifier': power_amplifier_arr_node, + 'default_reset_array_node': default_reset_array_node, + 'module_fs_2': module_fs_2, + 'dou_2': dou_2, + 'module_fs_3': module_fs_3, + 'dou_3': dou_3, + } + for_control_result.merge(control_data, true) + on_control_result(for_control_result) + + +static func on_control_result(for_result_dic: Dictionary) -> void: + temperature_fill(for_result_dic.power_amplifier, for_result_dic.temperature_um) + var all_y5_good: bool = true + var block_kasseta_y5_prd_config_n: Dictionary = for_result_dic.block_kasseta_y5_config + var nodes_y5: Array = for_result_dic.nodes_y5 for node_y5 in nodes_y5: var meta_y5 = node_y5.get_meta('y5') if block_kasseta_y5_prd_config_n.has(meta_y5): - if block_kasseta_y5_prd_config_n['yau07'] == false: + if not block_kasseta_y5_prd_config_n.yau07: node_y5.state = STATE_VAL.ERROR if meta_y5 == 'yau07' else STATE_VAL.NONE - break - node_y5.state = STATE_VAL.GOOD if block_kasseta_y5_prd_config_n[meta_y5] else STATE_VAL.ERROR + else: + node_y5.state = STATE_VAL.GOOD if block_kasseta_y5_prd_config_n[meta_y5] else STATE_VAL.ERROR + # Проверяем состояние после установки + if node_y5.state == STATE_VAL.ERROR: + all_y5_good = false - block_ip_config_n = control_prd_n.block_ip_config - var node_ip_power_arr: Array = get_tree().get_nodes_in_group('power_supply') - for power_supply in node_ip_power_arr: + var block_ip_config_n: Dictionary = for_result_dic.block_ip_config + for power_supply in for_result_dic.node_ip_power_arr: var meta_ip = power_supply.get_meta('ip') - if block_ip_config_n.has(meta_ip) and block_kasseta_y5_prd_config_n.ug: + if block_ip_config_n.has(meta_ip) and block_kasseta_y5_prd_config_n.ug and block_kasseta_y5_prd_config_n.yau07: power_supply.state = STATE_VAL.GOOD if block_ip_config_n[meta_ip][1] else STATE_VAL.ERROR + else: + power_supply.state = STATE_VAL.NONE + # Проверяем состояние после установки + if power_supply.state == STATE_VAL.ERROR: + all_y5_good = false - var fs_nodes: Array = get_tree().get_nodes_in_group('fs_group') - for f in fs_nodes: + if not for_result_dic.control_is_over: + set_default_state(for_result_dic.default_reset_array_node) + set_default_state(for_result_dic.power_amplifier) + return + var result_dic: Dictionary = for_result_dic.result_dic + for f in for_result_dic.fs_nodes: var fs_meta: String = f.get_meta('fs') if result_dic.has(fs_meta): - var new_state = result_dic[fs_meta] - f.state = new_state - result_dic[fs_meta] = new_state + f.state = result_dic[fs_meta] - if result_dic.fs_2 == 1: - $kasseta_FS_ND/ref_A4.state = STATE_VAL.GOOD if result_dic.dkm_2 else STATE_VAL.ERROR - $dou2_A5.state = STATE_VAL.GOOD if result_dic.dou_2 else STATE_VAL.ERROR - else: - result_dic.fs_2 = 0 - if result_dic.fs_3 == 1: - $kasseta_FS_ND/ref_A3.state = STATE_VAL.GOOD if result_dic.dkm_3 else STATE_VAL.ERROR - $dou3_A6.state = STATE_VAL.GOOD if result_dic.dou_3 else STATE_VAL.ERROR - else: - result_dic.fs_3 = 0 + if not all_y5_good: return + var fs_2 = true if int(result_dic.fs_2) == 1 else false + if fs_2 and block_kasseta_y5_prd_config_n['yau07']: + for_result_dic.module_fs_2.state = STATE_VAL.GOOD if result_dic.dkm_2 else STATE_VAL.ERROR + for_result_dic.dou_2.state = STATE_VAL.GOOD if result_dic.dou_2 else STATE_VAL.ERROR - power_fill(power_dic, result_dic) + var fs_3 = true if int(result_dic.fs_3) == 1 else false + if fs_3 and block_kasseta_y5_prd_config_n['yau07']: + for_result_dic.module_fs_3.state = STATE_VAL.GOOD if result_dic.dkm_3 else STATE_VAL.ERROR + for_result_dic.dou_3.state = STATE_VAL.GOOD if result_dic.dou_3 else STATE_VAL.ERROR - var result = true - for device in result_dic.values(): - if not device: - result = false - - var name_prd = control_prd_n.self_name - if result: - $control_result.text = 'Прибор ПРД-%s исправен' % name_prd - $control_result.add_theme_color_override('font_color', Color.GREEN) - else: - $control_result.text = 'Прибор ПРД-%s неисправен' % name_prd - $control_result.add_theme_color_override('font_color', Color.RED) + if block_kasseta_y5_prd_config_n['yau07']: + power_fill(for_result_dic.power_dic, for_result_dic.result_dic, for_result_dic.power_amplifier, for_result_dic.POWER_THRESHOLD) func find_labels(node1: Node): @@ -246,3 +194,22 @@ func find_labels(node1: Node): node1.set_meta("tooltip_set", true) for child in node1.get_children(): find_labels(child) + + +func _on_status_updated(status_text: String) -> void: + _update_status_text(status_text) + + +func _update_status_text(text: String) -> void: + $control_result.text = text + # Можно добавить смену цвета в зависимости от статуса + if "Ошибка" in text or "неисправен" in text: + $control_result.add_theme_color_override('font_color', Color.RED) + log.message(Logger.INFO, 'Прибор ПРД-%s неисправен' % [unit_prd_n.self_name]) + elif "Ограничена" in text or "Предупреждение" in text: + $control_result.add_theme_color_override('font_color', Color.YELLOW) + elif "исправен" in text or "завершён" in text: + $control_result.add_theme_color_override('font_color', Color.GREEN) + log.message(Logger.INFO, 'Прибор ПРД-%s исправен' % [unit_prd_n.self_name]) + else: + $control_result.add_theme_color_override('font_color', Color.WHITE) diff --git a/scenes/pribor-prd-n/pribor-prd-n.tscn b/scenes/pribor-prd-n/pribor-prd-n.tscn index a52ce38d..3e041ebf 100644 --- a/scenes/pribor-prd-n/pribor-prd-n.tscn +++ b/scenes/pribor-prd-n/pribor-prd-n.tscn @@ -1,12 +1,35 @@ -[gd_scene load_steps=8 format=3 uid="uid://dnuexoef2nnv5"] +[gd_scene load_steps=12 format=3 uid="uid://dnuexoef2nnv5"] [ext_resource type="Script" uid="uid://cto2r4ipew65m" path="res://scenes/pribor-prd-n/pribor-prd-n.gd" id="1_bnnv3"] [ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="2_is25t"] [ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="3_meukj"] -[ext_resource type="PackedScene" uid="uid://bk1655p4e8y4u" path="res://scenes/контроль/кассета-у-5-нв.tscn" id="4_xkifg"] [ext_resource type="Script" uid="uid://crpedygm3gohi" path="res://scenes/контроль/кассета.gd" id="6_b5wvk"] [ext_resource type="PackedScene" uid="uid://bcyxqni7gxvtq" path="res://scenes/контроль/блок-в.tscn" id="7_bnnv3"] [ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="7_eoqf2"] +[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="8_bnnv3"] +[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="9_is25t"] +[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="10_meukj"] +[ext_resource type="Texture2D" uid="uid://dvl3sq036gn75" path="res://data/эмс-бланк-замыкание.png" id="11_xkifg"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_1wf07"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("8_bnnv3") +}, { +"duration": 1.0, +"texture": ExtResource("9_is25t") +}, { +"duration": 1.0, +"texture": ExtResource("10_meukj") +}, { +"duration": 1.0, +"texture": ExtResource("11_xkifg") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] [node name="pribor_prd_n" type="Control"] layout_mode = 3 @@ -17,50 +40,50 @@ offset_right = 15.0 offset_bottom = 30.0 script = ExtResource("1_bnnv3") -[node name="maa2000_A23" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("2_is25t")] +[node name="maa2000_A23" parent="." groups=["power_supply"] instance=ExtResource("2_is25t")] layout_mode = 2 -offset_left = 8.0 -offset_top = 877.0 -offset_right = 175.0 -offset_bottom = 949.0 +offset_left = 47.0 +offset_top = 731.0 +offset_right = 214.0 +offset_bottom = 803.0 fname = "MAA2000" rname = "A23" metadata/ip = "maa2000_2" -[node name="maa2000_A22" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("2_is25t")] +[node name="maa2000_A22" parent="." groups=["power_supply"] instance=ExtResource("2_is25t")] layout_mode = 2 -offset_left = 485.0 -offset_top = 877.0 -offset_right = 652.0 -offset_bottom = 949.0 +offset_left = 524.0 +offset_top = 731.0 +offset_right = 691.0 +offset_bottom = 803.0 fname = "MAA2000" rname = "A22" metadata/ip = "maa2000_1" [node name="dou2_A5" parent="." groups=["default_reset"] instance=ExtResource("2_is25t")] layout_mode = 2 -offset_left = 485.0 -offset_top = 812.0 -offset_right = 652.0 -offset_bottom = 877.0 +offset_left = 524.0 +offset_top = 666.0 +offset_right = 691.0 +offset_bottom = 731.0 fname = "ДОУ-2" rname = "A5" [node name="dou3_A6" parent="." groups=["default_reset"] instance=ExtResource("2_is25t")] layout_mode = 2 -offset_left = 8.0 -offset_top = 812.0 -offset_right = 175.0 -offset_bottom = 877.0 +offset_left = 47.0 +offset_top = 666.0 +offset_right = 214.0 +offset_bottom = 731.0 fname = "ДОУ-3" rname = "A6" [node name="ref_ZZ3" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 812.0 -offset_right = 485.0 -offset_bottom = 949.0 +offset_left = 214.0 +offset_top = 666.0 +offset_right = 524.0 +offset_bottom = 803.0 texture = ExtResource("3_meukj") patch_margin_left = 16 patch_margin_top = 16 @@ -79,19 +102,90 @@ text = "Панель horizontal_alignment = 1 vertical_alignment = 1 -[node name="kasseta_U5" parent="." instance=ExtResource("4_xkifg")] +[node name="kasseta_U5" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 242.0 -offset_right = 485.0 -offset_bottom = 432.0 +offset_left = 214.0 +offset_top = 96.0 +offset_right = 524.0 +offset_bottom = 286.0 +texture = ExtResource("3_meukj") +patch_margin_left = 16 +patch_margin_top = 16 +patch_margin_right = 16 +patch_margin_bottom = 16 +script = ExtResource("6_b5wvk") + +[node name="lbl_fname" type="Label" parent="kasseta_U5"] +self_modulate = Color(1, 1, 1, 0.62) +layout_mode = 0 +offset_left = 5.0 +offset_top = 7.0 +offset_right = 305.0 +offset_bottom = 35.0 +text = "Кассета У5" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="ref_A24" parent="kasseta_U5" groups=["power_supply"] instance=ExtResource("7_eoqf2")] +offset_left = 5.0 +offset_top = 32.0 +offset_right = 55.0 +offset_bottom = 182.0 +fname = "ИП5-25" +rname = "A24" +metadata/ip = "ip5_25" + +[node name="ref_A30" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_eoqf2")] +offset_left = 55.0 +offset_top = 32.0 +offset_right = 105.0 +offset_bottom = 182.0 +fname = "ЯУ-07Б" +rname = "A30" +metadata/y5 = "yau07" + +[node name="ref_A26" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_eoqf2")] +offset_left = 105.0 +offset_top = 32.0 +offset_right = 155.0 +offset_bottom = 182.0 +fname = "ЭМС-Г" +rname = "A26" +metadata/y5 = "ems" + +[node name="ref_A27" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_eoqf2")] +offset_left = 155.0 +offset_top = 32.0 +offset_right = 205.0 +offset_bottom = 182.0 +fname = "УГ" +rname = "A27" +metadata/y5 = "ug" + +[node name="ref_A28" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_eoqf2")] +offset_left = 205.0 +offset_top = 32.0 +offset_right = 255.0 +offset_bottom = 182.0 +fname = "УКП" +rname = "A28" +metadata/y5 = "ukp1" + +[node name="ref_A29" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_eoqf2")] +offset_left = 254.0 +offset_top = 32.0 +offset_right = 304.0 +offset_bottom = 182.0 +fname = "УКП" +rname = "A29" +metadata/y5 = "ukp2" [node name="kasseta_FS_ND" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 432.0 -offset_right = 485.0 -offset_bottom = 622.0 +offset_left = 214.0 +offset_top = 286.0 +offset_right = 524.0 +offset_bottom = 476.0 texture = ExtResource("3_meukj") patch_margin_left = 16 patch_margin_top = 16 @@ -118,7 +212,7 @@ offset_top = 32.0 offset_right = 105.0 offset_bottom = 182.0 fname = "Блок ФС-3" -rname = "A3" +rname = "A4" [node name="ref_A1" parent="kasseta_FS_ND" groups=["default_reset", "fs_group"] instance=ExtResource("7_eoqf2")] offset_left = 105.0 @@ -126,7 +220,7 @@ offset_top = 32.0 offset_right = 155.0 offset_bottom = 182.0 fname = "Модуль ФС" -rname = "A1" +rname = "A2" metadata/fs = "fs_3" [node name="ref_A2" parent="kasseta_FS_ND" groups=["default_reset", "fs_group"] instance=ExtResource("7_eoqf2")] @@ -135,7 +229,7 @@ offset_top = 32.0 offset_right = 205.0 offset_bottom = 182.0 fname = "Модуль ФС" -rname = "A2" +rname = "A1" metadata/fs = "fs_2" [node name="ref_A4" parent="kasseta_FS_ND" groups=["default_reset"] instance=ExtResource("7_eoqf2")] @@ -144,14 +238,14 @@ offset_top = 32.0 offset_right = 255.0 offset_bottom = 182.0 fname = "Блок ФС-2" -rname = "A4" +rname = "A3" [node name="kasseta_P_1" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 622.0 -offset_right = 485.0 -offset_bottom = 812.0 +offset_left = 214.0 +offset_top = 476.0 +offset_right = 524.0 +offset_bottom = 666.0 texture = ExtResource("3_meukj") patch_margin_left = 16 patch_margin_top = 16 @@ -160,7 +254,7 @@ patch_margin_bottom = 16 script = ExtResource("6_b5wvk") fname = "Кассета П-1" -[node name="ref_A21" parent="kasseta_P_1" groups=["default_reset", "power_supply"] instance=ExtResource("7_eoqf2")] +[node name="ref_A21" parent="kasseta_P_1" groups=["power_supply"] instance=ExtResource("7_eoqf2")] offset_left = 9.0 offset_top = 33.0 offset_right = 59.0 @@ -169,7 +263,7 @@ fname = "ИП12-50" rname = "A21" metadata/ip = "ip12_50_1" -[node name="ref_A20" parent="kasseta_P_1" groups=["default_reset", "power_supply"] instance=ExtResource("7_eoqf2")] +[node name="ref_A20" parent="kasseta_P_1" groups=["power_supply"] instance=ExtResource("7_eoqf2")] offset_left = 59.0 offset_top = 33.0 offset_right = 109.0 @@ -178,7 +272,7 @@ fname = "ИП9-50" rname = "A20" metadata/ip = "ip9_50_1" -[node name="ref_A19" parent="kasseta_P_1" groups=["default_reset", "power_supply"] instance=ExtResource("7_eoqf2")] +[node name="ref_A19" parent="kasseta_P_1" groups=["power_supply"] instance=ExtResource("7_eoqf2")] offset_left = 109.0 offset_top = 33.0 offset_right = 159.0 @@ -200,153 +294,178 @@ vertical_alignment = 1 [node name="um1535_A7" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 485.0 -offset_top = 242.0 -offset_right = 652.0 -offset_bottom = 337.0 -fname = "УМ1535Б" +offset_left = 524.0 +offset_top = 96.0 +offset_right = 691.0 +offset_bottom = 191.0 +fname = "УМ1535А" rname = "A7" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_1" [node name="um1535_A8" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 485.0 -offset_top = 337.0 -offset_right = 652.0 -offset_bottom = 432.0 +offset_left = 524.0 +offset_top = 191.0 +offset_right = 691.0 +offset_bottom = 286.0 fname = "УМ1535А" rname = "A8" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_2" [node name="um1535_A9" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 485.0 -offset_top = 432.0 -offset_right = 652.0 -offset_bottom = 527.0 +offset_left = 524.0 +offset_top = 286.0 +offset_right = 691.0 +offset_bottom = 381.0 fname = "УМ1535А" rname = "A9" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_3" [node name="um1535_A10" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 485.0 -offset_top = 527.0 -offset_right = 652.0 -offset_bottom = 622.0 +offset_left = 524.0 +offset_top = 381.0 +offset_right = 691.0 +offset_bottom = 476.0 fname = "УМ1535А" rname = "A10" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_4" [node name="um1535_A11" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 485.0 -offset_top = 622.0 -offset_right = 652.0 -offset_bottom = 717.0 +offset_left = 524.0 +offset_top = 476.0 +offset_right = 691.0 +offset_bottom = 571.0 fname = "УМ1535А" rname = "A11" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_5" [node name="um1535_A12" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 485.0 -offset_top = 717.0 -offset_right = 652.0 -offset_bottom = 812.0 +offset_left = 524.0 +offset_top = 571.0 +offset_right = 691.0 +offset_bottom = 666.0 fname = "УМ1535А" rname = "A12" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_6" [node name="um1535_A13" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 8.0 -offset_top = 242.0 -offset_right = 175.0 -offset_bottom = 337.0 +offset_left = 47.0 +offset_top = 96.0 +offset_right = 214.0 +offset_bottom = 191.0 fname = "УМ1535А" rname = "A13" -value0_info = "Мощность, Вт" -value1_info = "Температура,°C" -metadata/um = "um_7" - -[node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] -layout_mode = 0 -offset_left = 8.0 -offset_top = 337.0 -offset_right = 175.0 -offset_bottom = 432.0 -fname = "УМ1535А" -rname = "A14" -value0_info = "Мощность, Вт" -value1_info = "Температура,°C" -metadata/um = "um_8" - -[node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] -layout_mode = 0 -offset_left = 8.0 -offset_top = 432.0 -offset_right = 175.0 -offset_bottom = 527.0 -fname = "УМ1535А" -rname = "A15" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_9" -[node name="um1535_A16" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] +[node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 8.0 -offset_top = 527.0 -offset_right = 175.0 -offset_bottom = 622.0 +offset_left = 47.0 +offset_top = 191.0 +offset_right = 214.0 +offset_bottom = 286.0 fname = "УМ1535А" -rname = "A16" -value0_info = "Мощность, Вт" +rname = "A14" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_10" -[node name="um1535_A17" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] +[node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 8.0 -offset_top = 622.0 -offset_right = 175.0 -offset_bottom = 717.0 +offset_left = 47.0 +offset_top = 286.0 +offset_right = 214.0 +offset_bottom = 381.0 fname = "УМ1535А" -rname = "A17" -value0_info = "Мощность, Вт" +rname = "A15" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_11" -[node name="um1535_A18" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] +[node name="um1535_A16" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] layout_mode = 0 -offset_left = 8.0 -offset_top = 717.0 -offset_right = 175.0 -offset_bottom = 812.0 +offset_left = 47.0 +offset_top = 381.0 +offset_right = 214.0 +offset_bottom = 476.0 fname = "УМ1535А" -rname = "A18" -value0_info = "Мощность, Вт" +rname = "A16" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_12" +[node name="um1535_A17" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] +layout_mode = 0 +offset_left = 47.0 +offset_top = 476.0 +offset_right = 214.0 +offset_bottom = 571.0 +fname = "УМ1535А" +rname = "A17" +value0_info = "Мощность" +value1_info = "Температура,°C" +metadata/um = "um_13" + +[node name="um1535_A18" parent="." groups=["power_amplifier"] instance=ExtResource("7_bnnv3")] +layout_mode = 0 +offset_left = 47.0 +offset_top = 571.0 +offset_right = 214.0 +offset_bottom = 666.0 +fname = "УМ1535А" +rname = "A18" +value0_info = "Мощность" +value1_info = "Температура,°C" +metadata/um = "um_14" + [node name="control_result" type="Label" parent="."] layout_mode = 0 -offset_left = 9.0 -offset_top = 960.0 -offset_right = 649.0 -offset_bottom = 1003.0 +offset_left = 49.0 +offset_top = 993.0 +offset_right = 689.0 +offset_bottom = 1036.0 +theme_override_font_sizes/font_size = 22 horizontal_alignment = 1 metadata/_edit_lock_ = true + +[node name="input_0" type="AnimatedSprite2D" parent="."] +position = Vector2(495, 443) +sprite_frames = SubResource("SpriteFrames_1wf07") + +[node name="input_1" type="AnimatedSprite2D" parent="."] +position = Vector2(246, 440) +sprite_frames = SubResource("SpriteFrames_1wf07") + +[node name="output_0" type="AnimatedSprite2D" parent="."] +position = Vector2(497, 330) +sprite_frames = SubResource("SpriteFrames_1wf07") + +[node name="output_1" type="AnimatedSprite2D" parent="."] +position = Vector2(249, 331) +sprite_frames = SubResource("SpriteFrames_1wf07") + +[node name="line" type="Line2D" parent="."] +position = Vector2(59, 920) +scale = Vector2(1.03548, 1) +points = PackedVector2Array(-8, 0, 61.8069, 0, 608, 0) +width = 2.0 +default_color = Color(1, 1, 1, 0.352941) +metadata/_edit_lock_ = true diff --git a/scenes/pribor-prd-v/pribor-prd-v.gd b/scenes/pribor-prd-v/pribor-prd-v.gd index a40768ad..2229c2a2 100644 --- a/scenes/pribor-prd-v/pribor-prd-v.gd +++ b/scenes/pribor-prd-v/pribor-prd-v.gd @@ -1,234 +1,179 @@ @tool extends 'res://scenes/контроль/прибор.gd' -const constants_v = { - 'POWER_UKP_1': 31, - 'POWER_UKP_2': 63, - 'DKM_BIT_4': 3, - 'DKM_BIT_5': 4, - 'BASE_ADDR_EMS_G': 0x120, - 'ADDR_UG_LITERA_1': 0x106, - 'ADDR_UG_LITERA_2': 0x108, - 'ADDR_UG_LITERA_3': 0x10A, - 'TEMP_THRESHOLD': 70, - 'POWER_THRESHOLD': 40, - 'RAY_DOU_NUM': 0x3, - 'ATT_UM_4': 0x2, - 'ATT_UM_5': 0x3, - 'POWER_UM': 100, - 'TIMER_DELAY': 10.0, - 'STATE_MASHINE_TIMER': 0.3, -} -# Конфигурация параметров для каждого прибора -const PRIBOR_CONFIG_V := { - '1в': {'angle': 0.0, 'sectors': [12, 16]}, - '2в': {'angle': 90.0, 'sectors': [15, 19]}, - '3в': {'angle': 180.0, 'sectors': [14, 18]}, - '4в': {'angle': 270.0, 'sectors': [13, 17]}, -} -# Конфигурация частот и ширин для каждого ФС -const FS_PARAMS_V := { - 4: {'freq': 1227.0, 'width': 100.0}, - 5: {'freq': 1575.0, 'width': 110.0}, -} enum STATE_VAL { NONE = 0, GOOD = 1, ERROR = 2 } -var block_ip_config_v := { - 'maa2000_1': [0, false], - 'maa2000_2': [1, false], - 'ip9_50_1': [2, false], - 'ip9_50_2': [3, false], - 'ip12_50_1': [4, false], - 'ip5_25': [7, false], -} -var block_kasseta_y5_prd_config_v: = { - 'yau07': false, - 'ems': false, - 'ug': false, - 'ukp1': false, - 'ukp2': false, -} # Основные переменные -var start_litera: int = 4 -var ug_work_1: int = 2 ## Аттенюация усилителей мощности -var ug_work_2: int = 3 ## Аттенюация усилителей мощности -# Флаги и таймеры -var mashine_timer: Timer = Timer.new() -var prd_v_module: Object var unit_prd_v: Object -var control_prd_v: Object -# Результаты контроля -var control_results_v: Dictionary = { - 'block_ip': false, # Проверка касет П1 и ИП МА2000 - 'temperature': true, # Проверка температур УМ - 'dkm_4': false, - 'dkm_5': false, - 'dou_4': false, - 'dou_5': false, - 'fs_4': 2, - 'fs_5': 2, -} -var test_control_v = preload('res://scripts/pribor-prd.gd') var ctrl_pos = 70 -func on_state_mashine() -> void: - control_prd_v.state_control_machine() - - func _ready() -> void: if Engine.is_editor_hint(): return - - initialize_connections() - setup_timer() - set_default_state() - find_labels(self) - - -func initialize_connections() -> void: var unit_name = get_meta('unit_name')[0] - prd_v_module = prd.prd_dict[unit_name] - unit_prd_v = prd_v_module.unit_yau07 - - unit_prd_v.connect('line_changed', Callable(self, 'on_line_changed')) - var power_amplifiers: Array = get_tree().get_nodes_in_group('power_amplifier') - var init_data: Dictionary = { - 'control_label': $control_result, - 'power_amplifiers': power_amplifiers, - 'unit_prd': unit_prd_v, - 'module_prd' : prd_v_module, - 'constants': constants_v, - 'prd_config': PRIBOR_CONFIG_V, - 'fs_params': FS_PARAMS_V, - 'block_ip_prd_config': block_ip_config_v, - 'block_kasseta_y5_prd_config': block_kasseta_y5_prd_config_v, - 'control_results': control_results_v, - 'current_litera': start_litera, - } - control_prd_v = test_control_v.TestPRD.new(init_data) - add_child(control_prd_v) - control_prd_v.connect('control_is_over', Callable(self, 'on_control_result')) + var prd_v_module = prd.prd_dict[unit_name] + unit_prd_v = prd_v_module.unit_control + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + for temp in power_amplifier: + temp.value1 = -70 + # Подписываемся на сигналы + signaller.conn(signaller.start_contol_device, Callable(self, '_on_start_control')) + unit_prd_v.connect('control_is_over', Callable(self, 'on_press_device')) + unit_prd_v.connect('status_updated', Callable(self, '_on_status_updated')) + # Устанавливаем начальный статус + _update_status_text(unit_prd_v.get_current_status()) + on_press_device(unit_prd_v.self_name) -func setup_timer() -> void: - add_child(mashine_timer) - mashine_timer.connect('timeout', Callable(self, 'on_state_mashine')) - mashine_timer.wait_time = constants_v.STATE_MASHINE_TIMER - mashine_timer.start() +func _process(_delta: float) -> void: + if Engine.is_editor_hint(): + return + set_frame($input_0, unit_prd_v.ems_g_sock_dic.ems_input_1) + set_frame($input_1, unit_prd_v.ems_g_sock_dic.ems_input_2) + set_frame($output_0, unit_prd_v.ems_g_sock_dic.ems_output_1) + set_frame($output_1, unit_prd_v.ems_g_sock_dic.ems_output_2) -func set_default_state() -> void: - for group in get_tree().get_nodes_in_group('default_reset'): - group.state = STATE_VAL.NONE +func set_frame(node_frame: Node, val: int): node_frame.set_frame(val) - for group in get_tree().get_nodes_in_group('power_amplifier'): + +func _on_start_control() -> void: + set_default_state(get_tree().get_nodes_in_group('default_reset')) + set_default_state(get_tree().get_nodes_in_group('power_amplifier')) + for um in get_tree().get_nodes_in_group('power_amplifier'): + um.value0 = [0, 0, 0, 0, 0, 0] + find_labels(self) + await get_tree().create_timer(1.0).timeout + on_press_device(unit_prd_v.self_name) + + +static func set_default_state(default_reset_array_node: Array) -> void: + for group in default_reset_array_node: group.state = STATE_VAL.NONE func _enter_tree() -> void: if Engine.is_editor_hint(): return - $control_result.text = 'Выполняется ...' - $control_result.add_theme_color_override('font_color', Color.ALICE_BLUE) - signaller.connect('режим_работа', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_журнал', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_эмс', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_настройки', Callable(self, 'on_mode_changed').bind(false)) - signaller.connect('режим_контроль', Callable(self, 'on_mode_changed').bind(true)) - + if unit_prd_v: + _update_status_text(unit_prd_v.get_current_status()) func _exit_tree() -> void: if Engine.is_editor_hint(): return - prd_v_module.cmd_array.append([unit_prd_v.CmdCode.WRITE_ISA, [constants_v.ADDR_UG_LITERA_1, ug_work_1, constants_v.ADDR_UG_LITERA_2, ug_work_2]]) -func on_line_changed(unit_pribor: Object) -> void: - if not unit_pribor.online: - set_default_state() +static func temperature_fill(temperature_arr_node: Array, temperature_dic: Dictionary)->void: + for i_node_temperature in temperature_arr_node: + var temperature_meta: String = i_node_temperature.get_meta('um') + if not temperature_dic.has(temperature_meta): return + i_node_temperature.value1 = temperature_dic[temperature_meta] if temperature_dic[temperature_meta] < 361 else -40 -func on_mode_changed(in_tree: bool) -> void: - if not in_tree: - mashine_timer.stop() - prd_v_module.cmd_array.append([unit_prd_v.CmdCode.WRITE_ISA, [constants_v.ADDR_UG_LITERA_1, ug_work_1, constants_v.ADDR_UG_LITERA_2, ug_work_2]]) - signaller.emit_signal('interfer_off_all') - else: - set_default_state() - control_prd_v.state = control_prd_v.STATE_MASHINE.INIT - mashine_timer.start() - - -func power_fill(pow_dic: Dictionary, fs_result: Dictionary) -> void: - var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') - for i_powapm in power_amplifier: - var powamp_meta: String = i_powapm.get_meta('um') +static func power_fill(pow_dic: Dictionary, fs_result: Dictionary, power_amplifier_arr_node: Array, POWER_THRESHOLD: int) -> void: + for i_node_powapm in power_amplifier_arr_node: + var powamp_meta: String = i_node_powapm.get_meta('um') var status = STATE_VAL.GOOD if pow_dic else STATE_VAL.NONE - if pow_dic[powamp_meta].size() < 6: - status = STATE_VAL.ERROR - else: - if powamp_meta in ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'] and not fs_result.fs_4: return - if powamp_meta in ['um_7', 'um_8', 'um_9', 'um_10', 'um_11', 'um_12'] and not fs_result.fs_5: return - i_powapm.value0 = pow_dic[powamp_meta] - for i_p in pow_dic[powamp_meta]: - if i_p < constants_v.POWER_THRESHOLD: - status = STATE_VAL.ERROR - i_powapm.state = status + if not pow_dic.has(powamp_meta): return + if powamp_meta in ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'] and not fs_result.fs_4: return + if powamp_meta in ['um_9', 'um_10', 'um_11', 'um_12', 'um_13', 'um_14'] and not fs_result.fs_5: return + i_node_powapm.value0 = pow_dic[powamp_meta] + # Проверка: если ВСЕ значения в массиве < 1 → STATE_VAL.NONE + var power_array: Array = pow_dic[powamp_meta] + var all_below_one: bool = true + for i_p in power_array: + if i_p >= 1: + all_below_one = false + break + + if all_below_one: + i_node_powapm.state = STATE_VAL.NONE + continue + var count_above_threshold = 0 + for i_p in pow_dic[powamp_meta]: + if i_p >= POWER_THRESHOLD: + count_above_threshold += 1 + + status = STATE_VAL.GOOD if count_above_threshold >= 3 else STATE_VAL.ERROR + i_node_powapm.state = status -func on_control_result(result_dic: Dictionary, power_dic: Dictionary) -> void: - mashine_timer.stop() - block_kasseta_y5_prd_config_v = control_prd_v.block_kasseta_y5_config +func on_press_device(_device_name: String) -> void: var nodes_y5: Array = get_tree().get_nodes_in_group('y-5') + var node_ip_power_arr: Array = get_tree().get_nodes_in_group('power_supply') + var fs_nodes: Array = get_tree().get_nodes_in_group('fs_group') + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + var default_reset_array_node: Array = get_tree().get_nodes_in_group('default_reset') + var module_fs_4: Node = $kasseta_FS_VD/ref_A6 + var dou_4: Node = $dou4_A5 + var module_fs_5: Node = $kasseta_FS_VD/ref_A2 + var dou_5: Node = $dou5_A6 + var control_data = unit_prd_v.get_control_results() + var for_control_result: Dictionary = { + 'nodes_y5': nodes_y5, + 'node_ip_power_arr': node_ip_power_arr, + 'fs_nodes': fs_nodes, + 'power_amplifier': power_amplifier, + 'default_reset_array_node': default_reset_array_node, + 'module_fs_4': module_fs_4, + 'dou_4': dou_4, + 'module_fs_5': module_fs_5, + 'dou_5': dou_5, + } + for_control_result.merge(control_data, true) + on_control_result(for_control_result) + + +static func on_control_result(for_result_dic: Dictionary) -> void: + temperature_fill(for_result_dic.power_amplifier, for_result_dic.temperature_um) + var all_y5_good: bool = true + var block_kasseta_y5_prd_config_v: Dictionary = for_result_dic.block_kasseta_y5_config + var nodes_y5: Array = for_result_dic.nodes_y5 for node_y5 in nodes_y5: var meta_y5 = node_y5.get_meta('y5') if block_kasseta_y5_prd_config_v.has(meta_y5): - if block_kasseta_y5_prd_config_v['yau07'] == false: + if not block_kasseta_y5_prd_config_v.yau07: node_y5.state = STATE_VAL.ERROR if meta_y5 == 'yau07' else STATE_VAL.NONE - break - node_y5.state = STATE_VAL.GOOD if block_kasseta_y5_prd_config_v[meta_y5] else STATE_VAL.ERROR + else: + node_y5.state = STATE_VAL.GOOD if block_kasseta_y5_prd_config_v[meta_y5] else STATE_VAL.ERROR + if node_y5.state == STATE_VAL.ERROR: + all_y5_good = false - block_ip_config_v = control_prd_v.block_ip_config - var node_ip_power_arr: Array = get_tree().get_nodes_in_group('power_supply') - for power_supply in node_ip_power_arr: + var block_ip_config_v: Dictionary = for_result_dic.block_ip_config + for power_supply in for_result_dic.node_ip_power_arr: var meta_ip = power_supply.get_meta('ip') - if block_ip_config_v.has(meta_ip) and block_kasseta_y5_prd_config_v.ug: + if block_ip_config_v.has(meta_ip) and block_kasseta_y5_prd_config_v.ug and block_kasseta_y5_prd_config_v.yau07: power_supply.state = STATE_VAL.GOOD if block_ip_config_v[meta_ip][1] else STATE_VAL.ERROR + else: + power_supply.state = STATE_VAL.NONE + if power_supply.state == STATE_VAL.ERROR: + all_y5_good = false - var fs_nodes: Array = get_tree().get_nodes_in_group('fs_group') - for f in fs_nodes: + if not for_result_dic.control_is_over: + set_default_state(for_result_dic.default_reset_array_node) + set_default_state(for_result_dic.power_amplifier) + return + var result_dic: Dictionary = for_result_dic.result_dic + for f in for_result_dic.fs_nodes: var fs_meta: String = f.get_meta('fs') if result_dic.has(fs_meta): - var new_state = result_dic[fs_meta] - f.state = new_state - result_dic[fs_meta] = new_state + f.state = result_dic[fs_meta] - if result_dic.fs_5 == 1: - $kasseta_FS_VD/ref_A2.state = STATE_VAL.GOOD if result_dic.dkm_5 else STATE_VAL.ERROR - $dou5_A6.state = STATE_VAL.GOOD if result_dic.dou_5 else STATE_VAL.ERROR - else: - result_dic.fs_5 = 0 - if result_dic.fs_4 == 1: - $kasseta_FS_VD/ref_A6.state = STATE_VAL.GOOD if result_dic.dkm_4 else STATE_VAL.ERROR - $dou4_A5.state = STATE_VAL.GOOD if result_dic.dou_4 else STATE_VAL.ERROR - else: - result_dic.fs_4 = 0 - power_fill(power_dic, result_dic) + if not all_y5_good: return + var fs_5 = true if int(result_dic.fs_5) == 1 else false + if fs_5 and block_kasseta_y5_prd_config_v['yau07']: + for_result_dic.module_fs_5.state = STATE_VAL.GOOD if result_dic.dkm_5 else STATE_VAL.ERROR + for_result_dic.dou_5.state = STATE_VAL.GOOD if result_dic.dou_5 else STATE_VAL.ERROR - var result = true - for device in result_dic.values(): - if not device: - result = false + var fs_4 = true if int(result_dic.fs_4) == 1 else false + if fs_4 and block_kasseta_y5_prd_config_v['yau07']: + for_result_dic.module_fs_4.state = STATE_VAL.GOOD if result_dic.dkm_4 else STATE_VAL.ERROR + for_result_dic.dou_4.state = STATE_VAL.GOOD if result_dic.dou_4 else STATE_VAL.ERROR - var name_prd = control_prd_v.self_name - if result: - $control_result.text = 'Прибор ПРД-%s исправен' % name_prd - $control_result.add_theme_color_override('font_color', Color.GREEN) - else: - $control_result.text = 'Прибор ПРД-%s неисправен' % name_prd - $control_result.add_theme_color_override('font_color', Color.RED) + if block_kasseta_y5_prd_config_v['yau07']: + power_fill(for_result_dic.power_dic, for_result_dic.result_dic, for_result_dic.power_amplifier, for_result_dic.POWER_THRESHOLD) func find_labels(node1: Node): @@ -245,3 +190,22 @@ func find_labels(node1: Node): node1.set_meta("tooltip_set", true) for child in node1.get_children(): find_labels(child) + + +func _on_status_updated(status_text: String) -> void: + _update_status_text(status_text) + + +func _update_status_text(text: String) -> void: + $control_result.text = text + # Можно добавить смену цвета в зависимости от статуса + if "Ошибка" in text or "неисправен" in text: + $control_result.add_theme_color_override('font_color', Color.RED) + log.message(Logger.INFO, 'Прибор ПРД-%s неисправен' % [unit_prd_v.self_name]) + elif "Ограничена" in text or "Предупреждение" in text: + $control_result.add_theme_color_override('font_color', Color.YELLOW) + elif "исправен" in text or "завершён" in text: + $control_result.add_theme_color_override('font_color', Color.GREEN) + log.message(Logger.INFO, 'Прибор ПРД-%s исправен' % [unit_prd_v.self_name]) + else: + $control_result.add_theme_color_override('font_color', Color.WHITE) diff --git a/scenes/pribor-prd-v/pribor-prd-v.tscn b/scenes/pribor-prd-v/pribor-prd-v.tscn index bf501cbd..8144c9c9 100644 --- a/scenes/pribor-prd-v/pribor-prd-v.tscn +++ b/scenes/pribor-prd-v/pribor-prd-v.tscn @@ -1,13 +1,36 @@ -[gd_scene load_steps=9 format=3 uid="uid://cvskpe1ti3p45"] +[gd_scene load_steps=13 format=3 uid="uid://cvskpe1ti3p45"] [ext_resource type="Script" uid="uid://cvuosuvjaci1h" path="res://scenes/pribor-prd-v/pribor-prd-v.gd" id="1_c20s6"] [ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="2_xpo4b"] [ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="3_wyy1b"] -[ext_resource type="PackedScene" uid="uid://bk1655p4e8y4u" path="res://scenes/контроль/кассета-у-5-нв.tscn" id="4_gl2bl"] [ext_resource type="PackedScene" uid="uid://cd5sue1e8iyrv" path="res://scenes/pribor-prd-n/kasseta-fs-nd.tscn" id="5_nhd2k"] [ext_resource type="Script" uid="uid://crpedygm3gohi" path="res://scenes/контроль/кассета.gd" id="6_os4mt"] [ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="7_38u2b"] [ext_resource type="PackedScene" uid="uid://bcyxqni7gxvtq" path="res://scenes/контроль/блок-в.tscn" id="8_4e87c"] +[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="9_4e87c"] +[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="10_g8fvp"] +[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="11_gsby4"] +[ext_resource type="Texture2D" uid="uid://dvl3sq036gn75" path="res://data/эмс-бланк-замыкание.png" id="12_vxfkm"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_s5gcy"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("9_4e87c") +}, { +"duration": 1.0, +"texture": ExtResource("10_g8fvp") +}, { +"duration": 1.0, +"texture": ExtResource("11_gsby4") +}, { +"duration": 1.0, +"texture": ExtResource("12_vxfkm") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] [node name="pribor_prd_v" type="Control"] layout_mode = 3 @@ -18,50 +41,50 @@ offset_right = 15.0 offset_bottom = 30.0 script = ExtResource("1_c20s6") -[node name="maa2000_A22" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("2_xpo4b")] +[node name="maa2000_A22" parent="." groups=["power_supply"] instance=ExtResource("2_xpo4b")] layout_mode = 2 -offset_left = 485.0 -offset_top = 877.0 -offset_right = 652.0 -offset_bottom = 949.0 +offset_left = 524.0 +offset_top = 731.0 +offset_right = 691.0 +offset_bottom = 803.0 fname = "MAA2000" rname = "A22" metadata/ip = "maa2000_1" [node name="dou4_A5" parent="." groups=["default_reset"] instance=ExtResource("2_xpo4b")] layout_mode = 2 -offset_left = 485.0 -offset_top = 812.0 -offset_right = 652.0 -offset_bottom = 877.0 +offset_left = 524.0 +offset_top = 666.0 +offset_right = 691.0 +offset_bottom = 731.0 fname = "ДОУ-4" rname = "A5" -[node name="maa2000_A23" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("2_xpo4b")] +[node name="maa2000_A23" parent="." groups=["power_supply"] instance=ExtResource("2_xpo4b")] layout_mode = 2 -offset_left = 8.0 -offset_top = 877.0 -offset_right = 175.0 -offset_bottom = 949.0 +offset_left = 47.0 +offset_top = 731.0 +offset_right = 214.0 +offset_bottom = 803.0 fname = "MAA2000" rname = "A23" metadata/ip = "maa2000_2" [node name="dou5_A6" parent="." groups=["default_reset"] instance=ExtResource("2_xpo4b")] layout_mode = 2 -offset_left = 8.0 -offset_top = 812.0 -offset_right = 175.0 -offset_bottom = 877.0 +offset_left = 47.0 +offset_top = 666.0 +offset_right = 214.0 +offset_bottom = 731.0 fname = "ДОУ-5" rname = "A6" [node name="ref_ZZ3" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 812.0 -offset_right = 485.0 -offset_bottom = 949.0 +offset_left = 214.0 +offset_top = 666.0 +offset_right = 524.0 +offset_bottom = 803.0 texture = ExtResource("3_wyy1b") patch_margin_left = 16 patch_margin_top = 16 @@ -80,27 +103,98 @@ text = "Панель horizontal_alignment = 1 vertical_alignment = 1 -[node name="kasseta_U5" parent="." instance=ExtResource("4_gl2bl")] +[node name="kasseta_U5" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 242.0 -offset_right = 485.0 -offset_bottom = 432.0 +offset_left = 214.0 +offset_top = 96.0 +offset_right = 524.0 +offset_bottom = 286.0 +texture = ExtResource("3_wyy1b") +patch_margin_left = 16 +patch_margin_top = 16 +patch_margin_right = 16 +patch_margin_bottom = 16 +script = ExtResource("6_os4mt") + +[node name="lbl_fname" type="Label" parent="kasseta_U5"] +self_modulate = Color(1, 1, 1, 0.62) +layout_mode = 0 +offset_left = 5.0 +offset_top = 7.0 +offset_right = 305.0 +offset_bottom = 35.0 +text = "Кассета У5" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="ref_A24" parent="kasseta_U5" groups=["power_supply"] instance=ExtResource("7_38u2b")] +offset_left = 5.0 +offset_top = 32.0 +offset_right = 55.0 +offset_bottom = 182.0 +fname = "ИП5-25" +rname = "A24" +metadata/ip = "ip5_25" + +[node name="ref_A30" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_38u2b")] +offset_left = 55.0 +offset_top = 32.0 +offset_right = 105.0 +offset_bottom = 182.0 +fname = "ЯУ-07Б" +rname = "A30" +metadata/y5 = "yau07" + +[node name="ref_A26" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_38u2b")] +offset_left = 105.0 +offset_top = 32.0 +offset_right = 155.0 +offset_bottom = 182.0 +fname = "ЭМС-Г" +rname = "A26" +metadata/y5 = "ems" + +[node name="ref_A27" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_38u2b")] +offset_left = 155.0 +offset_top = 32.0 +offset_right = 205.0 +offset_bottom = 182.0 +fname = "УГ" +rname = "A27" +metadata/y5 = "ug" + +[node name="ref_A28" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_38u2b")] +offset_left = 205.0 +offset_top = 32.0 +offset_right = 255.0 +offset_bottom = 182.0 +fname = "УКП" +rname = "A28" +metadata/y5 = "ukp1" + +[node name="ref_A29" parent="kasseta_U5" groups=["y-5"] instance=ExtResource("7_38u2b")] +offset_left = 254.0 +offset_top = 32.0 +offset_right = 304.0 +offset_bottom = 182.0 +fname = "УКП" +rname = "A29" +metadata/y5 = "ukp2" [node name="kasseta_FS_VD" parent="." instance=ExtResource("5_nhd2k")] layout_mode = 0 -offset_left = 175.0 -offset_top = 432.0 -offset_right = 485.0 -offset_bottom = 622.0 +offset_left = 214.0 +offset_top = 286.0 +offset_right = 524.0 +offset_bottom = 476.0 fname = "Кассета ФС-ВД" [node name="kasseta_P_1" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 175.0 -offset_top = 622.0 -offset_right = 485.0 -offset_bottom = 812.0 +offset_left = 214.0 +offset_top = 476.0 +offset_right = 524.0 +offset_bottom = 666.0 texture = ExtResource("3_wyy1b") patch_margin_left = 16 patch_margin_top = 16 @@ -109,7 +203,7 @@ patch_margin_bottom = 16 script = ExtResource("6_os4mt") fname = "Кассета П-1В" -[node name="ref_A19" parent="kasseta_P_1" groups=["default_reset", "power_supply"] instance=ExtResource("7_38u2b")] +[node name="ref_A19" parent="kasseta_P_1" groups=["power_supply"] instance=ExtResource("7_38u2b")] offset_left = 9.0 offset_top = 33.0 offset_right = 59.0 @@ -118,7 +212,7 @@ fname = "ИП9-50" rname = "A19" metadata/ip = "ip9_50_1" -[node name="ref_A20" parent="kasseta_P_1" groups=["default_reset", "power_supply"] instance=ExtResource("7_38u2b")] +[node name="ref_A20" parent="kasseta_P_1" groups=["power_supply"] instance=ExtResource("7_38u2b")] offset_left = 59.0 offset_top = 33.0 offset_right = 109.0 @@ -127,7 +221,7 @@ fname = "ИП9-50" rname = "A20" metadata/ip = "ip9_50_2" -[node name="ref_A21" parent="kasseta_P_1" groups=["default_reset", "power_supply"] instance=ExtResource("7_38u2b")] +[node name="ref_A21" parent="kasseta_P_1" groups=["power_supply"] instance=ExtResource("7_38u2b")] offset_left = 109.0 offset_top = 33.0 offset_right = 159.0 @@ -149,153 +243,178 @@ vertical_alignment = 1 [node name="um1535_A7" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 485.0 -offset_top = 242.0 -offset_right = 652.0 -offset_bottom = 337.0 -fname = "УМ1535Б" +offset_left = 524.0 +offset_top = 96.0 +offset_right = 691.0 +offset_bottom = 191.0 +fname = "УМ1535А" rname = "A7" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_1" [node name="um1535_A8" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 485.0 -offset_top = 337.0 -offset_right = 652.0 -offset_bottom = 432.0 +offset_left = 524.0 +offset_top = 191.0 +offset_right = 691.0 +offset_bottom = 286.0 fname = "УМ1535А" rname = "A8" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_2" [node name="um1535_A9" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 485.0 -offset_top = 432.0 -offset_right = 652.0 -offset_bottom = 527.0 +offset_left = 524.0 +offset_top = 286.0 +offset_right = 691.0 +offset_bottom = 381.0 fname = "УМ1535А" rname = "A9" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_3" [node name="um1535_A10" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 485.0 -offset_top = 527.0 -offset_right = 652.0 -offset_bottom = 622.0 +offset_left = 524.0 +offset_top = 381.0 +offset_right = 691.0 +offset_bottom = 476.0 fname = "УМ1535А" rname = "A10" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_4" [node name="um1535_A11" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 485.0 -offset_top = 622.0 -offset_right = 652.0 -offset_bottom = 717.0 +offset_left = 524.0 +offset_top = 476.0 +offset_right = 691.0 +offset_bottom = 571.0 fname = "УМ1535А" rname = "A11" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_5" [node name="um1535_A12" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 485.0 -offset_top = 717.0 -offset_right = 652.0 -offset_bottom = 812.0 +offset_left = 524.0 +offset_top = 571.0 +offset_right = 691.0 +offset_bottom = 666.0 fname = "УМ1535А" rname = "A12" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_6" [node name="um1535_A13" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 8.0 -offset_top = 242.0 -offset_right = 175.0 -offset_bottom = 337.0 +offset_left = 47.0 +offset_top = 96.0 +offset_right = 214.0 +offset_bottom = 191.0 fname = "УМ1535А" rname = "A13" -value0_info = "Мощность, Вт" -value1_info = "Температура,°C" -metadata/um = "um_7" - -[node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] -layout_mode = 0 -offset_left = 8.0 -offset_top = 337.0 -offset_right = 175.0 -offset_bottom = 432.0 -fname = "УМ1535А" -rname = "A14" -value0_info = "Мощность, Вт" -value1_info = "Температура,°C" -metadata/um = "um_8" - -[node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] -layout_mode = 0 -offset_left = 8.0 -offset_top = 432.0 -offset_right = 175.0 -offset_bottom = 527.0 -fname = "УМ1535А" -rname = "A15" -value0_info = "Мощность, Вт" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_9" -[node name="um1535_A16" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] +[node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 8.0 -offset_top = 527.0 -offset_right = 175.0 -offset_bottom = 622.0 +offset_left = 47.0 +offset_top = 191.0 +offset_right = 214.0 +offset_bottom = 286.0 fname = "УМ1535А" -rname = "A16" -value0_info = "Мощность, Вт" +rname = "A14" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_10" -[node name="um1535_A17" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] +[node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 8.0 -offset_top = 622.0 -offset_right = 175.0 -offset_bottom = 717.0 +offset_left = 47.0 +offset_top = 286.0 +offset_right = 214.0 +offset_bottom = 381.0 fname = "УМ1535А" -rname = "A17" -value0_info = "Мощность, Вт" +rname = "A15" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_11" -[node name="um1535_A18" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] +[node name="um1535_A16" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] layout_mode = 0 -offset_left = 8.0 -offset_top = 717.0 -offset_right = 175.0 -offset_bottom = 812.0 +offset_left = 47.0 +offset_top = 381.0 +offset_right = 214.0 +offset_bottom = 476.0 fname = "УМ1535А" -rname = "A18" -value0_info = "Мощность, Вт" +rname = "A16" +value0_info = "Мощность" value1_info = "Температура,°C" metadata/um = "um_12" +[node name="um1535_A17" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] +layout_mode = 0 +offset_left = 47.0 +offset_top = 476.0 +offset_right = 214.0 +offset_bottom = 571.0 +fname = "УМ1535А" +rname = "A17" +value0_info = "Мощность" +value1_info = "Температура,°C" +metadata/um = "um_13" + +[node name="um1535_A18" parent="." groups=["power_amplifier"] instance=ExtResource("8_4e87c")] +layout_mode = 0 +offset_left = 47.0 +offset_top = 571.0 +offset_right = 214.0 +offset_bottom = 666.0 +fname = "УМ1535А" +rname = "A18" +value0_info = "Мощность" +value1_info = "Температура,°C" +metadata/um = "um_14" + +[node name="input_0" type="AnimatedSprite2D" parent="."] +position = Vector2(496, 440) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="input_1" type="AnimatedSprite2D" parent="."] +position = Vector2(248, 440) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="output_0" type="AnimatedSprite2D" parent="."] +position = Vector2(496, 336) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="output_1" type="AnimatedSprite2D" parent="."] +position = Vector2(248, 336) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="line" type="Line2D" parent="."] +position = Vector2(59, 920) +scale = Vector2(1.03548, 1) +points = PackedVector2Array(-8, 0, 61.8069, 0, 608, 0) +width = 2.0 +default_color = Color(1, 1, 1, 0.352941) +metadata/_edit_lock_ = true + [node name="control_result" type="Label" parent="."] layout_mode = 0 -offset_left = 9.0 -offset_top = 960.0 -offset_right = 649.0 -offset_bottom = 1003.0 +offset_left = 49.0 +offset_top = 993.0 +offset_right = 689.0 +offset_bottom = 1036.0 +theme_override_font_sizes/font_size = 22 horizontal_alignment = 1 metadata/_edit_lock_ = true diff --git a/scenes/pribor-uf/pribor-uf.gd b/scenes/pribor-uf/pribor-uf.gd index 5f6b0380..acd59501 100644 --- a/scenes/pribor-uf/pribor-uf.gd +++ b/scenes/pribor-uf/pribor-uf.gd @@ -1,35 +1,39 @@ @tool class_name pribor_uf extends 'res://scenes/контроль/прибор.gd' +signal control_is_over(device_name: String) # Когда контроль завершен enum STATE_VAL {NONE = 0, GOOD = 1, ERROR = 2} -const DEV_LIST = ['00:1f.6', '07:00.0', '08:00.0', '0b:00.0'] -const USB_TRACKERBALL = '13ba:0018' -const REVFF = '(rev ff)' +const DEV_LIST: Array = ['00:1f.6', '07:00.0', '08:00.0', '0b:00.0'] +const USB_TRACKERBALL: String = '13ba:0018' +const REVFF: String = '(rev ff)' +var unit_uf: Object var ctrl_pos = 100 func _ready() -> void: - if Engine.is_editor_hint(): - return - var unit_uf: = network.get_unit_instance('уарэп-эмс') + if Engine.is_editor_hint(): return + signaller.conn(signaller.start_contol_device, Callable(self, '_on_start_contol_device')) + unit_uf = network.get_unit_instance('уарэп-эмс') unit_uf.connect('line_changed', on_line_changed) - control_vk() - on_line_changed(unit_uf) + on_line_changed() + #control_vk() + control_ems(unit_uf.status) + status_uf() find_labels(self) -func on_timer(unit_name: StringName): - var unit_uf = network.get_unit_instance(unit_name) +func _on_start_contol_device(): + on_line_changed() + control_ems(unit_uf.status) # проверка ЭМС ячеек status_uf() # отслеживание состояния прибора - if unit_uf.online: # проверка ЯУ, внутреннего коммутатора и ИП-5Б - control_ems(unit_uf.status) # проверка ЭМС ячеек -func on_line_changed(unit_uf): +func on_line_changed(): if unit_uf.online: # проверка ЯУ, внутреннего коммутатора и ИП-5Б $ref_uf/ref_kassetav13/ref_A7_YAU07.state = STATE_VAL.GOOD $ref_uf/ref_kassetav13/ref_A3_IP5B.state = STATE_VAL.GOOD $ref_uf/ref_kassetav13/ref_A9_ESW.state = STATE_VAL.GOOD + $ref_uf/ref_bu1/ref_A8_BU.state = STATE_VAL.GOOD ## заглушка для зеленения ВК-110 else: $ref_uf/ref_kassetav13/ref_A7_YAU07.state = STATE_VAL.ERROR $ref_uf/ref_kassetav13/ref_A4_KEMS.state = STATE_VAL.NONE @@ -38,6 +42,7 @@ func on_line_changed(unit_uf): $ref_uf/ref_kassetav13/ref_A3_IP5B.state = STATE_VAL.NONE $ref_uf/ref_kassetav13/ref_A9_ESW.state = STATE_VAL.NONE $ref_uf/ref_kassetav13/ref_A12_IP27B.state = STATE_VAL.NONE + $ref_uf/ref_bu1/ref_A8_BU.state = STATE_VAL.NONE func control_vk() -> void: @@ -76,14 +81,13 @@ func control_vk() -> void: else: $ref_uf/ref_bu1/ref_A8_BU.state = STATE_VAL.ERROR - $ref_uf/ref_bu1/ref_A8_BU.state = STATE_VAL.GOOD ## заглушка для зеленения ВК-110 - func control_ems(status: Array) -> void: - $ref_uf/ref_kassetav13/ref_A4_KEMS.state = STATE_VAL.GOOD if ((status[0] >> 0) & 1) and ((status[0] >> 3) & 1) else STATE_VAL.ERROR - $ref_uf/ref_kassetav13/ref_A5_EMS.state = STATE_VAL.GOOD if ((status[0] >> 1) & 1) and ((status[0] >> 4) & 1) else STATE_VAL.ERROR - $ref_uf/ref_kassetav13/ref_A6_EMS.state = STATE_VAL.GOOD if ((status[0] >> 2) & 1) and ((status[0] >> 5) & 1) else STATE_VAL.ERROR - $ref_uf/ref_kassetav13/ref_A12_IP27B.state = STATE_VAL.GOOD if ((status[2] >> 6) & 1) else STATE_VAL.ERROR + if status: + $ref_uf/ref_kassetav13/ref_A4_KEMS.state = STATE_VAL.GOOD if ((status[0] >> 0) & 1) and ((status[0] >> 3) & 1) else STATE_VAL.ERROR + $ref_uf/ref_kassetav13/ref_A5_EMS.state = STATE_VAL.GOOD if ((status[0] >> 1) & 1) and ((status[0] >> 4) & 1) else STATE_VAL.ERROR + $ref_uf/ref_kassetav13/ref_A6_EMS.state = STATE_VAL.GOOD if ((status[0] >> 2) & 1) and ((status[0] >> 5) & 1) else STATE_VAL.ERROR + $ref_uf/ref_kassetav13/ref_A12_IP27B.state = STATE_VAL.GOOD if ((status[2] >> 6) & 1) else STATE_VAL.ERROR func status_uf() -> void: @@ -100,9 +104,10 @@ func status_uf() -> void: $lbl_header2.text = 'Прибор исправен' $lbl_header2.modulate = Color.GREEN else: - $lbl_header2.text = 'Прибор не исправен' + $lbl_header2.text = 'Прибор неисправен' $lbl_header2.modulate = Color.RED $lbl_header2.visible = true + emit_signal('control_is_over', unit_uf.name) func find_labels(node1: Node): diff --git a/scenes/pribor-uf/pribor-uf.tscn b/scenes/pribor-uf/pribor-uf.tscn index 998ace6e..8e281371 100644 --- a/scenes/pribor-uf/pribor-uf.tscn +++ b/scenes/pribor-uf/pribor-uf.tscn @@ -7,14 +7,16 @@ [node name="pribor_uf" type="Control"] layout_mode = 3 anchors_preset = 0 +offset_left = -121.0 +offset_right = -121.0 script = ExtResource("1_7gtpa") [node name="ref_uf" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 187.0 -offset_top = 247.0 -offset_right = 708.0 -offset_bottom = 955.0 +offset_left = 244.0 +offset_top = 128.0 +offset_right = 765.0 +offset_bottom = 836.0 texture = ExtResource("2_ho0da") patch_margin_left = 16 patch_margin_top = 16 @@ -142,19 +144,20 @@ offset_bottom = 35.0 text = "Кассета В-13" [node name="lbl_header2" type="Label" parent="."] -visible = false layout_mode = 0 -offset_left = 199.0 -offset_top = 974.0 -offset_right = 704.0 -offset_bottom = 1000.0 +offset_left = 252.0 +offset_top = 1009.0 +offset_right = 757.0 +offset_bottom = 1064.0 theme_override_font_sizes/font_size = 22 -text = "Прибор не исправен -" +text = "Ожидание запуска контроля" horizontal_alignment = 1 vertical_alignment = 1 -[node name="timer" type="Timer" parent="."] -autostart = true - -[connection signal="timeout" from="timer" to="." method="on_timer" binds= [&"уарэп-эмс"]] +[node name="line" type="Line2D" parent="."] +position = Vector2(195, 950) +scale = Vector2(1.03548, 1) +points = PackedVector2Array(-8, 0, 61.8069, 0, 608, 0) +width = 2.0 +default_color = Color(1, 1, 1, 0.352941) +metadata/_edit_lock_ = true diff --git a/scenes/pribor-uyep/pribor-uyep.tscn b/scenes/pribor-uyep/pribor-uyep.tscn index e78e7826..f5a9c523 100644 --- a/scenes/pribor-uyep/pribor-uyep.tscn +++ b/scenes/pribor-uyep/pribor-uyep.tscn @@ -17,10 +17,10 @@ script = ExtResource("1_46rp6") [node name="ref_G1" type="NinePatchRect" parent="."] layout_mode = 0 -offset_left = 70.0 -offset_top = 303.0 -offset_right = 660.0 -offset_bottom = 1085.0 +offset_left = 88.0 +offset_top = 128.0 +offset_right = 678.0 +offset_bottom = 910.0 texture = ExtResource("1_6olof") patch_margin_left = 16 patch_margin_top = 16 @@ -29,10 +29,10 @@ patch_margin_bottom = 16 [node name="spt25_A1" parent="." instance=ExtResource("6_60xs3")] layout_mode = 0 -offset_left = 88.0 -offset_top = 319.0 -offset_right = 343.0 -offset_bottom = 749.0 +offset_left = 106.0 +offset_top = 144.0 +offset_right = 361.0 +offset_bottom = 574.0 tooltip_text = "Ящик - 11, Позиция - 3" script = ExtResource("4_v0lil") unit_name = "уарэп-спт25-1" @@ -64,10 +64,10 @@ offset_bottom = 417.0 [node name="spt25_A2" parent="." instance=ExtResource("6_60xs3")] layout_mode = 0 -offset_left = 392.0 -offset_top = 320.0 -offset_right = 642.0 -offset_bottom = 750.0 +offset_left = 410.0 +offset_top = 145.0 +offset_right = 660.0 +offset_bottom = 575.0 tooltip_text = "Ящик - 11, Позиция - 2" script = ExtResource("4_v0lil") unit_name = "уарэп-спт25-2" @@ -98,10 +98,10 @@ offset_right = 235.0 offset_bottom = 417.0 [node name="sch3" parent="." instance=ExtResource("7_qu7ja")] -offset_left = 88.0 -offset_top = 774.0 -offset_right = 643.0 -offset_bottom = 1059.0 +offset_left = 106.0 +offset_top = 599.0 +offset_right = 661.0 +offset_bottom = 884.0 unit_name = "уарэп-щ3" fname = "Щ3 (контроль и управление питанием)" rname = "A1" diff --git a/scenes/pribor-uyep/spt25-view.gd b/scenes/pribor-uyep/spt25-view.gd index 02938f55..ac1974fd 100644 --- a/scenes/pribor-uyep/spt25-view.gd +++ b/scenes/pribor-uyep/spt25-view.gd @@ -32,29 +32,29 @@ func disable_all(): func on_data_received(data: PackedByteArray): # Сеть 1. Использование - $block_input1.state = STATE_VAL.GOOD if data[4] & (1 << 5) else STATE_VAL.ERROR + $block_input1.state = STATE_VAL.GOOD if data[3] & (1 << 5) else STATE_VAL.ERROR # Сеть 1. Вход - $block_input1.state0 = STATE_VAL.GOOD if ((data[4] & (1 << 1)) == 0) and ((data[4] & (1 << 3)) == 0) else STATE_VAL.ERROR + $block_input1.state0 = STATE_VAL.GOOD if ((data[3] & (1 << 1)) == 0) and ((data[3] & (1 << 3)) == 0) else STATE_VAL.ERROR # Сеть 1. Неисправность блока инвертора 1 канала - $block_input1.state1 = STATE_VAL.GOOD if (data[6] & (1 << 2)) == 0 else STATE_VAL.ERROR + $block_input1.state1 = STATE_VAL.GOOD if (data[5] & (1 << 2)) == 0 else STATE_VAL.ERROR # Сеть 1. Перегрев 1 канала - $block_input1.state2 = STATE_VAL.GOOD if (data[5] & (1 << 3)) == 0 else STATE_VAL.ERROR + $block_input1.state2 = STATE_VAL.GOOD if (data[4] & (1 << 3)) == 0 else STATE_VAL.ERROR # Сеть 2. Использование - $block_input2.state = STATE_VAL.GOOD if data[4] & (1 << 6) else STATE_VAL.ERROR + $block_input2.state = STATE_VAL.GOOD if data[3] & (1 << 6) else STATE_VAL.ERROR # Сеть 2. Вход - $block_input2.state0 = STATE_VAL.GOOD if ((data[4] & (1 << 2)) == 0) and ((data[4] & (1 << 4)) == 0) else STATE_VAL.ERROR + $block_input2.state0 = STATE_VAL.GOOD if ((data[3] & (1 << 2)) == 0) and ((data[3] & (1 << 4)) == 0) else STATE_VAL.ERROR # Сеть 2. Неисправность блока инвертора 2 канала - $block_input2.state1 = STATE_VAL.GOOD if (data[6] & (1 << 3)) == 0 else STATE_VAL.ERROR + $block_input2.state1 = STATE_VAL.GOOD if (data[5] & (1 << 3)) == 0 else STATE_VAL.ERROR # Сеть 2. Перегрев 2 канала - $block_input2.state2 = STATE_VAL.GOOD if (data[5] & (1 << 4)) == 0 else STATE_VAL.ERROR + $block_input2.state2 = STATE_VAL.GOOD if (data[4] & (1 << 4)) == 0 else STATE_VAL.ERROR # Неисправность, напряжение меньше номинального, напряжение выше номинального - $block_output.state0 = STATE_VAL.GOOD if ((data[4] & (1 << 0)) == 0) and ((data[4] & (1 << 7)) == 0) and ((data[5] & (1 << 2)) == 0) else STATE_VAL.ERROR + $block_output.state0 = STATE_VAL.GOOD if ((data[3] & (1 << 0)) == 0) and ((data[3] & (1 << 7)) == 0) and ((data[4] & (1 << 2)) == 0) else STATE_VAL.ERROR # Перегрузка и короткое замыкание по выходу - $block_output.state1 = STATE_VAL.GOOD if ((data[5] & (1 << 0)) == 0) and ((data[5] & (1 << 1)) == 0) else STATE_VAL.ERROR + $block_output.state1 = STATE_VAL.GOOD if ((data[4] & (1 << 0)) == 0) and ((data[4] & (1 << 1)) == 0) else STATE_VAL.ERROR # Критическая температура - $block_output.state2 = STATE_VAL.GOOD if ((data[5] & (1 << 5)) == 0) else STATE_VAL.ERROR + $block_output.state2 = STATE_VAL.GOOD if ((data[4] & (1 << 5)) == 0) else STATE_VAL.ERROR # Обобщённое состояние state = STATE_VAL.GOOD \ diff --git a/scenes/tabs-switch/lbl_ready.gd b/scenes/tabs-switch/lbl_ready.gd index f35d4eda..19ecc2ea 100644 --- a/scenes/tabs-switch/lbl_ready.gd +++ b/scenes/tabs-switch/lbl_ready.gd @@ -1,48 +1,208 @@ extends Label -# Используем более понятные имена переменных -const STATUS_GOOD := {"text": "Исправно", "color": Color.GREEN, "font_color": Color.BLACK} -const STATUS_BAD := {"text": "Отказ", "color": Color.RED, "font_color": Color.WHITE} -var _is_uf_status_initialized: bool = false -var is_prd_operational: bool = true -var is_uf_operational: bool = false +enum PRD_STATE { + NONE, # Нет связи + GOOD, # Исправно + ERR # Отказ +} + +enum DEVICE_STATUS { + ONLINE, # Связь есть + STATUS, # Статус исправности + CONTROL # Контроль завершен +} + +const STATUS_CONFIG := { + PRD_STATE.NONE: {"text": "Нет связи", "color": Color.WHITE, "font_color": Color.BLACK}, + PRD_STATE.GOOD: {"text": "Исправно", "color": Color.GREEN, "font_color": Color.BLACK}, + PRD_STATE.ERR: {"text": "Отказ", "color": Color.RED, "font_color": Color.WHITE} +} + +class DeviceObserver: + var device_name: String + var status: Array = [false, false, false] # [online, operational, control_complete] + var last_results: Dictionary = {} + + func update_online_state(online: bool) -> bool: + if status[DEVICE_STATUS.ONLINE] != online: + status[DEVICE_STATUS.ONLINE] = online + return true + return false + + func update_control_results(results: Dictionary) -> bool: + var changed := false + last_results = results.duplicate() + + if results.get('is_over_control', false): + # Контроль завершен - проверяем все результаты + var all_ok := true + for key in results: + if key != 'is_over_control' and not results[key]: + all_ok = false + break + + if status[DEVICE_STATUS.STATUS] != all_ok or status[DEVICE_STATUS.CONTROL] != true: + status[DEVICE_STATUS.STATUS] = all_ok + status[DEVICE_STATUS.CONTROL] = true + changed = true + else: + # Контроль в процессе - проверяем базовые параметры + var basic_ok: bool = results.get('block_kasseta', false) and \ + results.get('block_ip', false) and \ + results.get('temperature', true) + + if status[DEVICE_STATUS.STATUS] != basic_ok or status[DEVICE_STATUS.CONTROL] != false: + status[DEVICE_STATUS.STATUS] = basic_ok + status[DEVICE_STATUS.CONTROL] = false + changed = true + return changed + +var device_observers: Dictionary = {} +var overall_prd_state: PRD_STATE = PRD_STATE.NONE func _ready() -> void: tooltip_text = 'Нет связи с приборами комплекса' - for prd_module in prd.prd_dict.values(): - prd_module.connect('update_serviceability', Callable(self, 'on_serviceability_changed').bind(prd_module)) - var unit_uf: = network.get_unit_instance('уарэп-эмс') - unit_uf.connect('data_received', Callable(self, 'on_uf_status_receive')) add_theme_color_override("font_color", Color.BLACK) + # Инициализация наблюдателей + _initialize_observers() -func on_serviceability_changed(unit_prd_module: Object) -> void: - var check_service: bool = true + # Подписка на сигналы ПРД модулей for prd_module in prd.prd_dict.values(): - if prd_module.unit_yau07.online: - if not unit_prd_module.serviceability: - check_service = false - if check_service != is_prd_operational: - is_prd_operational = check_service - _update_serviceability_display() + # Подключаемся к контролю ПРД + if prd_module.unit_control: + prd_module.unit_control.connect('control_results_updated', Callable(self, '_on_prd_control_results').bind(prd_module)) + # Подключаемся к онлайн-статусу ЯУ-07 + if prd_module.unit_yau07: + prd_module.unit_yau07.connect('line_changed', Callable(self, '_on_prd_online_changed').bind(prd_module)) + + # Подписка на УФ + var unit_uf = network.get_unit_instance('уарэп-эмс') + if unit_uf: + unit_uf.data_received.connect(Callable(self, '_on_uf_status_receive')) + + # Инициализация начального состояния + _recalculate_overall_state() -func _update_serviceability_display() -> void: - var status := STATUS_GOOD if (is_uf_operational and is_prd_operational) else STATUS_BAD - text = status.text - modulate = status.color - tooltip_text = 'Результаты обобщенного признака работоспособности изделия' - add_theme_color_override("font_color", status.font_color) +func _initialize_observers() -> void: + var device_names := [ + 'уарэп-яу07-1н', 'уарэп-яу07-1в', 'уарэп-яу07-1к', + 'уарэп-яу07-2н', 'уарэп-яу07-2в', 'уарэп-яу07-2к', + 'уарэп-яу07-3н', 'уарэп-яу07-3в', 'уарэп-яу07-3к', + 'уарэп-яу07-4н', 'уарэп-яу07-4в', 'уарэп-яу07-4к' + ] + + for device_name in device_names: + device_observers[device_name] = DeviceObserver.new() + device_observers[device_name].device_name = device_name -func on_uf_status_receive(unit_uf: Object) -> void: - var KEMS_B = ((unit_uf.status[0] >> 0) & 1) and ((unit_uf.status[0] >> 3) & 1) - var EMS_B_1 = ((unit_uf.status[0] >> 1) & 1) and ((unit_uf.status[0] >> 4) & 1) - var EMS_B_2 = ((unit_uf.status[0] >> 2) & 1) and ((unit_uf.status[0] >> 5) & 1) - var IP27B = ((unit_uf.status[2] >> 6) & 1) - var check_service: bool = KEMS_B and EMS_B_1 and EMS_B_2 and IP27B - if not _is_uf_status_initialized or check_service != is_uf_operational: - is_uf_operational = check_service - _update_serviceability_display() - signaller.emit_signal('update_uf_serviceability', check_service) - _is_uf_status_initialized = true +func _on_prd_online_changed(line_status: Object, prd_module: Object) -> void: + var online: bool = line_status.online + var observer: DeviceObserver = device_observers.get(prd_module.prd_name) + if observer and observer.update_online_state(online): + _recalculate_overall_state() + + +func _on_prd_control_results(results: Dictionary, prd_module: Object) -> void: + var observer: DeviceObserver = device_observers.get(prd_module.prd_name) + if observer and observer.update_control_results(results): + _recalculate_overall_state() + + +func _on_uf_status_receive(_unit_uf: Object) -> void: + # Логика для УФ (раскомментируй если нужно) + # var KEMS_B = ((unit_uf.status[0] >> 0) & 1) and ((unit_uf.status[0] >> 3) & 1) + # var EMS_B_1 = ((unit_uf.status[0] >> 1) & 1) and ((unit_uf.status[0] >> 4) & 1) + # var EMS_B_2 = ((unit_uf.status[0] >> 2) & 1) and ((unit_uf.status[0] >> 5) & 1) + # var IP27B = ((unit_uf.status[2] >> 6) & 1) + # var uf_operational = KEMS_B and EMS_B_1 and EMS_B_2 and IP27B + # signaller.emit_signal('update_uf_serviceability', uf_operational) + pass + + +func _recalculate_overall_state() -> void: + var new_state := PRD_STATE.NONE + var has_online_devices := false + var all_operational := true + + for observer in device_observers.values(): + if observer.status[DEVICE_STATUS.ONLINE]: + has_online_devices = true + + if observer.status[DEVICE_STATUS.CONTROL]: + # Если контроль завершен - строгая проверка + if not observer.status[DEVICE_STATUS.STATUS]: + all_operational = false + break + else: + # Если контроль в процессе - мягкая проверка + if not observer.status[DEVICE_STATUS.STATUS]: + all_operational = false + # Не прерываем, чтобы проверить все устройства + + if has_online_devices: + new_state = PRD_STATE.GOOD if all_operational else PRD_STATE.ERR + else: + new_state = PRD_STATE.NONE + + if overall_prd_state != new_state: + overall_prd_state = new_state + _update_display() + + +func _update_display() -> void: + var config: Dictionary = STATUS_CONFIG[overall_prd_state].duplicate() + + text = config.text + modulate = config.color + add_theme_color_override("font_color", config.font_color) + tooltip_text = _get_tooltip_text() + + +func _get_tooltip_text() -> String: + match overall_prd_state: + PRD_STATE.NONE: + return "Нет связи с приборами комплекса" + PRD_STATE.GOOD: + return "Все приборы комплекса исправны" + PRD_STATE.ERR: + return "Обнаружены неисправности в комплексе" + _: + return "Неизвестное состояние" + + +# Публичные методы для получения информации +func get_device_status(device_name: String) -> Dictionary: + var observer: DeviceObserver = device_observers.get(device_name) + if observer: + return { + "online": observer.status[DEVICE_STATUS.ONLINE], + "operational": observer.status[DEVICE_STATUS.STATUS], + "control_complete": observer.status[DEVICE_STATUS.CONTROL], + "last_results": observer.last_results.duplicate() + } + return {} + + +func get_overall_status() -> Dictionary: + var online_count := 0 + var operational_count := 0 + var control_complete_count := 0 + + for observer in device_observers.values(): + if observer.status[DEVICE_STATUS.ONLINE]: + online_count += 1 + if observer.status[DEVICE_STATUS.STATUS]: + operational_count += 1 + if observer.status[DEVICE_STATUS.CONTROL]: + control_complete_count += 1 + + return { + "overall_state": overall_prd_state, + "online_devices": online_count, + "operational_devices": operational_count, + "total_devices": device_observers.size(), + "control_complete_devices": control_complete_count + } diff --git a/scenes/tabs-switch/lbl_ready.gd.uid b/scenes/tabs-switch/lbl_ready.gd.uid index 6476ba86..cb970c5c 100644 --- a/scenes/tabs-switch/lbl_ready.gd.uid +++ b/scenes/tabs-switch/lbl_ready.gd.uid @@ -1 +1 @@ -uid://b5ykwyk5vpi6 +uid://b5ykwyk5vpi6 diff --git a/scenes/tabs-switch/tab-switch.tscn b/scenes/tabs-switch/tab-switch.tscn index a148f043..1c958ecf 100644 --- a/scenes/tabs-switch/tab-switch.tscn +++ b/scenes/tabs-switch/tab-switch.tscn @@ -79,25 +79,10 @@ visible = false layout_mode = 2 metadata/_tab_index = 5 -[node name="lbl_ready" type="Label" parent="."] -layout_mode = 0 -offset_left = 1503.0 -offset_right = 1600.0 -offset_bottom = 27.0 -tooltip_text = "Готовность аппаратуры к работе" -mouse_filter = 0 -theme_override_font_sizes/font_size = 14 -theme_override_styles/normal = SubResource("StyleBoxFlat_o1r22") -text = "Нет связи" -horizontal_alignment = 1 -vertical_alignment = 1 -script = ExtResource("8_tidwt") -metadata/_edit_lock_ = true - [node name="remote_control" type="Label" parent="."] layout_mode = 2 -offset_left = 1244.0 -offset_right = 1401.0 +offset_left = 1242.0 +offset_right = 1402.0 offset_bottom = 27.0 tooltip_text = "Комплекс находится под внешним управлением" mouse_filter = 0 @@ -109,7 +94,7 @@ vertical_alignment = 1 [node name="тренаж_режим" type="Button" parent="."] layout_mode = 0 -offset_left = 1404.0 +offset_left = 1405.0 offset_right = 1501.0 offset_bottom = 27.0 tooltip_text = "Задействовать режим Тренаж" @@ -125,5 +110,20 @@ toggle_mode = true text = "Тренаж" script = ExtResource("9_41d34") +[node name="lbl_ready" type="Label" parent="."] +layout_mode = 0 +offset_left = 1504.0 +offset_right = 1600.0 +offset_bottom = 27.0 +tooltip_text = "Готовность аппаратуры к работе" +mouse_filter = 0 +theme_override_font_sizes/font_size = 14 +theme_override_styles/normal = SubResource("StyleBoxFlat_o1r22") +text = "Нет связи" +horizontal_alignment = 1 +vertical_alignment = 1 +script = ExtResource("8_tidwt") +metadata/_edit_lock_ = true + [connection signal="tab_changed" from="tab_switch" to="tab_switch" method="_on_tab_changed"] -[connection signal="toggled" from="тренаж_режим" to="tab_switch" method="_on_button_trenaj_toggled"] +[connection signal="toggled" from="тренаж_режим" to="tab_switch" method="_on_button_trenazh_toggled"] diff --git a/scenes/tabs-switch/тренаж_режим.gd b/scenes/tabs-switch/тренаж_режим.gd index ace4117d..ab278048 100644 --- a/scenes/tabs-switch/тренаж_режим.gd +++ b/scenes/tabs-switch/тренаж_режим.gd @@ -1,11 +1,11 @@ -extends Button - -func _ready(): - connect("toggled", Callable(self, "_on_button_toggled")) - - -func _on_button_toggled(mode: bool): - if mode: - tooltip_text = "Режим \"Тренаж\" задействован\nТекущее состояние: включено" - else: - tooltip_text = "Задейстовать режим \"Тренаж\"\nТекущее состояние: отключено" +extends Button + +func _ready(): + connect("toggled", Callable(self, "_on_button_toggled")) + + +func _on_button_toggled(mode: bool): + if mode: + tooltip_text = "Режим \"Тренаж\" задействован\nТекущее состояние: включено" + else: + tooltip_text = "Задейстовать режим \"Тренаж\"\nТекущее состояние: отключено" diff --git a/scenes/tabs-switch/тренаж_режим.gd.uid b/scenes/tabs-switch/тренаж_режим.gd.uid index 89b2121e..5c5f1430 100644 --- a/scenes/tabs-switch/тренаж_режим.gd.uid +++ b/scenes/tabs-switch/тренаж_режим.gd.uid @@ -1 +1 @@ -uid://roajn6c6wvc1 +uid://roajn6c6wvc1 diff --git a/scenes/контроль/control_prd.gd b/scenes/контроль/control_prd.gd new file mode 100644 index 00000000..6e9a9d74 --- /dev/null +++ b/scenes/контроль/control_prd.gd @@ -0,0 +1,95 @@ +extends Button + +var base_style: StyleBoxFlat +var tween +var pulsing: bool = false +var original_text: String +var flag_control_is_over: bool = false + + +func _ready(): + original_text = text + _setup_styles() + _setup_signals() + + +func _setup_styles() -> void: + if get("theme_override_styles/disabled") == null: + base_style = StyleBoxFlat.new() + base_style.border_color = Color(1.0, 0.5, 0.0) + base_style.border_width_top = 4 + base_style.border_width_bottom = 4 + base_style.border_width_left = 4 + base_style.border_width_right = 4 + base_style.bg_color = Color(0.2, 0.2, 0.2) + set("theme_override_styles/disabled", base_style) + else: + base_style = get("theme_override_styles/disabled") + set("theme_override_colors/font_disabled_color", Color(1.0, 1.0, 1.0)) + + +func _setup_signals() -> void: + connect("pressed", Callable(self, "_on_pressed")) + + if not signaller: + return + var signals_to_connect := ["режим_работа", "режим_журнал", "режим_эмс", "режим_настройки", "режим_контроль"] + for signal_name in signals_to_connect: + if signaller.has_signal(signal_name): + signaller.connect(signal_name, Callable(self, "_on_status_change")) + + +func _on_pressed(): + disabled = true + text = "Идет выполнение контроля" + flag_control_is_over = false + _start_pulse() + + +func _start_pulse(): + if pulsing: + return + pulsing = true + tween = create_tween() + tween.set_loops() + var color1 = Color(1.0, 0.5, 0.0) # оранжевый + var color2 = Color(0.4, 0.4, 0.4) # серый + tween.tween_property(base_style, "border_color", color2, 0.5)\ + .set_trans(Tween.TRANS_SINE)\ + .set_ease(Tween.EASE_IN_OUT) + tween.tween_property(base_style, "border_color", color1, 0.5)\ + .set_trans(Tween.TRANS_SINE)\ + .set_ease(Tween.EASE_IN_OUT) + + +func _stop_pulse(): + if tween: + tween.kill() + tween = null + base_style.border_color = Color(1.0, 0.5, 0.0) + pulsing = false + disabled = false + text = original_text + tooltip_text = '' + + +func _on_status_change(): + if not flag_control_is_over: + _stop_pulse() + + +func _on_stop_control(): + var time_dict = Time.get_datetime_dict_from_system() + text = 'Контроль выполнен %02d:%02d/%02d.%02d' % [ + time_dict.hour, + time_dict.minute, + time_dict.day, + time_dict.month] + disabled = false + tooltip_text = 'Нажать для повторного контроля ' + flag_control_is_over = true + + +func _exit_tree() -> void: + if tween: + tween.kill() diff --git a/scenes/контроль/control_prd.gd.uid b/scenes/контроль/control_prd.gd.uid new file mode 100644 index 00000000..d2330c16 --- /dev/null +++ b/scenes/контроль/control_prd.gd.uid @@ -0,0 +1 @@ +uid://xjs7owe2iexn diff --git a/scenes/контроль/блок-в.tscn b/scenes/контроль/блок-в.tscn index 06dcfa85..5275bec3 100644 --- a/scenes/контроль/блок-в.tscn +++ b/scenes/контроль/блок-в.tscn @@ -35,7 +35,8 @@ signal pressed(control: PanelContainer) if not is_inside_tree(): return $margin/vbox/grid1/level7.value = v - $margin/vbox/grid1/level7.tint_progress = Color.RED if v > 70 else Color.WHITE + $margin/vbox/grid1/level7.tint_progress = Color.RED if v >= 50 else Color.GOLD if v >= 40 else Color.WHITE + on_level_changed(v, $margin/vbox/grid1/level7, value1_info) @export var min_value0: float: @@ -150,12 +151,11 @@ func _ready(): item.connect('value_changed', on_level_changed.bind(item, value0_info)) on_level_changed(item.value, item, value0_info) var level7: = $margin/vbox/grid1/level7 - level7.connect('value_changed', on_level_changed.bind(level7, value1_info)) on_level_changed(level7.value, level7, value1_info) -func on_level_changed(_val: float, item: TextureProgressBar, info: String): - item.tooltip_text = '%s\\nТекущее: %0.2f\\nДиапазон: %0.2f…%0.2f' % [info, item.value, item.min_value, item.max_value] +func on_level_changed(val: float, item: TextureProgressBar, info: String): + item.tooltip_text = '%s\\nТекущее: %0.2f\\nДиапазон: %0.2f…%0.2f' % [info, val, item.min_value, item.max_value] func set_group_param(items: Array, param: StringName, v) -> void: @@ -191,8 +191,8 @@ func _enter_tree_defered(): $margin/vbox/grid0/rname.text = rname $margin/vbox/grid0/fname.text = fname $margin/vbox/grid0/state.texture = textures[state] - else: - push_warning('обращение к %s вне дерева' % self) + #else: + #push_warning('обращение к %s вне дерева' % self) TODO: пишеться только когда заходишь в проект а дальше не используется func get_level_nodes() -> Array: @@ -273,10 +273,9 @@ theme_override_styles/panel = SubResource("StyleBoxEmpty_3nd2u") script = SubResource("GDScript_oj3k3") textures = [ExtResource("1_n1aqt"), ExtResource("2_rim3u"), ExtResource("3_3w8fg")] value0 = [20.0, 30.0, 40.0, 50.0, 60.0, 70.0] -value1 = 56.0 -min_value1 = -50.0 -max_value0 = 100.0 -max_value1 = 120.0 +min_value1 = -40.0 +max_value0 = 1400.0 +max_value1 = 55.0 step0 = 1.0 step1 = 1.0 value_name0 = "P,%" @@ -476,12 +475,11 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 tooltip_text = " -Текущее: 56.00 -Диапазон: -50.00…120.00" +Текущее: 0.00 +Диапазон: -40.00…55.00" mouse_filter = 0 -min_value = -50.0 -max_value = 120.0 -value = 56.0 +min_value = -40.0 +max_value = 55.0 fill_mode = 3 nine_patch_stretch = true stretch_margin_left = 8 diff --git a/scenes/контроль/блок-к.tscn b/scenes/контроль/блок-к.tscn new file mode 100644 index 00000000..6ffeb644 --- /dev/null +++ b/scenes/контроль/блок-к.tscn @@ -0,0 +1,410 @@ +[gd_scene load_steps=15 format=3 uid="uid://ffi1njkjceb5"] + +[ext_resource type="Texture2D" uid="uid://c6nve6f8sfyj2" path="res://data/состояние-исправности-0.png" id="1_uojqc"] +[ext_resource type="Texture2D" uid="uid://dnreyfh3cd1k2" path="res://data/состояние-исправности-1.png" id="2_a8ar3"] +[ext_resource type="Texture2D" uid="uid://c6booa8753u5t" path="res://data/состояние-исправности-2.png" id="3_xwd13"] +[ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="4_eobkx"] +[ext_resource type="Texture2D" uid="uid://00871pb6moln" path="res://data/прогресс-фон-1.png" id="5_mg57e"] +[ext_resource type="Texture2D" uid="uid://c1k856fxhrjnh" path="res://data/прогресс-заполнение-1.png" id="6_of7rd"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_3nd2u"] + +[sub_resource type="GDScript" id="GDScript_oj3k3"] +script/source = "@tool +class_name blok_v extends PanelContainer + +@export var textures: Array +@export var animation_duration: float = 1.5 +signal pressed(control: PanelContainer) + + +## Значения уровней +@export var value0: Array: + set(v): + value0.assign(v) + var items: Array = get_level_nodes() + var count: int = min(items.size(), v.size()) + for i in count: + set_value0_animated(items[i], v[i]) + + +## Значение уровня +@export var value1: float: + set(v): + value1 = v + if not is_inside_tree(): + return + $margin/vbox/grid1/level7.value = v + $margin/vbox/grid1/level7.tint_progress = Color.RED if v >= 50 else Color.GOLD if v >= 40 else Color.WHITE + on_level_changed(v, $margin/vbox/grid1/level7, value1_info) + + +@export var min_value0: float: + set(v): + min_value0 = v + var items: = get_level_nodes() + set_group_param(items, 'min_value', v) + + +@export var min_value1: float: + set(v): + min_value1 = v + if not is_inside_tree(): + return + $margin/vbox/grid1/level7.min_value = v + + +@export var max_value0: float: + set(v): + max_value0 = v + var items: = get_level_nodes() + set_group_param(items, 'max_value', v) + + +@export var max_value1: float: + set(v): + max_value1 = v + if not is_inside_tree(): + return + $margin/vbox/grid1/level7.max_value = v + + +@export var step0: float: + set(v): + step0 = v + var items: = get_level_nodes() + set_group_param(items, 'step', v) + + +@export var step1: float: + set(v): + step1 = v + if not is_inside_tree(): + return + $margin/vbox/grid1/level7.step = v + + +@export var value_name0: String: + set(v): + value_name0 = v + var items: Array = get_name_nodes() + set_group_param(items, 'text', v) + + +@export var value_name1: String: + set(v): + value_name1 = v + if not is_inside_tree(): + return + $margin/vbox/grid2/lbl7.text = v + + +@export var fname: String: + set(v): + fname = v + if not is_inside_tree(): + return + $margin/vbox/grid0/fname.text = v + + +@export var rname: String: + set(v): + rname = v + if not is_inside_tree(): + return + $margin/vbox/grid0/rname.text = v + + +@export var state: int: + set(v): + state = tools.clip_value(v, 0, textures.size() - 1) + if not is_inside_tree(): + return + $margin/vbox/grid0/state.texture = textures[state] + + +@export var alignment: int: + set(v): + alignment = v + if is_inside_tree(): + $margin/vbox.alignment = v + + +@export var value0_info: String: + set(v): + value0_info = v + + +@export var value1_info: String: + set(v): + value1_info = v + + +func _on_button_pressed(): emit_signal('pressed', self) +func set_value0(value: Array): value0.assign(value) +func _enter_tree() -> void: call_deferred('_enter_tree_defered') + + +func _ready(): + var items: Array = get_level_nodes() + for item in items: + item.connect('value_changed', on_level_changed.bind(item, value0_info)) + on_level_changed(item.value, item, value0_info) + var level7: = $margin/vbox/grid1/level7 + on_level_changed(level7.value, level7, value1_info) + + +func on_level_changed(val: float, item: TextureProgressBar, info: String): + item.tooltip_text = '%s\\nТекущее: %0.2f\\nДиапазон: %0.2f…%0.2f' % [info, val, item.min_value, item.max_value] + + +func set_group_param(items: Array, param: StringName, v) -> void: + if not is_inside_tree(): + return + if not get_tree(): + return + for i in items.size(): + items[i].set(param, v) + + +func set_value0_by_index(index: int, value: float) -> void: + var items: Array = get_level_nodes() + items[index].value = value + + +func _enter_tree_defered(): + var items: Array = get_level_nodes() + var count: int = min(items.size(), value0.size()) + for i in count: + items[i].min_value = min_value0 + items[i].max_value = 1400 # max_value0: TODO для отладки + items[i].step = step0 + items = get_name_nodes() + set_group_param(items, 'text', value_name0) + if is_inside_tree(): + $margin/vbox/grid1/level7.value = value1 + $margin/vbox/grid1/level7.min_value = min_value1 + $margin/vbox/grid1/level7.max_value = max_value1 + $margin/vbox/grid1/level7.step = step1 + $margin/vbox/grid2/lbl7.text = value_name1 + $margin/vbox.alignment = alignment + $margin/vbox/grid0/rname.text = rname + $margin/vbox/grid0/fname.text = fname + $margin/vbox/grid0/state.texture = textures[state] + + +func get_level_nodes() -> Array: + if not is_inside_tree(): + return [] + if not get_tree(): + return [] + return [$margin/vbox/grid1/level1] + + +func get_name_nodes() -> Array: + if not is_inside_tree(): + return [] + if not get_tree(): + return [] + return [$margin/vbox/grid2/lbl1] + + +func set_value0_animated(target_node, target_value: float) -> void: + var tween: Tween = create_tween() + tween.set_ease(Tween.EASE_OUT) + tween.set_trans(Tween.TRANS_QUINT) + tween.tween_property(target_node, 'value', target_value, animation_duration) +" + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_rceim"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8yvwo"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6qu57"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_mlxje"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_3dspb"] + +[sub_resource type="GDScript" id="GDScript_45hqb"] +script/source = "@tool + +extends MarginContainer + + +func _enter_tree() -> void: + margins = [8, 8, 8, 8] + + +@export var margins: Array: + set(vals): + add_theme_constant_override('margin_top', vals[0]) + add_theme_constant_override('margin_left', vals[1]) + add_theme_constant_override('margin_bottom', vals[2]) + add_theme_constant_override('margin_right', vals[3]) + get: + var vals = [0, 0, 0, 0] + vals[0] = get_theme_constant('margin_top') + vals[1] = get_theme_constant('margin_left') + vals[2] = get_theme_constant('margin_bottom') + vals[3] = get_theme_constant('margin_right') + return vals +" + +[node name="блок-к" type="PanelContainer"] +editor_description = "Элемент замены из ЗИП" +offset_right = 160.0 +offset_bottom = 88.0 +theme_override_styles/panel = SubResource("StyleBoxEmpty_3nd2u") +script = SubResource("GDScript_oj3k3") +textures = [ExtResource("1_uojqc"), ExtResource("2_a8ar3"), ExtResource("3_xwd13")] +value0 = [20.0, 30.0, 40.0, 50.0, 60.0, 70.0] +value1 = -40.0 +min_value1 = -40.0 +max_value0 = 1400.0 +max_value1 = 55.0 +step0 = 1.0 +step1 = 1.0 +value_name0 = "P,%" +value_name1 = "°C" +fname = "Блок В" +rname = "A1" + +[node name="button" type="Button" parent="."] +layout_mode = 2 +theme_override_styles/focus = SubResource("StyleBoxEmpty_rceim") +theme_override_styles/disabled = SubResource("StyleBoxEmpty_8yvwo") +theme_override_styles/hover = SubResource("StyleBoxEmpty_6qu57") +theme_override_styles/pressed = SubResource("StyleBoxEmpty_mlxje") +theme_override_styles/normal = SubResource("StyleBoxEmpty_3dspb") + +[node name="rect" type="NinePatchRect" parent="."] +layout_mode = 2 +texture = ExtResource("4_eobkx") +draw_center = false +region_rect = Rect2(0, 0, 63, 63) +patch_margin_left = 17 +patch_margin_top = 17 +patch_margin_right = 17 +patch_margin_bottom = 15 + +[node name="margin" type="MarginContainer" parent="."] +layout_mode = 2 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 8 +script = SubResource("GDScript_45hqb") +margins = [8, 8, 8, 8] + +[node name="vbox" type="VBoxContainer" parent="margin"] +layout_mode = 2 + +[node name="grid0" type="GridContainer" parent="margin/vbox"] +layout_mode = 2 +columns = 3 + +[node name="state" type="TextureRect" parent="margin/vbox/grid0"] +custom_minimum_size = Vector2(24, 24) +layout_mode = 2 +size_flags_horizontal = 2 +size_flags_vertical = 6 +texture = ExtResource("1_uojqc") +expand_mode = 1 + +[node name="fname" type="Label" parent="margin/vbox/grid0"] +self_modulate = Color(1, 1, 1, 0.627451) +custom_minimum_size = Vector2(0, 20) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +theme_override_font_sizes/font_size = 17 +text = "Блок В" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="rname" type="Label" parent="margin/vbox/grid0"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 6 +theme_override_font_sizes/font_size = 18 +text = "A1" +horizontal_alignment = 2 +vertical_alignment = 1 + +[node name="grid1" type="GridContainer" parent="margin/vbox"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 3 +columns = 7 + +[node name="level1" type="TextureProgressBar" parent="margin/vbox/grid1" groups=["уровни"]] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00 +Диапазон: 0.00…1400.00" +mouse_filter = 0 +max_value = 1400.0 +fill_mode = 3 +nine_patch_stretch = true +stretch_margin_left = 8 +stretch_margin_top = 8 +stretch_margin_right = 8 +stretch_margin_bottom = 8 +texture_under = ExtResource("5_mg57e") +texture_progress = ExtResource("6_of7rd") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + +[node name="level7" type="TextureProgressBar" parent="margin/vbox/grid1"] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: -40.00 +Диапазон: -40.00…55.00" +mouse_filter = 0 +min_value = -40.0 +max_value = 55.0 +value = -40.0 +fill_mode = 3 +nine_patch_stretch = true +stretch_margin_left = 8 +stretch_margin_top = 8 +stretch_margin_right = 8 +stretch_margin_bottom = 8 +texture_under = ExtResource("5_mg57e") +texture_progress = ExtResource("6_of7rd") +tint_under = Color(0.890196, 0.486275, 0.196078, 1) +tint_over = Color(0.890196, 0.486275, 0.196078, 1) + +[node name="grid2" type="GridContainer" parent="margin/vbox"] +clip_contents = true +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +columns = 7 + +[node name="lbl1" type="Label" parent="margin/vbox/grid2" groups=["названия"]] +clip_contents = true +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_font_sizes/font_size = 8 +text = "P,%" +horizontal_alignment = 1 + +[node name="lbl7" type="Label" parent="margin/vbox/grid2"] +clip_contents = true +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_font_sizes/font_size = 8 +text = "°C" +horizontal_alignment = 1 + +[connection signal="pressed" from="button" to="." method="_on_button_pressed"] diff --git a/scenes/контроль/кассета-п-2.tscn b/scenes/контроль/кассета-п-2.tscn index a265d9d7..cf2dd65a 100644 --- a/scenes/контроль/кассета-п-2.tscn +++ b/scenes/контроль/кассета-п-2.tscn @@ -14,7 +14,7 @@ patch_margin_right = 16 patch_margin_bottom = 16 script = ExtResource("2_mdnod") -[node name="ref_A26" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("3_4a27g")] +[node name="ref_A26" parent="." groups=["power_supply"] instance=ExtResource("3_4a27g")] offset_left = 10.0 offset_top = 30.0 offset_right = 60.0 @@ -23,7 +23,7 @@ fname = "ИП9-50" rname = "A22" metadata/ip = "ip9_50_3" -[node name="ref_A23" parent="." groups=["default_reset", "power_supply"] instance=ExtResource("3_4a27g")] +[node name="ref_A23" parent="." groups=["power_supply"] instance=ExtResource("3_4a27g")] offset_left = 60.0 offset_top = 30.0 offset_right = 110.0 @@ -35,9 +35,10 @@ metadata/ip = "ip12_50_2" [node name="lbl_fname" type="Label" parent="."] self_modulate = Color(1, 1, 1, 0.62) layout_mode = 0 -offset_left = 5.0 +offset_left = 8.0 offset_top = 5.0 -offset_right = 105.0 +offset_right = 112.0 offset_bottom = 30.0 +text = "Касета П-2" horizontal_alignment = 1 vertical_alignment = 1 diff --git a/scenes/контроль/кассета-у-5-нв.tscn b/scenes/контроль/кассета-у-5-нв.tscn index dad7c794..011731bb 100644 --- a/scenes/контроль/кассета-у-5-нв.tscn +++ b/scenes/контроль/кассета-у-5-нв.tscn @@ -31,7 +31,7 @@ offset_top = 32.0 offset_right = 55.0 offset_bottom = 182.0 fname = "ИП5-25" -rname = "A24" +rname = "A31" metadata/ip = "ip5_25" [node name="ref_A30" parent="." groups=["y-5"] instance=ExtResource("3_picsk")] @@ -40,7 +40,7 @@ offset_top = 32.0 offset_right = 105.0 offset_bottom = 182.0 fname = "ЯУ-07Б" -rname = "A30" +rname = "A37" metadata/y5 = "yau07" [node name="ref_A26" parent="." groups=["y-5"] instance=ExtResource("3_picsk")] @@ -49,7 +49,7 @@ offset_top = 32.0 offset_right = 155.0 offset_bottom = 182.0 fname = "ЭМС-Г" -rname = "A26" +rname = "A33" metadata/y5 = "ems" [node name="ref_A27" parent="." groups=["y-5"] instance=ExtResource("3_picsk")] @@ -58,7 +58,7 @@ offset_top = 32.0 offset_right = 205.0 offset_bottom = 182.0 fname = "УГ" -rname = "A27" +rname = "A34" metadata/y5 = "ug" [node name="ref_A28" parent="." groups=["y-5"] instance=ExtResource("3_picsk")] @@ -67,7 +67,7 @@ offset_top = 32.0 offset_right = 255.0 offset_bottom = 182.0 fname = "УКП" -rname = "A28" +rname = "A36" metadata/y5 = "ukp1" [node name="ref_A29" parent="." groups=["y-5"] instance=ExtResource("3_picsk")] @@ -76,5 +76,5 @@ offset_top = 32.0 offset_right = 304.0 offset_bottom = 182.0 fname = "УКП" -rname = "A29" +rname = "A35" metadata/y5 = "ukp2" diff --git a/scenes/контроль/контроль.tscn b/scenes/контроль/контроль.tscn index 7ca15a0a..792d41eb 100644 --- a/scenes/контроль/контроль.tscn +++ b/scenes/контроль/контроль.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=26 format=3 uid="uid://lwmw4egynmd1"] +[gd_scene load_steps=30 format=3 uid="uid://lwmw4egynmd1"] [ext_resource type="Texture2D" uid="uid://bar8k5qef7kch" path="res://data/УФ.png" id="2_0nvm1"] [ext_resource type="Script" uid="uid://q3gmpsqspjfp" path="res://scenes/контроль/внешний.gd" id="2_8r80x"] @@ -16,12 +16,16 @@ [ext_resource type="Texture2D" uid="uid://b4isaggma6q3" path="res://data/Грани22.png" id="9_iqgf5"] [ext_resource type="Texture2D" uid="uid://c6booa8753u5t" path="res://data/состояние-исправности-2.png" id="9_ll0vs"] [ext_resource type="Texture2D" uid="uid://bktiige0i2lhl" path="res://data/У-РЭП-РПД-Н.png" id="9_qe1go"] -[ext_resource type="Texture2D" uid="uid://b2vf7en1jj8dv" path="res://data/У-РЭП-РПД-В.png" id="9_w6m6a"] +[ext_resource type="Texture2D" uid="uid://00871pb6moln" path="res://data/прогресс-фон-1.png" id="9_w6m6a"] +[ext_resource type="Texture2D" uid="uid://c1k856fxhrjnh" path="res://data/прогресс-заполнение-1.png" id="10_lbx5w"] [ext_resource type="Texture2D" uid="uid://u7h3l0jjrsnp" path="res://data/У-УФ.png" id="11_gjf0t"] [ext_resource type="Script" uid="uid://bncy1x53jp73d" path="res://scenes/контроль/connect_pribor.gd" id="11_u7tym"] [ext_resource type="Texture2D" uid="uid://vdhmga62vjsj" path="res://data/АФСП-РТР.png" id="13_32yvq"] [ext_resource type="Texture2D" uid="uid://dm350ta8noa0v" path="res://data/У-РЭП-РПД-К.png" id="16_32yvq"] [ext_resource type="Texture2D" uid="uid://c3cyog3gy24ft" path="res://data/У-ЭП.png" id="16_gjf0t"] +[ext_resource type="Script" uid="uid://xjs7owe2iexn" path="res://scenes/контроль/control_prd.gd" id="18_lbx5w"] +[ext_resource type="Texture2D" uid="uid://b2vf7en1jj8dv" path="res://data/У-РЭП-РПД-В.png" id="20_l5wui"] +[ext_resource type="Texture2D" uid="uid://cllxcfa130vqu" path="res://data/УА-РЭП.png" id="22_1s34a"] [sub_resource type="GDScript" id="GDScript_iqgf5"] script/source = "extends Panel @@ -50,9 +54,10 @@ const PRIBORS_RES = \\ 'pribor_uf': ['res://scenes/pribor-uf/pribor-uf.tscn', 'Контроль исправности прибора УФ'], 'pribor_uyep': ['res://scenes/pribor-uyep/pribor-uyep.tscn', 'Контроль исправности устройства У-ЭП'], } - - +var ctl_btn_state := false var cur_pribor_node = null +var check_ready_control: Dictionary = {} +var device_wait_control_result:Array = ['1н', '2н', '3н', '4н', '1в', '2в', '3в', '4в', '1к', '2к', '3к', '4к'] func on_line_changed(u, conn_node, _pribor_meta): conn_node.set_val(u.online) @@ -62,6 +67,8 @@ func on_serv_changed(u, pribor_node, _pribor_meta): pribor_node.state = int(u.se func on_mode_changed(): clean_pribor_items() reset_pribor_buttons() + $chk_show_functional.visible = false + $chk_show_functional.button_pressed = false func reset_pribor_buttons(): @@ -94,9 +101,13 @@ func _ready(): for item in unit_names: if prd.prd_dict.has(item): var prd_module = prd.prd_dict[item] - prd_module.connect('update_serviceability', Callable(self, 'on_serviceability_changed').bind(prd_module, pribor_node)) + prd_module.connect('update_serviceability', Callable(self, 'on_serviceability_changed').bind(pribor_node)) + prd_module.unit_control.connect('update_progress', Callable(self, 'on_update_progress').bind(pribor_node)) + prd_module.unit_control.connect('update_max_value_progress', Callable(self, 'on_update_max_value_progress').bind(pribor_node)) + prd_module.unit_control.connect('control_is_over', Callable(self, 'on_control_is_over')) if item == 'уарэп-эмс': signaller.connect('update_uf_serviceability', Callable(self, 'on_update_uf_serviceability').bind(pribor_node)) + # Пиктограммы приборов, которые отображают состояние подключения только for pribor_node in get_tree().get_nodes_in_group('pribor_pics'): var unit_name = pribor_node.get_meta('unit_name') @@ -108,6 +119,7 @@ func _ready(): signaller.conn(signaller.режим_журнал, on_mode_changed) signaller.conn(signaller.режим_настройки, on_mode_changed) signaller.conn(signaller.режим_эмс, on_mode_changed) + signaller.connect('debag_control_pressed', Callable(self, 'on_control_button_pressed')) func online_change_arr(_u, conn_node, pribor_meta): @@ -142,20 +154,19 @@ func on_pribor_press(pribor_path, header_text, pribor_node): push_error('экземпляр не создан: \\\"%s\\\" (%s)' % [pribor_path, header_text]) return $lbl_header.text = header_text - $chk_show_functional.disabled = false + $chk_show_functional.visible = true var meta_list = pribor_node.get_meta_list() if meta_list.find('unit_name') > -1: var unit_name = pribor_node.get_meta('unit_name') pribor.set_meta('unit_name', unit_name) pribor.add_to_group('pribor_items') add_child(pribor) + update_pribor_items_visibility() -func on_serviceability_changed(prd_module: Object, prd_pribor:Node)-> void: - if not prd_module.unit_yau07.online: - prd_pribor.state = 0 - return - prd_pribor.state = 1 if prd_module.serviceability else 2 +## Прием сигналов о текущем состояниях приборах +func on_serviceability_changed(state: int, prd_pribor_node: Node)-> void: + prd_pribor_node.state = state func on_update_uf_serviceability(uf_serviceaability: bool, uf_pribor: Node)-> void: @@ -165,6 +176,64 @@ func on_update_uf_serviceability(uf_serviceaability: bool, uf_pribor: Node)-> vo func _on_chk_show_functional_toggled(toggled_on: bool) -> void: if cur_pribor_node: cur_pribor_node.show_functional = toggled_on + + +func _on_control_prd_pressed() -> void: + check_ready_control = {} + for pribor in get_tree().get_nodes_in_group('pribor_buttons'): + pribor.state = 0 # NONE + signaller.emit_signal('start_contol_device') + + +func on_update_progress(value_progress: float, pribor_node: Node) -> void: + pribor_node.progress_value = value_progress + pribor_node.progress_visible = value_progress > 0 + + +func on_update_max_value_progress(max_value_progress: int, pribor_node: Node) -> void: + pribor_node.progress_max_value = max_value_progress + + +func on_control_is_over(pribor_name: String) -> void: + if pribor_name in device_wait_control_result: + check_ready_control[pribor_name] = true + if not _is_all_control_complete(): return + # После завершения контроля всех приборов + $control_prd_button._on_stop_control() + + +func _is_all_control_complete() -> bool: + for device in device_wait_control_result: + if not check_ready_control.get(device, false): + return false + return true + + +func _on_gui_input(event: InputEvent) -> void: + if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: + if cur_pribor_node: + cur_pribor_node.show_functional = false + var pribor_buttons := get_tree().get_nodes_in_group('pribor_buttons') + for node in pribor_buttons: + node.button_pressed = false + clean_pribor_items() + cur_pribor_node = null + $chk_show_functional.button_pressed = false + $chk_show_functional.visible = false + $lbl_header.text = \"\" + + +func on_control_button_pressed(state: bool) -> void: + ctl_btn_state = state + update_pribor_items_visibility() + + +func update_pribor_items_visibility(): + var pribor_items = get_tree().get_nodes_in_group('pribor_items') + for pribor in pribor_items: + for child_name in ['input_0', 'output_0', 'input_1', 'output_1', 'input_2', 'output_2']: + if pribor.has_node(child_name): + pribor.get_node(child_name).visible = ctl_btn_state " [sub_resource type="SpriteFrames" id="SpriteFrames_foasq"] @@ -202,9 +271,9 @@ metadata/_edit_horizontal_guides_ = [200.0, 51.0] editor_description = "Кнопка для отображения внешних соединений." self_modulate = Color(0.788235, 0.788235, 0.788235, 1) layout_mode = 0 -offset_left = 959.0 +offset_left = 945.0 offset_top = 1021.0 -offset_right = 1215.0 +offset_right = 1201.0 offset_bottom = 1277.0 scale = Vector2(0.25, 0.25) size_flags_horizontal = 15 @@ -236,9 +305,9 @@ script = ExtResource("11_u7tym") editor_description = "Кнопка для отображения внешних соединений." self_modulate = Color(0.788235, 0.788235, 0.788235, 1) layout_mode = 0 -offset_left = 1088.0 +offset_left = 1074.0 offset_top = 1021.0 -offset_right = 1344.0 +offset_right = 1330.0 offset_bottom = 1277.0 scale = Vector2(0.25, 0.25) size_flags_horizontal = 15 @@ -271,9 +340,9 @@ script = ExtResource("11_u7tym") editor_description = "Кнопка для отображения внешних соединений." self_modulate = Color(0.788235, 0.788235, 0.788235, 1) layout_mode = 0 -offset_left = 1216.0 +offset_left = 1202.0 offset_top = 1021.0 -offset_right = 1472.0 +offset_right = 1458.0 offset_bottom = 1277.0 scale = Vector2(0.25, 0.25) size_flags_horizontal = 15 @@ -306,9 +375,9 @@ script = ExtResource("11_u7tym") editor_description = "Кнопка для отображения внешних соединений." self_modulate = Color(0.788235, 0.788235, 0.788235, 1) layout_mode = 0 -offset_left = 1344.0 +offset_left = 1330.0 offset_top = 1021.0 -offset_right = 1600.0 +offset_right = 1586.0 offset_bottom = 1277.0 scale = Vector2(0.25, 0.25) size_flags_horizontal = 15 @@ -341,9 +410,9 @@ script = ExtResource("11_u7tym") editor_description = "Кнопка для отображения внешних соединений." self_modulate = Color(0.788235, 0.788235, 0.788235, 1) layout_mode = 0 -offset_left = 1472.0 +offset_left = 1458.0 offset_top = 1021.0 -offset_right = 1728.0 +offset_right = 1714.0 offset_bottom = 1277.0 scale = Vector2(0.25, 0.25) size_flags_horizontal = 15 @@ -376,9 +445,9 @@ script = ExtResource("11_u7tym") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1048.0 -offset_top = 193.0 +offset_top = 179.0 offset_right = 1125.0 -offset_bottom = 309.0 +offset_bottom = 295.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -394,9 +463,9 @@ metadata/unit_name = ["уарэп-яу07-1н"] [node name="label" type="Label" parent="pribor_prd_n_1"] layout_mode = 0 offset_left = 8.0 -offset_top = -38.0 +offset_top = -40.0 offset_right = 60.0 -offset_bottom = -19.0 +offset_bottom = -21.0 text = "ПРД Н1" horizontal_alignment = 1 vertical_alignment = 1 @@ -417,7 +486,6 @@ patch_margin_right = 16 patch_margin_bottom = 16 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_prd_n_1"] -visible = false light_mask = 3 position = Vector2(35, -10) scale = Vector2(0.625, 0.625) @@ -425,6 +493,29 @@ sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_n_1"] +visible = false +layout_mode = 0 +offset_left = -4.0 +offset_top = 124.0 +offset_right = 89.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_n_1"] visible = false z_index = 1 @@ -441,9 +532,9 @@ texture = ExtResource("9_qe1go") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1183.0 -offset_top = 565.0 +offset_top = 558.0 offset_right = 1294.0 -offset_bottom = 750.0 +offset_bottom = 743.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -452,17 +543,15 @@ texture_normal = ExtResource("2_0nvm1") stretch_mode = 0 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -state = 1 metadata/unit_name = ["уарэп-эмс"] metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_uf"] -self_modulate = Color(0, 1, 0, 1) layout_mode = 0 offset_left = 15.0 -offset_top = -34.0 +offset_top = -44.0 offset_right = 91.0 -offset_bottom = -15.0 +offset_bottom = -25.0 text = "УФ" horizontal_alignment = 1 vertical_alignment = 1 @@ -506,9 +595,9 @@ texture = ExtResource("11_gjf0t") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1058.0 -offset_top = 595.0 +offset_top = 588.0 offset_right = 1164.0 -offset_bottom = 751.0 +offset_bottom = 744.0 pivot_offset = Vector2(-10, -65) size_flags_horizontal = 15 size_flags_vertical = 15 @@ -523,10 +612,10 @@ metadata/online_proc = "online_change_arr" [node name="label" type="Label" parent="pribor_rtr"] layout_mode = 0 -offset_left = 12.0 -offset_top = -54.0 -offset_right = 95.0 -offset_bottom = -35.0 +offset_left = 11.0 +offset_top = -49.0 +offset_right = 94.0 +offset_bottom = -30.0 text = "РТР" horizontal_alignment = 1 vertical_alignment = 1 @@ -548,17 +637,17 @@ patch_margin_bottom = 16 [node name="label2" type="Label" parent="pribor_rtr"] layout_mode = 0 -offset_left = 12.0 -offset_top = -54.0 -offset_right = 95.0 -offset_bottom = -35.0 +offset_left = 11.0 +offset_top = -49.0 +offset_right = 94.0 +offset_bottom = -30.0 text = "РТР" horizontal_alignment = 1 vertical_alignment = 1 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_rtr"] light_mask = 3 -position = Vector2(55, -15) +position = Vector2(53, -15) scale = Vector2(0.625, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 @@ -580,9 +669,9 @@ texture = ExtResource("13_32yvq") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1053.0 -offset_top = 432.0 +offset_top = 425.0 offset_right = 1886.0 -offset_bottom = 1072.0 +offset_bottom = 1065.0 scale = Vector2(0.2, 0.2) pivot_offset = Vector2(-10, -65) size_flags_horizontal = 15 @@ -598,9 +687,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_afsp_1"] layout_mode = 0 -offset_left = 165.0 +offset_left = 175.0 offset_top = -245.0 -offset_right = 262.0 +offset_right = 272.0 offset_bottom = -225.0 scale = Vector2(5, 5) text = "АФСП 1" @@ -625,9 +714,9 @@ patch_margin_bottom = 16 [node name="label2" type="Label" parent="pribor_afsp_1"] layout_mode = 0 -offset_left = 165.0 +offset_left = 175.0 offset_top = -245.0 -offset_right = 262.0 +offset_right = 272.0 offset_bottom = -225.0 scale = Vector2(5, 5) text = "АФСП 1" @@ -658,9 +747,9 @@ texture = ExtResource("13_32yvq") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1243.0 -offset_top = 432.0 +offset_top = 425.0 offset_right = 2076.0 -offset_bottom = 1072.0 +offset_bottom = 1065.0 scale = Vector2(0.2, 0.2) pivot_offset = Vector2(-10, -65) size_flags_horizontal = 15 @@ -677,9 +766,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_afsp_2"] layout_mode = 0 -offset_left = 200.0 +offset_left = 175.0 offset_top = -240.0 -offset_right = 297.0 +offset_right = 272.0 offset_bottom = -220.0 scale = Vector2(5, 5) text = "АФСП 2" @@ -704,9 +793,9 @@ patch_margin_bottom = 16 [node name="label2" type="Label" parent="pribor_afsp_2"] layout_mode = 0 -offset_left = 200.0 +offset_left = 175.0 offset_top = -240.0 -offset_right = 297.0 +offset_right = 272.0 offset_bottom = -220.0 scale = Vector2(5, 5) text = "АФСП 2" @@ -715,7 +804,7 @@ vertical_alignment = 1 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_afsp_2"] light_mask = 3 -position = Vector2(425, -40) +position = Vector2(415, -40) scale = Vector2(3, 3) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 @@ -737,9 +826,9 @@ texture = ExtResource("13_32yvq") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1313.0 -offset_top = 565.0 +offset_top = 558.0 offset_right = 1407.0 -offset_bottom = 751.0 +offset_bottom = 744.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -754,9 +843,9 @@ metadata/online_proc = "online_change_arr" [node name="label" type="Label" parent="pribor_uyep"] layout_mode = 0 offset_left = 26.8566 -offset_top = -38.3276 +offset_top = -43.3276 offset_right = 66.8566 -offset_bottom = -19.3276 +offset_bottom = -24.3276 text = "У-ЭП" horizontal_alignment = 1 vertical_alignment = 1 @@ -800,9 +889,9 @@ texture = ExtResource("16_gjf0t") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1440.0 -offset_top = 680.0 +offset_top = 687.0 offset_right = 1517.0 -offset_bottom = 796.0 +offset_bottom = 803.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -817,10 +906,10 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_2"] layout_mode = 0 -offset_left = 14.0 -offset_top = -38.0 -offset_right = 66.0 -offset_bottom = -19.0 +offset_left = 11.0 +offset_top = -42.0 +offset_right = 63.0 +offset_bottom = -23.0 text = "ПРД В2" horizontal_alignment = 1 vertical_alignment = 1 @@ -842,12 +931,35 @@ patch_margin_bottom = 16 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_prd_v_2"] light_mask = 3 -position = Vector2(40, -10) +position = Vector2(37, -10) scale = Vector2(0.625, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_v_2"] +visible = false +layout_mode = 0 +offset_left = -4.0 +offset_top = 124.0 +offset_right = 89.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_v_2"] visible = false z_index = 1 @@ -858,15 +970,15 @@ offset_top = -480.0 offset_right = 173.0 offset_bottom = 328.0 scale = Vector2(0.977411, 0.977411) -texture = ExtResource("9_w6m6a") +texture = ExtResource("20_l5wui") [node name="pribor_prd_n_2" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1440.0 -offset_top = 345.0 +offset_top = 322.0 offset_right = 1517.0 -offset_bottom = 461.0 +offset_bottom = 438.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -881,10 +993,10 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_n_2"] layout_mode = 0 -offset_left = 15.0 -offset_top = -38.0 -offset_right = 67.0 -offset_bottom = -19.0 +offset_left = 11.0 +offset_top = -42.0 +offset_right = 63.0 +offset_bottom = -23.0 theme_override_colors/font_outline_color = Color(0, 0, 0, 1) theme_override_constants/outline_size = 0 text = "ПРД Н2" @@ -907,9 +1019,8 @@ patch_margin_right = 16 patch_margin_bottom = 16 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_prd_n_2"] -visible = false light_mask = 3 -position = Vector2(40, -10) +position = Vector2(37, -10) scale = Vector2(0.625, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 @@ -927,13 +1038,36 @@ offset_bottom = 676.0 scale = Vector2(0.96888, 0.96888) texture = ExtResource("9_qe1go") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_n_2"] +visible = false +layout_mode = 0 +offset_left = -4.0 +offset_top = 124.0 +offset_right = 89.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pribor_prd_k_2" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1440.0 -offset_top = 515.0 +offset_top = 504.0 offset_right = 1517.0 -offset_bottom = 631.0 +offset_bottom = 620.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -948,10 +1082,10 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_2"] layout_mode = 0 -offset_left = 17.0 -offset_top = -38.0 -offset_right = 69.0 -offset_bottom = -19.0 +offset_left = 11.0 +offset_top = -42.0 +offset_right = 63.0 +offset_bottom = -23.0 text = "ПРД К2" horizontal_alignment = 1 vertical_alignment = 1 @@ -973,7 +1107,7 @@ patch_margin_bottom = 16 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_prd_k_2"] light_mask = 3 -position = Vector2(43, -10) +position = Vector2(37, -10) scale = Vector2(0.625, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 @@ -991,13 +1125,36 @@ offset_bottom = 649.0 scale = Vector2(0.881522, 0.881522) texture = ExtResource("16_32yvq") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_k_2"] +visible = false +layout_mode = 0 +offset_left = -4.0 +offset_top = 124.0 +offset_right = 89.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pribor_prd_v_3" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1048.0 -offset_top = 802.0 +offset_top = 803.0 offset_right = 1125.0 -offset_bottom = 918.0 +offset_bottom = 919.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1013,9 +1170,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_3"] layout_mode = 0 offset_left = 9.0 -offset_top = -38.0 +offset_top = -41.0 offset_right = 61.0 -offset_bottom = -19.0 +offset_bottom = -22.0 text = "ПРД В3" horizontal_alignment = 1 vertical_alignment = 1 @@ -1037,12 +1194,35 @@ patch_margin_bottom = 16 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_prd_v_3"] light_mask = 3 -position = Vector2(34, -10) +position = Vector2(35, -10) scale = Vector2(0.625, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_v_3"] +visible = false +layout_mode = 0 +offset_left = -8.0 +offset_top = 124.0 +offset_right = 85.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_v_3"] visible = false z_index = 1 @@ -1053,15 +1233,15 @@ offset_top = -601.0 offset_right = 566.0 offset_bottom = 207.0 scale = Vector2(0.975409, 0.975409) -texture = ExtResource("9_w6m6a") +texture = ExtResource("20_l5wui") [node name="pribor_prd_n_3" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1323.0 -offset_top = 802.0 +offset_top = 803.0 offset_right = 1400.0 -offset_bottom = 918.0 +offset_bottom = 919.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1077,9 +1257,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_n_3"] layout_mode = 0 offset_left = 8.0 -offset_top = -38.0 +offset_top = -43.0 offset_right = 60.0 -offset_bottom = -19.0 +offset_bottom = -24.0 text = "ПРД Н3" horizontal_alignment = 1 vertical_alignment = 1 @@ -1107,6 +1287,29 @@ sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_n_3"] +visible = false +layout_mode = 0 +offset_left = -7.0 +offset_top = 124.0 +offset_right = 86.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_n_3"] visible = false z_index = 1 @@ -1123,9 +1326,9 @@ texture = ExtResource("9_qe1go") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1188.0 -offset_top = 802.0 +offset_top = 803.0 offset_right = 1265.0 -offset_bottom = 918.0 +offset_bottom = 919.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1141,9 +1344,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_3"] layout_mode = 0 offset_left = 9.0 -offset_top = -38.0 +offset_top = -42.0 offset_right = 61.0 -offset_bottom = -19.0 +offset_bottom = -23.0 text = "ПРД К3" horizontal_alignment = 1 vertical_alignment = 1 @@ -1171,6 +1374,29 @@ sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_k_3"] +visible = false +layout_mode = 0 +offset_left = -8.0 +offset_top = 124.0 +offset_right = 85.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_k_3"] visible = false z_index = 1 @@ -1187,9 +1413,9 @@ texture = ExtResource("16_32yvq") editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1328.0 -offset_top = 198.0 +offset_top = 179.0 offset_right = 1405.0 -offset_bottom = 314.0 +offset_bottom = 295.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1205,9 +1431,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_1"] layout_mode = 0 offset_left = 8.0 -offset_top = -38.0 +offset_top = -44.0 offset_right = 60.0 -offset_bottom = -19.0 +offset_bottom = -25.0 text = "ПРД В1" horizontal_alignment = 1 vertical_alignment = 1 @@ -1245,15 +1471,38 @@ offset_top = 2.0 offset_right = 288.0 offset_bottom = 810.0 scale = Vector2(0.974661, 0.974661) -texture = ExtResource("9_w6m6a") +texture = ExtResource("20_l5wui") + +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_v_1"] +visible = false +layout_mode = 0 +offset_left = -4.0 +offset_top = 124.0 +offset_right = 89.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) [node name="pribor_prd_k_1" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1183.0 -offset_top = 193.0 +offset_top = 179.0 offset_right = 1260.0 -offset_bottom = 309.0 +offset_bottom = 295.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1269,9 +1518,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_1"] layout_mode = 0 offset_left = 9.0 -offset_top = -38.0 +offset_top = -44.0 offset_right = 61.0 -offset_bottom = -19.0 +offset_bottom = -25.0 text = "ПРД К1" horizontal_alignment = 1 vertical_alignment = 1 @@ -1299,6 +1548,29 @@ sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_k_1"] +visible = false +layout_mode = 0 +offset_left = -4.0 +offset_top = 124.0 +offset_right = 89.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_k_1"] visible = false z_index = 1 @@ -1314,10 +1586,10 @@ texture = ExtResource("16_32yvq") [node name="pribor_prd_v_4" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 -offset_left = 946.0 -offset_top = 345.0 -offset_right = 1023.0 -offset_bottom = 461.0 +offset_left = 940.0 +offset_top = 322.0 +offset_right = 1017.0 +offset_bottom = 438.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1331,10 +1603,10 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_v_4"] layout_mode = 0 -offset_left = 17.0 -offset_top = -38.0 -offset_right = 69.0 -offset_bottom = -19.0 +offset_left = 15.0 +offset_top = -41.0 +offset_right = 67.0 +offset_bottom = -22.0 text = "ПРД В4" horizontal_alignment = 1 vertical_alignment = 1 @@ -1362,6 +1634,29 @@ sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_v_4"] +visible = false +layout_mode = 0 +offset_left = -6.0 +offset_top = 124.0 +offset_right = 87.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_v_4"] visible = false z_index = 1 @@ -1372,15 +1667,15 @@ offset_top = -144.0 offset_right = 669.0 offset_bottom = 664.0 scale = Vector2(0.976707, 0.976707) -texture = ExtResource("9_w6m6a") +texture = ExtResource("20_l5wui") [node name="pribor_prd_n_4" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 941.0 -offset_top = 685.0 +offset_top = 687.0 offset_right = 1018.0 -offset_bottom = 801.0 +offset_bottom = 803.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1395,9 +1690,9 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_n_4"] layout_mode = 0 offset_left = 14.0 -offset_top = -38.0 +offset_top = -41.0 offset_right = 66.0 -offset_bottom = -19.0 +offset_bottom = -22.0 text = "ПРД Н4" horizontal_alignment = 1 vertical_alignment = 1 @@ -1425,6 +1720,29 @@ sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_n_4"] +visible = false +layout_mode = 0 +offset_left = -8.0 +offset_top = 124.0 +offset_right = 85.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_n_4"] visible = false z_index = 1 @@ -1440,10 +1758,10 @@ texture = ExtResource("9_qe1go") [node name="pribor_prd_k_4" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 -offset_left = 946.0 -offset_top = 515.0 -offset_right = 1023.0 -offset_bottom = 631.0 +offset_left = 941.0 +offset_top = 504.0 +offset_right = 1018.0 +offset_bottom = 620.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1457,10 +1775,10 @@ metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_prd_k_4"] layout_mode = 0 -offset_left = 17.0 -offset_top = -38.0 -offset_right = 69.0 -offset_bottom = -19.0 +offset_left = 14.0 +offset_top = -40.0 +offset_right = 66.0 +offset_bottom = -21.0 text = "ПРД К4" horizontal_alignment = 1 vertical_alignment = 1 @@ -1482,12 +1800,35 @@ patch_margin_bottom = 16 [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_prd_k_4"] light_mask = 3 -position = Vector2(42, -10) +position = Vector2(39, -10) scale = Vector2(0.625, 0.625) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 script = ExtResource("11_u7tym") +[node name="control_progress" type="TextureProgressBar" parent="pribor_prd_k_4"] +visible = false +layout_mode = 0 +offset_left = -8.0 +offset_top = 124.0 +offset_right = 85.0 +offset_bottom = 134.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = " +Текущее: 0.00" +mouse_filter = 0 +max_value = 30.0 +nine_patch_stretch = true +stretch_margin_left = 5 +stretch_margin_top = 5 +stretch_margin_right = 5 +stretch_margin_bottom = 5 +texture_under = ExtResource("9_w6m6a") +texture_progress = ExtResource("10_lbx5w") +tint_under = Color(1, 1, 1, 0.419608) +tint_progress = Color(0.890196, 0.486275, 0.196078, 1) + [node name="pic_functional" type="TextureRect" parent="pribor_prd_k_4"] visible = false z_index = 1 @@ -1502,9 +1843,9 @@ texture = ExtResource("16_32yvq") [node name="txr_legend0" type="TextureRect" parent="."] layout_mode = 0 -offset_left = 219.0 +offset_left = 316.0 offset_top = 1141.0 -offset_right = 443.0 +offset_right = 540.0 offset_bottom = 1365.0 scale = Vector2(0.1, 0.1) texture = ExtResource("7_6j01w") @@ -1512,9 +1853,9 @@ texture = ExtResource("7_6j01w") [node name="lbl_legend0" type="Label" parent="."] self_modulate = Color(1, 1, 1, 0.627451) layout_mode = 0 -offset_left = 247.0 +offset_left = 344.0 offset_top = 1142.0 -offset_right = 403.0 +offset_right = 500.0 offset_bottom = 1162.0 theme_override_font_sizes/font_size = 17 text = "Ожидание результата" @@ -1522,27 +1863,27 @@ text = "Ожидание результата" [node name="lbl_legend1" type="Label" parent="."] self_modulate = Color(1, 1, 1, 0.627451) layout_mode = 0 -offset_left = 52.0 +offset_left = 149.0 offset_top = 1142.0 -offset_right = 125.0 +offset_right = 222.0 offset_bottom = 1162.0 theme_override_font_sizes/font_size = 17 text = "Исправно" [node name="txr_legend1" type="TextureRect" parent="."] layout_mode = 0 -offset_left = 26.0001 +offset_left = 123.0 offset_top = 1141.0 -offset_right = 250.0 +offset_right = 347.0 offset_bottom = 1365.0 scale = Vector2(0.1, 0.1) texture = ExtResource("8_isjua") [node name="txr_legend2" type="TextureRect" parent="."] layout_mode = 0 -offset_left = 476.0 +offset_left = 573.0 offset_top = 1141.0 -offset_right = 700.0 +offset_right = 797.0 offset_bottom = 1365.0 scale = Vector2(0.1, 0.1) texture = ExtResource("9_ll0vs") @@ -1550,24 +1891,36 @@ texture = ExtResource("9_ll0vs") [node name="lbl_legend2" type="Label" parent="."] self_modulate = Color(1, 1, 1, 0.627451) layout_mode = 0 -offset_left = 504.0 +offset_left = 601.0 offset_top = 1142.0 -offset_right = 548.0 +offset_right = 645.0 offset_bottom = 1162.0 theme_override_font_sizes/font_size = 17 text = "Сбой" [node name="lbl_header" type="Label" parent="."] +visible = false layout_mode = 0 -offset_left = 78.0 +offset_left = 88.0 offset_top = 27.0 -offset_right = 656.0 +offset_right = 666.0 offset_bottom = 58.0 theme_override_font_sizes/font_size = 22 text = "Контроль исправности прибора" horizontal_alignment = 1 vertical_alignment = 1 +[node name="chk_show_functional" type="CheckButton" parent="."] +visible = false +layout_mode = 0 +offset_left = 1028.0 +offset_top = 26.0 +offset_right = 1407.0 +offset_bottom = 60.0 +theme_override_font_sizes/font_size = 22 +text = "Показть функциональную схему Э2" +flat = true + [node name="connect_legend0" type="AnimatedSprite2D" parent="."] light_mask = 3 position = Vector2(1219, 1151) @@ -1604,33 +1957,44 @@ text = "На связи" metadata/_edit_use_anchors_ = true [node name="line0" type="Line2D" parent="."] -position = Vector2(936, 950) -points = PackedVector2Array(-8, 0, 608, 0) +position = Vector2(929, 950) +points = PackedVector2Array(-8, 0, 582.16, 0, 608, 0) width = 2.0 default_color = Color(1, 1, 1, 0.352941) [node name="line1" type="Line2D" parent="."] -position = Vector2(936, 1128) +position = Vector2(929, 1128) points = PackedVector2Array(-8, 0, 608, 0) width = 2.0 default_color = Color(1, 1, 1, 0.352941) [node name="line2" type="Line2D" parent="."] -position = Vector2(32, 1128) +position = Vector2(73.3548, 1127) +scale = Vector2(1.03548, 1) points = PackedVector2Array(-8, 0, 608, 0) width = 2.0 default_color = Color(1, 1, 1, 0.352941) -[node name="chk_show_functional" type="CheckButton" parent="."] +[node name="control_prd_button" type="Button" parent="."] layout_mode = 0 -offset_left = 1050.0 -offset_top = 26.0 -offset_right = 1429.0 -offset_bottom = 60.0 -theme_override_font_sizes/font_size = 22 -disabled = true -text = "Показть функциональную схему Э2" -flat = true +offset_left = 1043.0 +offset_top = 64.0 +offset_right = 1390.0 +offset_bottom = 104.0 +focus_mode = 0 +text = "Запуск контроля" +script = ExtResource("18_lbx5w") +metadata/_edit_lock_ = true + +[node name="pic_functional" type="TextureRect" parent="."] +visible = false +layout_mode = 0 +offset_left = -962.0 +offset_top = 73.0 +offset_right = 96.9999 +offset_bottom = 746.0 +scale = Vector2(5, 5) +texture = ExtResource("22_1s34a") [connection signal="gui_input" from="." to="." method="_on_gui_input"] [connection signal="toggled" from="pribor_prd_n_1" to="pribor_prd_n_1" method="_on_toggled"] @@ -1651,3 +2015,4 @@ flat = true [connection signal="toggled" from="pribor_prd_n_4" to="pribor_prd_n_4" method="_on_toggled"] [connection signal="toggled" from="pribor_prd_k_4" to="pribor_prd_k_4" method="_on_toggled"] [connection signal="toggled" from="chk_show_functional" to="." method="_on_chk_show_functional_toggled"] +[connection signal="pressed" from="control_prd_button" to="." method="_on_control_prd_pressed"] diff --git a/scenes/настройки/настройки.tscn b/scenes/настройки/настройки.tscn index 9a6497d2..d115368b 100644 --- a/scenes/настройки/настройки.tscn +++ b/scenes/настройки/настройки.tscn @@ -35,6 +35,7 @@ const SETTING_TABLE = [ ['Кнопка «Подавление»', TableEdit, TableToggle, 'Разрешить отображение кнопки'], ['Виртуальная клавиатура', TableEdit, TableToggle, 'Включить отображение экранной клавиатуры'], ['Скрыть вкладку ЭМС 2', TableEdit, TableToggle, 'Отображать вкладку \\\"ЭМС-2\\\"'], + ['Отладка контроля', TableEdit, TableToggle, 'Отображать отладку контроля'], ['Текущая версия ПО УАРЭП', TableEdit, TableEdit, 'Время сборки, версия и номер фиксации'], ['уарэп-яу07-частный', TableEdit, TableEdit, 'IP-адрес для получения частных сообщений от ЯУ-07'], ['уарэп-яу07-общий', TableEdit, TableEdit, 'IP-адрес для получения широковещательных сообщений от ЯУ-07'], @@ -73,8 +74,9 @@ const TRASSA = 17 const SUPPRESS = 18 ## Строка - Подавление const KEYBOARD = 19 ## Строка - Виртуальная клавиатура const HIDE_EMS2 = 20 ## Строка - Скрыть вкладку ЭМС 2 -const COMMIT = 21 ## Строка - Версия УАРЭП -const GOS_BTN = 51 ## Разрешить работу по своим целям +const DEBAG_CONTROL = 21## Строка - Отладка контроля +const COMMIT = 22 ## Строка - Версия УАРЭП +const GOS_BTN = 52 ## Разрешить работу по своим целям var name_to_line_index: = {} ## Для преобразования названия параметра в номер строки @@ -114,6 +116,11 @@ func on_ems2_pressed(btn) -> void: signaller.emit_signal('ems2_hide_pressed', state) +func on_debag_control_pressed(btn) -> void: + var state = btn.button_pressed + signaller.emit_signal(\"debag_control_pressed\", state) + + func on_row_pressed(i_row: int): $scroll_set/table.clear_rows_selected() $scroll_set/table.set_row_selected(i_row, true) @@ -231,6 +238,10 @@ func button_settings(): on_ems2_pressed(ems2_hide_node) var gos_node = $scroll_set/table.get_node2(1, GOS_BTN).get_children()[0] gos_node.connect('pressed', on_gos_pressed.bind(gos_node)) + var debag_control = $scroll_set/table.get_node2(1, DEBAG_CONTROL).get_children()[0] + debag_control.connect('pressed', on_debag_control_pressed.bind(debag_control)) + debag_control.set_pressed(false) + on_debag_control_pressed(debag_control) func _on_btn_save_settings_pressed(): diff --git a/scenes/работа/работа.gd b/scenes/работа/работа.gd index 56203b25..6ae374b5 100644 --- a/scenes/работа/работа.gd +++ b/scenes/работа/работа.gd @@ -578,7 +578,7 @@ func set_btns_disabled(value: bool, btn): btn.set_disabled(value) -func on_interfer_prinuditelno (prenuditelno_sectors, btns): +func on_interfer_prinuditelno(prenuditelno_sectors, btns): for key in prenuditelno_sectors: var sectors = [] for sector in prenuditelno_sectors[key]: diff --git a/scenes/эмс/yems-consts.gd b/scenes/эмс/yems-consts.gd index dd27c0e5..fe9be29f 100644 --- a/scenes/эмс/yems-consts.gd +++ b/scenes/эмс/yems-consts.gd @@ -54,15 +54,15 @@ const EMS_G_BOARDS = { ## Таблица с данными для входов, первое значение - индекс устройства в ячейке КЭМС. const INPUT_KEMS = [ - [1 ,['УИЗП №1', 'Х7', '0.00', '0.00']], + [1 ,['5П-26М', 'Х7', '0.00', '0.00']], [2 ,['УИЗПФ №1','Х8', '0.00', '0.00']], - [3 ,['УИЗП №2', 'Х10', '0.00', '0.00']], + [3 ,['НРЛС МР-231', 'Х10', '0.00', '0.00']], [4 ,['УИЗПФ №2','Х11', '0.00', '0.00']], - [5 ,['УИЗП №3', 'Х13', '0.00', '0.00']], + [5 ,['НРЛС-231-3', 'Х13', '0.00', '0.00']], [6 ,['УИЗПФ №3','Х14', '0.00', '0.00']], - [7 ,['УИЗП №4', 'Х16', '0.00', '0.00']], + [7 ,['3Р87-1Ф', 'Х16', '0.00', '0.00']], [8 ,['УИЗПФ №4','Х17', '0.00', '0.00']], - [9 ,['УИЗП №5', 'Х19', '0.00', '0.00']], + [9 ,['ПРЛ ИСБУ-23900', 'Х19', '0.00', '0.00']], [10,['УИЗПФ №5','Х20', '0.00', '0.00']], [11,['УИЗП №6', 'Х22', '0.00', '0.00']], [12,['УИЗПФ №6','Х23', '0.00', '0.00']], @@ -77,11 +77,11 @@ const INPUT_KEMS = [ ## Таблица с данными для выходов, первое значение - индекс устройства в ячейке КЭМС. const OUTPUT_KEMS = [ - [47,['Бланк №1','Х6', '0.00', '0.00']], - [48,['Бланк №2','Х9', '0.00', '0.00']], - [49,['Бланк №3','Х12', '0.00', '0.00']], - [50,['Бланк №4','Х15', '0.00', '0.00']], - [51,['Бланк №5','Х18', '0.00', '0.00']], + [47,['5П-26М','Х6', '0.00', '0.00']], + [48,['НРЛС МР-231','Х9', '0.00', '0.00']], + [49,['НРЛС-231-3','Х12', '0.00', '0.00']], + [50,['3Р87-1Ф','Х15', '0.00', '0.00']], + [51,['ПРЛ ИСБУ-23900','Х18', '0.00', '0.00']], [52,['Бланк №6','Х21', '0.00', '0.00']], [53,['Бланк №7','Х24', '0.00', '0.00']], [55,['Бланк_МП №1', 'X28 : 8', '0.00', '0.00']], diff --git a/scenes/эмс2/эмс_тг.gd b/scenes/эмс2/эмс_тг.gd index 429c0e0c..88c93a61 100644 --- a/scenes/эмс2/эмс_тг.gd +++ b/scenes/эмс2/эмс_тг.gd @@ -30,7 +30,7 @@ func on_trassa_line_changed(unit_trassa): $'СкруглённыйПрямоугольникБелый/Label10'.text = '-' -func on_sector_klaster(data, unit_trassa): +func on_sector_klaster(_data, unit_trassa): $'СкруглённыйПрямоугольникБелый/Label6'.text = str(unit_trassa.dap) $'СкруглённыйПрямоугольникБелый/Label7'.text = str(unit_trassa.daa) $'СкруглённыйПрямоугольникБелый/Label8'.text = '1' diff --git a/scripts/interfer.gd b/scripts/interfer.gd index 405dacbe..4dcc22dc 100644 --- a/scripts/interfer.gd +++ b/scripts/interfer.gd @@ -205,7 +205,7 @@ func _ready() -> void: signaller.connect('interfer_new', Callable(self, 'on_interfer_new').bind(unit_caps)) signaller.connect('interfer_off_all', Callable(self, 'on_interfer_off_all').bind(unit_caps, ecms)) signaller.connect('th_aoa_update', Callable(self, 'on_th_aoa_update').bind(ecms, unit_caps)) - signaller.connect('interfer_off', Callable(self, 'on_interfer_off').bind(ecms)) + signaller.connect('interfer_off', Callable(self, 'on_interfer_off').bind(ecms, unit_caps)) signaller.connect('manual_control', Callable(self, 'on_manual_control')) signaller.connect('full_auto', Callable(self, 'on_full_auto')) signaller.connect('interfer_prinuditelno', Callable(self, 'on_interfer_prinuditelno')) @@ -218,6 +218,7 @@ func _ready() -> void: ProjectSettings.connect('settings_changed', on_settings_changed) var unit_nav: = network.get_unit_instance('навигация') unit_nav.connect('data_received', on_nav_data_received.bind(unit_caps)) + call_deferred('emit_signal', 'interfer_resized', ecms) func on_trenazh_mode(val: bool): trenazh_mode = val @@ -334,10 +335,12 @@ func map_msvk_to_ecms(unit_instance: unit.Unit, ecms: Dictionary): var json_dic = unit_instance.json_dic if not json_dic.has('msvk'): return var msvk = unit_instance.json_dic.get('msvk', []) + var ispp_arr: Array = [] for dic_msvk in msvk: if dic_msvk is not Dictionary: continue if not dic_msvk.has('ispp'): continue var ispp = int(dic_msvk['ispp']) + ispp_arr.append(ispp) var errmsg = dic_msvk.get('errmsg', '') if errmsg: log.error('сеанс %d: \"%s\"' % [ispp, errmsg]) @@ -345,11 +348,17 @@ func map_msvk_to_ecms(unit_instance: unit.Unit, ecms: Dictionary): var ecm = ecms[ispp] ecm.set_from_dic(dic_msvk) call_deferred('emit_signal', 'interfer_update', ecm) - else: - var ecm = Interfer.new() - ecm.set_from_dic(dic_msvk) - ecm.krp = INTERFER_OFF - send_ecm(ecm, unit_instance) + for ecm in ecms.values(): + if (ecm.ispp not in ispp_arr) and (ecm.krp == INTERFER_OFF): + var sz = ecms.size() + signaller.emit_signal('on_prog_ecm_off', ecm) + ecms.erase(ecm.ispp) + thrs.erase(ecm.ispp) + cu.erase(ecm.ispp) + fs.erase(ecm.ispp) + push_id(ecm.ispp) + if sz != ecms.size(): + interfer.call_deferred('emit_signal', 'interfer_resized', ecms) ## Извлекает массив пространственно-частотных фильтров @@ -638,21 +647,12 @@ func get_krp(threat: threats.Threat): return krp -func on_interfer_off(ecm: Interfer, ecms): - var sz = ecms.size() - signaller.emit_signal('on_prog_ecm_off', ecm) - ecms.erase(ecm.ispp) - thrs.erase(ecm.ispp) - interfer.cu.erase(ecm.ispp) - interfer.fs.erase(ecm.ispp) - interfer.push_id(ecm.ispp) - if sz != ecms.size(): - interfer.call_deferred('emit_signal', 'interfer_resized', ecms) - - -func interfer_off(ecm, unit_caps): +func on_interfer_off(ecm: Interfer, _ecms, unit_caps): ecm.krp = INTERFER_OFF send_ecm(ecm, unit_caps) + + +func interfer_off(ecm, _unit_caps): signaller.emit_signal('interfer_off', ecm) diff --git a/scripts/prd-ctl-config.gd b/scripts/prd-ctl-config.gd new file mode 100644 index 00000000..b5851062 --- /dev/null +++ b/scripts/prd-ctl-config.gd @@ -0,0 +1,240 @@ +class_name PRDConfigManager +extends RefCounted + +## Менеджер конфигурации для системы контроля ПРД +## Загружает и управляет настройками из JSON-конфигурации + +#region CONSTANTS +const CONFIG_PATH = "user://config/setting_prd_control.json" +const DEFAULT_CONFIG_PATH = "res://config/setting_prd_control.json" +const CONFIG_VERSION = "1.0.0" # Версия конфигурации - увеличивать при изменениях +#endregion + +#region PRIVATE_VARIABLES +var _config_data: Dictionary # Все данные конфигурации +var _device_constants: Dictionary # Константы устройств +var _base_configs: Dictionary # Базовые конфигурации +var _device_configs: Dictionary # Конфигурации устройств +var _data_indices: Dictionary # Индексы данных +var _fs_keys: Dictionary # Ключи ФС (функциональных систем) +var _temperature_constants: Dictionary # Константы температуры +var _ems_input_bits_config: Dictionary # Конфигурация битов ввода ЭМС +var _fs_rules: Array # Правила ФС + +var _is_loaded: bool = false # Флаг успешной загрузки +var _current_version: String = "" # Текущая версия загруженной конфигурации +#endregion + +#region INITIALIZATION +func _init() -> void: + """Инициализация менеджера конфигурации""" + _load_configuration() +#endregion + +#region PUBLIC_API +## Проверяет, успешно ли загружена конфигурация +func is_loaded() -> bool: + return _is_loaded + +## Возвращает текущую версию загруженной конфигурации +func get_config_version() -> String: + return _current_version + +## Проверяет, актуальна ли конфигурация +func is_config_up_to_date() -> bool: + return _current_version == CONFIG_VERSION + +## Возвращает все данные конфигурации +func get_config_data() -> Dictionary: + return _config_data.duplicate(true) + +## Возвращает константы устройств +func get_device_constants() -> Dictionary: + return _device_constants.duplicate(true) + +## Возвращает базовые конфигурации +func get_base_configs() -> Dictionary: + return _base_configs.duplicate(true) + +## Возвращает конфигурации устройств +func get_device_configs() -> Dictionary: + return _device_configs.duplicate(true) + +## Возвращает индексы данных +func get_data_indices() -> Dictionary: + return _data_indices.duplicate(true) + +## Возвращает ключи ФС +func get_fs_keys() -> Dictionary: + return _fs_keys.duplicate(true) + +## Возвращает константы температуры +func get_temperature_constants() -> Dictionary: + return _temperature_constants.duplicate(true) + +## Возвращает конфигурацию битов ввода ЭМС +func get_ems_input_bits_config() -> Dictionary: + return _ems_input_bits_config.duplicate(true) + +## Возвращает правила ФС +func get_fs_rules() -> Array: + return _fs_rules.duplicate(true) + +## Возвращает индекс данных по ключу +func get_data_index(key: String) -> int: + return _data_indices.get(key, -1) +#endregion + +#region PRIVATE_METHODS +## Загружает конфигурацию из JSON файла +func _load_configuration() -> void: + if not _ensure_config_exists(): + _is_loaded = false + return + + var config_file = FileAccess.open(CONFIG_PATH, FileAccess.READ) + if config_file: + var json_text = config_file.get_as_text() + config_file.close() + + var json = JSON.new() + var parse_result = json.parse(json_text) + if parse_result == OK: + _config_data = json.data + _current_version = _config_data.get("config_version", "0.0.0") + _parse_config_data() + _is_loaded = true + else: + push_error("Ошибка разбора JSON конфигурации: " + json.get_error_message()) + _is_loaded = false + else: + push_error("Ошибка загрузки файла конфигурации: " + CONFIG_PATH) + _is_loaded = false + + +## Парсит данные конфигурации по секциям +func _parse_config_data() -> void: + _device_constants = _convert_numbers(_config_data.get("device_constants", {})) + _base_configs = _convert_numbers(_config_data.get("base_configs", {})) + _device_configs = _convert_numbers(_config_data.get("device_configs", {})) + _data_indices = _convert_numbers(_config_data.get("data_indices", {})) + _fs_keys = _convert_numbers(_config_data.get("fs_keys", {})) + _temperature_constants = _convert_numbers(_config_data.get("temperature_constants", {})) + _ems_input_bits_config = _convert_numbers(_config_data.get("ems_input_bits_config", {})) + _fs_rules = _convert_numbers(_config_data.get("fs_rules", [])) + + +## Конвертирует числовые значения в правильные типы (float -> int если возможно) +static func _convert_numbers(value): + if value is float: + # Конвертируем float в int если нет дробной части + if value == int(value): + return int(value) + return value + elif value is Dictionary: + var result = {} + for key in value: + result[key] = _convert_numbers(value[key]) + return result + elif value is Array: + var result = [] + for item in value: + result.append(_convert_numbers(item)) + return result + else: + return value + + +## Обеспечивает существование файла конфигурации +## Создает папку и копирует дефолтный файл если нужно +func _ensure_config_exists() -> bool: + # Создаем папку конфигурации если не существует + DirAccess.make_dir_recursive_absolute("user://config") + + # Проверяем, нужно ли обновить конфигурацию + if _should_update_config(): + return _update_config() + + # Если файл уже существует - все ок + if FileAccess.file_exists(CONFIG_PATH): + return true + + # Если дефолтного файла нет - ошибка + if not FileAccess.file_exists(DEFAULT_CONFIG_PATH): + return false + + # Копируем дефолтный конфиг в user директорию + return _copy_default_config() + + +## Проверяет, нужно ли обновить конфигурацию +func _should_update_config() -> bool: + # Если файла конфигурации нет - нужно создать + if not FileAccess.file_exists(CONFIG_PATH): + return true + + # Проверяем версию существующей конфигурации + var config_file = FileAccess.open(CONFIG_PATH, FileAccess.READ) + if config_file: + var json_text = config_file.get_as_text() + config_file.close() + + var json = JSON.new() + if json.parse(json_text) == OK: + var existing_version = json.data.get("config_version", "0.0.0") + # Сравниваем версии + return _compare_versions(existing_version, CONFIG_VERSION) < 0 + else: + # Если ошибка парсинга - нужно обновить + return true + + return false + + +## Сравнивает две версии (semantic versioning) +## Возвращает -1 если version1 < version2, 0 если равны, 1 если version1 > version2 +static func _compare_versions(version1: String, version2: String) -> int: + var v1_parts = version1.split(".") + var v2_parts = version2.split(".") + + for i in range(max(v1_parts.size(), v2_parts.size())): + var v1_part = int(v1_parts[i]) if i < v1_parts.size() else 0 + var v2_part = int(v2_parts[i]) if i < v2_parts.size() else 0 + + if v1_part < v2_part: + return -1 + elif v1_part > v2_part: + return 1 + + return 0 + + +## Обновляет конфигурацию до актуальной версии +func _update_config() -> bool: + # Создаем резервную копию старой конфигурации + if FileAccess.file_exists(CONFIG_PATH): + var backup_path = CONFIG_PATH + ".backup_v" + _current_version + DirAccess.copy_absolute(CONFIG_PATH, backup_path) + print("Создана резервная копия: ", backup_path) + + # Копируем актуальную конфигурацию + return _copy_default_config() + + +## Копирует дефолтную конфигурацию в user директорию +func _copy_default_config() -> bool: + if not FileAccess.file_exists(DEFAULT_CONFIG_PATH): + push_error("Дефолтный файл конфигурации не найден: " + DEFAULT_CONFIG_PATH) + return false + + var src := FileAccess.open(DEFAULT_CONFIG_PATH, FileAccess.READ) + var dst := FileAccess.open(CONFIG_PATH, FileAccess.WRITE) + if src == null or dst == null: + push_error("Ошибка копирования конфигурации") + return false + + dst.store_string(src.get_as_text()) + src.close() + dst.close() + return true +#endregion diff --git a/scripts/prd-ctl-config.gd.uid b/scripts/prd-ctl-config.gd.uid new file mode 100644 index 00000000..add5876f --- /dev/null +++ b/scripts/prd-ctl-config.gd.uid @@ -0,0 +1 @@ +uid://bi7elq60squds diff --git a/scripts/prd.gd b/scripts/prd.gd index 46c8e08b..33f804f8 100644 --- a/scripts/prd.gd +++ b/scripts/prd.gd @@ -105,8 +105,8 @@ class Fs: [10, 20], [20, 30], [30, 40], - [40, 50], - [50, 55]] + [40, 90], + [90, 100]] var index ## Индекс блока усилителей var modulation: bool ## Состояние модуляции @@ -151,22 +151,33 @@ class Fs: class PRD: + enum STATE_DEVICE { + NONE, + GOOD, + ERROR + } var prd_name: String ## Имя прибора - var unit_yau07 ## Юнит эмс + var unit_yau07: Object ## Юнит эмс + var unit_control: Object ## Класс проверки прибора ПРД var fs_dic: Dictionary ## Массив блоков ФС var yemsg_board: yemsboards.EmsBoard ## Плата ЭМС-Г var state = PrdState.WORK var cmd_array: Array ## Очередь команд var ug_online: bool = false ## Состояние ячейки УГ - var serviceability: bool = false var set_ug_state: bool = true ## Необходимо ли записать в УГ настройки - signal update_serviceability() + signal update_serviceability(state: int) ## Сообщает изменение текущего состояния юнита ПРД + var serviceability: int: + set(v): + if v != serviceability: + serviceability = v + emit_signal('update_serviceability', v) func _init(u_name, u_yau07): prd_name = u_name unit_yau07 = u_yau07 init_ems_g() + func init_ems_g(): var in_tbl: Array = [] var out_tbl: Array = [] @@ -199,11 +210,11 @@ class PRD: func on_line_changed(unit_ems): - emit_signal('update_serviceability') if not unit_ems.online: yemsg_board.ems_load = yemsg_board.LoadState.NOT_DEFINED yemsg_board.set_wait() set_ug_state = true + serviceability = STATE_DEVICE.NONE func on_data_received(_u): set_prd_status() @@ -221,18 +232,76 @@ class PRD: return execute_cmd() - func set_prd_status(): + ## Мониторинг состояния юнита прд + func set_prd_status() -> void: + # Обновление статуса платы ЯУ-07 yemsg_board.set_status(unit_yau07.status) + + # Проверка онлайн-статусов основных модулей ug_online = (unit_yau07.status[0] >> 1) & 1 - if not ug_online: - set_ug_state = true var ukp_1_online = (unit_yau07.status[0] >> 2) & 1 var ukp_2_online = (unit_yau07.status[0] >> 3) & 1 - var ems_g_online = (unit_yau07.status[0] & 1) & 1 - var check_serviceability = ug_online and ukp_1_online and ukp_2_online and ems_g_online - if serviceability != check_serviceability: - serviceability = check_serviceability - emit_signal('update_serviceability') + var ems_g_online = (unit_yau07.status[0] & 1) & 1 + + # Установка флага состояния УГ + if not ug_online: + set_ug_state = true + + # Проверка источников питания + var ip_online: bool = _check_dry_contact(unit_yau07.status, prd_name) + var check_temperature_um: bool = unit_control.flags.temperature_ok + var check_dic: Dictionary = { + 'ukp_1_online': ukp_1_online, + 'ukp_2_online': ukp_2_online, + 'ems_g_online': ems_g_online, + 'ip_online': ip_online, + 'ug_online': ug_online, + 'temperature_um': check_temperature_um + } + # Определение состояния обслуживания + if unit_control: + if unit_control.flags.control_is_over: + serviceability = _set_serviceability_from_control_results(unit_control) + else: + serviceability = _set_serviceability_from_online_status(check_dic) + + ## Проверка онлайн-статуса сухих контактов + static func _check_dry_contact(unit_yau07_status: PackedByteArray, self_name: String) -> bool: + var bit_ip_config: Array = [0, 1, 2, 3, 4, 5, 6, 7] + var is_k_type: bool = self_name in ['уарэп-яу07-1к', 'уарэп-яу07-2к', 'уарэп-яу07-3к', 'уарэп-яу07-4к'] + for bit in bit_ip_config: + if not is_k_type and bit in [5, 6]: # Игнорируем биты 5 и 6 для всех приборов, кроме типа "к" + continue + var status: bool = unit_yau07_status[27] >> bit & 1 + if status: + return false + return true + + ## Установка состояния обслуживания на основе результатов контроля + static func _set_serviceability_from_control_results(unit_ctrl: Object) -> int: + var control_results = unit_ctrl.get_control_results() + var result_dic = control_results.result_dic + const CRITICAL_DEVICES: Array = [ + 'fs_1', 'fs_2', 'fs_3', 'fs_4', 'fs_5', 'fs_6', 'fs_7', + 'dkm_1', 'dkm_2', 'dkm_3', 'dkm_4', 'dkm_5', 'dkm_6', 'dkm_7', + 'block_ip', 'dou_2', 'dou_3', 'dou_4', 'dou_5', 'dou_6', 'dou_7' + ] + var all_ok: bool = true + for device_key in CRITICAL_DEVICES: + if result_dic.has(device_key) and result_dic[device_key] is bool: + if not result_dic[device_key]: + all_ok = false + break + return STATE_DEVICE.GOOD if all_ok else STATE_DEVICE.ERROR + + ## Установка состояния обслуживания на основе онлайн-статусов + static func _set_serviceability_from_online_status(check_dic: Dictionary) -> int: + var all_online: bool = true + for status in check_dic: + if not check_dic[status]: + all_online = false + break + return STATE_DEVICE.NONE if all_online else STATE_DEVICE.ERROR func execute_cmd(): @@ -277,12 +346,16 @@ class PRD: cmd_array.append([unit_yau07.CmdCode.WRITE_ISA, data_arr]) + func _ready() -> void: check_dir() for prd_name in PRD_NAMES: var unit_prd = network.get_unit_instance(prd_name) var new_prd = PRD.new(prd_name, unit_prd) prd_dict[prd_name] = new_prd + var unit_control = TestPRD.new({'unit_prd': unit_prd}, new_prd.cmd_array) + add_child(unit_control) + new_prd.unit_control = unit_control for key in FS_PRD.keys(): var fs = Fs.new(key, FS_PRD[key][0]) fs_dict[key] = fs diff --git a/scripts/pribor-prd.gd b/scripts/pribor-prd.gd index c717f50b..e6385964 100644 --- a/scripts/pribor-prd.gd +++ b/scripts/pribor-prd.gd @@ -1,746 +1,1398 @@ -class TestPRD extends Node: - const RAY_m5:= 'RAY_m5' - const RAY_5:= 'RAY_5' - const RAY_15:= 'RAY_15' - const RAY_25:= 'RAY_25' - const RAY_35:= 'RAY_35' - const RAY_45:= 'RAY_45' - enum DataIndices { - STATUS_BOARD = 0, - IN_BLANK_PRD = 1, - IN_IMPULS_PRD = 7, - OUT_BLANK_PRD = 13, - OUT_IMPULS_PRD = 19, - DRY_CONTACT = 27, - DKM = 28, - POWER_UKP_1 = 31, - TEMPERATURE_UKP_1 = 47, - POWER_UKP_2 = 63, - TEMPERATURE_UKP_2 = 79, - } +class_name TestPRD +extends Node - enum STATE_MASHINE { - INIT, - FS_TURN_ON, - FS_WORK, - WRITE_ISA, - READ_ISA, - CHEK_KASSETA_Y5, - UG_SET_RAY, - UG_SET_RAY_0, - UG_SET_RAY_1, - UG_SET_RAY_2, - UG_SET_RAY_3, - UG_SET_RAY_4, - UG_SET_RAY_5, - IN_EMS_RUN, - IN_EMS_STOP, - FS_TURN_OFF, - STOP_CONTROL, - AWAIT - } - const FS_KEYS := { - 1: 'fs_1', - 2: 'fs_2', - 3: 'fs_3', - 4: 'fs_4', - 5: 'fs_5', - 6: 'fs_6', - 7: 'fs_7' - } - const TEMPERATURE_CONSTANTS := { - 'CONST_MIN_TEMP': -25, - 'MAXIMUM_CODE_ADC': 3796, - 'MINIMUM_CODE_AD': 2660, - 'TEMPERATURE_UKP_1': 47, - 'TEMPERATURE_UKP_2': 79, +#region CONSTANTS +## Константы прогресса для визуализации выполнения контроля +const PROGRESS_INIT: float = 5.0 +const PROGRESS_FS_TURN_ON: float = 10.0 +const PROGRESS_FS_WORK: float = 20.0 +const PROGRESS_CHECK_KASSETA: float = 25.0 +const PROGRESS_WRITE_ISA: float = 30.0 +const PROGRESS_READ_ISA: float = 35.0 +const PROGRESS_UG_SET_RAY: float = 40.0 +const PROGRESS_RAY_STATES: float = 50.0 +const PROGRESS_COMPLETE: float = 100.0 + +## Константы для работы с лучами управления +const COUNT_PACK_POWER_RECIEVE = 15 +const RAY_MASK = 0x07 +const SPECIAL_LITERAS = [3, 5, 7] +const RAY_m5: String = 'RAY_m5' +const RAY_5: String = 'RAY_5' +const RAY_15: String = 'RAY_15' +const RAY_25: String = 'RAY_25' +const RAY_35: String = 'RAY_35' +const RAY_45: String = 'RAY_45' + +## Конфигурация лучей: состояния, названия, задержки и требования +const RAY_CONFIG = { + 0: { 'state': 'UG_SET_RAY_0', 'name': '-5°'}, + 1: { 'state': 'UG_SET_RAY_1', 'name': '5°'}, + 2: { 'state': 'UG_SET_RAY_2', 'name': '15°'}, + 3: { 'state': 'UG_SET_RAY_3', 'name': '25°'}, + 4: { 'state': 'UG_SET_RAY_4', 'name': '35°'}, + 5: { 'state': 'UG_SET_RAY_5', 'name': '45°'}, + 6: { 'state': 'UG_SET_RAY_0', 'name': 'Контроль'} # ДКМ +} +const ATT_MAPPING = { + 1: 'ATT_UM_3', + 2: 'ATT_UM_1', 4: 'ATT_UM_1', 6: 'ATT_UM_1', + 3: 'ATT_UM_2', 5: 'ATT_UM_2', 7: 'ATT_UM_2' +} +# Таблица соответствий: device_name -> (current_lit -> nmfs в ecms) +const LITER_TO_NMFS: Dictionary = { + '1к': {1: 11, 6: 16, 7: 17}, + '2к': {1: 21, 6: 26, 7: 27}, + '3к': {1: 31, 6: 36, 7: 37}, + '4к': {1: 41, 6: 46, 7: 47}, + '1н': {2: 12, 3: 13}, + '2н': {2: 22, 3: 23}, + '3н': {2: 32, 3: 33}, + '4н': {2: 42, 3: 43}, + '1в': {4: 14, 5: 15}, + '2в': {4: 24, 5: 25}, + '3в': {4: 34, 5: 35}, + '4в': {4: 44, 5: 45} +} +const RAY_TYPES := [RAY_m5, RAY_5, RAY_15, RAY_25, RAY_35, RAY_45] +const DATA_EXIT_CONTOL_ISA: int = 0 + +## Перечисление состояний машины контроля ПРД +enum STATE_MACHINE { + INIT, + FS_TURN_ON, + FS_WORK, + READ_ISA, + CHEK_KASSETA_Y5, + CHEK_BLOCK_IP, + UG_SET_RAY, + UG_SET_RAY_0, + UG_SET_RAY_1, + UG_SET_RAY_2, + UG_SET_RAY_3, + UG_SET_RAY_4, + UG_SET_RAY_5, + UG_SET_RAY_CTRL, + IN_EMS_RUN, + IN_EMS_STOP, + FS_TURN_OFF, + STOP_CONTROL, + AWAIT +} +#endregion + + +#region VARIABLES +## Словарь состояния сокетов ЭМС-Г +var ems_g_sock_dic: Dictionary = { + 'ems_input_1': 0, + 'ems_input_2': 0, + 'ems_input_lit_1': 0, + 'ems_output_1': 0, + 'ems_output_2': 0, + 'ems_output_lit_1': 0, +} + +## Маппинги состояний лучей +var _ray_state_mapping: Dictionary +var _ray_state_enums: Dictionary = {} + +## Загруженные конфигурации (приватные) +var _device_constants: Dictionary +var _base_configs: Dictionary +var _device_configs: Dictionary +var _data_indices: Dictionary +var _fs_keys: Dictionary +var _temperature_constants: Dictionary +var _ems_input_bits_config: Dictionary +var _default_states: Dictionary = {} ## Сохраняет состояния по умолчанию для сброса +var _fs_rules: Array + +## Основные переменные класса +var config_manager: PRDConfigManager +var unit_prd: Object +var control_results: Dictionary +var power_result: Dictionary +var constants: Dictionary +var pribor_config: Dictionary +var fs_parameters: Dictionary +var block_ip_config: Dictionary +var block_kasseta_y5_config: Dictionary +var temperature_um: Dictionary +var ecms: Dictionary +var power_for_litera: Dictionary +var self_name: String +var state: int = STATE_MACHINE.INIT +var current_litera: int +var count_packets_power: int = 0 +var current_ecm_key: int + +## Флаги состояния системы +var flags: Dictionary = { + 'write_isa': false, + 'fs_status_ok': false, + 'si_fs_input': false, + 'si_fs_output': false, + 'in_control': false, + 'control_is_over': false, + 'no_trust_yau07': false, + 'only_fs': false, + 'ecm_is_comming': false, + 'temperature_ok': true, +} + +## Таймеры контроля +var control_timer: Timer = Timer.new() +var ems_6666_timer: Timer = Timer.new() +var machine_timer: Timer = Timer.new() + +## Счетчики и команды +var cc: int = 0 +var cmd_array: Array + +## Переменные для отслеживания прогресса +var prog_back: float = 0.0 +var total_fs_to_check: int = 0 +var completed_fs_count: int = 0 +var current_fs_progress: float = 0.0 +var current_status: String = 'Ожидание запуска контроля' + +## Сигналы класса +signal control_is_over(device_name: String) # Когда контроль завершен +signal status_updated(status_text: String) # Сигнал для обновления статуса +signal control_results_updated(control_results: Dictionary) # Обновление результатов контроля +signal update_progress(progress_value: float) # Обновление статуса выполнения контроля +signal update_max_value_progress(max_progress_value: int) # Установка максимального значения для прогресс бара + +## Свойство прогресса с автоматическим emit сигнала +var progress_value: float: + set(v): + if progress_value != v: + progress_value = v + call_deferred('emit_signal', 'update_progress', v) +#endregion + + +#region INITIALIZATION +## Инициализация объекта контроля ПРД +func _init(init_data: Dictionary, cmd_array_from_prd: Array) -> void: + unit_prd = init_data['unit_prd'] + cmd_array = cmd_array_from_prd + config_manager = PRDConfigManager.new() + _initialize_config_from_manager() # Инициализация конфигурации из менеджера + _initialize_ray_mapping() # Инициализация маппинга состояний лучей + _initialize_power_structure() # Инициализация структуры данных для хранения мощностей + + +## Инициализация состояний по умолчанию +func _initialize_default_states() -> void: + _default_states = { + # Флаги состояния системы + 'flags': flags.duplicate(true), + + # Состояние машины и литеры + 'state': state, + 'current_litera': current_litera, + + # Переменные прогресса + 'progress_value': progress_value, + 'current_status': current_status, + 'total_fs_to_check': total_fs_to_check, + 'completed_fs_count': completed_fs_count, + 'current_fs_progress': current_fs_progress, + + # Счетчики + 'cc': cc, + + # Сокеты ЭМС-Г + 'ems_g_sock_dic': ems_g_sock_dic.duplicate(true), + + # Структуры данных (глубокое копирование) + 'power_for_litera': _deep_copy_power_structure(), + 'control_results': control_results.duplicate(true), + 'power_result': power_result.duplicate(true), + 'temperature_um': temperature_um.duplicate(true), + + # Конфигурации блоков + 'block_ip_config': block_ip_config.duplicate(true), + 'block_kasseta_y5_config': block_kasseta_y5_config.duplicate(true), + + # Конфигурация устройства + 'self_name': self_name, + 'constants': constants.duplicate(true), + 'pribor_config': pribor_config.duplicate(true), + 'fs_parameters': fs_parameters.duplicate(true) } - var power_result: Dictionary = { - 1: {RAY_m5: [], RAY_5: [], RAY_15: [], RAY_25: [], RAY_35: [], RAY_45: [],}, - 2: {RAY_m5: [], RAY_5: [], RAY_15: [], RAY_25: [], RAY_35: [], RAY_45: [],}, - 3: {RAY_m5: [], RAY_5: [], RAY_15: [], RAY_25: [], RAY_35: [], RAY_45: [],}, - 4: {RAY_m5: [], RAY_5: [], RAY_15: [], RAY_25: [], RAY_35: [], RAY_45: [],}, - 5: {RAY_m5: [], RAY_5: [], RAY_15: [], RAY_25: [], RAY_35: [], RAY_45: [],}, - 6: {RAY_m5: [], RAY_5: [], RAY_15: [], RAY_25: [], RAY_35: [], RAY_45: [],}, - 7: {RAY_m5: [], RAY_5: [], RAY_15: [], RAY_25: [], RAY_35: [], RAY_45: [],}, - } - var constants: Dictionary - var pribor_config: Dictionary - var fs_parameters: Dictionary - var block_ip_config: Dictionary - var block_kasseta_y5_config: Dictionary - var control_results: Dictionary - var self_name: String - var state: int = STATE_MASHINE.INIT - var current_litera: int - var flag_write_isa: bool = false - var flag_fs_status_ok: bool = false - var flag_si_fs_input: bool = false - var flag_si_fs_output: bool = false - var unit_prd: Object - var module_prd: Object - var power_amplify: Array - var control_label: Label - var control_timer: Timer = Timer.new() - var ems_6666_timer: Timer = Timer.new() - signal control_is_over(control_results, power_result) + +## Инициализация конфигурации из менеджера +func _initialize_config_from_manager() -> void: + if not config_manager.is_loaded(): + push_error('ConfigManager не загружен!') + return + + _device_constants = config_manager.get_device_constants() + _base_configs = config_manager.get_base_configs() + _device_configs = config_manager.get_device_configs() + _data_indices = config_manager.get_data_indices() + _fs_keys = config_manager.get_fs_keys() + _temperature_constants = config_manager.get_temperature_constants() + _ems_input_bits_config = config_manager.get_ems_input_bits_config() + _fs_rules = config_manager.get_fs_rules() - var ecms: Dictionary ## Словарь помеховых воздействий - - ## Инициализация аргуметнов - func _init(init_data: Dictionary) -> void: - control_label = init_data['control_label'] - power_amplify = init_data['power_amplifiers'] - unit_prd = init_data['unit_prd'] - module_prd = init_data['module_prd'] - constants = init_data['constants'] - pribor_config = init_data['prd_config'] - fs_parameters = init_data['fs_params'] - block_ip_config = init_data['block_ip_prd_config'] - block_kasseta_y5_config = init_data['block_kasseta_y5_prd_config'] - control_results = init_data['control_results'] - current_litera = init_data['current_litera'] +## Инициализация структуры данных для хранения мощностей +func _initialize_power_structure() -> void: + power_for_litera = {} + for litera in range(1, 8): + power_for_litera[litera] = {} + for ray_type in RAY_TYPES: + power_for_litera[litera][ray_type] = [] - func _ready() -> void: - initialize_connections() - setup_timer() +## Инициализация при готовности узла +func _ready() -> void: + _determine_self_name() # Определение имени и конфигурации устройства + _initialize_default_states() # Инициализация состояний по умолчанию + initialize_connections() # Инициализация соединений и сигналов + setup_timer() # Настройка таймеров контроля + _initialize_ray_state_enums() # Инициализация перечислений значений для состояний лучей - func _process(_delta: float) -> void: - pass +## Инициализация маппинга состояний лучей +func _initialize_ray_mapping() -> void: + _ray_state_mapping = { + STATE_MACHINE.UG_SET_RAY_0: 'RAY_m5', + STATE_MACHINE.UG_SET_RAY_1: 'RAY_5', + STATE_MACHINE.UG_SET_RAY_2: 'RAY_15', + STATE_MACHINE.UG_SET_RAY_3: 'RAY_25', + STATE_MACHINE.UG_SET_RAY_4: 'RAY_35', + STATE_MACHINE.UG_SET_RAY_5: 'RAY_45', + STATE_MACHINE.UG_SET_RAY_CTRL: 'RAY_CTRL', + } - ## Пакеты от ЯУ-07 - func on_data_received(unit_pribor: Object) -> void: - if not is_inside_tree(): - return - - var status: PackedByteArray = unit_pribor.status - block_kasseta_y5_config = check_block_kasseta_y5(status, block_kasseta_y5_config) - block_ip_config = check_block_ip(status, block_ip_config) - control_results.temperature = check_temperature_um(status, power_amplify) - socket_status_ems_g(status) - _process_dkm_status(status) - if current_litera != 0: - var tek_litera: Dictionary = power_result[current_litera] - var interes = _get_ray_key(state) - if interes != '': - tek_litera[_get_ray_key(state)] = power_um_ukp(status, current_litera, tek_litera[_get_ray_key(state)]) - power_result[current_litera] = tek_litera +## Инициализация enum значений для состояний лучей +func _initialize_ray_state_enums() -> void: + for ray_value in RAY_CONFIG: + var state_name = RAY_CONFIG[ray_value].state + _ray_state_enums[state_name] = STATE_MACHINE.get(state_name) +#endregion - func socket_status_ems_g(packet_form_yau_07: PackedByteArray) -> void: - var number_socket_input: int - if current_litera >= 1 and current_litera <= 7: - number_socket_input = current_litera + 7 - - var in_blank: int = packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) - flag_si_fs_input = (in_blank & (1 << number_socket_input)) != 0 ## Флаг СИ от ФС входа в ЭМС-Г для текущей литеры - - var number_socket_output: int - number_socket_output = 4 if current_litera in [2, 4, 6] else 3 if current_litera == 1 else 5 - - var out_blank: int = packet_form_yau_07.decode_u16(DataIndices.OUT_BLANK_PRD) - flag_si_fs_output = (out_blank & (1 << number_socket_output)) != 0 ## Флаг Модуляции УМ ЭМС-Г для текущей литеры +#region PROCESS_METHODS +## Основной процесс (не используется, но оставлен для совместимости) +func _process(_delta: float) -> void: + pass - ## Пакеты от MP550Service - func on_fs_update_state(packet_type_7: Dictionary, fs_mapping: Dictionary) -> void: - var fs_key: String = FS_KEYS.get(current_litera, '') - if fs_key.is_empty(): - return - - var fs_result := {fs_key: 0} - fs_result = on_fs_state(packet_type_7, fs_mapping, fs_result) - control_results[fs_key] = fs_result[fs_key] - flag_fs_status_ok = control_results[fs_key] == 1 +## Обработка данных от ЯУ-07 +func on_data_received(unit_pribor: Object) -> void: + var status: PackedByteArray = unit_pribor.status + temperature_um = check_temperature_um(status) + flags.temperature_ok = check_overheating(temperature_um) + block_ip_config = check_block_ip(status, block_ip_config) + block_kasseta_y5_config = check_block_kasseta_y5(status, block_kasseta_y5_config, flags.no_trust_yau07) + _set_control_result('block_kasseta', on_y5_control_result(block_kasseta_y5_config)) + _set_control_result('temperature', flags.temperature_ok) + _set_control_result('block_ip', on_dry_control_result(block_ip_config)) + if not flags.in_control: return + if machine_timer.is_stopped(): return + if flags.no_trust_yau07: return + socket_status_ems_g(status) + _process_dkm_status(status) + # Формирование мощностей в литерах + if current_litera != 0: + var tek_litera: Dictionary = power_for_litera[current_litera] + var interes = _get_ray_key(state) + if interes == 'RAY_CTRL': + count_packets_power += 1 + elif interes != '': + tek_litera[_get_ray_key(state)] = power_um_ukp(status, current_litera, tek_litera[_get_ray_key(state)]) + power_for_litera[current_litera] = tek_litera + count_packets_power += 1 - ## - func state_control_machine() -> void: - match state: - STATE_MASHINE.INIT: - _handle_init_state() - STATE_MASHINE.FS_TURN_ON: - _handle_fs_turn_on_state() - state = STATE_MASHINE.FS_WORK - STATE_MASHINE.FS_WORK: - if ecms.size() and flag_fs_status_ok: - ems_6666_timer.start() - _handle_fs_work_state() - STATE_MASHINE.CHEK_KASSETA_Y5: - if block_kasseta_y5_config['yau07']: - state = STATE_MASHINE.WRITE_ISA - STATE_MASHINE.WRITE_ISA: - if not flag_write_isa: - _handle_ug_set_state(0x6) - state = STATE_MASHINE.READ_ISA - STATE_MASHINE.READ_ISA: - if (unit_prd.cmd_state == unit_prd.CmdState.DONE) or (unit_prd.cmd_state == unit_prd.CmdState.FAIL): - _handle_read_isa(module_prd, unit_prd, [constants.ADDR_UG_LITERA_1, constants.ADDR_UG_LITERA_2, constants.ADDR_UG_LITERA_3]) - flag_write_isa = false - state = STATE_MASHINE.UG_SET_RAY - STATE_MASHINE.UG_SET_RAY: - var addr: int = constants.ADDR_UG_LITERA_1 - if current_litera == 3 or current_litera == 5 or current_litera == 7: - addr = constants.ADDR_UG_LITERA_2 - if unit_prd.isa_ports.has(addr) and (unit_prd.cmd_state == unit_prd.CmdState.DONE): - if unit_prd.isa_ports[addr] & 0x07 == 0: - state = STATE_MASHINE.UG_SET_RAY_1 - elif unit_prd.isa_ports[addr] & 0x07 == 1: - state = STATE_MASHINE.UG_SET_RAY_2 - elif unit_prd.isa_ports[addr] & 0x07 == 2: - state = STATE_MASHINE.UG_SET_RAY_3 - elif unit_prd.isa_ports[addr] & 0x07 == 3: - state = STATE_MASHINE.UG_SET_RAY_4 - elif unit_prd.isa_ports[addr] & 0x07 == 4: - state = STATE_MASHINE.UG_SET_RAY_5 - elif unit_prd.isa_ports[addr] & 0x07 == 5: - if not current_litera == 1: - control_results = check_dou_result(control_results, power_result, self_name, current_litera, constants) - state = STATE_MASHINE.IN_EMS_STOP - elif unit_prd.isa_ports[addr] & 0x07 == 6: - state = STATE_MASHINE.UG_SET_RAY_0 - - STATE_MASHINE.UG_SET_RAY_0: - if flag_si_fs_input and not flag_write_isa: - control_timer.stop() - _handle_ug_set_state(0x0) - await get_tree().create_timer(0.5).timeout - state = STATE_MASHINE.READ_ISA - STATE_MASHINE.UG_SET_RAY_1: - if not flag_write_isa: - _handle_ug_set_state(0x1) - state = STATE_MASHINE.READ_ISA - STATE_MASHINE.UG_SET_RAY_2: - if not flag_write_isa: - _handle_ug_set_state(0x2) - state = STATE_MASHINE.READ_ISA - STATE_MASHINE.UG_SET_RAY_3: - if not flag_write_isa: - _handle_ug_set_state(0x3) - state = STATE_MASHINE.READ_ISA - STATE_MASHINE.UG_SET_RAY_4: - if not flag_write_isa: - _handle_ug_set_state(0x4) - state = STATE_MASHINE.READ_ISA - STATE_MASHINE.UG_SET_RAY_5: - if not flag_write_isa: - _handle_ug_set_state(0x5) - state = STATE_MASHINE.READ_ISA - STATE_MASHINE.IN_EMS_STOP: - ems_6666_timer.stop() - state = STATE_MASHINE.FS_TURN_OFF - STATE_MASHINE.FS_TURN_OFF: - ems_6666_timer.stop() - _handle_fs_turn_off_state() - state = STATE_MASHINE.STOP_CONTROL - STATE_MASHINE.STOP_CONTROL: - _handle_stop_control_state() +## Получение ключа луча по состоянию машины +func _get_ray_key(machine_state: int) -> String: + return _ray_state_mapping.get(machine_state, '') +#endregion - func _handle_init_state() -> void: - control_label.text = 'Выполняется инициализация ФС-%s' % current_litera - if current_litera in [1, 2, 3, 4, 5, 6, 7]: - if not ecms.size(): - state = STATE_MASHINE.FS_TURN_ON - else: - control_results = on_control_result(block_ip_config, control_results) - var send_power_pack = prep_power(power_result, self_name) - emit_signal('control_is_over', control_results, send_power_pack) - state = STATE_MASHINE.AWAIT +#region EMS_SOCKET_HANDLING +## Обработка статуса сокетов ЭМС-Г из пакета ЯУ-07 +func socket_status_ems_g(packet_form_yau_07: PackedByteArray) -> void: + # Обработка для разных типов приборов + if self_name in ['1н', '2н', '3н', '4н']: + ems_g_sock_dic.ems_input_1 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) & (1 << 9)) != 0 + ems_g_sock_dic.ems_input_2 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) & (1 << 10)) != 0 + + if self_name in ['1в', '2в', '3в', '4в']: + ems_g_sock_dic.ems_input_1 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) & (1 << 11)) != 0 + ems_g_sock_dic.ems_input_2 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) & (1 << 12)) != 0 + + if self_name in ['1к', '2к', '3к', '4к']: + ems_g_sock_dic.ems_input_lit_1 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) & (1 << 8)) != 0 + ems_g_sock_dic.ems_input_1 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) & (1 << 13)) != 0 + ems_g_sock_dic.ems_input_2 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) & (1 << 14)) != 0 + + # Обработка выходных сокетов + ems_g_sock_dic.ems_output_lit_1 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('OUT_BLANK_PRD')) & (1 << 3)) != 0 + ems_g_sock_dic.ems_output_1 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('OUT_BLANK_PRD')) & (1 << 4)) != 0 + ems_g_sock_dic.ems_output_2 = (packet_form_yau_07.decode_u16(config_manager.get_data_index('OUT_BLANK_PRD')) & (1 << 5)) != 0 + + # Определение флагов СИ ФС входа + var number_socket_input: int + if current_litera >= 1 and current_litera <= 7: + number_socket_input = current_litera + 7 + + var in_blank: int = packet_form_yau_07.decode_u16(config_manager.get_data_index('IN_BLANK_PRD')) + flags.si_fs_input = (in_blank & (1 << number_socket_input)) != 0 + + # Определение флагов СИ ФС выхода + var number_socket_output: int + number_socket_output = 4 if current_litera in [2, 4, 6] else 3 if current_litera == 1 else 5 + + var out_blank: int = packet_form_yau_07.decode_u16(config_manager.get_data_index('OUT_BLANK_PRD')) + flags.si_fs_output = (out_blank & (1 << number_socket_output)) != 0 +#endregion - func _handle_fs_turn_on_state() -> void: - control_label.text = 'Выполняется включение ФС-%s' % current_litera - manage_fs(true, self_name, pribor_config, fs_parameters, current_litera, constants.POWER_UM) - control_timer.wait_time = constants.TIMER_DELAY - control_timer.start() +#region STATE_MACHINE +## Основная машина состояний контроля ПРД +func state_control_machine() -> void: + match state: + STATE_MACHINE.INIT: _handle_init_state() + STATE_MACHINE.CHEK_KASSETA_Y5: _handle_check_kasseta_state() # Проверка Кассеты У5 + STATE_MACHINE.CHEK_BLOCK_IP: _handle_check_block_ip_state() # Проверка ИП + STATE_MACHINE.FS_TURN_ON: _handle_fs_turn_on_state() + STATE_MACHINE.FS_WORK: _handle_fs_work_state() + STATE_MACHINE.READ_ISA: _handle_read_isa_state() + STATE_MACHINE.UG_SET_RAY_CTRL: _handle_ray_operation(6) + STATE_MACHINE.UG_SET_RAY: _handle_ray_operation() # Режим чтения + STATE_MACHINE.UG_SET_RAY_0: _handle_ray_operation(0) + STATE_MACHINE.UG_SET_RAY_1: _handle_ray_operation(1) + STATE_MACHINE.UG_SET_RAY_2: _handle_ray_operation(2) + STATE_MACHINE.UG_SET_RAY_3: _handle_ray_operation(3) + STATE_MACHINE.UG_SET_RAY_4: _handle_ray_operation(4) + STATE_MACHINE.UG_SET_RAY_5: _handle_ray_operation(5) + STATE_MACHINE.IN_EMS_STOP: _handle_ems_stop_state() + STATE_MACHINE.FS_TURN_OFF: _handle_fs_turn_off_state() + STATE_MACHINE.STOP_CONTROL: _handle_stop_control_state() + # Обновление прогресс-бара после обработки состояния + if block_kasseta_y5_config['yau07'] or flags.no_trust_yau07: + progressbar_status() + +## Обработка состояния INIT - инициализация ФС +func _handle_init_state() -> void: + if current_litera in [1, 2, 3, 4, 5, 6, 7]: + _set_status('Инициализация ФС-%s' % current_litera) + if _get_current_ecm(): return + state = STATE_MACHINE.CHEK_KASSETA_Y5 + else: + if _get_current_ecm(): return + # Завершение контроля если литеры закончились + flags.control_is_over = true + power_result = prep_power(power_for_litera, self_name) + machine_timer.stop() + _set_control_result('is_over_control', flags.control_is_over) + + var result: bool = true + for device in control_results.values(): + if not device: + result = false + _set_status('Прибор ПРД-%s: %s' % [self_name, ['неисправен', 'исправен'][int(result)]]) + emit_signal('control_is_over', self_name) - func _handle_fs_work_state() -> void: - control_label.text = 'Выполняется проверка ФС-%s' % current_litera +## Обработка состояния FS_TURN_ON - включение ФС +func _handle_fs_turn_on_state() -> void: + _set_status('Включение ФС-%s' % current_litera) + manage_fs(self_name, pribor_config, fs_parameters, current_litera, constants.POWER_UM) + current_ecm_key = take_ecm_id(ecms, self_name, current_litera) + flags.ecm_is_comming = current_ecm_key != -1 + control_timer.wait_time = constants.TIMER_DELAY + control_timer.start() + state = STATE_MACHINE.FS_WORK + + +static func take_ecm_id(ecm_dic: Dictionary, device_name: String, current_lit: int) -> int: + # Получаем целевой nmfs из таблицы + var target_nmfs: int = LITER_TO_NMFS.get(device_name, {}).get(current_lit, -1) + if target_nmfs == -1: + return 0 + # Ищем ECM с соответствующим nmfs + for ecm_id in ecm_dic: + if ecm_dic[ecm_id].nmfs == target_nmfs: + return ecm_id + return 0 + + +## Обработка состояния FS_WORK - проверка работы ФС +func _handle_fs_work_state() -> void: + _set_status('Проверка связи сервиса КАПС РПБ') + _set_status('Ожидание выполнения помехи состояние %s литеры %s' % [ecms[current_ecm_key].svk, current_litera]) + if current_ecm_key > 0 and ecms[current_ecm_key].svk == 1: + if not flags.si_fs_input: + _set_status('Ожидание сигнала излучения от ФС-%s' % current_litera) + # Если ФС в порядке if (current_litera == 2 and control_results.fs_2) or \ - (current_litera == 3 and control_results.fs_3) or \ - (current_litera == 4 and control_results.fs_4) or \ - (current_litera == 5 and control_results.fs_5) or \ - (current_litera == 6 and control_results.fs_6) or \ - (current_litera == 7 and control_results.fs_7) or \ - (current_litera == 1 and control_results.fs_1): - state = STATE_MASHINE.CHEK_KASSETA_Y5 + (current_litera == 3 and control_results.fs_3) or \ + (current_litera == 4 and control_results.fs_4) or \ + (current_litera == 5 and control_results.fs_5) or \ + (current_litera == 6 and control_results.fs_6) or \ + (current_litera == 7 and control_results.fs_7) or \ + (current_litera == 1 and control_results.fs_1): + if not block_kasseta_y5_config['yau07']: + _set_status('Ожидание данных от ЯУ-07...') + return # НЕ переходим дальше пока нет данных от сервиса МП550 + + if flags.only_fs: + state = STATE_MACHINE.IN_EMS_STOP + else: + state = STATE_MACHINE.UG_SET_RAY_5 if current_litera == 1 else STATE_MACHINE.UG_SET_RAY_CTRL - func _handle_ug_set_state(RAY_DOU_NUM: int) -> void: - var dic_att := { - 'RAY_DOU_NUM': RAY_DOU_NUM, - 'ADDR_UG_LITERA_1': constants.ADDR_UG_LITERA_1, - 'ADDR_UG_LITERA_2': constants.ADDR_UG_LITERA_2, - 'ADDR_UG_LITERA_3': constants.ADDR_UG_LITERA_3, - 'ATT_UM_3': 0x00, - 'BASE_EMS_G': constants.BASE_ADDR_EMS_G - } - if self_name == '1к' or self_name == '2к' or self_name == '3к' or self_name == '4к': - dic_att['ATT_UM_1'] = constants.ATT_UM_6 - dic_att['ATT_UM_2'] = constants.ATT_UM_7 - dic_att['ATT_UM_3'] = constants.ATT_UM_1 - elif self_name == '1в' or self_name == '2в' or self_name == '3в' or self_name == '4в': - dic_att['ATT_UM_1'] = constants.ATT_UM_4 - dic_att['ATT_UM_2'] = constants.ATT_UM_5 - elif self_name == '1н' or self_name == '2н' or self_name == '3н' or self_name == '4н': - dic_att['ATT_UM_1'] = constants.ATT_UM_2 - dic_att['ATT_UM_2'] = constants.ATT_UM_3 - - var log_text = dic_att.ATT_UM_3 if current_litera == 1 else dic_att.ATT_UM_1 if current_litera in [2, 4, 6] else dic_att.ATT_UM_2 - control_label.text = 'Выполняется настройка угла (%s) и атт (0x0%s)' % [ - dic_att.RAY_DOU_NUM, - log_text - ] - flag_write_isa = on_ug_setting(module_prd, unit_prd, dic_att) +## Обработка состояния CHECK_KASSETA - проверка кассеты Y5 +func _handle_check_kasseta_state() -> void: + _set_status('Проверка кассеты У5') + var block_kasseta_y5 = true + for case in block_kasseta_y5_config: + if not block_kasseta_y5_config[case]: + block_kasseta_y5 = false + if block_kasseta_y5: + if flags.temperature_ok: + ems_6666_timer.start() + state = STATE_MACHINE.CHEK_BLOCK_IP + else: + _set_status('Перегрев УМ') + state = STATE_MACHINE.IN_EMS_STOP + else: + flags.flag_only_fs = true + _set_status('Касета У5: ERROR, Проверка ФС.') + state = STATE_MACHINE.FS_TURN_ON - func _on_ems_6666_timer() -> void: - module_prd.cmd_array.append([unit_prd.CmdCode.WRITE_ISA, [constants.BASE_ADDR_EMS_G, 6666]]) +## Обработка состояния CHECK_BLOCK_IP - проверка кассеты Y5 +func _handle_check_block_ip_state() -> void: + _set_status('Проверка источников питания') + var block_ip = true + for ip in block_ip_config: + if not block_ip_config[ip][1]: + block_ip = false + + state = STATE_MACHINE.FS_TURN_ON if block_ip else STATE_MACHINE.IN_EMS_STOP - func _handle_fs_turn_off_state() -> void: - control_label.text = 'Выполняется отключение ФС-%s' % current_litera - flag_fs_status_ok = false - manage_fs(false, self_name, pribor_config, fs_parameters, current_litera, constants.POWER_UM) +## Обработка состояния READ_ISA - чтение из УГ +func _handle_read_isa_state() -> void: + if (unit_prd.cmd_state == unit_prd.CmdState.DONE) or (unit_prd.cmd_state == unit_prd.CmdState.FAIL): + _handle_read_isa(unit_prd, [constants.ADDR_UG_LITERA_1, constants.ADDR_UG_LITERA_2, constants.ADDR_UG_LITERA_3], cmd_array) + flags.write_isa = false + state = STATE_MACHINE.UG_SET_RAY - func _handle_stop_control_state() -> void: - control_label.text = 'Выполняется завершение проверки ФС-%s' % current_litera - _advance_to_next_fs() - state = STATE_MASHINE.INIT +## Обработка состояния EMS_STOP - остановка ЭМС +func _handle_ems_stop_state() -> void: + ems_6666_timer.stop() + state = STATE_MACHINE.FS_TURN_OFF - func _advance_to_next_fs() -> void: - match current_litera: - 1: current_litera = 6 - 2: current_litera = 3 - 3: current_litera = 0 - 4: current_litera = 5 - 5: current_litera = 0 - 6: current_litera = 7 - 7: current_litera = 0 +## Обработка состояния FS_TURN_OFF - выключение ФС +func _handle_fs_turn_off_state() -> void: + state = STATE_MACHINE.STOP_CONTROL + if not _get_current_ecm(): return + _set_status('Отключение ФС-%s' % current_litera) + flags.fs_status_ok = false + signaller.emit_signal('interfer_off', ecms[current_ecm_key]) - ###################################### - func initialize_connections() -> void: - _determine_self_name() - var fs_mapping = _create_fs_mapping(self_name) - signaller.conn(signaller.fs_update_state, Callable(self, 'on_fs_update_state').bind(fs_mapping)) - interfer.connect('interfer_resized', Callable(self, 'on_interfer_resized')) - unit_prd.connect('data_received', Callable(self, 'on_data_received')) +## Обработка состояния STOP_CONTROL - завершение контроля +func _handle_stop_control_state() -> void: + _set_status('Завершение контроля ФС-%s' % current_litera) + completed_fs_count += 1 + _advance_to_next_fs() + flags.ecm_is_comming = false + state = STATE_MACHINE.INIT - func on_interfer_resized(ecms_dic: Dictionary) -> void: - ecms = ecms_dic +## Переход к следующей литере контроля +func _advance_to_next_fs() -> void: + match current_litera: + 1: current_litera = 6 + 2: current_litera = 3 + 3: current_litera = 0 + 4: current_litera = 5 + 5: current_litera = 0 + 6: current_litera = 7 + 7: current_litera = 0 +#endregion - func _determine_self_name() -> void: - var current_unit = unit_prd.name - var parts = current_unit.split('-') - self_name = parts[-1] +#region RAY_OPERATIONS +## Универсальный обработчик операций с лучами +func _handle_ray_operation(ray_num: int = -1) -> void: + if ray_num == -1: + # Режим чтения - определение текущего луча + _handle_ray_read_mode() + else: + # Режим записи - установка конкретного луча + _handle_ray_write_mode(ray_num) - func setup_timer() -> void: - add_child(control_timer) - control_timer.timeout.connect(on_stop_control) - control_timer.one_shot = true - control_timer.wait_time = 15.0 - control_timer.start() +## Обработка чтения состояния луча +func _handle_ray_read_mode() -> void: + var addr: int = _get_ug_address() + if not _can_process_ray_state(addr): + return - add_child(ems_6666_timer) - ems_6666_timer.timeout.connect(_on_ems_6666_timer) - ems_6666_timer.wait_time = 1.0 + var ray_value = unit_prd.isa_ports[addr] & RAY_MASK + _process_ray_value(ray_value) - func _process_dkm_status(status: PackedByteArray) -> void: - if not control_results.has(_get_current_fs_key()): - return - var dkm_bit = _get_dkm_bit_for_current_fs(current_litera, constants) - if dkm_bit == 0: - control_results['dkm_1'] = check_dkm(status, dkm_bit) +## Обработка записи состояния луча +func _handle_ray_write_mode(ray_num: int) -> void: + if not _can_write_ray(): + return - var addr: int = constants.ADDR_UG_LITERA_1 - if current_litera == 3 or current_litera == 5 or current_litera == 7: - addr = constants.ADDR_UG_LITERA_2 - if not unit_prd.isa_ports.has(addr) or not (unit_prd.cmd_state == unit_prd.CmdState.DONE): - return - if not unit_prd.isa_ports[addr] & 0x07 == 6: return + if (ray_num == 6 or ray_num == 5) and not control_timer.is_stopped(): + control_timer.stop() + # Установка луча + if not flags.write_isa: + _handle_ug_set_state(ray_num) + flags.write_isa = true - if dkm_bit == 1: - control_results['dkm_2'] = check_dkm(status, dkm_bit) - elif dkm_bit == 2: - control_results['dkm_3'] = check_dkm(status, dkm_bit) - elif dkm_bit == 3: - control_results['dkm_4'] = check_dkm(status, dkm_bit) - elif dkm_bit == 4: - control_results['dkm_5'] = check_dkm(status, dkm_bit) - elif dkm_bit == 5: - control_results['dkm_6'] = check_dkm(status, dkm_bit) - elif dkm_bit == 6: - control_results['dkm_7'] = check_dkm(status, dkm_bit) + # Ожидание COUNT_PACK_POWER_RECIEVE пакетов от ЯУ-07 + if count_packets_power < COUNT_PACK_POWER_RECIEVE: return + state = STATE_MACHINE.READ_ISA - func _get_current_fs_key() -> String: - return FS_KEYS.get(current_litera, '') +## Обработка значения луча из UG_SET_RAY состояния +func _process_ray_value(ray_value: int) -> void: + match ray_value: + 0, 1, 2, 3, 4: + var next_ray = ray_value + 1 + if next_ray in RAY_CONFIG: + state = _ray_state_enums[RAY_CONFIG[next_ray].state] + 5: + if not current_litera == 1: + control_results = check_dou_result(control_results, power_for_litera, self_name, current_litera, constants) + state = STATE_MACHINE.IN_EMS_STOP + 6: + if count_packets_power < COUNT_PACK_POWER_RECIEVE: return + state = STATE_MACHINE.UG_SET_RAY_0 - static func _get_dkm_bit_for_current_fs(litera: int, constants_dic: Dictionary) -> int: - match litera: - 1: return constants_dic.DKM_BIT_1 - 2: return constants_dic.DKM_BIT_2 - 3: return constants_dic.DKM_BIT_3 - 4: return constants_dic.DKM_BIT_4 - 5: return constants_dic.DKM_BIT_5 - 6: return constants_dic.DKM_BIT_6 - 7: return constants_dic.DKM_BIT_7 - _: return -1 +## Проверка возможности обработки состояния луча +func _can_process_ray_state(addr: int) -> bool: + return unit_prd.isa_ports.has(addr) and (unit_prd.cmd_state == unit_prd.CmdState.DONE) - static func _get_ray_key(machine_state: int) -> String: - match machine_state: - STATE_MASHINE.UG_SET_RAY_0: return RAY_m5 - STATE_MASHINE.UG_SET_RAY_1: return RAY_5 - STATE_MASHINE.UG_SET_RAY_2: return RAY_15 - STATE_MASHINE.UG_SET_RAY_3: return RAY_25 - STATE_MASHINE.UG_SET_RAY_4: return RAY_35 - STATE_MASHINE.UG_SET_RAY_5: return RAY_45 - _: return '' - - - func on_stop_control() -> void: - _handle_fs_turn_off_state() - state = STATE_MASHINE.FS_TURN_OFF - - - static func on_control_result(ip_config: Dictionary, ctrl_results: Dictionary) -> Dictionary: - var all_blocks_ip_ok = true - - for block in ip_config: - if not ip_config[block][1]: - all_blocks_ip_ok = false - ctrl_results['block_ip'] = all_blocks_ip_ok - return ctrl_results - - - ## Установка угла и аттенюации для УМ - static func on_ug_setting(prd_module: Object, prd_unit: Object, settings_ug: Dictionary) -> bool: - var result_1 = ((settings_ug.ATT_UM_1 & 0x07) << 3) | (settings_ug.RAY_DOU_NUM & 0x07) - var result_2 = ((settings_ug.ATT_UM_2 & 0x07) << 3) | (settings_ug.RAY_DOU_NUM & 0x07) - prd_module.cmd_array.append([prd_unit.CmdCode.WRITE_ISA, [ settings_ug.ADDR_UG_LITERA_1, result_1, - settings_ug.ADDR_UG_LITERA_2, result_2, - settings_ug.ADDR_UG_LITERA_3, settings_ug.ATT_UM_3, - ] - ]) +## Проверка возможности записи луча +func _can_write_ray() -> bool: + if not flags.si_fs_input: + _set_status('Ожидание сигнала излучения от ФС-%s' % current_litera) + return false + else: return true - static func _handle_read_isa(prd_module: Object, prd_unit: Object, read_isa_ports: Array) -> void: - prd_module.cmd_array.append([prd_unit.CmdCode.READ_ISA, read_isa_ports]) +## Получение адреса UG для текущей литеры +func _get_ug_address() -> int: + return constants.ADDR_UG_LITERA_2 if current_litera in SPECIAL_LITERAS else constants.ADDR_UG_LITERA_1 +#endregion - ## Управаление модулем фс (включить/отключить излучение) - static func manage_fs(mode: bool, pribor: String, p_conf: Dictionary, fs_params: Dictionary, litera: int, power_um: int) -> void: - # Получаем конфигурацию для текущего прибора - var config: Dictionary = p_conf[pribor] - var angle: float = config.angle - var sectors: Array = config.sectors +#region UG_OPERATIONS +## Подготовка к настройке и записи в УГ +func _handle_ug_set_state(RAY_DOU_NUM: int) -> void: + var def_att: int = 0x00 + var dic_att := { + 'RAY_DOU_NUM': RAY_DOU_NUM, + 'ADDR_UG_LITERA_1': constants.ADDR_UG_LITERA_1, + 'ADDR_UG_LITERA_2': constants.ADDR_UG_LITERA_2, + 'ADDR_UG_LITERA_3': constants.ADDR_UG_LITERA_3, + 'ATT_UM_3': def_att, + 'BASE_EMS_G': constants.BASE_ADDR_EMS_G + } - # Формируем выходные данные - var interfer_name: String = 'k1' if mode else 'off' - var fs_arr: Array = [] + # Конфигурация аттенюаторов для разных типов приборов + if self_name == '1к' or self_name == '2к' or self_name == '3к' or self_name == '4к': + dic_att['ATT_UM_1'] = constants.ATT_UM_6 + dic_att['ATT_UM_2'] = constants.ATT_UM_7 + dic_att['ATT_UM_3'] = constants.ATT_UM_1 + elif self_name == '1в' or self_name == '2в' or self_name == '3в' or self_name == '4в': + dic_att['ATT_UM_1'] = constants.ATT_UM_4 + dic_att['ATT_UM_2'] = constants.ATT_UM_5 + elif self_name == '1н' or self_name == '2н' or self_name == '3н' or self_name == '4н': + dic_att['ATT_UM_1'] = constants.ATT_UM_2 + dic_att['ATT_UM_2'] = constants.ATT_UM_3 - if litera in fs_params: - var params = fs_params[litera] - fs_arr.append([ - angle, - params.freq, - params.width, - sectors[litera - 1] if litera == 1 else sectors[litera - 5] if litera > 5 else sectors[litera - 4] if litera > 3 else sectors[litera - 2] - ]) - signaller.emit_signal('emit_changed', mode) + var att_key = ATT_MAPPING[current_litera] + _set_status('Литера-%s: Настройка угла %s, АТТ %s' % [current_litera, _get_ray_name(RAY_DOU_NUM), dic_att[att_key]]) + flags.write_isa = on_ug_setting(unit_prd, dic_att, cmd_array, current_litera) + count_packets_power = 0 + + +## Получение имени луча по номеру +func _get_ray_name(ray_num: int) -> String: + return RAY_CONFIG.get(ray_num, {}).get('name', 'неизвестный угол') +#endregion + + +#region PROGRESS_MANAGEMENT +## Обновление статуса прогресс-бара +func progressbar_status() -> void: + if current_litera == 0: + progress_value = PROGRESS_COMPLETE + await get_tree().create_timer(0.5).timeout + progress_value = 0 + return + + var base_progress: float = 0.0 + + # Базовый прогресс в зависимости от состояния + match state: + STATE_MACHINE.INIT: base_progress = PROGRESS_INIT + STATE_MACHINE.FS_TURN_ON: base_progress = PROGRESS_FS_TURN_ON + STATE_MACHINE.FS_WORK: base_progress = PROGRESS_FS_WORK + STATE_MACHINE.CHEK_KASSETA_Y5: base_progress = PROGRESS_CHECK_KASSETA + STATE_MACHINE.UG_SET_RAY_0: base_progress = PROGRESS_RAY_STATES + STATE_MACHINE.UG_SET_RAY_1: base_progress = PROGRESS_RAY_STATES + 5 + STATE_MACHINE.UG_SET_RAY_2: base_progress = PROGRESS_RAY_STATES + 10 + STATE_MACHINE.UG_SET_RAY_3: base_progress = PROGRESS_RAY_STATES + 15 + STATE_MACHINE.UG_SET_RAY_4: base_progress = PROGRESS_RAY_STATES + 20 + STATE_MACHINE.UG_SET_RAY_5: base_progress = PROGRESS_RAY_STATES + 25 + STATE_MACHINE.IN_EMS_STOP: base_progress = PROGRESS_COMPLETE + STATE_MACHINE.FS_TURN_OFF: base_progress = PROGRESS_COMPLETE + 5 + STATE_MACHINE.STOP_CONTROL: base_progress = PROGRESS_COMPLETE + 10 + + # Плавное заполнение во время ожидания таймера + if control_timer.time_left > 0 and state != STATE_MACHINE.STOP_CONTROL: + var timer_progress = (control_timer.wait_time - control_timer.time_left) / control_timer.wait_time + base_progress = lerp(base_progress - 5.0, base_progress, timer_progress) + + # Учитываем прогресс по лучам внутри UG_SET_RAY состояния + if state == STATE_MACHINE.UG_SET_RAY: + var addr: int = _get_ug_address() + if _can_process_ray_state(addr): + var ray_value = unit_prd.isa_ports[addr] & RAY_MASK + var max_ray_value = 5.0 # максимальное значение луча для прогресса + var ray_progress = float(ray_value) / max_ray_value * 40.0 + base_progress += ray_progress + + # Распределяем прогресс по ФС + if total_fs_to_check > 0: + var progress_per_fs = (PROGRESS_COMPLETE - PROGRESS_INIT) / total_fs_to_check + var fs_base_progress = completed_fs_count * progress_per_fs + prog_back = fs_base_progress + (base_progress * progress_per_fs / PROGRESS_COMPLETE) + else: + prog_back = base_progress + + if control_timer.time_left > 0 and not control_timer.is_stopped(): + prog_back += (control_timer.wait_time - control_timer.time_left) + 10 + + prog_back = progress_value if progress_value > prog_back else prog_back + progress_value = clamp(progress_value, prog_back, PROGRESS_COMPLETE) + + +## Установка нового статуса с emit сигнала +func _set_status(new_status: String) -> void: + if current_status != new_status: + current_status = new_status + call_deferred('emit_signal', 'status_updated', new_status) +#endregion + + +#region TIMER_MANAGEMENT +## Настройка таймеров контроля +func setup_timer() -> void: + # Таймер контроля + add_child(control_timer) + control_timer.timeout.connect(on_stop_control) + control_timer.one_shot = true + control_timer.wait_time = constants.get('TIMER_DELAY', 10.0) + + # Таймер ЭМС-Г + add_child(ems_6666_timer) + ems_6666_timer.timeout.connect(_on_ems_6666_timer) + ems_6666_timer.wait_time = 1.0 + + # Таймер машины состояний + add_child(machine_timer) + machine_timer.connect('timeout', Callable(self, 'on_state_mashine')) + + +## Таймер отправки команды в ЭМС-Г для модуляции +func _on_ems_6666_timer() -> void: + cmd_array.append([unit_prd.CmdCode.WRITE_ISA, [constants.BASE_ADDR_EMS_G, 6666]]) + + +## Таймер вызова машины состояний +func on_state_mashine(): + state_control_machine() + + +## Обработка таймаута контроля +func on_stop_control() -> void: + if state == STATE_MACHINE.UG_SET_RAY: + flags.no_trust_yau07 = true + push_error('no_trust_yau07: ', self_name) + state = STATE_MACHINE.IN_EMS_STOP +#endregion + + +#region DEVICE_CONFIGURATION +## Определение имени и конфигурации устройства +func _determine_self_name() -> void: + flags.no_trust_yau07 = false + flags.only_fs = false + cc = 0 + state = STATE_MACHINE.get('INIT', 0) + var current_unit = unit_prd.name + var parts = current_unit.split('-') + self_name = parts[-1] + + var device_type: String = _get_device_type() + if device_type.is_empty(): + return + + # Загрузка конфигурации устройства + var device_config = _device_constants.get(device_type, {}) + var device_data_config = _device_configs.get(device_type, {}) + + constants = device_config.get('constants', {}) + pribor_config = device_config.get('pribor_config', {}) + + # Конвертация fs_params ключей в int + var raw_fs_params = device_config.get('fs_params', {}) + fs_parameters = {} + for key in raw_fs_params: + fs_parameters[int(key)] = raw_fs_params[key] + + # Загрузка конфигураций блоков + block_ip_config = _load_block_config(device_data_config.get('block_ip', {}), 'block_ip') + block_kasseta_y5_config = _load_block_config(device_data_config.get('block_kasseta', {}), 'block_kasseta') + control_results = device_data_config.get('control_results', {}) + current_litera = device_config.get('start_litera', 0) + + # Определение общего количества ФС для контроля + match self_name: + '1к', '2к', '3к', '4к': + total_fs_to_check = 3 # Литеры 1, 6, 7 + '1н', '2н', '3н', '4н': + total_fs_to_check = 2 # Литеры 2, 3 + '1в', '2в', '3в', '4в': + total_fs_to_check = 2 # Литеры 4, 5 + + progress_value = 0 + completed_fs_count = 0 + current_fs_progress = 0.0 + prog_back = 0 + call_deferred('emit_signal', 'update_max_value_progress', 100) + + +## Загрузка конфигурации блока +func _load_block_config(config, config_type: String) -> Dictionary: + if config is String and config == 'base': + return _base_configs.get(config_type, {}).duplicate(true) + elif config is Dictionary: + return config.duplicate(true) + return {} + + +## Определение типа устройства по имени +func _get_device_type() -> String: + if self_name.ends_with('н'): + return 'PRD_N' + elif self_name.ends_with('в'): + return 'PRD_V' + elif self_name.ends_with('к'): + return 'PRD_K' + return '' +#endregion + + +#region CONNECTIONS_MANAGEMENT +## Инициализация соединений и сигналов +func initialize_connections() -> void: + var fs_mapping = _create_fs_mapping(self_name) + signaller.conn(signaller.fs_update_state, Callable(self, 'on_fs_update_state').bind(fs_mapping)) + signaller.conn(signaller.start_contol_device, Callable(self, '_on_start_contol_device')) + interfer.connect('interfer_resized', Callable(self, 'on_interfer_resized')) + unit_prd.connect('data_received', Callable(self, 'on_data_received')) + unit_prd.connect('line_changed', Callable(self, 'on_line_changed_yau07')) + + # Подключение сигналов режимов работы + var mode_signals = ['режим_работа', 'режим_журнал', 'режим_эмс', 'режим_настройки'] + for signal_name in mode_signals: + signaller.connect(signal_name, Callable(self, 'on_mode_changed').bind(false)) + signaller.connect('режим_контроль', Callable(self, 'on_mode_changed').bind(true)) + + +## Обработка обновления состояния ФС от MP550Service +func on_fs_update_state(packet_type_7: Dictionary, fs_mapping: Dictionary) -> void: + var fs_key: String = _fs_keys.get(str(current_litera), '') + if fs_key.is_empty(): + return + + var fs_result := {fs_key: 0} + fs_result = on_fs_state(packet_type_7, fs_mapping, fs_result, _fs_rules) + flags.fs_status_ok = true if fs_result[fs_key] == 1 else false + if not flags.si_fs_input: return + control_results[fs_key] = fs_result[fs_key] + + +## Обработка изменения размера интерферометра +func on_interfer_resized(ecms_dic: Dictionary) -> void: + ecms = ecms_dic + + +## Обработка запуска контроля устройства +func _on_start_contol_device()-> void: + _set_status('Подготовка к контролю') + restore_default_states() + signaller.emit_signal('interfer_off_all') + flags.in_control = true + machine_timer.wait_time = constants.STATE_MASHINE_TIMER + machine_timer.start() + + +## Обработка изменения режима работы +func on_mode_changed(in_tree: bool) -> void: + if not in_tree and flags.in_control: ## При нажатии выхода из режима контроль + state = STATE_MACHINE.INIT + cmd_array.append([unit_prd.CmdCode.WRITE_ISA,[ + constants.ADDR_UG_LITERA_1, DATA_EXIT_CONTOL_ISA, + constants.ADDR_UG_LITERA_2, DATA_EXIT_CONTOL_ISA, + constants.ADDR_UG_LITERA_3, DATA_EXIT_CONTOL_ISA]]) + flags.no_trust_yau07 = false + flags.only_fs = false + flags.ecm_is_comming = false + flags.in_control = false + progress_value = 0 + _handle_fs_turn_off_state() + if not machine_timer.is_stopped(): + flags.control_is_over = false + restore_default_states() + machine_timer.stop() + else: ## При нажатии на режим контроль + _set_status('Ожидание запуска контроля') + + +# Вызывается при смене связи я ячейков ЯУ-07Б +func on_line_changed_yau07(_status: Object)->void: + _set_status('Ожидание запуска контроля') + flags.control_is_over = false + flags.no_trust_yau07 = false + flags.only_fs = false + restore_default_states() +#endregion + + +#region ECMS +## Универсальная проверка доступа к ecms: +func _get_current_ecm() -> Variant: + if current_ecm_key != 0 and ecms.has(current_ecm_key): + return ecms[current_ecm_key] + return null +#endregion + + +#region DKM_PROCESSING +## Обработка статуса ДКМ из пакета ЯУ-07 +func _process_dkm_status(status: PackedByteArray) -> void: + if not control_results.has(_get_current_fs_key(current_litera, _fs_keys)): + return + + var dkm_bit = _get_dkm_bit_for_current_fs(current_litera, constants) + if dkm_bit == 0: + control_results['dkm_1'] = check_dkm(status, dkm_bit) + + var addr: int = constants.ADDR_UG_LITERA_1 + if current_litera == 3 or current_litera == 5 or current_litera == 7: + addr = constants.ADDR_UG_LITERA_2 + + if not unit_prd.isa_ports.has(addr) or not (unit_prd.cmd_state == unit_prd.CmdState.DONE): + return + + if not unit_prd.isa_ports[addr] & 0x07 == 6: + return + + # Обработка битов ДКМ в зависимости от текущей литеры + if dkm_bit == 1: + control_results['dkm_2'] = check_dkm(status, dkm_bit) + elif dkm_bit == 2: + control_results['dkm_3'] = check_dkm(status, dkm_bit) + elif dkm_bit == 3: + control_results['dkm_4'] = check_dkm(status, dkm_bit) + elif dkm_bit == 4: + control_results['dkm_5'] = check_dkm(status, dkm_bit) + elif dkm_bit == 5: + control_results['dkm_6'] = check_dkm(status, dkm_bit) + elif dkm_bit == 6: + control_results['dkm_7'] = check_dkm(status, dkm_bit) + + +## Получение ключа текущей ФС +static func _get_current_fs_key(litera: int, fs_keys_dic: Dictionary) -> String: + return fs_keys_dic.get(str(litera), '') + + +## Возвращает бит ДКМ для проверки текущей литеры +static func _get_dkm_bit_for_current_fs(litera: int, constants_dic: Dictionary) -> int: + match litera: + 1: return constants_dic.DKM_BIT_1 + 2: return constants_dic.DKM_BIT_2 + 3: return constants_dic.DKM_BIT_3 + 4: return constants_dic.DKM_BIT_4 + 5: return constants_dic.DKM_BIT_5 + 6: return constants_dic.DKM_BIT_6 + 7: return constants_dic.DKM_BIT_7 + _: return -1 +#endregion + + +#region PUBLIC_API +## Геттер для текущего статуса +func get_current_status() -> String: + return current_status + + +## Геттер для результатов контроля +func get_control_results() -> Dictionary: + return { + 'control_is_over': flags.control_is_over, + 'result_dic': control_results, + 'power_dic': power_result, + 'block_kasseta_y5_config': block_kasseta_y5_config, + 'block_ip_config': block_ip_config, + 'temperature_um': temperature_um, + 'POWER_THRESHOLD': constants.POWER_THRESHOLD, + 'name_prd': self_name + } +#endregion + + +#region STATIC_UTILITY_METHODS +## Итоговое заключение по результатам контроля всех ИП +static func on_dry_control_result(ip_config: Dictionary) -> bool: + var all_blocks_ip_ok = true + for block in ip_config: + if not ip_config[block][1]: + all_blocks_ip_ok = false + return all_blocks_ip_ok + + +## Итоговое заключение по результатам контроля кассеты у5 +static func on_y5_control_result(block_kasseta: Dictionary) -> bool: + var all_blocks_y5_ok = true + for block in block_kasseta: + if not block_kasseta[block]: + all_blocks_y5_ok = false + return all_blocks_y5_ok + + +## Установка угла и аттенюации для УМ +static func on_ug_setting(prd_unit: Object, settings_ug: Dictionary, prd_cmd_array: Array, cur_litera: int) -> bool: + var result_1: int + var result_2: int + if cur_litera == 1: + result_1 = ((settings_ug.ATT_UM_1 & 0x07) << 3) | (settings_ug.RAY_DOU_NUM & 0x07) + prd_cmd_array.append([prd_unit.CmdCode.WRITE_ISA, [settings_ug.ADDR_UG_LITERA_1, result_1]]) + prd_cmd_array.append([prd_unit.CmdCode.WRITE_ISA, [settings_ug.ADDR_UG_LITERA_3, settings_ug.ATT_UM_3]]) + else: + #if cur_litera in [2, 4, 6]: + result_1 = ((settings_ug.ATT_UM_1 & 0x07) << 3) | (settings_ug.RAY_DOU_NUM & 0x07) + prd_cmd_array.append([prd_unit.CmdCode.WRITE_ISA, [settings_ug.ADDR_UG_LITERA_1, result_1]]) + #elif cur_litera in [3, 5, 7]: + result_2 = ((settings_ug.ATT_UM_2 & 0x07) << 3) | (settings_ug.RAY_DOU_NUM & 0x07) + prd_cmd_array.append([prd_unit.CmdCode.WRITE_ISA, [settings_ug.ADDR_UG_LITERA_2, result_2]]) + return true + + +## Обработка чтения ISA портов +static func _handle_read_isa(prd_unit: Object, read_isa_ports: Array, prd_cmd_array) -> void: + prd_cmd_array.append([prd_unit.CmdCode.READ_ISA, read_isa_ports]) + + +## Управление модулем ФС (включить/отключить излучение) +static func manage_fs(pribor: String, p_conf: Dictionary, fs_params: Dictionary, litera: int, power_um: int) -> void: + var config: Dictionary = p_conf[pribor] + var angle: float = config.angle + var sectors: Array = config.sectors + var interfer_name: String = 'k1' + var fs_arr: Array = [] + + if litera in fs_params: + var params = fs_params[litera] + fs_arr.append([ + angle, + params.freq, + params.width, + sectors[litera - 1] if litera == 1 else sectors[litera - 5] if litera > 5 else sectors[litera - 4] if litera > 3 else sectors[litera - 2] + ]) signaller.emit_signal('interfer_init', interfer_name, fs_arr, power_um) - ## Проверка касет П1 и ИП МА2000 - static func check_block_ip(status_prd: PackedByteArray, ip_config: Dictionary) -> Dictionary: - # Конфигурация проверяемых блоков - var byte_dry: int = 27 - var ug_valid: bool = (status_prd[0] >> 1) & 1 - for block in ip_config: - var bit: int = ip_config[block][0] - if ug_valid: - var status = status_prd[byte_dry] >> bit & 1 - ip_config[block][1] = false if status else true - return ip_config +## Проверка кассет П1 и ИП МА2000 +static func check_block_ip(status_prd: PackedByteArray, ip_config: Dictionary) -> Dictionary: + var byte_dry: int = 27 + var ug_valid: bool = (status_prd[0] >> 1) & 1 + for block in ip_config: + var bit: int = ip_config[block][0] + if ug_valid: + var status = status_prd[byte_dry] >> bit & 1 + ip_config[block][1] = false if status else true + return ip_config - ## Проверка кассеты у-5 (ЯУ-07Б, ЭМС-Г, УГ, УКП-1, УКП-2) - static func check_block_kasseta_y5(status_prd: PackedByteArray, y5_config: Dictionary) -> Dictionary: - y5_config.yau07 = true +## Проверка кассеты у-5 (ЯУ-07Б, ЭМС-Г, УГ, УКП-1, УКП-2) +static func check_block_kasseta_y5(status_prd: PackedByteArray, y5_config: Dictionary, flag_not_trust: bool) -> Dictionary: + y5_config.yau07 = not flag_not_trust + if y5_config.yau07: y5_config.ems = (status_prd[0] & 1) and ((status_prd[0] >> 4) & 1) y5_config.ug = (status_prd[0] >> 1) & 1 y5_config.ukp1 = (status_prd[0] >> 2) & 1 y5_config.ukp2 = (status_prd[0] >> 3) & 1 - return y5_config + return y5_config - ## Проверка температур УМ от УКП - static func check_temperature_um(status_prd: PackedByteArray, power_amplifier: Array) -> bool: - const Constants: Dictionary = { - 'CONST_MIN_TEMP': -25, - 'MAXIMUM_CODE_ADC': 3796, - 'MINIMUM_CODE_AD': 2660, - 'TEMPERATURE_UKP_1': 47, - 'TEMPERATURE_UKP_2': 79, - } - const TEMP: float = 115.0 / (Constants.MAXIMUM_CODE_ADC - Constants.MINIMUM_CODE_AD) - var ukp1_online: int = (status_prd[0] >> 2) & 1 - var ukp2_online = (status_prd[0] >> 3) & 1 - var all_temp_is_ok: bool = true +## Мониторинг температуры УМ +static func check_temperature_um(status_prd: PackedByteArray) -> Dictionary: + const Constants: Dictionary = { + 'CONST_MIN_TEMP': -25, + 'MAXIMUM_CODE_ADC': 3796, + 'MINIMUM_CODE_AD': 2660, + 'TEMPERATURE_UKP_1': 47, + 'TEMPERATURE_UKP_2': 79, + } + const arr_um: Array = ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6', 'um_7', 'um_8', 'um_9', 'um_10', 'um_11', 'um_12', 'um_13', 'um_14', 'um_15', 'um_16'] + const TEMP: float = 115.0 / (Constants.MAXIMUM_CODE_ADC - Constants.MINIMUM_CODE_AD) + var return_dic_temp: Dictionary + var ukp1_online: int = (status_prd[0] >> 2) & 1 + var ukp2_online = (status_prd[0] >> 3) & 1 - if ukp1_online: - var tmp_1: int - var temperature_ukp_1: int - for i_temp in 6: - temperature_ukp_1 = status_prd.decode_u16(Constants.TEMPERATURE_UKP_1 + 2 * i_temp) - tmp_1 = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3) - power_amplifier[i_temp].value1 = tmp_1 - if tmp_1>70: - all_temp_is_ok = false + if ukp1_online: + var tmp_1: int + var temperature_ukp_1: int + for i_temp in 8: + temperature_ukp_1 = status_prd.decode_u16(Constants.TEMPERATURE_UKP_1 + 2 * i_temp) + tmp_1 = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3) + return_dic_temp[arr_um[i_temp]] = tmp_1 + else: + for i_temp in 8: + return_dic_temp[arr_um[i_temp]] = -999 # Заполняем нулями если УКП нет на связи - if power_amplifier.size() > 12: # Темпуратура от УМ литеры 1 - temperature_ukp_1 = status_prd.decode_u16(Constants.TEMPERATURE_UKP_1 + 2 * 7) - tmp_1 = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3) - power_amplifier[6].value1 = tmp_1 - if tmp_1>70: - all_temp_is_ok = false - - if ukp2_online: - for i_temp in 6: - var temperature_ukp_2: int = status_prd.decode_u16(Constants.TEMPERATURE_UKP_2 + 2 * i_temp) - var tmp_2: int = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_2) * TEMP + 3) - if power_amplifier.size() > 12: - power_amplifier[i_temp+7].value1 = tmp_2 - if tmp_2>70: - all_temp_is_ok = false - else: - power_amplifier[i_temp+6].value1 = tmp_2 - if tmp_2>70: - all_temp_is_ok = false - return all_temp_is_ok - - ## Проверка ДКМ - static func check_dkm(status_prd: PackedByteArray, bit_dkm: int) -> bool: - var dkm: int = 28 - var status_dkm: bool = status_prd[dkm] >> bit_dkm & 1 - return status_dkm + if ukp2_online: + for i_temp in 8: + var temperature_ukp_2: int = status_prd.decode_u16(Constants.TEMPERATURE_UKP_2 + 2 * i_temp) + var tmp_2: int = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_2) * TEMP + 3) + return_dic_temp[arr_um[i_temp+8]] = tmp_2 + else: + for i_temp in 8: + return_dic_temp[arr_um[i_temp+8]] = -999 # Заполняем -999 если УКП нет на связи + return return_dic_temp - ## - static func _create_fs_mapping(s_name: String) -> Dictionary: - var suffixes: Dictionary = { - 0: '1к', 1: '4к', 2: '3к', 3: '2к', - 4: '1н', 5: '4н', 6: '3н', 7: '2н', - 8: '1н', 9: '4н', 10: '3н', 11: '2н', +static func check_overheating(temperature_data: Dictionary) -> bool: + const MAX_TEMP: int = 55 + const MIN_VALID_TEMP: int = -1500 + const MAX_VALID_TEMP: int = 130 + + for key in temperature_data: + var temp = temperature_data[key] + + # Пропускаем невалидные значения + if temp < MIN_VALID_TEMP or temp > MAX_VALID_TEMP: + continue + + # Проверяем превышение температуры + if temp > MAX_TEMP: + return false + return true + + +## Проверка ДКМ +static func check_dkm(status_prd: PackedByteArray, bit_dkm: int) -> bool: + var dkm: int = 28 + var status_dkm: bool = status_prd[dkm] >> bit_dkm & 1 + return status_dkm + + +## Распределение номеров ФС по приборам +static func _create_fs_mapping(s_name: String) -> Dictionary: + var suffixes: Dictionary = { + 0: '1к', 1: '4к', 2: '3к', 3: '2к', + 4: '1н', 5: '4н', 6: '3н', 7: '2н', + 8: '1н', 9: '4н', 10: '3н', 11: '2н', 12: '1в', 13: '4в', 14: '3в', 15: '2в', 16: '1в', 17: '4в', 18: '3в', 19: '2в', 20: '1к', 21: '4к', 22: '3к', 23: '2к', 24: '1к', 25: '4к', 26: '3к', 27: '2к', - } + } - var mapping: Dictionary = {} - for fs_num in suffixes: - mapping[fs_num] = {'condition': s_name == suffixes[fs_num]} - return mapping + var mapping: Dictionary = {} + for fs_num in suffixes: + mapping[fs_num] = {'condition': s_name == suffixes[fs_num]} + return mapping - ## - static func on_fs_state(packet_type_7: Dictionary, fs_mapping: Dictionary, fs_results: Dictionary) -> Dictionary: - var FS_RULES = [ - {'key': 'fs_1', 'min': 0, 'max': 4}, - {'key': 'fs_2', 'min': 4, 'max': 8}, - {'key': 'fs_3', 'min': 8, 'max': 12}, - {'key': 'fs_4', 'min': 12, 'max': 16}, - {'key': 'fs_5', 'min': 16, 'max': 20}, - {'key': 'fs_6', 'min': 20, 'max': 24}, - {'key': 'fs_7', 'min': 24, 'max': 27} - ] - - var updated_results := fs_results.duplicate() - for fs_num in packet_type_7: - if not (fs_num in fs_mapping and fs_mapping[fs_num]['condition']): - continue - var fs_data = packet_type_7[fs_num] - for rule_key in FS_RULES.size(): - var rule: Dictionary = FS_RULES[rule_key] - if _should_apply_rule(fs_num, rule, updated_results): - updated_results[rule.key] = fs_data.isg - break - return updated_results +## Получение статуса ФС +static func on_fs_state(packet_type_7: Dictionary, fs_mapping: Dictionary, fs_results: Dictionary, fs_rules_config: Array) -> Dictionary: + var updated_results := fs_results.duplicate() + for fs_num in packet_type_7: + if not (fs_num in fs_mapping and fs_mapping[fs_num]['condition']): + continue + var fs_data = packet_type_7[fs_num] + for rule in fs_rules_config: + if _should_apply_rule(fs_num, rule, updated_results): + updated_results[rule.key] = fs_data.isg + break + return updated_results - ## Вспомогательная функция для проверки применения правила - static func _should_apply_rule(fs_num: int, rule: Dictionary, results: Dictionary) -> bool: - return bool(fs_num >= rule.min and fs_num < rule.max) and results.has(rule.key) +## Вспомогательная функция для проверки применения правила +static func _should_apply_rule(fs_num: int, rule: Dictionary, results: Dictionary) -> bool: + return bool(fs_num >= rule.min and fs_num < rule.max) and results.has(rule.key) - ## - static func power_um_ukp(status: PackedByteArray, litera: int, pwr_result: Array) -> Array: - const Constants: Dictionary = {'POWER_UKP_1' : 31, 'POWER_UKP_2': 63} - var power_values: Array = [] - var base_offset = 0 - var iteration: int = 6 - var ug_valid: bool = (status[0] >> 2) & 1 +## Получение мощности при выполнении контроля +static func power_um_ukp(status: PackedByteArray, litera: int, pwr_result: Array) -> Array: + const Constants: Dictionary = {'POWER_UKP_1' : 31, 'POWER_UKP_2': 63} + var power_values: Array = [] + var base_offset = 0 + var iteration: int = 6 + var ug_valid: bool = (status[0] >> 2) & 1 - match litera: - 1: - # Обработка для current_fs = 1 (одно значение) - var value = status.decode_u16(Constants.POWER_UKP_1 + 2 * 7) - if ug_valid: - power_values = [value] - 2: - # Обработка для current_fs = 2 (6 значений из УКП1) - base_offset = Constants.POWER_UKP_1 - if ug_valid: - for i in iteration: - power_values.append(status.decode_u16(base_offset + 2 * i)) - 3: - # Обработка для current_fs = 3 (6 значений из УКП2) - base_offset = Constants.POWER_UKP_2 - if ug_valid: - for i in iteration: - power_values.append(status.decode_u16(base_offset + 2 * i)) - 4: - # Обработка для current_fs = 4 (6 значений из УКП1) - base_offset = Constants.POWER_UKP_1 - if ug_valid: - for i in iteration: - power_values.append(status.decode_u16(base_offset + 2 * i)) - 5: - # Обработка для current_fs = 5 (6 значений из УКП2) - base_offset = Constants.POWER_UKP_2 - if ug_valid: - for i in iteration: - power_values.append(status.decode_u16(base_offset + 2 * i)) - 6: - # Обработка для current_fs = 6 (6 значений из УКП1) - base_offset = Constants.POWER_UKP_1 - if ug_valid: - for i in iteration: - power_values.append(status.decode_u16(base_offset + 2 * i)) - 7: - # Обработка для current_fs = 7 (6 значений из УКП2) - base_offset = Constants.POWER_UKP_2 - if ug_valid: - for i in iteration: - power_values.append(status.decode_u16(base_offset + 2 * i)) + match litera: + 1: + var value = status.decode_u16(Constants.POWER_UKP_1 + 2 * 7) + if ug_valid: + power_values = [value] + 2: + base_offset = Constants.POWER_UKP_1 + if ug_valid: + for i in iteration: + power_values.append(status.decode_u16(base_offset + 2 * i)) + 3: + base_offset = Constants.POWER_UKP_2 + if ug_valid: + for i in iteration: + power_values.append(status.decode_u16(base_offset + 2 * i)) + 4: + base_offset = Constants.POWER_UKP_1 + if ug_valid: + for i in iteration: + power_values.append(status.decode_u16(base_offset + 2 * i)) + 5: + base_offset = Constants.POWER_UKP_2 + if ug_valid: + for i in iteration: + power_values.append(status.decode_u16(base_offset + 2 * i)) + 6: + base_offset = Constants.POWER_UKP_1 + if ug_valid: + for i in iteration: + power_values.append(status.decode_u16(base_offset + 2 * i)) + 7: + base_offset = Constants.POWER_UKP_2 + if ug_valid: + for i in iteration: + power_values.append(status.decode_u16(base_offset + 2 * i)) - power_values = update_max_power_values(power_values, pwr_result) - return power_values + power_values = update_max_power_values(power_values, pwr_result) + return power_values - ## Обновление максимальных значений - static func update_max_power_values(power_data: Array, max_power_values: Array) -> Array: - if power_data.size() != 6: - if max_power_values.is_empty(): - max_power_values = power_data.duplicate() - elif power_data[0] > max_power_values[0]: - max_power_values = power_data.duplicate() - return max_power_values - +## Обновление максимальных значений мощности +static func update_max_power_values(power_data: Array, max_power_values: Array) -> Array: + if power_data.size() != 6: if max_power_values.is_empty(): max_power_values = power_data.duplicate() - else: - for i in 6: - if power_data[i] > max_power_values[i]: - max_power_values[i] = power_data[i] + elif power_data[0] > max_power_values[0]: + max_power_values = power_data.duplicate() + return max_power_values - return max_power_values.duplicate() + if max_power_values.is_empty(): + max_power_values = power_data.duplicate() + else: + for i in 6: + if power_data[i] > max_power_values[i]: + max_power_values[i] = power_data[i] + + return max_power_values.duplicate() - static func check_dou_result(control_dic: Dictionary, power_dic: Dictionary, pribor: String, litera: int, cnst: Dictionary) -> Dictionary: - var all_dou_ok = true - var dou: String = 'dou_2' if litera == 2 else 'dou_3' - if pribor == '1к' or pribor == '2к' or pribor == '3к' or pribor == '4к': - dou = 'dou_6' if litera == 6 else 'dou_7' - elif pribor == '1в' or pribor == '2в' or pribor == '3в' or pribor == '4в': - dou = 'dou_4' if litera == 4 else 'dou_5' +## Подготовка принятых данных по контролю для передачи в сцену +static func prep_power(power_dic: Dictionary, prd_name: String)-> Dictionary: + const RAY_KEYS := ['RAY_m5', 'RAY_5', 'RAY_15', 'RAY_25', 'RAY_35', 'RAY_45'] + var prep_pow_dic: Dictionary = {} - var ray_dic: Dictionary = power_dic[litera] - if ray_dic[RAY_m5].size() == 0 or \ - ray_dic[RAY_5 ].size() == 0 or \ - ray_dic[RAY_15].size() == 0 or \ - ray_dic[RAY_25].size() == 0 or \ - ray_dic[RAY_35].size() == 0 or \ - ray_dic[RAY_45].size() == 0: - control_dic[dou] = false - return control_dic + var arr_litera: Array[int] + match prd_name: + '1н', '2н', '3н', '4н': + arr_litera = [2, 3] + '1в', '2в', '3в', '4в': + arr_litera = [4, 5] + '1к', '2к', '3к', '4к': + arr_litera = [6, 7, 1] - for i_pow_arr in ray_dic.values(): - for i_pow in i_pow_arr.size(): - if i_pow_arr[i_pow] < cnst.POWER_THRESHOLD: - all_dou_ok = false + if not arr_litera: + print_debug('Ошибка в prd_name') + return prep_pow_dic - control_dic[dou] = all_dou_ok + var um_names: Array[Array] = [] + if arr_litera.size() != 3: + um_names = [ + ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'], + ['um_9', 'um_10', 'um_11', 'um_12', 'um_13', 'um_14'] + ] + else: + um_names = [ + ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'], + ['um_9', 'um_10', 'um_11', 'um_12', 'um_13', 'um_14'], + ['um_8'] + ] + for litera_index in arr_litera.size(): + var litera: int = arr_litera[litera_index] + var litera_data: Dictionary = power_dic.get(litera, {}) + var um_data: Array[Array] = [[], [], [], [], [], []] + + for i in range(RAY_KEYS.size()): + var ray_key: String = RAY_KEYS[i] + var ray_array: Array = litera_data.get(ray_key, []) + + if ray_array.size() == 1: + var single_value = ray_array[0] + for j in range(6): + um_data[j].append(single_value) + else: + for j in range(6): + um_data[j].append(ray_array[j] if j < ray_array.size() else 0) + + var current_um_names: Array = um_names[litera_index] + for um_index in range(current_um_names.size()): + prep_pow_dic[current_um_names[um_index]] = um_data[um_index] + return prep_pow_dic + + +## Проверка результатов ДОУ +static func check_dou_result(control_dic: Dictionary, power_dic: Dictionary, pribor: String, litera: int, cnst: Dictionary) -> Dictionary: + var dou: String = 'dou_2' if litera == 2 else 'dou_3' + if pribor == '1к' or pribor == '2к' or pribor == '3к' or pribor == '4к': + dou = 'dou_6' if litera == 6 else 'dou_7' + elif pribor == '1в' or pribor == '2в' or pribor == '3в' or pribor == '4в': + dou = 'dou_4' if litera == 4 else 'dou_5' + + var ray_dic: Dictionary = power_dic[litera] + # Проверка наличия данных + if ray_dic[RAY_m5].size() == 0 or \ + ray_dic[RAY_5 ].size() == 0 or \ + ray_dic[RAY_15].size() == 0 or \ + ray_dic[RAY_25].size() == 0 or \ + ray_dic[RAY_35].size() == 0 or \ + ray_dic[RAY_45].size() == 0: + control_dic[dou] = false return control_dic + # Подсчет значений ниже порога по позициям + var low_power_by_position: Array = [0, 0, 0, 0, 0, 0] # Счетчики для 6 позиций + for ray_key in [RAY_m5, RAY_5, RAY_15, RAY_25, RAY_35, RAY_45]: + var power_array: Array = ray_dic[ray_key] + for i in range(power_array.size()): + if power_array[i] < cnst.POWER_THRESHOLD: + low_power_by_position[i] += 1 - static func prep_power(power_dic: Dictionary, prd_name: String)-> Dictionary: - const RAY_KEYS := ["RAY_m5", "RAY_5", "RAY_15", "RAY_25", "RAY_35", "RAY_45"] - var prep_pow_dic: Dictionary = {} + # Проверяем, нет ли позиции где много низких значений + var limit_power_um: int = 2 + var good_positions: int = 0 + for count in low_power_by_position: + if count <= limit_power_um: + good_positions += 1 + control_dic[dou] = good_positions >= 4 + return control_dic +#endregion - var arr_litera: Array[int] - match prd_name: - '1н', '2н', '3н', '4н': - arr_litera = [2, 3] - '1в', '2в', '3в', '4в': - arr_litera = [4, 5] - '1к', '2к', '3к', '4к': - arr_litera = [6, 7, 1] +#region DEFAULT_STATES +## Глубокое копирование структуры мощностей +func _deep_copy_power_structure() -> Dictionary: + var copy = {} + for litera in power_for_litera: + copy[litera] = {} + for ray_type in power_for_litera[litera]: + copy[litera][ray_type] = power_for_litera[litera][ray_type].duplicate() + return copy - if not arr_litera: - print_debug('Ошибка в prd_name') - return prep_pow_dic +## Восстановление состояний по умолчанию +func restore_default_states() -> void: + if _default_states.is_empty(): + _initialize_default_states() - var um_names: Array[Array] = [] - if arr_litera.size() != 3: - um_names = [ - ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'], - ['um_7', 'um_8', 'um_9', 'um_10', 'um_11', 'um_12'] - ] - else: - um_names = [ - ['um_1', 'um_2', 'um_3', 'um_4', 'um_5', 'um_6'], - ['um_8', 'um_9', 'um_10', 'um_11', 'um_12', 'um_13'], - ['um_7'] # Особый случай для третьего элемента - ] + # Восстановление простых переменных + flags = _default_states['flags'].duplicate(true) + state = _default_states['state'] + current_litera = _default_states['current_litera'] - for litera_index in arr_litera.size(): - var litera: int = arr_litera[litera_index] - var litera_data: Dictionary = power_dic.get(litera, {}) - var um_data: Array[Array] = [[], [], [], [], [], []] + progress_value = _default_states['progress_value'] + current_status = _default_states['current_status'] + total_fs_to_check = _default_states['total_fs_to_check'] + completed_fs_count = _default_states['completed_fs_count'] + current_fs_progress = _default_states['current_fs_progress'] - for i in range(RAY_KEYS.size()): - var ray_key: String = RAY_KEYS[i] - var ray_array: Array = litera_data.get(ray_key, []) + cc = _default_states['cc'] - if ray_array.size() == 1: - var single_value = ray_array[0] - for j in range(6): - um_data[j].append(single_value) - else: - for j in range(6): - um_data[j].append(ray_array[j] if j < ray_array.size() else 0) + # Восстановление словарей (глубокое копирование) + ems_g_sock_dic = _default_states['ems_g_sock_dic'].duplicate(true) + power_for_litera = _default_states['power_for_litera'].duplicate(true) + control_results = _default_states['control_results'].duplicate(true) + power_result = _default_states['power_result'].duplicate(true) + temperature_um = _default_states['temperature_um'].duplicate(true) + block_ip_config = _default_states['block_ip_config'].duplicate(true) - var current_um_names: Array = um_names[litera_index] - for um_index in range(current_um_names.size()): - prep_pow_dic[current_um_names[um_index]] = um_data[um_index] - return prep_pow_dic + # Остановка таймеров + control_timer.stop() + ems_6666_timer.stop() + machine_timer.stop() + + _set_status('Состояния сброшены к значениям по умолчанию') + +## Получение текущих состояний для отладки +func get_current_states() -> Dictionary: + return { + 'flags': flags.duplicate(true), + 'state_machine': { + 'state': state, + 'current_litera': current_litera + }, + 'progress': { + 'value': progress_value, + 'status': current_status, + 'total_fs': total_fs_to_check, + 'completed_fs': completed_fs_count, + 'current_fs_progress': current_fs_progress + }, + 'counters': { + 'cc': cc, + 'cmd_array_size': cmd_array.size() + }, + 'results': { + 'power_for_litera': power_for_litera, + 'power_results': power_result, + 'control_results': control_results, + } + } +#endregion + +#region setters +func _set_control_result(key: String, status: bool)-> void: + var old_value = control_results.get(key) + if key == 'is_over_control' or old_value != status: + control_results[key] = status + emit_signal('control_results_updated', control_results) + + +func _get_control_result(key: String) -> bool: + return control_results[key] +#endregion diff --git a/scripts/signaller.gd b/scripts/signaller.gd index 16c703b1..434df1ea 100644 --- a/scripts/signaller.gd +++ b/scripts/signaller.gd @@ -182,6 +182,11 @@ signal kb_pressed(state) signal ems2_hide_pressed(state) +## Вызывается при нажатии на кнопку отладки контроля +## [param state] - состояние показа отладки контроля +signal debag_control_pressed(state) + + ## Вызывается при нажатии на кнопку экранной клавиатуры ## [param state] - состояние скрытия кнопки ЭМС2 signal emit_changed(state) @@ -216,6 +221,10 @@ signal sector_klaster (new_sector_data) signal clear_klaster () +## Вызывается при нажатии на кнопку "Запуск контроля".[br] +signal start_contol_device() + + ## Вызывается при программном отключении помехи.[br] ## [param ecm] - выключаемая помеха ([b]true[/b] signal on_prog_ecm_off(ecm: interfer.Interfer) diff --git a/scripts/trassa.gd b/scripts/trassa.gd index d9b0fbf6..cb8896fc 100644 --- a/scripts/trassa.gd +++ b/scripts/trassa.gd @@ -269,8 +269,6 @@ class Trassa extends unit.Unit: tx_stack[65] = 0 for ecm in ecms.values(): if ecm.krp == "srni1" and ecm.svk == 1: - ecm.krp = interfer.INTERFER_OFF - interfer.send_ecm(ecm, unit_caps) signaller.emit_signal('interfer_off', ecm) if jtids == 1: tx_stack[66] = 1 @@ -279,6 +277,4 @@ class Trassa extends unit.Unit: tx_stack[66] = 0 for ecm in ecms.values(): if ecm.krp == 'svi1' and ecm.svk == 1: - ecm.krp = interfer.INTERFER_OFF - interfer.send_ecm(ecm, unit_caps) signaller.emit_signal('interfer_off', ecm) diff --git a/table/table.gd b/table/table.gd index 4d645d52..f17dbfe2 100644 --- a/table/table.gd +++ b/table/table.gd @@ -322,7 +322,6 @@ func _set_row_selected(i_row: int, selected: bool = true) -> void: push_error('нет такого ряда: %d (всего %d рядов)\n' % [i_row, rows_count]) return if nodes.has(selector_key) and (not selected): - var node = nodes[node_key] var selector = nodes[selector_key] nodes.erase(selector_key) if is_instance_valid(selector): @@ -450,9 +449,11 @@ func remove_row(i_row: int): if nodes.has(sel_key): var selector = nodes[sel_key] - var prnt = selector.get_parent() - prnt.remove_child(selector) - selector.queue_free() + if is_instance_valid(selector): + var prnt = selector.get_parent() + if prnt: + prnt.remove_child(selector) + selector.queue_free() nodes.erase(sel_key) for i_col in columns: