Рефактор

This commit is contained in:
sasha80
2024-10-30 10:01:12 +03:00
parent e00533c035
commit 5020b62c9b
4 changed files with 12 additions and 3 deletions

View File

@@ -65,7 +65,11 @@ func _enter_tree() -> void:
$back.scale = size
$back.material.set('shader_parameter/scale', size / Vector2(20.0, 20.0))
$button.set_toggle_mode(true)
$button.connect('toggled', Callable(self, '_on_button_toggled'))
$button.connect('toggled', _on_button_toggled)
func _exit_tree() -> void:
$button.disconnect('toggled', _on_button_toggled)
func set_toggle_mode(val: bool):

View File

@@ -3,7 +3,7 @@
[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="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"]

View File

@@ -1,3 +1,5 @@
@tool
extends "res://scenes/контроль/элемент-я.gd"
@export var unit_name: String = ''
@@ -11,12 +13,14 @@ enum STATE_VAL
func _enter_tree() -> void:
if Engine.is_editor_hint(): return
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 _exit_tree() -> void:
if Engine.is_editor_hint(): return
var unit_key = repsettings.get_unit_key(unit_name)
var unit = repnetwork.units[unit_key]
unit.disconnect('data_received', on_data_received)
@@ -26,7 +30,7 @@ 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.state1 = STATE_VAL.GOOD if ((data[5] & (1 << 0)) == 0) and ((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. Вход

View File

@@ -28,6 +28,7 @@ func _on_button_pressed():
func _ready() -> void: call_deferred('_on_resized')
func _on_resized() -> void:
$rect.size = size
$margin.size = size