Merge remote-tracking branch 'MaD_CaT/master-prd'
# Conflicts: # scenes/frame-ecm-list/scroll-ecm-list.gd # scenes/настройки/настройки.gd # scenes/работа/работа.gd # scenes/эмс2/эмс2.tscn
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
extends Label
|
||||
|
||||
enum PRD_STATE {
|
||||
enum DEVICE_STATE {
|
||||
NONE, # Нет связи
|
||||
GOOD, # Исправно
|
||||
ERR # Отказ
|
||||
@@ -13,9 +13,9 @@ enum DEVICE_STATUS {
|
||||
}
|
||||
|
||||
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}
|
||||
DEVICE_STATE.NONE: {"text": "Нет связи", "color": Color.WHITE, "font_color": Color.BLACK},
|
||||
DEVICE_STATE.GOOD: {"text": "Исправно", "color": Color.GREEN, "font_color": Color.BLACK},
|
||||
DEVICE_STATE.ERR: {"text": "Отказ", "color": Color.RED, "font_color": Color.WHITE}
|
||||
}
|
||||
|
||||
class DeviceObserver:
|
||||
@@ -58,7 +58,8 @@ class DeviceObserver:
|
||||
return changed
|
||||
|
||||
var device_observers: Dictionary = {}
|
||||
var overall_prd_state: PRD_STATE = PRD_STATE.NONE
|
||||
var overall_prd_state: DEVICE_STATE = DEVICE_STATE.NONE
|
||||
var status_uf: int = DEVICE_STATE.NONE # Статус УФ (УАРЭП-ЭМС)
|
||||
|
||||
func _ready() -> void:
|
||||
tooltip_text = 'Нет связи с приборами комплекса'
|
||||
@@ -77,9 +78,7 @@ func _ready() -> void:
|
||||
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'))
|
||||
signaller.connect('update_uf_serviceability', _on_uf_status_receive)
|
||||
|
||||
# Инициализация начального состояния
|
||||
_recalculate_overall_state()
|
||||
@@ -111,41 +110,51 @@ func _on_prd_control_results(results: Dictionary, prd_module: Object) -> void:
|
||||
_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 _on_uf_status_receive(unit_uf_status: int) -> void:
|
||||
if status_uf != unit_uf_status:
|
||||
status_uf = unit_uf_status
|
||||
_recalculate_overall_state()
|
||||
|
||||
|
||||
func _recalculate_overall_state() -> void:
|
||||
var new_state := PRD_STATE.NONE
|
||||
var has_online_devices := false
|
||||
var all_operational := true
|
||||
var new_state := DEVICE_STATE.NONE
|
||||
|
||||
# Проверяем статус ПРД
|
||||
var prd_state := DEVICE_STATE.NONE
|
||||
var has_online_prd := false
|
||||
var all_prd_operational := true
|
||||
|
||||
for observer in device_observers.values():
|
||||
if observer.status[DEVICE_STATUS.ONLINE]:
|
||||
has_online_devices = true
|
||||
has_online_prd = true
|
||||
|
||||
if observer.status[DEVICE_STATUS.CONTROL]:
|
||||
# Если контроль завершен - строгая проверка
|
||||
if not observer.status[DEVICE_STATUS.STATUS]:
|
||||
all_operational = false
|
||||
all_prd_operational = false
|
||||
break
|
||||
else:
|
||||
# Если контроль в процессе - мягкая проверка
|
||||
if not observer.status[DEVICE_STATUS.STATUS]:
|
||||
all_operational = false
|
||||
# Не прерываем, чтобы проверить все устройства
|
||||
all_prd_operational = false
|
||||
|
||||
if has_online_devices:
|
||||
new_state = PRD_STATE.GOOD if all_operational else PRD_STATE.ERR
|
||||
if has_online_prd:
|
||||
if all_prd_operational:
|
||||
prd_state = DEVICE_STATE.GOOD
|
||||
else:
|
||||
prd_state = DEVICE_STATE.ERR
|
||||
else:
|
||||
new_state = PRD_STATE.NONE
|
||||
prd_state = DEVICE_STATE.NONE
|
||||
|
||||
# Комбинируем статусы по правилу:
|
||||
# 1. Если хоть один ERROR → ERROR
|
||||
# 2. Если нет ERROR и хоть один GOOD → GOOD
|
||||
# 3. Иначе → NONE
|
||||
|
||||
if prd_state == DEVICE_STATE.ERR or status_uf == DEVICE_STATE.ERR:
|
||||
new_state = DEVICE_STATE.ERR
|
||||
elif prd_state == DEVICE_STATE.GOOD or status_uf == DEVICE_STATE.GOOD:
|
||||
new_state = DEVICE_STATE.GOOD
|
||||
else:
|
||||
new_state = DEVICE_STATE.NONE
|
||||
|
||||
if overall_prd_state != new_state:
|
||||
overall_prd_state = new_state
|
||||
@@ -162,15 +171,83 @@ func _update_display() -> void:
|
||||
|
||||
|
||||
func _get_tooltip_text() -> String:
|
||||
var tooltip := ""
|
||||
|
||||
# Получаем статистику по ПРД
|
||||
var prd_summary = _get_prd_summary()
|
||||
var uf_status_str = _get_uf_status_text()
|
||||
|
||||
match overall_prd_state:
|
||||
PRD_STATE.NONE:
|
||||
return "Нет связи с приборами комплекса"
|
||||
PRD_STATE.GOOD:
|
||||
return "Все приборы комплекса исправны"
|
||||
PRD_STATE.ERR:
|
||||
return "Обнаружены неисправности в комплексе"
|
||||
DEVICE_STATE.NONE:
|
||||
tooltip = "Нет исправных систем в комплексе"
|
||||
DEVICE_STATE.GOOD:
|
||||
tooltip = "Комплекс исправен"
|
||||
DEVICE_STATE.ERR:
|
||||
tooltip = "Обнаружены неисправности в комплексе"
|
||||
|
||||
tooltip += "\n\nСтатус ПРД систем: " + prd_summary
|
||||
tooltip += "\nСтатус УФ: " + uf_status_str
|
||||
|
||||
# Детализация по источникам статуса
|
||||
tooltip += "\n\nСостояние систем:"
|
||||
|
||||
# ПРД системы
|
||||
var prd_ok_count = 0
|
||||
var prd_total = 0
|
||||
for observer in device_observers.values():
|
||||
if observer.status[DEVICE_STATUS.ONLINE]:
|
||||
prd_total += 1
|
||||
if observer.status[DEVICE_STATUS.STATUS]:
|
||||
prd_ok_count += 1
|
||||
|
||||
tooltip += "\nПРД: %d/%d исправно" % [prd_ok_count, prd_total]
|
||||
|
||||
# УФ система
|
||||
tooltip += "\nУФ: " + _get_uf_status_text()
|
||||
|
||||
return tooltip
|
||||
|
||||
|
||||
func _get_prd_summary() -> String:
|
||||
var online_count := 0
|
||||
var operational_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 online_count == 0:
|
||||
return "Нет связи"
|
||||
else:
|
||||
return "%d/%d исправно" % [operational_count, online_count]
|
||||
|
||||
|
||||
func _get_uf_status_text() -> String:
|
||||
match status_uf:
|
||||
DEVICE_STATE.NONE:
|
||||
return "Нет данных"
|
||||
DEVICE_STATE.GOOD:
|
||||
return "Исправен"
|
||||
DEVICE_STATE.ERR:
|
||||
return "Неисправен"
|
||||
_:
|
||||
return "Неизвестное состояние"
|
||||
return "Неизвестно"
|
||||
|
||||
|
||||
func _has_prd_errors() -> bool:
|
||||
for observer in device_observers.values():
|
||||
if observer.status[DEVICE_STATUS.ONLINE] and not observer.status[DEVICE_STATUS.STATUS]:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _has_operational_prd() -> bool:
|
||||
for observer in device_observers.values():
|
||||
if observer.status[DEVICE_STATUS.ONLINE] and observer.status[DEVICE_STATUS.STATUS]:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
# Публичные методы для получения информации
|
||||
@@ -181,7 +258,8 @@ func get_device_status(device_name: String) -> Dictionary:
|
||||
"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()
|
||||
"last_results": observer.last_results.duplicate(),
|
||||
"status_uf": status_uf
|
||||
}
|
||||
return {}
|
||||
|
||||
@@ -204,5 +282,6 @@ func get_overall_status() -> Dictionary:
|
||||
"online_devices": online_count,
|
||||
"operational_devices": operational_count,
|
||||
"total_devices": device_observers.size(),
|
||||
"control_complete_devices": control_complete_count
|
||||
"control_complete_devices": control_complete_count,
|
||||
"uf_status": status_uf
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://3slb0i3pvowc"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://3slb0i3pvowc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bvo6tcreqyuex" path="res://scenes/tabs-switch/tab-switch.gd" id="1_fg0vd"]
|
||||
[ext_resource type="PackedScene" uid="uid://b276iygic5itk" path="res://scenes/работа/работа.tscn" id="2_u7p16"]
|
||||
@@ -22,16 +22,13 @@
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_o1r22"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nmdfd"]
|
||||
bg_color = Color(0.061, 100, 0.051, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cw2ss"]
|
||||
bg_color = Color(0.473976, 0.473976, 0.473976, 1)
|
||||
bg_color = Color(0.47451, 0.47451, 0.47451, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nmdfd"]
|
||||
bg_color = Color(0, 100, 0, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_41d34"]
|
||||
bg_color = Color(0.39, 100, 0.327, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_imu1q"]
|
||||
|
||||
[node name="panel" type="Panel"]
|
||||
offset_right = 1600.0
|
||||
@@ -102,10 +99,9 @@ focus_mode = 0
|
||||
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
|
||||
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_nmdfd")
|
||||
theme_override_styles/hover = SubResource("StyleBoxFlat_cw2ss")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxFlat_41d34")
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_imu1q")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxFlat_nmdfd")
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_41d34")
|
||||
toggle_mode = true
|
||||
text = "Тренаж"
|
||||
script = ExtResource("9_41d34")
|
||||
|
||||
Reference in New Issue
Block a user