diff --git a/data/DSEG7Classic-Regular.ttf.import b/data/DSEG7Classic-Regular.ttf.import index 1c1fddb5..edd46ee5 100644 --- a/data/DSEG7Classic-Regular.ttf.import +++ b/data/DSEG7Classic-Regular.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/DSEG7Classic-Regular.ttf-32df8fc6f2e5584d5a5b Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/data/DejaVuSans.ttf.import b/data/DejaVuSans.ttf.import index 3e412bcd..de13c3dc 100644 --- a/data/DejaVuSans.ttf.import +++ b/data/DejaVuSans.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/DejaVuSans.ttf-b4085dde282b5d503d6a56e258b526 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/data/DejaVuSansCondensed.ttf.import b/data/DejaVuSansCondensed.ttf.import index 42c3c526..2d8fd9ed 100644 --- a/data/DejaVuSansCondensed.ttf.import +++ b/data/DejaVuSansCondensed.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/DejaVuSansCondensed.ttf-7a8251b7291db131ffa4e Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/scenes/pribor-uf/pribor-uf.tscn b/scenes/pribor-uf/pribor-uf.tscn index b3296bbc..f06a78d9 100644 --- a/scenes/pribor-uf/pribor-uf.tscn +++ b/scenes/pribor-uf/pribor-uf.tscn @@ -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 diff --git a/scenes/pribor-uf/pribor_uf.gd b/scenes/pribor-uf/pribor_uf.gd new file mode 100644 index 00000000..a8765bf7 --- /dev/null +++ b/scenes/pribor-uf/pribor_uf.gd @@ -0,0 +1,101 @@ +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)' + + +func _ready() -> void: + var unit_key = settings.get_unit_key('уарэп-эмс') + var unit_uf = network.units[unit_key] + + var unit_key_5p28 = settings.get_unit_key('уарэп-5п28') + var unit_5p28 = network.units[unit_key_5p28] + + self.add_child(timer) + timer.connect('timeout', Callable(self, 'on_timer').bind(unit_uf)) + timer.start(1) + + +func on_timer(unit_uf): + Control_VK() # проверка трекбола и pci + 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 diff --git a/scenes/контроль/кассета.gd b/scenes/контроль/кассета.gd index a91fc7a1..26eed3dc 100644 --- a/scenes/контроль/кассета.gd +++ b/scenes/контроль/кассета.gd @@ -7,12 +7,12 @@ extends NinePatchRect """ @export var fname: String: - set(v): - fname = v - if is_inside_tree(): - $lbl_fname.text = v + set(v): + fname = v + if is_inside_tree(): + $lbl_fname.text = v @export var rname: String: - set(v): - rname = v + set(v): + rname = v diff --git a/scenes/контроль/кнопка-прибора.gd b/scenes/контроль/кнопка-прибора.gd index 4575a6ca..e0f2369e 100644 --- a/scenes/контроль/кнопка-прибора.gd +++ b/scenes/контроль/кнопка-прибора.gd @@ -7,7 +7,7 @@ extends Node func _on_toggled(toggled_on): $frame.visible = toggled_on @export var state: int: - set(v): - v = 0 if v < 0 else v % state_colors.size() - state = v - $label.self_modulate = state_colors[v] + set(v): + v = 0 if v < 0 else v % state_colors.size() + state = v + $label.self_modulate = state_colors[v] diff --git a/scenes/контроль/элемент-в.tscn b/scenes/контроль/элемент-в.tscn index 9c8c4cae..5e4e9614 100644 --- a/scenes/контроль/элемент-в.tscn +++ b/scenes/контроль/элемент-в.tscn @@ -18,55 +18,55 @@ extends Control @export var self_size: Vector2i = Vector2i(50, 150): - set(v): - self_size = v - size = v - $np_rect.size = v - _resize_children() - get: return size + set(v): + self_size = v + size = v + $np_rect.size = v + _resize_children() + get: return size @export var fname: String: - set(v): - fname = v - $lbl_fname.text = v + set(v): + fname = v + $lbl_fname.text = v @export var rname: String: - set(v): - rname = v - $lbl_rname.text = v + set(v): + rname = v + $lbl_rname.text = v func _resize_children() -> void: - $lbl_rname.size.x = size.x - $lbl_rname.position.y = margins[0] - $lbl_fname.size.y = size.x - $lbl_fname.position.y = size.y / 2 + $lbl_fname.size.x / 2 - $txr_state.position.x = size.x / 2 - ($txr_state.size.x * $txr_state.scale.x) / 2 - $txr_state.position.y = size.y - $txr_state.size.y * $txr_state.scale.x - margins[2] + $lbl_rname.size.x = size.x + $lbl_rname.position.y = margins[0] + $lbl_fname.size.y = size.x + $lbl_fname.position.y = size.y / 2 + $lbl_fname.size.x / 2 + $txr_state.position.x = size.x / 2 - ($txr_state.size.x * $txr_state.scale.x) / 2 + $txr_state.position.y = size.y - $txr_state.size.y * $txr_state.scale.x - margins[2] func _on_nine_patch_rect_resized() -> void: - size = $np_rect.size - self_size = $np_rect.size - _resize_children() + size = $np_rect.size + self_size = $np_rect.size + _resize_children() func _on_resized() -> void: - $np_rect.size = size - self_size = size - _resize_children() + $np_rect.size = size + self_size = size + _resize_children() @export var state: int: - set(v): - v = 0 if v < 0 else v - v %= textures.size() - state = v - $txr_state.texture = textures[v] - get: - return state + set(v): + v = 0 if v < 0 else v + v %= textures.size() + state = v + $txr_state.texture = textures[v] + get: + return state " [node name="yelement_v" type="Control"] diff --git a/scripts/network.gd b/scripts/network.gd index 025199ca..c14c04da 100644 --- a/scripts/network.gd +++ b/scripts/network.gd @@ -122,12 +122,13 @@ func _ready() -> void: dst_ports[unit_key] = st[2][0] if proto in TCP_PROTO: - var unit = TCP_PROTO[proto].new(unit_name) + var unit_tcp = TCP_PROTO[proto].new(unit_name) var unit_key = settings.get_unit_key(unit_name) - units_tcp[unit_key] = unit + units_tcp[unit_key] = unit_tcp + units[unit_key] = unit_tcp if logger_page: - unit.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key)) - unit.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key)) + unit_tcp.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key)) + unit_tcp.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key)) if proto in SERIAL_PROTO: var unit_serial = SERIAL_PROTO[proto].new(unit_name) diff --git a/scripts/settings.gd b/scripts/settings.gd index 6fbfdb96..99f64ba4 100644 --- a/scripts/settings.gd +++ b/scripts/settings.gd @@ -23,7 +23,7 @@ class_name rep_settings extends Node 'уарэп-яу07-3к': ['yau07tx', '10.1.1.33', [50033], false, false, 'IP-адрес ЯУ-07 прибора ПРД-Н'], # Название: [ Протокол, Адрес, Порт получения, Комментарий ] - 'уарэп-5п28': [ '5p28', '127.0.0.1', [50000], 'IP-адрес комплекса 5П-28'], + 'уарэп-5п28': [ '5p28', '192.168.3.109', [50000], 'IP-адрес комплекса 5П-28'], # Название: [ Протокол, Адрес, [ Порт получения, Порт отправки], ??, ??, Комментарий 'уарэп-щ3': ['udp-json-mbcs', '127.0.0.1', [48000, 44100], false, true, 'IP-адрес и порты через которые производят обмен сообщения с драйвером клиента Modbus Serial'], diff --git a/scripts/unit.gd b/scripts/unit.gd index 5209cc9e..e920fd6c 100644 --- a/scripts/unit.gd +++ b/scripts/unit.gd @@ -3,26 +3,26 @@ class_name base_unit extends Node ## Базовый класс для управления подключаемыми устройствами class Unit extends Object: - ## Состояние автомата выполнения команды. - enum CmdState { - UNCK, ## Номер команды не ининциирован. - SEND, ## Буфер готов для отправки. - WAIT, ## Ожидание выполнения. - DONE, ## Команда выполнена. - FAIL ## Команда не выполнена. - } + ## Состояние автомата выполнения команды. + enum CmdState { + UNCK, ## Номер команды не ининциирован. + SEND, ## Буфер готов для отправки. + WAIT, ## Ожидание выполнения. + DONE, ## Команда выполнена. + FAIL ## Команда не выполнена. + } - signal line_changed(unit) ## Вызывается при изменении состояния связи - signal command_done(unit) ## Вызывается после успешного выполнения команды. - signal command_fail(unit) ## Вызывается если возникла ошибка при выполнении команды и команда не выполнена. - signal parse_failed(unit) ## Вызывается при обнаружении ошибки во входных данных - signal data_received(data: PackedByteArray) ## Вызывается по приёму данных + signal line_changed(unit) ## Вызывается при изменении состояния связи + signal command_done(unit) ## Вызывается после успешного выполнения команды. + signal command_fail(unit) ## Вызывается если возникла ошибка при выполнении команды и команда не выполнена. + signal parse_failed(unit) ## Вызывается при обнаружении ошибки во входных данных + signal data_received(data: PackedByteArray) ## Вызывается по приёму данных - var tx_data: = PackedByteArray() ## Буфер для отправки. - var tx_len: int = 0 ## Длина последнего отправленного пакета. - var tx_tick: int = 0 ## Тик-время отправки буфера - var rx_tick: int = 0 ## Тик-время последнего приёма данных - var online: bool = false ## Состояние подключения устройства - var name: String = '<без имени>' ## Уникальное имя устройства - func _init(nm) -> void: self.name = nm - func _to_string() -> String: return String('устройство: %s %s' % [self.name, ['отключен', 'на связи'][int(online)]]) + var tx_data: = PackedByteArray() ## Буфер для отправки. + var tx_len: int = 0 ## Длина последнего отправленного пакета. + var tx_tick: int = 0 ## Тик-время отправки буфера + var rx_tick: int = 0 ## Тик-время последнего приёма данных + var online: bool = false ## Состояние подключения устройства + var name: String = '<без имени>' ## Уникальное имя устройства + func _init(nm) -> void: self.name = nm + func _to_string() -> String: return String('устройство: %s %s' % [self.name, ['отключен', 'на связи'][int(online)]])