Доработка УГ 0х10А порта

This commit is contained in:
TotMaxim
2025-11-23 13:58:11 +03:00
parent e9811ae42b
commit bdb50989f9
5 changed files with 194 additions and 36 deletions

View File

@@ -13,10 +13,12 @@ func _emit_initial_ports() -> void:
# Просто устанавливаем текущие значения (это вызовет update_isa_ports)
var current_106 = _device.get_isa_port(0x106)
var current_108 = _device.get_isa_port(0x108)
var current_10A = _device.get_isa_port(0x10A)
# Триггерим обновление через установку тех же значений
_device.set_isa_port(0x106, current_106)
_device.set_isa_port(0x108, current_108)
_device.set_isa_port(0x10A, current_10A)
# Универсальные методы для работы с битовыми полями
func set_status_field(port: int, value: int, bit_mask: int, shift: int = 0) -> void:
@@ -36,6 +38,9 @@ func set_dou2_status(status: int) -> void:
func get_dou2_status() -> int:
return get_status_field(0x106, 0b111, 0)
func set_att1_status(status: int) -> void:
set_status_field(0x10A, status, 0b111, 0)
func set_att2_status(status: int) -> void:
set_status_field(0x106, status, 0b111, 3)

15
main.gd
View File

@@ -71,6 +71,12 @@ func _fill_ukp_fields(prd_node: Control, device_data: Dictionary):
for i in range(min(dou3_fields.size(), device_data["dou3"].size())):
dou3_fields[i].set_pressed_no_signal(device_data["dou3"][i])
# Устанавливаем состояния аттенюаторов 1
if device_data.has("att1"):
var att1_fields = _get_ukp_nodes_for_device(device_name, [prd_node], "att1")
for i in range(min(att1_fields.size(), device_data["att1"].size())):
att1_fields[i].set_pressed_no_signal(device_data["att1"][i])
# Устанавливаем состояния аттенюаторов 2
if device_data.has("att2"):
var att2_fields = _get_ukp_nodes_for_device(device_name, [prd_node], "att2")
@@ -120,6 +126,10 @@ func _ready() -> void:
for dou3 in dou3_arr_node:
dou3.toggled.connect(_on_modify_status.bind(dou3.get_meta('bit'), dou3.get_meta('device'), "dou3"))
var att1_arr_node: Array = get_tree().get_nodes_in_group('att1')
for att1 in att1_arr_node:
att1.toggled.connect(_on_modify_status.bind(att1.get_meta('bit'), att1.get_meta('device'), "att1"))
var att2_arr_node: Array = get_tree().get_nodes_in_group('att2')
for att2 in att2_arr_node:
att2.toggled.connect(_on_modify_status.bind(att2.get_meta('bit'), att2.get_meta('device'), "att2"))
@@ -203,6 +213,9 @@ func _on_update_isa_ports(isa_ports: Dictionary, device_name: String)->void:
0x108: [ # Порт 0x108
{'group': 'dou3', 'mask': 0b111, 'shift': 0},
{'group': 'att3', 'mask': 0b111, 'shift': 3}
],
0x10A: [ # Порт 0x10A
{'group': 'att1', 'mask': 0b111, 'shift': 0}
]
}
@@ -281,6 +294,8 @@ func _on_modify_status(toggled: bool, bit: int, device: String, status_type: Str
match status_type:
"dou2":
udp_unit.status_manager.set_dou2_status(bit)
"att1":
udp_unit.status_manager.set_att1_status(bit)
"att2":
udp_unit.status_manager.set_att2_status(bit)
"dou3":

178
main.tscn
View File

@@ -24,8 +24,8 @@ script = ExtResource("1_ig7tw")
[node name="Panel" type="Panel" parent="."]
layout_mode = 0
offset_right = 1208.0
offset_bottom = 607.0
offset_right = 1541.0
offset_bottom = 615.0
[node name="Yau-07-addr" type="GridContainer" parent="."]
layout_mode = 0
@@ -98,8 +98,8 @@ metadata/device = "ПРД-К4"
layout_mode = 0
offset_left = 187.0
offset_top = 19.0
offset_right = 1147.0
offset_bottom = 395.0
offset_right = 1373.0
offset_bottom = 442.0
current_tab = 2
use_hidden_tabs_for_min_size = true
tab_focus_mode = 0
@@ -639,8 +639,8 @@ metadata/device = "ПРД-В1"
layout_mode = 0
offset_left = 199.0
offset_top = 9.0
offset_right = 957.0
offset_bottom = 334.0
offset_right = 970.0
offset_bottom = 370.0
current_tab = 2
tabs_position = 1
tab_focus_mode = 0
@@ -837,6 +837,10 @@ metadata/_tab_index = 2
[node name="GridContainer4" type="GridContainer" parent="TabContainer/ПРД-В1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer4"]
layout_mode = 2
text = "Младшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer4" groups=["dou2"]]
layout_mode = 2
text = "ЛУЧ -5°"
@@ -879,9 +883,18 @@ text = "ЛУЧ КОНТРОЛЬ"
metadata/bit = 6
metadata/device = "ПРД-В1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer4"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Адрес: 0х106 & 7"
[node name="GridContainer" type="GridContainer" parent="TabContainer/ПРД-В1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer"]
layout_mode = 2
text = "Старшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer" groups=["dou3"]]
layout_mode = 2
text = "ЛУЧ -5°"
@@ -924,9 +937,17 @@ text = "ЛУЧ КОНТРОЛЬ"
metadata/bit = 6
metadata/device = "ПРД-В1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer"]
layout_mode = 2
text = "Адрес: 0х108 & 7"
[node name="GridContainer2" type="GridContainer" parent="TabContainer/ПРД-В1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer2"]
layout_mode = 2
text = "Младшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer2" groups=["att2"]]
layout_mode = 2
text = "АТТ 0 dB"
@@ -975,9 +996,18 @@ text = "АТТ 10.5 dB"
metadata/bit = 7
metadata/device = "ПРД-В1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer2"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Адрес: 0х106 & 56"
[node name="GridContainer5" type="GridContainer" parent="TabContainer/ПРД-В1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer5"]
layout_mode = 2
text = "Старшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 0 dB"
@@ -1026,6 +1056,11 @@ text = "АТТ 10.5 dB"
metadata/bit = 7
metadata/device = "ПРД-В1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-В1/TabBar/ug/GridContainer5"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Адрес: 0х108 & 56"
[node name="GridContainer3" type="GridContainer" parent="TabContainer/ПРД-В1/TabBar/ug"]
layout_mode = 2
@@ -1124,11 +1159,12 @@ metadata/bit = 4
metadata/device = "ПРД-К1"
[node name="TabBar" type="TabContainer" parent="TabContainer/ПРД-К1"]
layout_direction = 2
layout_mode = 0
offset_left = 199.0
offset_left = 170.0
offset_top = 9.0
offset_right = 957.0
offset_bottom = 334.0
offset_right = 1144.0
offset_bottom = 370.0
current_tab = 3
tabs_position = 1
tab_focus_mode = 0
@@ -1351,12 +1387,17 @@ metadata/device = "ПРД-К1"
[node name="ug" type="GridContainer" parent="TabContainer/ПРД-К1/TabBar"]
layout_mode = 2
columns = 5
columns = 6
metadata/_tab_index = 3
[node name="GridContainer4" type="GridContainer" parent="TabContainer/ПРД-К1/TabBar/ug"]
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer4"]
layout_mode = 2
text = "Младшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer4" groups=["dou2"]]
layout_mode = 2
text = "ЛУЧ -5°"
@@ -1399,9 +1440,18 @@ text = "ЛУЧ КОНТРОЛЬ"
metadata/bit = 6
metadata/device = "ПРД-К1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer4"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Адрес: 0х106 & 7"
[node name="GridContainer" type="GridContainer" parent="TabContainer/ПРД-К1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer"]
layout_mode = 2
text = "Старшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer" groups=["dou3"]]
layout_mode = 2
text = "ЛУЧ -5°"
@@ -1444,9 +1494,17 @@ text = "ЛУЧ КОНТРОЛЬ"
metadata/bit = 6
metadata/device = "ПРД-К1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer"]
layout_mode = 2
text = "Адрес: 0х108 & 7"
[node name="GridContainer2" type="GridContainer" parent="TabContainer/ПРД-К1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer2"]
layout_mode = 2
text = "Младшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer2" groups=["att2"]]
layout_mode = 2
text = "АТТ 0 dB"
@@ -1495,9 +1553,18 @@ text = "АТТ 10.5 dB"
metadata/bit = 7
metadata/device = "ПРД-К1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer2"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Адрес: 0х106 & 56"
[node name="GridContainer5" type="GridContainer" parent="TabContainer/ПРД-К1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5"]
layout_mode = 2
text = "Старшая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 0 dB"
@@ -1506,46 +1573,111 @@ metadata/device = "ПРД-К1"
[node name="CheckBox2" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 0.5 dB"
text = "АТТ 1 dB"
metadata/bit = 1
metadata/device = "ПРД-К1"
[node name="CheckBox3" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 2 dB"
text = "АТТ 4 dB"
metadata/bit = 2
metadata/device = "ПРД-К1"
[node name="CheckBox4" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 2.5 dB"
text = "АТТ 5 dB"
metadata/bit = 3
metadata/device = "ПРД-К1"
[node name="CheckBox5" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 8 dB"
text = "АТТ 16 dB"
metadata/bit = 4
metadata/device = "ПРД-К1"
[node name="CheckBox6" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 8.5 dB"
text = "АТТ 17 dB"
metadata/bit = 5
metadata/device = "ПРД-К1"
[node name="CheckBox7" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 10 dB"
text = "АТТ 20 dB"
metadata/bit = 6
metadata/device = "ПРД-К1"
[node name="CheckBox8" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5" groups=["att3"]]
layout_mode = 2
text = "АТТ 10.5 dB"
text = "АТТ 21.5 dB"
metadata/bit = 7
metadata/device = "ПРД-К1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer5"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Адрес: 0х108 & 56"
[node name="GridContainer6" type="GridContainer" parent="TabContainer/ПРД-К1/TabBar/ug"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6"]
layout_mode = 2
text = "Особая литера"
[node name="CheckBox" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 0 dB"
metadata/bit = 0
metadata/device = "ПРД-К1"
[node name="CheckBox2" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 1 dB"
metadata/bit = 1
metadata/device = "ПРД-К1"
[node name="CheckBox3" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 4 dB"
metadata/bit = 2
metadata/device = "ПРД-К1"
[node name="CheckBox4" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 5 dB"
metadata/bit = 3
metadata/device = "ПРД-К1"
[node name="CheckBox5" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 16 dB"
metadata/bit = 4
metadata/device = "ПРД-К1"
[node name="CheckBox6" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 17 dB"
metadata/bit = 5
metadata/device = "ПРД-К1"
[node name="CheckBox7" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 20 dB"
metadata/bit = 6
metadata/device = "ПРД-К1"
[node name="CheckBox8" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6" groups=["att1"]]
layout_mode = 2
text = "АТТ 21.5 dB"
metadata/bit = 7
metadata/device = "ПРД-К1"
[node name="Label2" type="Label" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer6"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Адрес: 0х10A & 7"
[node name="GridContainer3" type="GridContainer" parent="TabContainer/ПРД-К1/TabBar/ug"]
layout_mode = 2
@@ -1581,6 +1713,18 @@ metadata/device = "ПРД-К1"
[node name="CheckBox6" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer3" groups=["ip"]]
layout_mode = 2
text = "ИП9-50 №3"
metadata/bit = 5
metadata/device = "ПРД-К1"
[node name="CheckBox7" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer3" groups=["ip"]]
layout_mode = 2
text = "ИП12-50 №2"
metadata/bit = 6
metadata/device = "ПРД-К1"
[node name="CheckBox8" type="CheckBox" parent="TabContainer/ПРД-К1/TabBar/ug/GridContainer3" groups=["ip"]]
layout_mode = 2
text = "ИП5-25"
metadata/bit = 7
metadata/device = "ПРД-К1"

View File

@@ -17,7 +17,7 @@ config/icon="res://icon.svg"
[display]
window/size/viewport_width=1200
window/size/viewport_width=1400
window/size/viewport_height=600
[rendering]

View File

@@ -79,11 +79,6 @@ func _initialize_timers() -> void:
_timer.wait_time = 1.0 / 5.0
_timer.timeout.connect(_on_broadcast_timeout)
# Таймер для частого опроса сокета (100 раз в секунду)
#_poll_timer = Timer.new()
#_poll_timer.wait_time = 0.05
#_poll_timer.timeout.connect(_on_poll_timeout)
func _initialize_ukp_data() -> void:
"""Инициализация данных UKP нулевыми значениями"""
@@ -139,16 +134,10 @@ func add_timers_to_scene(parent: Node) -> void:
elif _timer.get_parent() != parent:
push_warning("Таймер broadcast уже добавлен в другую сцену")
#if not _poll_timer.get_parent():
#parent.add_child(_poll_timer)
#elif _poll_timer.get_parent() != parent:
#push_warning("Таймер poll уже добавлен в другую сцену")
func start_broadcast() -> void:
"""Запуск широковещательной рассылки и опроса сокета"""
_timer.start()
#_poll_timer.start()
print("Широковещательная рассылка запущена")
@@ -453,7 +442,7 @@ func _handle_write_isa_command(data: PackedByteArray, address: String, port: int
"""Обработка команды записи ISA портов"""
var ports = _parse_command_ports(data)
var data_to_write = _parse_command_ports_data(data)
print_debug('data_to_write: ', data_to_write)
if ports.size() != data_to_write.size():
push_warning("Несоответствие размеров портов и данных от %s:%d" % [address, port])
return
@@ -500,10 +489,16 @@ func _parse_command_ports(data: PackedByteArray) -> Array:
return []
var ports = []
for i in range(ports_count):
var port_address = data.decode_u16(8 + i * 2)
ports.append(port_address)
print("Порт %d: 0x%03X" % [i, port_address])
if data.decode_u8(6) == 0:
for i in range(ports_count):
var port_address = data.decode_u16(8 + i * 2)
ports.append(port_address)
print("Порт %d: 0x%03X" % [i, port_address])
elif data.decode_u8(6) == 1:
for i in range(ports_count):
var port_address = data.decode_u16(8 + i * 4)
ports.append(port_address)
print("Порт %d: 0x%03X" % [i, port_address])
return ports
@@ -524,8 +519,7 @@ func _parse_command_ports_data(data: PackedByteArray) -> Array:
if data_offset + i * 2 < data.size():
var port_data = data.decode_u16(data_offset + i * 2)
ports_data.append(port_data)
print("Данные порта %d: 0x%04X" % [i, port_data])
print("Данные порта %d: 0x%03X" % [i, port_data])
return ports_data