Доработка. Значёк прибор на связи на вкладке контроль, получает информацию от юнитов.

This commit is contained in:
MaD_CaT
2025-03-25 15:00:20 +03:00
parent e6f3d993fd
commit 189aebaddf
6 changed files with 79 additions and 15 deletions

View File

@@ -7,7 +7,7 @@ enum STATE_VAL {
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var unit_key = settings.get_unit_key(get_meta('unit_name'))
var unit_key = settings.get_unit_key(get_meta('unit_name')[0])
var unit_prd = network.units[unit_key]
unit_prd.connect('data_received', Callable(self, 'on_data_received'))
unit_prd.connect('line_changed', Callable(self, 'on_line_changed'))

View File

@@ -0,0 +1,7 @@
extends AnimatedSprite2D
## Изменяет состояние значка "прибор на связи"
func set_val(val: bool):
set_frame(val)
if val: modulate = Color(0.3, 1.0, 0.3, 1)
else: modulate = Color(0.5, 0.5, 0.5, 1)

View File

@@ -7,7 +7,7 @@ enum STATE_VAL {
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var unit_key = settings.get_unit_key(get_parent().get_meta('unit_name'))
var unit_key = settings.get_unit_key(get_parent().get_meta('unit_name')[0])
var unit_prd = network.units[unit_key]
unit_prd.connect('data_received', Callable(self, 'on_data_received'))
unit_prd.connect('line_changed', Callable(self, 'on_line_changed'))

View File

@@ -35,9 +35,32 @@ func _ready():
var header_text = PRIBORS_RES[k][1]
pribor_node.set_button_group(group)
pribor_node.connect('button_down', Callable(self, 'on_pribor_press').bind(pribor_path, header_text, pribor_node))
var conn_node = pribor_node.get_node("connect_pribor")
var pribor_meta = pribor_node.get_meta('unit_name', [])
var pribor_proc = pribor_node.get_meta('online_proc', '')
if pribor_proc == '':
continue
if pribor_meta.size():
for i in pribor_meta.size():
var unit_key = settings.get_unit_key(pribor_meta[i])
var unit_pribor = network.units[unit_key]
unit_pribor.connect('line_changed', Callable(self, pribor_proc).bind(conn_node, pribor_meta))
log.info('Модуль контроля работы готов')
func on_line_changed(u, conn_node, _pribor_meta): conn_node.set_val(u.online)
func online_change_arr(u, conn_node, pribor_meta):
var state_online = true
for i in pribor_meta.size():
var unit_key = settings.get_unit_key(pribor_meta[i])
var unit_pribor = network.units[unit_key]
if not unit_pribor.online:
state_online = false
break
conn_node.set_val(state_online)
func on_pribor_press(pribor_path, header_text, pribor_node):
clear_obj($mnemo_container)
var pribor_obj = load(pribor_path)

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://lwmw4egynmd1"]
[gd_scene load_steps=16 format=3 uid="uid://lwmw4egynmd1"]
[ext_resource type="Script" path="res://scenes/контроль/контроль.gd" id="1_x5d6w"]
[ext_resource type="Texture2D" uid="uid://bar8k5qef7kch" path="res://data/УФ.png" id="2_0nvm1"]
@@ -13,6 +13,7 @@
[ext_resource type="Texture2D" uid="uid://u3tnejvpm8it" path="res://data/disconnect_1.png" id="8_gs2be"]
[ext_resource type="Texture2D" uid="uid://dnreyfh3cd1k2" path="res://data/состояние-исправности-1.png" id="8_isjua"]
[ext_resource type="Texture2D" uid="uid://c6booa8753u5t" path="res://data/состояние-исправности-2.png" id="9_ll0vs"]
[ext_resource type="Script" path="res://scenes/контроль/connect_pribor.gd" id="11_u7tym"]
[sub_resource type="SpriteFrames" id="SpriteFrames_foasq"]
animations = [{
@@ -52,6 +53,8 @@ texture_normal = ExtResource("2_0nvm1")
stretch_mode = 0
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.74, 0.37, 1), Color(0.854902, 0.0705882, 0.0705882, 1)]
metadata/unit_name = ["уарэп-эмс"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_uf"]
layout_mode = 0
@@ -85,6 +88,7 @@ position = Vector2(52, -6)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_rtr" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -134,6 +138,7 @@ position = Vector2(49, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_afsp_l" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -186,6 +191,7 @@ position = Vector2(410, -30)
scale = Vector2(3.23077, 3.28125)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_afsp_r" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -238,6 +244,7 @@ position = Vector2(410, -30)
scale = Vector2(3.23077, 3.28125)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_uyep" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -254,6 +261,8 @@ texture_normal = ExtResource("5_kvnex")
stretch_mode = 0
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = ["уарэп-щ3", "уарэп-спт25-1", "уарэп-спт25-2"]
metadata/online_proc = "online_change_arr"
[node name="label" type="Label" parent="pribor_uyep"]
layout_mode = 0
@@ -287,6 +296,7 @@ position = Vector2(45, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.872305
script = ExtResource("11_u7tym")
[node name="pribor_prd_v_2" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -303,7 +313,8 @@ texture_normal = ExtResource("6_i1yfn")
stretch_mode = 4
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-2в"
metadata/unit_name = ["уарэп-яу07-2в"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_v_2"]
layout_mode = 0
@@ -337,6 +348,7 @@ position = Vector2(40, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_n_2" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -353,7 +365,8 @@ texture_normal = ExtResource("6_i1yfn")
stretch_mode = 4
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-2н"
metadata/unit_name = ["уарэп-яу07-2н"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_n_2"]
layout_mode = 0
@@ -389,6 +402,7 @@ position = Vector2(40, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_k_2" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -405,7 +419,8 @@ texture_normal = ExtResource("6_i1yfn")
stretch_mode = 4
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-2к"
metadata/unit_name = ["уарэп-яу07-2к"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_k_2"]
layout_mode = 0
@@ -439,6 +454,7 @@ position = Vector2(43, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_v_3" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -456,7 +472,8 @@ stretch_mode = 4
flip_h = true
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-3в"
metadata/unit_name = ["уарэп-яу07-3в"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_v_3"]
layout_mode = 0
@@ -490,6 +507,7 @@ position = Vector2(34, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_n_3" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -507,7 +525,8 @@ stretch_mode = 4
flip_h = true
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-3н"
metadata/unit_name = ["уарэп-яу07-3н"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_n_3"]
layout_mode = 0
@@ -541,6 +560,7 @@ position = Vector2(33, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_k_3" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -558,7 +578,8 @@ stretch_mode = 4
flip_h = true
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-3к"
metadata/unit_name = ["уарэп-яу07-3к"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_k_3"]
layout_mode = 0
@@ -592,6 +613,7 @@ position = Vector2(35, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_v_1" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -609,7 +631,8 @@ stretch_mode = 4
flip_h = true
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-1в"
metadata/unit_name = ["уарэп-яу07-1в"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_v_1"]
layout_mode = 0
@@ -643,6 +666,7 @@ position = Vector2(34, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_n_1" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -660,7 +684,8 @@ stretch_mode = 4
flip_h = true
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-1н"
metadata/online_proc = "on_line_changed"
metadata/unit_name = ["уарэп-яу07-1н"]
[node name="label" type="Label" parent="pribor_prd_n_1"]
layout_mode = 0
@@ -694,6 +719,7 @@ position = Vector2(35, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_k_1" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -711,7 +737,8 @@ stretch_mode = 4
flip_h = true
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-1к"
metadata/unit_name = ["уарэп-яу07-1к"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_k_1"]
layout_mode = 0
@@ -745,6 +772,7 @@ position = Vector2(35, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_v_4" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -761,7 +789,8 @@ texture_normal = ExtResource("6_i1yfn")
stretch_mode = 4
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-4в"
metadata/unit_name = ["уарэп-яу07-4в"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_v_4"]
layout_mode = 0
@@ -795,6 +824,7 @@ position = Vector2(41, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_n_4" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -811,7 +841,8 @@ texture_normal = ExtResource("6_i1yfn")
stretch_mode = 4
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-4н"
metadata/unit_name = ["уарэп-яу07-4н"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_n_4"]
layout_mode = 0
@@ -845,6 +876,7 @@ position = Vector2(40, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="pribor_prd_k_4" type="TextureButton" parent="."]
editor_description = "Кнопка для выбора прибора."
@@ -861,7 +893,8 @@ texture_normal = ExtResource("6_i1yfn")
stretch_mode = 4
script = ExtResource("3_4pt7j")
state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)]
metadata/unit_name = "уарэп-яу07-4к"
metadata/unit_name = ["уарэп-яу07-4к"]
metadata/online_proc = "on_line_changed"
[node name="label" type="Label" parent="pribor_prd_k_4"]
layout_mode = 0
@@ -895,6 +928,7 @@ position = Vector2(42, -10)
scale = Vector2(0.615385, 0.625)
sprite_frames = SubResource("SpriteFrames_foasq")
frame_progress = 0.72355
script = ExtResource("11_u7tym")
[node name="mnemo_container" type="Panel" parent="."]
layout_mode = 0