Рефактор.

This commit is contained in:
sasha80
2025-08-05 15:45:16 +03:00
parent 7c3dfd3016
commit 207a997d89
4 changed files with 38 additions and 36 deletions

View File

@@ -61,5 +61,5 @@ func on_threat_update(th):
func on_rto_threat_unsel(_th_id):
for item in len(TABLE_PARAMS):
for item in TABLE_PARAMS.size():
$table.set_node_text(1, item, '')

View File

@@ -1,31 +1,32 @@
extends 'res://scenes/контроль/прибор.gd'
@tool
class_name pribor_uf extends 'res://scenes/контроль/прибор.gd'
enum STATE_VAL {
NONE = 0,
GOOD = 1,
ERROR = 2 }
var timer = Timer.new()
var DEV_LIST = ['00:1f.6', '07:00.0', '08:00.0', '0b:00.0']
var USB_TRACKERBALL = '13ba:0018'
var REVFF = '(rev ff)'
enum STATE_VAL {NONE = 0, GOOD = 1, ERROR = 2}
const DEV_LIST = ['00:1f.6', '07:00.0', '08:00.0', '0b:00.0']
const USB_TRACKERBALL = '13ba:0018'
const REVFF = '(rev ff)'
func _ready() -> void:
if Engine.is_editor_hint():
return
var unit_uf = network.get_unit_instance('уарэп-эмс')
self.add_child(timer)
timer.connect('timeout', Callable(self, 'on_timer').bind(unit_uf))
timer.start(1)
unit_uf.connect('line_changed', on_line_changed)
on_timer.bind(unit_uf)
control_vk()
func on_timer(unit_uf):
Control_VK() # проверка трекбола и pci
func on_timer(unit_uf: unit.Unit):
status_uf() # отслеживание состояния прибора
if unit_uf.online: # проверка ЯУ, внутреннего коммутатора и ИП-5Б
control_ems(unit_uf.status) # проверка ЭМС ячеек
func on_line_changed(unit_uf):
if unit_uf.online: # проверка ЯУ, внутреннего коммутатора и ИП-5Б
$ref_uf/ref_kassetav13/ref_A7_YAU07.state = STATE_VAL.GOOD
$ref_uf/ref_kassetav13/ref_A3_IP5B.state = STATE_VAL.GOOD
$ref_uf/ref_kassetav13/ref_A9_ESW.state = STATE_VAL.GOOD
Control_EMS(unit_uf.status) # проверка ЭМС ячеек
else:
$ref_uf/ref_kassetav13/ref_A7_YAU07.state = STATE_VAL.ERROR
$ref_uf/ref_kassetav13/ref_A4_KEMS.state = STATE_VAL.NONE
@@ -34,20 +35,19 @@ func on_timer(unit_uf):
$ref_uf/ref_kassetav13/ref_A3_IP5B.state = STATE_VAL.NONE
$ref_uf/ref_kassetav13/ref_A9_ESW.state = STATE_VAL.NONE
$ref_uf/ref_kassetav13/ref_A12_IP27B.state = STATE_VAL.NONE
status_uf() # отслеживание состояния прибора
func Control_VK() -> void:
func control_vk() -> void:
var out_usb_str = ''
var out_pci_str = ''
var out_usb = []
var out_pci = []
OS.execute('lsusb', [], out_usb)
OS.execute('lsusb', [], out_usb) # TODO: Не переносимое, платформозависимое
for element in out_usb:
out_usb_str += element
OS.execute('lspci', [], out_pci)
OS.execute('lspci', [], out_pci) # TODO: Не переносимое, платформозависимое
for element in out_pci:
out_pci_str += element
@@ -68,13 +68,13 @@ func Control_VK() -> void:
i -= 1
break
if i == (len(DEV_LIST) + 1):
if i == (DEV_LIST.size() + 1):
$ref_uf/ref_bu1/ref_A8_BU.state = STATE_VAL.GOOD
else:
$ref_uf/ref_bu1/ref_A8_BU.state = STATE_VAL.ERROR
func Control_EMS(status:Array) -> void:
func control_ems(status: Array) -> void:
$ref_uf/ref_kassetav13/ref_A4_KEMS.state = STATE_VAL.GOOD if ((status[0] >> 0) & 1) and ((status[0] >> 3) & 1) else STATE_VAL.ERROR
$ref_uf/ref_kassetav13/ref_A5_EMS.state = STATE_VAL.GOOD if ((status[0] >> 1) & 1) and ((status[0] >> 4) & 1) else STATE_VAL.ERROR
$ref_uf/ref_kassetav13/ref_A6_EMS.state = STATE_VAL.GOOD if ((status[0] >> 2) & 1) and ((status[0] >> 5) & 1) else STATE_VAL.ERROR
@@ -82,19 +82,19 @@ func Control_EMS(status:Array) -> void:
func status_uf() -> void:
var status_bu:int = $ref_uf/ref_bu1/ref_A8_BU.state
var status_yay:int = $ref_uf/ref_kassetav13/ref_A7_YAU07.state
var status_kems:int = $ref_uf/ref_kassetav13/ref_A4_KEMS.state
var status_ems0:int = $ref_uf/ref_kassetav13/ref_A5_EMS.state
var status_ems1:int = $ref_uf/ref_kassetav13/ref_A6_EMS.state
var status_ip5:int = $ref_uf/ref_kassetav13/ref_A3_IP5B.state
var status_ip27:int = $ref_uf/ref_kassetav13/ref_A12_IP27B.state
var status_bu: int = $ref_uf/ref_bu1/ref_A8_BU.state
var status_yau: int = $ref_uf/ref_kassetav13/ref_A7_YAU07.state
var status_kyems: int = $ref_uf/ref_kassetav13/ref_A4_KEMS.state
var status_yems0: int = $ref_uf/ref_kassetav13/ref_A5_EMS.state
var status_yems1: int = $ref_uf/ref_kassetav13/ref_A6_EMS.state
var status_ip5: int = $ref_uf/ref_kassetav13/ref_A3_IP5B.state
var status_ip27: int = $ref_uf/ref_kassetav13/ref_A12_IP27B.state
if (status_yay == 1) and (status_bu == 1) and (status_kems == 1) \
and (status_ems0 == 1) and (status_ems1 == 1) and (status_ip5 == 1) and (status_ip27 == 1):
if (status_yau == 1) and (status_bu == 1) and (status_kyems == 1) \
and (status_yems0 == 1) and (status_yems1 == 1) and (status_ip5 == 1) and (status_ip27 == 1):
$lbl_header2.text = 'Прибор исправен'
$lbl_header2.modulate = Color(0,1,0,1)
$lbl_header2.modulate = Color.GREEN
else:
$lbl_header2.text = 'Прибор не исправен'
$lbl_header2.modulate = Color(1,0,0,1)
$lbl_header2.modulate = Color.RED
$lbl_header2.visible = true

View File

@@ -153,3 +153,5 @@ text = "Прибор не исправен
"
horizontal_alignment = 1
vertical_alignment = 1
[node name="timer" type="Timer" parent="."]

View File

@@ -18,7 +18,7 @@ const PRIBORS_RES = \
'pribor_prd_v_2': ['res://scenes/pribor-prd-v/pribor-prd-v.tscn', 'Контроль исправности прибора ПРД-В 2'],
'pribor_prd_v_3': ['res://scenes/pribor-prd-v/pribor-prd-v.tscn', 'Контроль исправности прибора ПРД-В 3'],
'pribor_prd_v_4': ['res://scenes/pribor-prd-v/pribor-prd-v.tscn', 'Контроль исправности прибора ПРД-В 4'],
'pribor_rtr': ['res://scenes/pribor-afsp/pribor-rtr.tscn', 'Контроль исправности прибора РТР'],
'pribor_rtr': ['res://scenes/pribor-afsp/pribor-bpo.tscn', 'Контроль исправности прибора РТР'],
'pribor_afsp_1': ['res://scenes/pribor-afsp/pribor-afsp-1.tscn', 'Контроль исправности прибора АФСП 1'],
'pribor_afsp_2': ['res://scenes/pribor-afsp/pribor-afsp-2.tscn', 'Контроль исправности прибора АФСП 2'],
'pribor_uf': ['res://scenes/pribor-uf/pribor-uf.tscn', 'Контроль исправности прибора УФ'],