From e1aaa0b39fc1a7f3b6355adfba44ae1407d9f18d Mon Sep 17 00:00:00 2001
From: TotMaxim
Date: Fri, 14 Nov 2025 22:53:46 +0300
Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=BA=D0=B0=20=D0=94=D0=9A=D0=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main.gd | 31 ++++++++++++++++--------
main.tscn | 63 +++++++++++++++++++++++++++++++++++++++++++++++-
udp_broadcast.gd | 5 +++-
3 files changed, 87 insertions(+), 12 deletions(-)
diff --git a/main.gd b/main.gd
index cc97a1c..a2bc443 100644
--- a/main.gd
+++ b/main.gd
@@ -14,14 +14,18 @@ func _ready() -> void:
for soc in sockets:
soc.connect('toggled', _on_modify_sockets.bind(soc.get_meta('bit'), soc.get_meta('device'))) ## Мета bit от 0 до 3, мета ПРД
- var power_ukp: Array = get_tree().get_nodes_in_group('power_ukp')
- for socket_power in power_ukp:
+ var power_ukp_arr_node: Array = get_tree().get_nodes_in_group('power_ukp')
+ for socket_power in power_ukp_arr_node:
socket_power.connect('text_submitted', _on_ukp_submitted.bind(socket_power.get_meta('device')))
- var temperature_ukp: Array = get_tree().get_nodes_in_group('temperature_ukp')
- for socket_temp in temperature_ukp:
+ var temperature_ukp_arr_node: Array = get_tree().get_nodes_in_group('temperature_ukp')
+ for socket_temp in temperature_ukp_arr_node:
socket_temp.connect('text_submitted', _on_ukp_submitted.bind(socket_temp.get_meta('device')))
+ var dkm_arr_node: Array = get_tree().get_nodes_in_group('dkm')
+ for dkm in dkm_arr_node:
+ dkm.connect('toggled', _on_modify_dkm.bind(dkm.get_meta('bit'), dkm.get_meta('device')))
+
func _exit_tree():
for device in dictionary_yau07:
@@ -39,12 +43,6 @@ func on_modify_device(toggled: bool, name_device: String) -> void:
dictionary_yau07[name_device].close_udp_unit()
-func _process(_delta: float) -> void:
- for device in dictionary_yau07.keys():
- if dictionary_yau07[device]:
- dictionary_yau07[device].poll_receive()
-
-
## Функция для установки статусов ячеек на связи (УГ, ЭМС-Г, УКП)
func _on_modify_sockets(toggled: bool, bit: int, device: String)->void:
if dictionary_yau07.has(device):
@@ -52,6 +50,19 @@ func _on_modify_sockets(toggled: bool, bit: int, device: String)->void:
udp_unit.sockets_status_bit = _set_bit(udp_unit.sockets_status_bit, bit, toggled)
+## Функция для установки статусов ДКМ в ПРД
+func _on_modify_dkm(toggled: bool, bit: int, device: String)->void:
+ if dictionary_yau07.has(device):
+ var udp_unit = dictionary_yau07[device]
+ udp_unit.dkm_status_bit = _set_bit(udp_unit.dkm_status_bit, bit, toggled)
+
+
+func _process(_delta: float) -> void:
+ for device in dictionary_yau07.keys():
+ if dictionary_yau07[device]:
+ dictionary_yau07[device].poll_receive()
+
+
## Функция для установки значений в ячейках УКП
func _on_ukp_submitted(_new_text: String, device: String) -> void:
var prep_temperature_ukp1_array: Array = _on_text_temperature_changed(device, 1)
diff --git a/main.tscn b/main.tscn
index 6744367..38ea6d6 100644
--- a/main.tscn
+++ b/main.tscn
@@ -99,7 +99,7 @@ layout_mode = 0
offset_left = 187.0
offset_top = 19.0
offset_right = 1147.0
-offset_bottom = 338.0
+offset_bottom = 395.0
current_tab = 0
use_hidden_tabs_for_min_size = true
tab_focus_mode = 0
@@ -333,6 +333,25 @@ layout_mode = 2
placeholder_text = "0"
metadata/device = "ПРД-Н1"
+[node name="dkm" type="GridContainer" parent="TabContainer/ПРД-Н1"]
+layout_mode = 0
+offset_left = 10.0
+offset_top = 201.0
+offset_right = 50.0
+offset_bottom = 241.0
+
+[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-Н1/dkm" groups=["dkm"]]
+layout_mode = 2
+text = "ДКМ 2"
+metadata/bit = 1
+metadata/device = "ПРД-Н1"
+
+[node name="CheckBox2" type="CheckBox" parent="TabContainer/ПРД-Н1/dkm" groups=["dkm"]]
+layout_mode = 2
+text = "ДКМ 3"
+metadata/bit = 2
+metadata/device = "ПРД-Н1"
+
[node name="ПРД-В1" type="Panel" parent="TabContainer" groups=["prd"]]
visible = false
layout_mode = 2
@@ -561,6 +580,24 @@ layout_mode = 2
metadata/place = 13
metadata/device = "ПРД-В1"
+[node name="dkm" type="GridContainer" parent="TabContainer/ПРД-В1"]
+offset_left = 10.0
+offset_top = 201.0
+offset_right = 50.0
+offset_bottom = 241.0
+
+[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-В1/dkm" groups=["dkm"]]
+layout_mode = 2
+text = "ДКМ 4"
+metadata/bit = 3
+metadata/device = "ПРД-В1"
+
+[node name="CheckBox2" type="CheckBox" parent="TabContainer/ПРД-В1/dkm" groups=["dkm"]]
+layout_mode = 2
+text = "ДКМ 5"
+metadata/bit = 4
+metadata/device = "ПРД-В1"
+
[node name="ПРД-К1" type="Panel" parent="TabContainer" groups=["prd"]]
visible = false
layout_mode = 2
@@ -820,6 +857,30 @@ layout_mode = 2
metadata/place = 13
metadata/device = "ПРД-К1"
+[node name="dkm" type="GridContainer" parent="TabContainer/ПРД-К1"]
+offset_left = 10.0
+offset_top = 201.0
+offset_right = 50.0
+offset_bottom = 241.0
+
+[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-К1/dkm" groups=["dkm"]]
+layout_mode = 2
+text = "ДКМ 1"
+metadata/bit = 0
+metadata/device = "ПРД-К1"
+
+[node name="CheckBox2" type="CheckBox" parent="TabContainer/ПРД-К1/dkm" groups=["dkm"]]
+layout_mode = 2
+text = "ДКМ 6"
+metadata/bit = 5
+metadata/device = "ПРД-К1"
+
+[node name="CheckBox3" type="CheckBox" parent="TabContainer/ПРД-К1/dkm" groups=["dkm"]]
+layout_mode = 2
+text = "ДКМ 7"
+metadata/bit = 6
+metadata/device = "ПРД-К1"
+
[node name="ПРД-Н2" type="Panel" parent="TabContainer" groups=["prd"]]
visible = false
layout_mode = 2
diff --git a/udp_broadcast.gd b/udp_broadcast.gd
index 1fe5de8..fdd958e 100644
--- a/udp_broadcast.gd
+++ b/udp_broadcast.gd
@@ -20,6 +20,8 @@ var _socket: SocketUDP
var self_name: String
var _timer: Timer
var sockets_status_bit: int = 0
+var dkm_status_bit: int = 0
+
var ukp0_data: PackedByteArray:
set(v):
ukp0_data = v
@@ -122,7 +124,8 @@ func _form_status_packet() -> PackedByteArray:
buf.encode_u16(9 + i * 2, ems_g_data[i])
# Данные UG (байты 35-38)
- buf.encode_u16(35, 0x0000) # 00 00
+ buf.encode_u8(35, 0x00)
+ buf.encode_u8(36, dkm_status_bit)
buf.encode_u16(37, 0x059e) # 9e 05
# Данные UKP0 (байты 39-70)