From 92608f5e82996be760eaa6fe0af2411e70b84e32 Mon Sep 17 00:00:00 2001
From: TotMaxim
Date: Thu, 20 Nov 2025 16:57:58 +0300
Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=9A=D0=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 3 +++
Main.gd | 1 +
Plata-check.tscn | 4 ++--
project.godot | 2 +-
table/table.gd.uid | 1 +
unit.gd | 30 ++++++++++++++++++++++++++++++
6 files changed, 38 insertions(+), 3 deletions(-)
create mode 100644 table/table.gd.uid
create mode 100644 unit.gd
diff --git a/.gitignore b/.gitignore
index 4709183..7467baa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
# Godot 4+ specific ignores
.godot/
+/bin/
+/*.cfg
+/*.uid
diff --git a/Main.gd b/Main.gd
index 71a9a16..557fea4 100644
--- a/Main.gd
+++ b/Main.gd
@@ -211,6 +211,7 @@ func on_command_fail(_unit) -> void:
## Индикация чтения портов
func on_command_done(_unit) -> void:
+ if not unit.isa_ports.has(port_select): return
var isa: Array = []
ports_wr[port_select] = unit.isa_ports[port_select]
if (unit.isa_ports[port_select] == ports_wr[port_select]) and flag_online:
diff --git a/Plata-check.tscn b/Plata-check.tscn
index 0a8f179..b1d1560 100644
--- a/Plata-check.tscn
+++ b/Plata-check.tscn
@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://ccp4ypftnrbwq"]
-[ext_resource type="Script" path="res://Main.gd" id="1_8v2wa"]
-[ext_resource type="Script" path="res://table/table.gd" id="2_ri1qb"]
+[ext_resource type="Script" uid="uid://cf85o5e0hhlej" path="res://Main.gd" id="1_8v2wa"]
+[ext_resource type="Script" uid="uid://brfcvsto5bx3" path="res://table/table.gd" id="2_ri1qb"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jbuuq"]
bg_color = Color(0.0901961, 0.52549, 0.0588235, 1)
diff --git a/project.godot b/project.godot
index 151b7e7..903c8c5 100644
--- a/project.godot
+++ b/project.godot
@@ -12,7 +12,7 @@ config_version=5
config/name="Plata-check.exe"
run/main_scene="res://Plata-check.tscn"
-config/features=PackedStringArray("4.3", "GL Compatibility")
+config/features=PackedStringArray("4.4", "GL Compatibility")
config/icon="res://icon.svg"
[autoload]
diff --git a/table/table.gd.uid b/table/table.gd.uid
new file mode 100644
index 0000000..b093cc8
--- /dev/null
+++ b/table/table.gd.uid
@@ -0,0 +1 @@
+uid://brfcvsto5bx3
diff --git a/unit.gd b/unit.gd
new file mode 100644
index 0000000..db8e8b3
--- /dev/null
+++ b/unit.gd
@@ -0,0 +1,30 @@
+class_name base_unit extends Node
+
+## Базовый класс для управления подключаемыми устройствами
+class Unit extends Object:
+
+ ## Состояние автомата выполнения команды.
+ 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) ## Вызывается по приёму данных
+
+ var cmd_state = CmdState.UNCK ## Состояние выполнения команды
+ 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: StringName = '<без имени>' ## Уникальное имя устройства
+ func _init(nm) -> void: self.name = nm
+ func _to_string() -> String:
+ return String('Unit(\"%s\", %s)' % [self.name, 'на связи' if online else 'отключен'])