Доработан контроль
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dwxn2puh462nl"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/контроль/прибор.gd" id="1_2qyst"]
|
||||
[ext_resource type="Script" path="res://scenes/pribor-uf/pribor_uf.gd" id="1_7gtpa"]
|
||||
[ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="2_ho0da"]
|
||||
[ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="3_dp78y"]
|
||||
|
||||
[node name="pribor_uf" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_2qyst")
|
||||
script = ExtResource("1_7gtpa")
|
||||
|
||||
[node name="ref_uf" type="NinePatchRect" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 98.0
|
||||
offset_left = 187.0
|
||||
offset_top = 247.0
|
||||
offset_right = 708.0
|
||||
offset_bottom = 1121.0
|
||||
offset_bottom = 955.0
|
||||
texture = ExtResource("2_ho0da")
|
||||
patch_margin_left = 16
|
||||
patch_margin_top = 16
|
||||
@@ -23,17 +23,17 @@ patch_margin_bottom = 16
|
||||
|
||||
[node name="ref_bu1" type="NinePatchRect" parent="ref_uf"]
|
||||
layout_mode = 0
|
||||
offset_left = 282.0
|
||||
offset_top = 138.0
|
||||
offset_right = 591.0
|
||||
offset_bottom = 468.0
|
||||
offset_left = 199.0
|
||||
offset_top = 14.0
|
||||
offset_right = 508.0
|
||||
offset_bottom = 344.0
|
||||
texture = ExtResource("2_ho0da")
|
||||
patch_margin_left = 16
|
||||
patch_margin_top = 16
|
||||
patch_margin_right = 16
|
||||
patch_margin_bottom = 16
|
||||
|
||||
[node name="ref_A13" parent="ref_uf/ref_bu1" instance=ExtResource("3_dp78y")]
|
||||
[node name="ref_A13_MKEG" parent="ref_uf/ref_bu1" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 7.0
|
||||
offset_top = 60.0
|
||||
offset_right = 59.0
|
||||
@@ -42,21 +42,14 @@ self_size = Vector2i(52, 262)
|
||||
fname = "MKEG/C"
|
||||
rname = "A13"
|
||||
|
||||
[node name="ref_A" parent="ref_uf/ref_bu1" instance=ExtResource("3_dp78y")]
|
||||
[node name="ref_A8_BU" parent="ref_uf/ref_bu1" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 59.0
|
||||
offset_top = 60.0
|
||||
offset_right = 302.0
|
||||
offset_bottom = 322.0
|
||||
self_size = Vector2i(243, 262)
|
||||
fname = "ВК-110"
|
||||
|
||||
[node name="А8" type="Label" parent="ref_uf/ref_bu1"]
|
||||
layout_mode = 0
|
||||
offset_left = 21.0
|
||||
offset_top = 12.0
|
||||
offset_right = 39.0
|
||||
offset_bottom = 31.0
|
||||
text = "А8"
|
||||
rname = "A8"
|
||||
|
||||
[node name="А1" type="Label" parent="ref_uf/ref_bu1"]
|
||||
layout_mode = 0
|
||||
@@ -68,83 +61,74 @@ text = "БУ-1"
|
||||
|
||||
[node name="ref_kassetav13" type="NinePatchRect" parent="ref_uf"]
|
||||
layout_mode = 0
|
||||
offset_left = 12.0
|
||||
offset_top = 513.0
|
||||
offset_right = 601.0
|
||||
offset_bottom = 852.0
|
||||
offset_left = 11.0
|
||||
offset_top = 353.0
|
||||
offset_right = 509.0
|
||||
offset_bottom = 692.0
|
||||
texture = ExtResource("2_ho0da")
|
||||
patch_margin_left = 16
|
||||
patch_margin_top = 16
|
||||
patch_margin_right = 16
|
||||
patch_margin_bottom = 16
|
||||
|
||||
[node name="ref_A18" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 6.0
|
||||
[node name="ref_A9_ESW" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 62.0
|
||||
offset_top = 65.0
|
||||
offset_right = 165.0
|
||||
offset_right = 170.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(159, 260)
|
||||
self_size = Vector2i(108, 260)
|
||||
fname = "ESW-6U16TP"
|
||||
rname = "A18"
|
||||
rname = "A9"
|
||||
|
||||
[node name="ref_A7" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 166.0
|
||||
[node name="ref_A7_YAU07" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 438.0
|
||||
offset_top = 65.0
|
||||
offset_right = 218.0
|
||||
offset_right = 490.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(52, 260)
|
||||
fname = "ЯУ-07Б"
|
||||
rname = "A7"
|
||||
|
||||
[node name="ref_A2" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 218.0
|
||||
[node name="ref_A4_KEMS" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 279.0
|
||||
offset_top = 65.0
|
||||
offset_right = 270.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(52, 260)
|
||||
fname = "КЭМС-Б"
|
||||
rname = "A2"
|
||||
|
||||
[node name="ref_A4" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 269.0
|
||||
offset_top = 65.0
|
||||
offset_right = 321.0
|
||||
offset_right = 331.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(52, 260)
|
||||
fname = "КЭМС-Б1"
|
||||
rname = "A4"
|
||||
|
||||
[node name="ref_A5" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 322.0
|
||||
[node name="ref_A5_EMS" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 225.0
|
||||
offset_top = 65.0
|
||||
offset_right = 374.0
|
||||
offset_right = 277.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(52, 260)
|
||||
fname = "ЭМС-Б"
|
||||
rname = "A5"
|
||||
|
||||
[node name="ref_A6" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 374.0
|
||||
[node name="ref_A6_EMS" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 171.0
|
||||
offset_top = 65.0
|
||||
offset_right = 426.0
|
||||
offset_right = 223.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(52, 260)
|
||||
fname = "ЭМС-Б"
|
||||
rname = "A6"
|
||||
|
||||
[node name="ref_A3" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 427.0
|
||||
[node name="ref_A3_IP5B" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 332.0
|
||||
offset_top = 65.0
|
||||
offset_right = 532.0
|
||||
offset_right = 437.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(105, 260)
|
||||
fname = "ИП-220-5Б"
|
||||
rname = "A3"
|
||||
|
||||
[node name="ref_A8" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 531.0
|
||||
[node name="ref_A12_IP27B" parent="ref_uf/ref_kassetav13" instance=ExtResource("3_dp78y")]
|
||||
offset_left = 9.0
|
||||
offset_top = 65.0
|
||||
offset_right = 582.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = 325.0
|
||||
self_size = Vector2i(51, 260)
|
||||
fname = "ИП220-27Б"
|
||||
@@ -168,7 +152,7 @@ text = "Кассета В-13"
|
||||
|
||||
[node name="lbl_header" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 105.0
|
||||
offset_left = 199.0
|
||||
offset_top = 225.0
|
||||
offset_right = 704.0
|
||||
offset_bottom = 251.0
|
||||
@@ -177,3 +161,16 @@ text = "Контроль исправности прибора УФ
|
||||
"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="lbl_header2" type="Label" parent="."]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_left = 199.0
|
||||
offset_top = 974.0
|
||||
offset_right = 704.0
|
||||
offset_bottom = 1000.0
|
||||
theme_override_font_sizes/font_size = 22
|
||||
text = "Прибор не исправен
|
||||
"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
@@ -1,14 +1,106 @@
|
||||
extends "res://scenes/контроль/прибор.gd"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
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 = '046d:c31c'
|
||||
var REVFF = '(rev ff)'
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var unit_key = settings.get_unit_key('уарэп-эмс')
|
||||
var unit_uf = network.units[unit_key]
|
||||
unit_uf.connect('data_received', on_data_received.bind(unit_uf))
|
||||
|
||||
func on_data_received(data, unit_uf):
|
||||
print_debug(data)
|
||||
var unit_key_5p28 = settings.get_unit_key('уарэп-5п28')
|
||||
var unit_5p28 = network.units[unit_key_5p28]
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
self.add_child(timer)
|
||||
timer.connect('timeout', Callable(self, 'on_timer').bind(unit_uf, unit_5p28))
|
||||
timer.start(1)
|
||||
|
||||
|
||||
func on_timer(unit_uf, unit_5p28):
|
||||
Control_VK() # проверка трекбола и pci
|
||||
if unit_5p28.online: # проверка внешнего коммутатора
|
||||
$ref_uf/ref_bu1/ref_A13_MKEG.state = STATE_VAL.GOOD
|
||||
else:
|
||||
$ref_uf/ref_bu1/ref_A13_MKEG.state = STATE_VAL.NONE
|
||||
|
||||
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
|
||||
$ref_uf/ref_kassetav13/ref_A5_EMS.state = STATE_VAL.NONE
|
||||
$ref_uf/ref_kassetav13/ref_A6_EMS.state = STATE_VAL.NONE
|
||||
$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:
|
||||
var out_usb_str = ''
|
||||
var out_pci_str = ''
|
||||
var out_usb = []
|
||||
var out_pci = []
|
||||
|
||||
OS.execute('lsusb', [], out_usb)
|
||||
for element in out_usb:
|
||||
out_usb_str += element
|
||||
|
||||
OS.execute('lspci', [], out_pci)
|
||||
for element in out_pci:
|
||||
out_pci_str += element
|
||||
|
||||
out_usb_str = out_usb_str.split("\n")
|
||||
out_pci_str = out_pci_str.split("\n")
|
||||
|
||||
var i: int = 0
|
||||
|
||||
for string in out_usb_str:
|
||||
if USB_TRACKERBALL in string:
|
||||
i += 1
|
||||
break
|
||||
for string in out_pci_str:
|
||||
for item in DEV_LIST:
|
||||
if item in string:
|
||||
i += 1
|
||||
if REVFF in string:
|
||||
i -= 1
|
||||
break
|
||||
|
||||
if i == (len(DEV_LIST) + 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:
|
||||
$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
|
||||
$ref_uf/ref_kassetav13/ref_A12_IP27B.state = STATE_VAL.GOOD if ((status[2] >> 6) & 1) else STATE_VAL.ERROR
|
||||
|
||||
|
||||
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
|
||||
|
||||
if (status_yay == 1) and (status_bu == 1) and (status_kems == 1) and (status_ems0 == 1) and (status_ems1 == 1):
|
||||
$lbl_header2.text = "Прибор исправен"
|
||||
$lbl_header2.modulate = Color(0,1,0,1)
|
||||
else:
|
||||
$lbl_header2.text = "Прибор не исправен"
|
||||
$lbl_header2.modulate = Color(1,0,0,1)
|
||||
$lbl_header2.visible = true
|
||||
|
||||
Reference in New Issue
Block a user