Рефактор.
This commit is contained in:
@@ -13,9 +13,9 @@ enum DEVICE_STATUS {
|
||||
}
|
||||
|
||||
const STATUS_CONFIG := {
|
||||
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}
|
||||
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:
|
||||
@@ -161,15 +161,15 @@ func _recalculate_overall_state() -> void:
|
||||
|
||||
|
||||
func _update_display() -> void:
|
||||
var config: Dictionary
|
||||
var config: Dictionary = STATUS_CONFIG[overall_prd_state]
|
||||
text = config.text
|
||||
modulate = config.color
|
||||
add_theme_color_override("font_color", config.font_color)
|
||||
add_theme_color_override('font_color', config.font_color)
|
||||
tooltip_text = _get_tooltip_text()
|
||||
|
||||
|
||||
func _get_tooltip_text() -> String:
|
||||
var tooltip := ""
|
||||
var tooltip := ''
|
||||
|
||||
# Получаем статистику по ПРД
|
||||
var prd_summary = _get_prd_summary()
|
||||
@@ -177,17 +177,17 @@ func _get_tooltip_text() -> String:
|
||||
|
||||
match overall_prd_state:
|
||||
DEVICE_STATE.NONE:
|
||||
tooltip = "Нет исправных систем в комплексе"
|
||||
tooltip = 'Нет исправных систем в комплексе'
|
||||
DEVICE_STATE.GOOD:
|
||||
tooltip = "Комплекс исправен"
|
||||
tooltip = 'Комплекс исправен'
|
||||
DEVICE_STATE.ERR:
|
||||
tooltip = "Обнаружены неисправности в комплексе"
|
||||
tooltip = 'Обнаружены неисправности в комплексе'
|
||||
|
||||
tooltip += "\n\nСтатус ПРД систем: " + prd_summary
|
||||
tooltip += "\nСтатус УФ: " + uf_status_str
|
||||
tooltip += '\n\nСтатус ПРД систем: ' + prd_summary
|
||||
tooltip += '\nСтатус УФ: ' + uf_status_str
|
||||
|
||||
# Детализация по источникам статуса
|
||||
tooltip += "\n\nСостояние систем:"
|
||||
tooltip += '\n\nСостояние систем:'
|
||||
|
||||
# ПРД системы
|
||||
var prd_ok_count = 0
|
||||
@@ -198,10 +198,10 @@ func _get_tooltip_text() -> String:
|
||||
if observer.status[DEVICE_STATUS.STATUS]:
|
||||
prd_ok_count += 1
|
||||
|
||||
tooltip += "\nПРД: %d/%d исправно" % [prd_ok_count, prd_total]
|
||||
tooltip += '\nПРД: %d/%d исправно' % [prd_ok_count, prd_total]
|
||||
|
||||
# УФ система
|
||||
tooltip += "\nУФ: " + _get_uf_status_text()
|
||||
tooltip += '\nУФ: ' + _get_uf_status_text()
|
||||
|
||||
return tooltip
|
||||
|
||||
@@ -217,21 +217,21 @@ func _get_prd_summary() -> String:
|
||||
operational_count += 1
|
||||
|
||||
if online_count == 0:
|
||||
return "Нет связи"
|
||||
return 'Нет связи'
|
||||
else:
|
||||
return "%d/%d исправно" % [operational_count, online_count]
|
||||
return '%d/%d исправно' % [operational_count, online_count]
|
||||
|
||||
|
||||
func _get_uf_status_text() -> String:
|
||||
match status_uf:
|
||||
DEVICE_STATE.NONE:
|
||||
return "Нет данных"
|
||||
return 'Нет данных'
|
||||
DEVICE_STATE.GOOD:
|
||||
return "Исправен"
|
||||
return 'Исправен'
|
||||
DEVICE_STATE.ERR:
|
||||
return "Неисправен"
|
||||
return 'Неисправен'
|
||||
_:
|
||||
return "Неизвестно"
|
||||
return 'Неизвестно'
|
||||
|
||||
|
||||
func _has_prd_errors() -> bool:
|
||||
@@ -253,11 +253,11 @@ func get_device_status(device_name: String) -> Dictionary:
|
||||
var observer: DeviceObserver = device_observers.get(device_name)
|
||||
if observer:
|
||||
return {
|
||||
"online": observer.status[DEVICE_STATUS.ONLINE],
|
||||
"operational": observer.status[DEVICE_STATUS.STATUS],
|
||||
"control_complete": observer.status[DEVICE_STATUS.CONTROL],
|
||||
"last_results": observer.last_results,
|
||||
"status_uf": status_uf
|
||||
'online': observer.status[DEVICE_STATUS.ONLINE],
|
||||
'operational': observer.status[DEVICE_STATUS.STATUS],
|
||||
'control_complete': observer.status[DEVICE_STATUS.CONTROL],
|
||||
'last_results': observer.last_results,
|
||||
'status_uf': status_uf
|
||||
}
|
||||
return {}
|
||||
|
||||
@@ -276,10 +276,10 @@ func get_overall_status() -> Dictionary:
|
||||
control_complete_count += 1
|
||||
|
||||
return {
|
||||
"overall_state": overall_prd_state,
|
||||
"online_devices": online_count,
|
||||
"operational_devices": operational_count,
|
||||
"total_devices": device_observers.size(),
|
||||
"control_complete_devices": control_complete_count,
|
||||
"uf_status": status_uf
|
||||
'overall_state': overall_prd_state,
|
||||
'online_devices': online_count,
|
||||
'operational_devices': operational_count,
|
||||
'total_devices': device_observers.size(),
|
||||
'control_complete_devices': control_complete_count,
|
||||
'uf_status': status_uf
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://dab6loryocc73" path="res://scenes/эмс/эмс.tscn" id="5_u71bh"]
|
||||
[ext_resource type="PackedScene" uid="uid://musb21x2u0xs" path="res://scenes/эмс2/эмс2.tscn" id="6_41d34"]
|
||||
[ext_resource type="PackedScene" uid="uid://bnptm4rlp60dq" path="res://scenes/настройки/настройки.tscn" id="6_i8iv3"]
|
||||
[ext_resource type="Script" uid="uid://b5ykwyk5vpi6" path="res://scenes/tabs-switch/lbl_ready.gd" id="8_tidwt"]
|
||||
[ext_resource type="Script" uid="uid://b5ykwyk5vpi6" path="res://scenes/tabs-switch/lbl-ready.gd" id="8_tidwt"]
|
||||
[ext_resource type="Script" uid="uid://roajn6c6wvc1" path="res://scenes/tabs-switch/тренаж_режим.gd" id="9_41d34"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tidwt"]
|
||||
|
||||
Reference in New Issue
Block a user