From ffd22b59f46189a7dadf5e62bb0d7cd280b4af6b Mon Sep 17 00:00:00 2001 From: Maxim Date: Tue, 24 Jun 2025 14:25:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=9F=D0=A0=D0=94-=D0=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/pribor-prd-n/pribor-prd-n.tscn | 1 + scenes/pribor-prd-n/pribor_prd_n.gd | 4 +- scenes/pribor-prd-v/pribor-prd-v.tscn | 130 +++++++++++++++++++++---- scenes/pribor-prd-v/pribor_prd_v.gd | 131 +++++++++++++++++++++----- 4 files changed, 226 insertions(+), 40 deletions(-) diff --git a/scenes/pribor-prd-n/pribor-prd-n.tscn b/scenes/pribor-prd-n/pribor-prd-n.tscn index 1e23a7e..f97936e 100644 --- a/scenes/pribor-prd-n/pribor-prd-n.tscn +++ b/scenes/pribor-prd-n/pribor-prd-n.tscn @@ -376,6 +376,7 @@ fname = "УМ1535А" rname = "A18" [node name="Monitoring_panel" type="Panel" parent="."] +visible = false layout_mode = 0 theme_override_styles/panel = SubResource("StyleBoxTexture_bnnv3") diff --git a/scenes/pribor-prd-n/pribor_prd_n.gd b/scenes/pribor-prd-n/pribor_prd_n.gd index 89f8775..6f822dd 100644 --- a/scenes/pribor-prd-n/pribor_prd_n.gd +++ b/scenes/pribor-prd-n/pribor_prd_n.gd @@ -38,12 +38,12 @@ func set_default_state() -> void: group.state = STATE_VAL.NONE -func on_line_changed(unit_prd: Object): +func on_line_changed(unit_prd: Object) -> void: if not unit_prd.online: set_default_state() -func on_data_received(unit_prd: Object): +func on_data_received(unit_prd: Object) -> void: if not is_inside_tree(): return diff --git a/scenes/pribor-prd-v/pribor-prd-v.tscn b/scenes/pribor-prd-v/pribor-prd-v.tscn index b6b22cb..a86227f 100644 --- a/scenes/pribor-prd-v/pribor-prd-v.tscn +++ b/scenes/pribor-prd-v/pribor-prd-v.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://cvskpe1ti3p45"] +[gd_scene load_steps=15 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"] @@ -9,8 +9,33 @@ [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://bkxblfoj7ejv0" path="res://scenes/контроль/блок-а.tscn" id="7_e22c6"] +[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="10_4e87c"] +[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="11_g8fvp"] +[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="12_gsby4"] -[node name="pribor_prd_n" type="Control"] +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_vxfkm"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_s5gcy"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("10_4e87c") +}, { +"duration": 1.0, +"texture": ExtResource("11_g8fvp") +}, { +"duration": 1.0, +"texture": ExtResource("12_gsby4") +}, { +"duration": 1.0, +"texture": null +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[node name="pribor_prd_v" type="Control"] layout_mode = 3 anchors_preset = 0 offset_left = 15.0 @@ -110,7 +135,7 @@ patch_margin_bottom = 16 script = ExtResource("6_os4mt") fname = "Кассета П-1В" -[node name="ref_A26" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] +[node name="ref_A19" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] offset_left = 9.0 offset_top = 33.0 offset_right = 59.0 @@ -118,7 +143,7 @@ offset_bottom = 183.0 fname = "ИП9-50" rname = "A19" -[node name="ref_A23" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] +[node name="ref_A20" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] offset_left = 59.0 offset_top = 33.0 offset_right = 109.0 @@ -126,7 +151,7 @@ offset_bottom = 183.0 fname = "ИП9-50" rname = "A20" -[node name="ref_A24" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] +[node name="ref_A21" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] offset_left = 109.0 offset_top = 33.0 offset_right = 159.0 @@ -145,7 +170,7 @@ text = "Кассета П-1В" horizontal_alignment = 1 vertical_alignment = 1 -[node name="um1535_A7" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A7" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 242.0 @@ -160,7 +185,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A7" -[node name="um1535_A8" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A8" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 337.0 @@ -173,7 +198,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A8" -[node name="um1535_A9" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A9" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 432.0 @@ -186,7 +211,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A9" -[node name="um1535_A10" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A10" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 527.0 @@ -199,7 +224,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A10" -[node name="um1535_A11" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A11" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 622.0 @@ -212,7 +237,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A11" -[node name="um1535_A12" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A12" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 717.0 @@ -225,7 +250,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A12" -[node name="um1535_A13" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A13" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 242.0 @@ -238,7 +263,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A13" -[node name="um1535_A14" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 337.0 @@ -251,7 +276,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A14" -[node name="um1535_A15" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 432.0 @@ -264,7 +289,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A15" -[node name="um1535_A16" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A16" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 527.0 @@ -277,7 +302,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A16" -[node name="um1535_A17" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A17" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 622.0 @@ -290,7 +315,7 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A17" -[node name="um1535_A18" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A18" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 717.0 @@ -302,3 +327,74 @@ name_min_size0 = Vector2i(35, 20) name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A18" + +[node name="Monitoring_panel" type="Panel" parent="."] +theme_override_styles/panel = SubResource("StyleBoxTexture_vxfkm") + +[node name="in_fs_1" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(454, 577) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="in_fs_1" type="Label" parent="Monitoring_panel/in_fs_1"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "In FS 1" +horizontal_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="in_fs_2" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(207, 577) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="in_fs_2" type="Label" parent="Monitoring_panel/in_fs_2"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "In FS 2" +horizontal_alignment = 1 + +[node name="out_ems_1" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(454, 465) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="Out_ems_1" type="Label" parent="Monitoring_panel/out_ems_1"] +anchors_preset = -1 +anchor_left = 0.0185185 +anchor_right = 0.0185185 +anchor_bottom = 0.555556 +offset_left = -18.5 +offset_top = 14.0 +offset_right = 17.5 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "Out +ems 1" +horizontal_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="out_ems_2" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(207, 465) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="Out_ems_1" type="Label" parent="Monitoring_panel/out_ems_2"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "Out +ems 2" +horizontal_alignment = 1 diff --git a/scenes/pribor-prd-v/pribor_prd_v.gd b/scenes/pribor-prd-v/pribor_prd_v.gd index c919ba1..7a94735 100644 --- a/scenes/pribor-prd-v/pribor_prd_v.gd +++ b/scenes/pribor-prd-v/pribor_prd_v.gd @@ -1,12 +1,28 @@ @tool extends "res://scenes/контроль/прибор.gd" +const IN_BLANK_PRD: int = 1 +const OUT_BLANK_PRD: int = 13 +const CI_4_OT_FS: int = 11 +const CI_5_OT_FS: int = 12 +const CI_4_B_UF: int = 1 +const CI_5_B_UF: int = 2 +const POWER_UKP_1: int = 31 +const POWER_UKP_2: int = 63 +const bit_dkm_3: int = 3 +const bit_dkm_4: int = 4 + +var count_packet_1:int = 0 +var power_array_1: Array = [] +var count_packet_2:int = 0 +var power_array_2: Array = [] + enum STATE_VAL { NONE = 0, GOOD = 1, ERROR = 2 } -# Called when the node enters the scene tree for the first time. + func _ready() -> void: var unit_key = settings.get_unit_key(get_meta('unit_name')[0]) var unit_prd = network.units[unit_key] @@ -15,31 +31,104 @@ func _ready() -> void: set_default_state() -func set_default_state(): - $um1535_A7.state = STATE_VAL.NONE - $um1535_A8.state = STATE_VAL.NONE - $um1535_A9.state = STATE_VAL.NONE - $um1535_A10.state = STATE_VAL.NONE - $um1535_A11.state = STATE_VAL.NONE - $um1535_A12.state = STATE_VAL.NONE - $um1535_A13.state = STATE_VAL.NONE - $um1535_A14.state = STATE_VAL.NONE - $um1535_A15.state = STATE_VAL.NONE - $um1535_A16.state = STATE_VAL.NONE - $um1535_A17.state = STATE_VAL.NONE - $um1535_A18.state = STATE_VAL.NONE +func set_default_state() -> void: + for group in get_tree().get_nodes_in_group('power_amplifier'): + group.state = STATE_VAL.NONE -func on_line_changed(unit_prd): +func on_line_changed(unit_prd: Object) -> void: if not unit_prd.online: set_default_state() -func on_data_received(unit_prd): - var _ukp1_online = (unit_prd.status[0] >> 2) & 1 - var _ukp2_online = (unit_prd.status[0] >> 3) & 1 - var ug_online = (unit_prd.status[0] >> 1) & 1 +func on_data_received(unit_prd: Object) -> void: + if not is_inside_tree(): + return + + check_block_ip(unit_prd.status) + check_temperature_um(unit_prd.status) + + ## Контроль ЭМС + var in_blank: int = unit_prd.status.decode_u16(IN_BLANK_PRD) + var out_blank: int = unit_prd.status.decode_u16(OUT_BLANK_PRD) + + $Monitoring_panel/in_fs_1.frame = (in_blank >> CI_4_OT_FS) & 1 + $Monitoring_panel/in_fs_2.frame = (in_blank >> CI_5_OT_FS) & 1 + + $Monitoring_panel/out_ems_1.frame = (out_blank >> CI_4_B_UF) & 1 + $Monitoring_panel/out_ems_2.frame = (out_blank >> CI_5_B_UF) & 1 + + ## Мощность УМ от УКП 1 + if (in_blank >> CI_4_OT_FS) & 1: + check_dkm(unit_prd.status, bit_dkm_3) + + ## Мощность УМ от УКП 2 + if (in_blank >> CI_5_OT_FS) & 1: + check_dkm(unit_prd.status, bit_dkm_4) + + +## Проверка касет П1 и ИП МА2000 +func check_block_ip(status_prd: PackedByteArray) -> void : + var ug_online: bool = (status_prd[0] >> 1) & 1 if ug_online: - pass + const BYTE_DRY_CONTACT: int = 27 + const BIT_MAA2000_1: int = 0 + const BIT_MAA2000_2: int = 1 + const BIT_IP9_50_1: int = 2 + const BIT_IP9_50_2: int = 3 + const BIT_IP12_50_1: int = 4 + + var maa2000_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_MAA2000_1 & 1 + var maa2000_2 = status_prd[BYTE_DRY_CONTACT] >> BIT_MAA2000_2 & 1 + var ip9_50_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP9_50_1 & 1 + var ip9_50_2 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP9_50_2 & 1 + var ip12_50_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP12_50_1 & 1 + + $maa2000_A23.state = STATE_VAL.ERROR if maa2000_1 else STATE_VAL.GOOD + $maa2000_A22.state = STATE_VAL.ERROR if maa2000_2 else STATE_VAL.GOOD + $kasseta_P_1/ref_A19.state = STATE_VAL.ERROR if ip9_50_1 else STATE_VAL.GOOD + $kasseta_P_1/ref_A20.state = STATE_VAL.ERROR if ip9_50_2 else STATE_VAL.GOOD + $kasseta_P_1/ref_A21.state = STATE_VAL.ERROR if ip12_50_1 else STATE_VAL.GOOD else: - pass + $maa2000_A23.state = STATE_VAL.NONE + $maa2000_A22.state = STATE_VAL.NONE + $kasseta_P_1/ref_A19.state = STATE_VAL.NONE + $kasseta_P_1/ref_A20.state = STATE_VAL.NONE + $kasseta_P_1/ref_A21.state = STATE_VAL.NONE + + +## Проверка температур УМ от УКП +func check_temperature_um(status_prd: PackedByteArray) -> void: + const CONST_MIN_TEMP: int = -25 + const MAXIMUM_CODE_ADC: int = 3796 + const MINIMUM_CODE_AD: int = 2660 + const TEMP: float = 115.0 / (MAXIMUM_CODE_ADC - MINIMUM_CODE_AD) + const TEMPERATURE_UKP_1: int = 47 + const TEMPERATURE_UKP_2: int = 79 + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + + var ukp1_online: int = (status_prd[0] >> 2) & 1 + if ukp1_online: + for i_temp in range(6): + var temperature_ukp_1: int = status_prd.decode_u16(TEMPERATURE_UKP_1 + 2 * i_temp) + var tmp_1: int = round(CONST_MIN_TEMP + (MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3) + power_amplifier[i_temp].value0 = tmp_1 + + var ukp2_online = (status_prd[0] >> 3) & 1 + if ukp2_online: + for i_temp in range(6): + var temperature_ukp_2: int = status_prd.decode_u16(TEMPERATURE_UKP_2 + 2 * i_temp) + var tmp_2: int = round(CONST_MIN_TEMP + (MAXIMUM_CODE_ADC - temperature_ukp_2) * TEMP + 3) + power_amplifier[i_temp+6].value0 = tmp_2 + + +## Проверка ДКМ +func check_dkm(status_prd: PackedByteArray, bit_dkm: int) -> void: + const DKM: int = 28 + var status_dkm = status_prd[DKM] >> bit_dkm & 1 + if bit_dkm == bit_dkm_3: + $dou4_A5.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + $kasseta_FS_VD/ref_A6.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + elif bit_dkm == bit_dkm_4: + $dou5_A6.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + $kasseta_FS_VD/ref_A2.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR