diff --git a/scenes/pribor-uyep/block-output.tscn b/scenes/pribor-uyep/block-output.tscn index b7cd077..3248d18 100644 --- a/scenes/pribor-uyep/block-output.tscn +++ b/scenes/pribor-uyep/block-output.tscn @@ -16,6 +16,7 @@ extends PanelContainer signal pressed(control: PanelContainer) + @export var fname: String: set(v): fname = v @@ -28,10 +29,22 @@ signal pressed(control: PanelContainer) $margin/vbox/title/rname.text = v -@export var state: int: +@export var state0: int: set(v): - state = tools.clip_value(v, 0, textures.size() - 1) - $margin/vbox/grid/state.texture = textures[v] + state0 = tools.clip_value(v, 0, textures.size() - 1) + $margin/vbox/table/state0.texture = textures[v] + + +@export var state1: int: + set(v): + state1 = tools.clip_value(v, 0, textures.size() - 1) + $margin/vbox/table/state1.texture = textures[v] + + +@export var state2: int: + set(v): + state1 = tools.clip_value(v, 0, textures.size() - 1) + $margin/vbox/table/state2.texture = textures[v] @export var alignment: int: @@ -87,6 +100,7 @@ offset_bottom = 70.0 theme_override_styles/panel = SubResource("StyleBoxEmpty_3nd2u") script = SubResource("GDScript_oj3k3") textures = [ExtResource("1_20kkm"), ExtResource("2_t54t5"), ExtResource("3_et31i")] +state2 = null [node name="rect" type="NinePatchRect" parent="."] layout_mode = 2 @@ -151,6 +165,18 @@ layout_mode = 2 theme_override_font_sizes/font_size = 17 text = "Нагрузка" +[node name="state2" type="TextureRect" parent="margin/vbox/table"] +custom_minimum_size = Vector2(24, 24) +layout_mode = 2 +texture = ExtResource("1_20kkm") +expand_mode = 1 + +[node name="name2" type="Label" parent="margin/vbox/table"] +self_modulate = Color(1, 1, 1, 0.627451) +layout_mode = 2 +theme_override_font_sizes/font_size = 17 +text = "Температура" + [node name="button" type="Button" parent="."] layout_mode = 2 theme_override_styles/normal = SubResource("StyleBoxEmpty_ox0yw") diff --git a/scenes/pribor-uyep/pribor-uyep.tscn b/scenes/pribor-uyep/pribor-uyep.tscn index 823959f..e22929e 100644 --- a/scenes/pribor-uyep/pribor-uyep.tscn +++ b/scenes/pribor-uyep/pribor-uyep.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://bs7h65e7bodp3"] +[gd_scene load_steps=7 format=3 uid="uid://bs7h65e7bodp3"] [ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="1_6olof"] [ext_resource type="Script" path="res://scenes/контроль/прибор.gd" id="1_46rp6"] [ext_resource type="PackedScene" uid="uid://ku8rdjoyscai" path="res://scenes/pribor-uyep/block-input.tscn" id="4_mrvir"] +[ext_resource type="Script" path="res://scenes/pribor-uyep/spt25_view.gd" id="4_v0lil"] [ext_resource type="PackedScene" uid="uid://bsixhjfesq6r4" path="res://scenes/pribor-uyep/block-output.tscn" id="5_x74mk"] [ext_resource type="PackedScene" uid="uid://btpc78gucr57f" path="res://scenes/контроль/элемент-я.tscn" id="6_60xs3"] @@ -10,7 +11,6 @@ layout_mode = 3 anchors_preset = 0 script = ExtResource("1_46rp6") -unit_name = "уарэп-спт25-1" [node name="ref_G1" type="NinePatchRect" parent="."] layout_mode = 0 @@ -39,10 +39,10 @@ vertical_alignment = 1 [node name="Label" type="Label" parent="."] self_modulate = Color(0.835294, 0.141176, 0.286275, 1) layout_mode = 0 -offset_left = 245.0 -offset_top = 1065.0 -offset_right = 620.0 -offset_bottom = 1084.0 +offset_left = 225.0 +offset_top = 990.0 +offset_right = 600.0 +offset_bottom = 1009.0 text = "** Позиционные обозначения требуют уточнения **" horizontal_alignment = 1 vertical_alignment = 1 @@ -52,9 +52,11 @@ layout_mode = 0 offset_left = 135.0 offset_top = 485.0 offset_right = 375.0 -offset_bottom = 870.0 +offset_bottom = 895.0 +script = ExtResource("4_v0lil") fname = "СПТ-25-230-400" rname = "A1" +unit_name = "уарэп-спт25-1" [node name="block_input1" parent="spt25_A1" instance=ExtResource("4_mrvir")] layout_mode = 0 @@ -78,15 +80,18 @@ offset_left = 15.0 offset_top = 275.0 offset_right = 225.0 offset_bottom = 367.0 +state2 = null [node name="spt25_A2" parent="." instance=ExtResource("6_60xs3")] layout_mode = 0 offset_left = 435.0 offset_top = 485.0 offset_right = 675.0 -offset_bottom = 875.0 +offset_bottom = 895.0 +script = ExtResource("4_v0lil") fname = "СПТ-25-230-400" rname = "A2" +unit_name = "уарэп-спт25-2" [node name="block_input1" parent="spt25_A2" instance=ExtResource("4_mrvir")] layout_mode = 0 @@ -110,3 +115,4 @@ offset_left = 15.0 offset_top = 275.0 offset_right = 225.0 offset_bottom = 367.0 +state2 = null diff --git a/scenes/pribor-uyep/spt25_view.gd b/scenes/pribor-uyep/spt25_view.gd new file mode 100644 index 0000000..e332583 --- /dev/null +++ b/scenes/pribor-uyep/spt25_view.gd @@ -0,0 +1,37 @@ +@tool + +extends "res://scenes/контроль/элемент-я.gd" + +enum STATE_VAL +{ + NONE = 0, + GOOD = 1, + ERROR = 2 +} + + +func _ready() -> void: + var unit_key = repsettings.get_unit_key(unit_name) + var unit = repnetwork.units[unit_key] + unit.connect('data_received', on_data_received.bind(unit)) + + +func on_data_received(data, unit): + # Неисправность, напряжение на выходе меньше номинального + $block_output.state0 = STATE_VAL.GOOD if (data[4] & (1 << 0)) == 0 else STATE_VAL.ERROR + # Перегрузка и короткое замыкание по выходу + $block_output.state1 = STATE_VAL.GOOD if ((data[5] & (1 << 0)) == 0) or ((data[5] & (1 << 1)) == 0) else STATE_VAL.ERROR + # Критическая температура + $block_output.state2 = STATE_VAL.GOOD if ((data[5] & (1 << 5)) == 0) else STATE_VAL.ERROR + # Сеть 1. Вход + $block_input1.state0 = STATE_VAL.GOOD if ((data[4] & (1 << 1)) == 0) or ((data[4] & (1 << 3)) == 0) else STATE_VAL.ERROR + # Сеть 2. Вход + $block_input2.state0 = STATE_VAL.GOOD if ((data[4] & (1 << 2)) == 0) or ((data[4] & (1 << 4)) == 0) else STATE_VAL.ERROR + # Неисправность блока инвертора 1 канала + $block_input1.state1 = STATE_VAL.GOOD if (data[6] & (1 << 2)) == 0 else STATE_VAL.ERROR + # Неисправность блока инвертора 2 канала + $block_input2.state1 = STATE_VAL.GOOD if (data[6] & (1 << 3)) == 0 else STATE_VAL.ERROR + # Перегрев 1 канала + $block_input1.state2 = STATE_VAL.GOOD if (data[5] & (1 << 3)) == 0 else STATE_VAL.ERROR + # Перегрев 2 канала + $block_input1.state2 = STATE_VAL.GOOD if (data[5] & (1 << 4)) == 0 else STATE_VAL.ERROR diff --git a/scenes/контроль/элемент-я.gd b/scenes/контроль/элемент-я.gd new file mode 100644 index 0000000..759ec17 --- /dev/null +++ b/scenes/контроль/элемент-я.gd @@ -0,0 +1,37 @@ +@tool + +extends Control + +signal pressed(control: PanelContainer) + + +func _on_button_pressed(): + emit_signal('pressed', self) + + +@export var fname: String: + set(v): + fname = v + $margin/vbox/grid/fname.text = v + + +@export var rname: String: + set(v): + rname = v + $margin/vbox/grid/rname.text = v + + +@export var alignment: int: + set(v): + $margin/vbox.alignment = v + + +@export var unit_name: String = '' + + +func _enter_tree() -> void: _on_resized() + +func _on_resized() -> void: + $rect.size = size + $margin.size = size + $button.size = size diff --git a/scenes/контроль/элемент-я.tscn b/scenes/контроль/элемент-я.tscn index ddb9e9a..3ec2da4 100644 --- a/scenes/контроль/элемент-я.tscn +++ b/scenes/контроль/элемент-я.tscn @@ -1,46 +1,8 @@ [gd_scene load_steps=9 format=3 uid="uid://btpc78gucr57f"] +[ext_resource type="Script" path="res://scenes/контроль/элемент-я.gd" id="1_fwxi0"] [ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="4_or1kj"] -[sub_resource type="GDScript" id="GDScript_oj3k3"] -script/source = "@tool - -extends Control - -signal pressed(control: PanelContainer) - - -func _on_button_pressed(): - emit_signal('pressed', self) - - -@export var fname: String: - set(v): - fname = v - $margin/vbox/grid/fname.text = v - - -@export var rname: String: - set(v): - rname = v - $margin/vbox/grid/rname.text = v - - -@export var alignment: int: - set(v): - $margin/vbox.alignment = v - - -@export var unit_name: String = '' - - -func _enter_tree() -> void: _on_resized() - -func _on_resized() -> void: - $rect.size = size - $margin.size = size -" - [sub_resource type="GDScript" id="GDScript_45hqb"] script/source = "@tool @@ -80,14 +42,17 @@ func _enter_tree() -> void: [node name="yelement_ya" type="Control"] editor_description = "Элемент замены из ЗИП" +custom_minimum_size = Vector2(32, 32) layout_mode = 3 anchors_preset = 0 -script = SubResource("GDScript_oj3k3") +offset_right = 180.0 +offset_bottom = 155.0 +script = ExtResource("1_fwxi0") [node name="rect" type="NinePatchRect" parent="."] layout_mode = 2 -offset_right = 34.0 -offset_bottom = 32.0 +offset_right = 180.0 +offset_bottom = 155.0 size_flags_horizontal = 3 size_flags_vertical = 3 texture = ExtResource("4_or1kj") @@ -100,8 +65,8 @@ patch_margin_bottom = 15 [node name="margin" type="MarginContainer" parent="."] layout_mode = 2 -offset_right = 22.0 -offset_bottom = 42.0 +offset_right = 180.0 +offset_bottom = 155.0 theme_override_constants/margin_left = 8 theme_override_constants/margin_top = 8 theme_override_constants/margin_right = 8 @@ -135,6 +100,8 @@ vertical_alignment = 1 [node name="button" type="Button" parent="."] layout_mode = 2 +offset_right = 180.0 +offset_bottom = 155.0 theme_override_styles/normal = SubResource("StyleBoxEmpty_ox0yw") theme_override_styles/hover = SubResource("StyleBoxEmpty_xxyaa") theme_override_styles/pressed = SubResource("StyleBoxEmpty_cd4fw") diff --git a/scripts/repnetwork.gd b/scripts/repnetwork.gd index f615501..1ffaf91 100644 --- a/scripts/repnetwork.gd +++ b/scripts/repnetwork.gd @@ -122,9 +122,10 @@ func _ready() -> void: 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)) var serial = create_serial(unit_name) + units_serial[unit_key] = unit + units[unit_key] = unit + serials[unit_key] = serial if serial: - units_serial[unit_key] = unit - serials[unit_key] = serial serial.data_received.connect(unit.parse) serial.start_monitoring(20000) diff --git a/scripts/signaller.gd b/scripts/signaller.gd index 714238c..e640896 100644 --- a/scripts/signaller.gd +++ b/scripts/signaller.gd @@ -15,10 +15,6 @@ func emmit(sgnl: Signal): emit_signal(sgnl.get_name()) signal serial_error() -## Вызывается при приёме данных от устройства -signal data_received(data: PackedByteArray, unit_name: String) - - ## Вызывается при переходе в режим [b]Работа[/b]. signal режим_работа() diff --git a/scripts/spt25.gd b/scripts/spt25.gd index 2e9fee4..5ef00ae 100644 --- a/scripts/spt25.gd +++ b/scripts/spt25.gd @@ -5,6 +5,8 @@ class SPT25: signal command_done(unit: SPT25) ## Вызывается после выполнения команды. signal command_fail(unit: SPT25) ## Вызывается если возникла ошибка при выполнении команды и команда не выполнена. signal parse_failed(unit: SPT25) ## Вызывается при обнаружении ошибки во входных данных + signal data_received(unit: SPT25) ## Вызывается по приёму данных + var online: bool var name: String func _init(nm) -> void: self.name = nm @@ -14,8 +16,8 @@ class SPT25: if not self.online: self.online = true emit_signal('line_changed', self) + emit_signal('data_received', rx_data) func process(delta: float): pass -