Доработка. В процессе. Разделить прибор РТР на два АФСП
This commit is contained in:
79
scenes/pribor-afsp/pribor-afsp-1.tscn
Normal file
79
scenes/pribor-afsp/pribor-afsp-1.tscn
Normal file
@@ -0,0 +1,79 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://8ll27id5ajq1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0jwv5opi3mrl" path="res://scenes/pribor-afsp/pribor-afsp.gd" id="1_151rh"]
|
||||
[ext_resource type="Script" uid="uid://bux47vkw71w1t" path="res://scenes/pribor-afsp/request.gd" id="2_4vyhj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnxq870xf6pkh" path="res://scenes/pribor-afsp/bort-afsp.tscn" id="3_d7iti"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_yhnwg"]
|
||||
script/source = "extends Timer
|
||||
|
||||
func _ready(): wait_time = ProjectSettings.get_setting('application/config/unit_rr_request_period')
|
||||
"
|
||||
|
||||
[node name="pribor_rtr" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 78.0
|
||||
offset_right = 10.0
|
||||
offset_bottom = 78.0
|
||||
scale = Vector2(0.9, 0.9)
|
||||
script = ExtResource("1_151rh")
|
||||
|
||||
[node name="lbl_header" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_top = -44.8889
|
||||
offset_right = 1044.0
|
||||
offset_bottom = -15.8889
|
||||
theme_override_font_sizes/font_size = 22
|
||||
text = "Контроль исправности прибора"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="request_rtr" type="HTTPRequest" parent="."]
|
||||
script = ExtResource("2_4vyhj")
|
||||
|
||||
[node name="timer" type="Timer" parent="request_rtr"]
|
||||
wait_time = 4.168
|
||||
autostart = true
|
||||
script = SubResource("GDScript_yhnwg")
|
||||
|
||||
[node name="left" parent="." instance=ExtResource("3_d7iti")]
|
||||
scale = Vector2(0.9, 0.9)
|
||||
metadata/DeviceName = &"Устройство РР левого борта"
|
||||
|
||||
[node name="right" parent="." instance=ExtResource("3_d7iti")]
|
||||
offset_left = 522.0
|
||||
offset_right = 1102.0
|
||||
scale = Vector2(0.9, 0.9)
|
||||
metadata/DeviceName = &"Устройство РР правого борта"
|
||||
|
||||
[node name="lbl_left" type="Label" parent="."]
|
||||
self_modulate = Color(1, 1, 1, 0.627451)
|
||||
layout_mode = 0
|
||||
offset_left = 217.0
|
||||
offset_top = -18.6666
|
||||
offset_right = 306.0
|
||||
offset_bottom = 3.33341
|
||||
theme_override_font_sizes/font_size = 17
|
||||
text = "левый борт"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="lbl_right" type="Label" parent="."]
|
||||
self_modulate = Color(1, 1, 1, 0.627451)
|
||||
layout_mode = 0
|
||||
offset_left = 739.0
|
||||
offset_top = -18.6666
|
||||
offset_right = 833.0
|
||||
offset_bottom = 3.33341
|
||||
theme_override_font_sizes/font_size = 17
|
||||
text = "правый борт"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[connection signal="child_entered_tree" from="request_rtr" to="request_rtr" method="_on_child_entered_tree"]
|
||||
[connection signal="request_completed" from="request_rtr" to="." method="_on_request_rtr_request_completed"]
|
||||
[connection signal="timeout" from="request_rtr/timer" to="request_rtr" method="_on_request_timer"]
|
||||
[connection signal="pressed" from="left" to="." method="_on_item_pressed"]
|
||||
[connection signal="pressed" from="right" to="." method="_on_item_pressed"]
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://5uv1idl3lqet"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0jwv5opi3mrl" path="res://scenes/pribor-afsp/pribor-afsp.gd" id="1_f33d3"]
|
||||
[ext_resource type="Script" uid="uid://bux47vkw71w1t" path="res://scenes/контроль/request.gd" id="2_0b8u2"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnxq870xf6pkh" path="res://scenes/pribor-afsp/bort-afsp.tscn" id="3_6rjuf"]
|
||||
[ext_resource type="Script" uid="uid://d0jwv5opi3mrl" path="res://scenes/pribor-afsp/pribor-afsp.gd" id="1_tfses"]
|
||||
[ext_resource type="Script" uid="uid://bux47vkw71w1t" path="res://scenes/pribor-afsp/request.gd" id="2_miwrd"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnxq870xf6pkh" path="res://scenes/pribor-afsp/bort-afsp.tscn" id="3_xpxb5"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_yhnwg"]
|
||||
script/source = "extends Timer
|
||||
@@ -18,7 +18,7 @@ offset_top = 78.0
|
||||
offset_right = 10.0
|
||||
offset_bottom = 78.0
|
||||
scale = Vector2(0.9, 0.9)
|
||||
script = ExtResource("1_f33d3")
|
||||
script = ExtResource("1_tfses")
|
||||
|
||||
[node name="lbl_header" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
@@ -31,18 +31,18 @@ horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="request_rtr" type="HTTPRequest" parent="."]
|
||||
script = ExtResource("2_0b8u2")
|
||||
script = ExtResource("2_miwrd")
|
||||
|
||||
[node name="timer" type="Timer" parent="request_rtr"]
|
||||
wait_time = 4.168
|
||||
autostart = true
|
||||
script = SubResource("GDScript_yhnwg")
|
||||
|
||||
[node name="left" parent="." instance=ExtResource("3_6rjuf")]
|
||||
[node name="left" parent="." instance=ExtResource("3_xpxb5")]
|
||||
scale = Vector2(0.9, 0.9)
|
||||
metadata/DeviceName = &"Устройство РР левого борта"
|
||||
|
||||
[node name="right" parent="." instance=ExtResource("3_6rjuf")]
|
||||
[node name="right" parent="." instance=ExtResource("3_xpxb5")]
|
||||
offset_left = 522.0
|
||||
offset_right = 1102.0
|
||||
scale = Vector2(0.9, 0.9)
|
||||
42
scenes/pribor-afsp/request.gd
Normal file
42
scenes/pribor-afsp/request.gd
Normal file
@@ -0,0 +1,42 @@
|
||||
extends HTTPRequest
|
||||
|
||||
## Для приборов АФСП и РТР
|
||||
|
||||
const RESULT_STRINGS = {
|
||||
RESULT_SUCCESS: 'Запрос успешен',
|
||||
RESULT_CHUNKED_BODY_SIZE_MISMATCH: 'Несоответствие размеров частей сообщения',
|
||||
RESULT_CANT_CONNECT: 'Запрос не выполнен при подключении',
|
||||
RESULT_CANT_RESOLVE: 'Запрос не выполнен при разрешении',
|
||||
RESULT_CONNECTION_ERROR: 'Запрос не выполнен из-за ошибки соединения (чтения/записи)',
|
||||
RESULT_TLS_HANDSHAKE_ERROR: 'Запрос не выполнен на TLS рукопожатии',
|
||||
RESULT_NO_RESPONSE: 'Запрос не имеет ответа (пока)',
|
||||
RESULT_BODY_SIZE_LIMIT_EXCEEDED: 'Запрос превысил максимальный размер, см. `body_size_limit`',
|
||||
RESULT_BODY_DECOMPRESS_FAILED: 'Не удалось распаковать сообщение',
|
||||
RESULT_REQUEST_FAILED: 'Запрос не удался (в настоящее время не используется)',
|
||||
RESULT_DOWNLOAD_FILE_CANT_OPEN: 'Невозможно открыть файл загрузки',
|
||||
RESULT_DOWNLOAD_FILE_WRITE_ERROR: 'Невозможно записать в файл загрузки',
|
||||
RESULT_REDIRECT_LIMIT_REACHED: 'Запрос достиг максимального предела перенаправления, см. `max_redirects`',
|
||||
RESULT_TIMEOUT: 'Время истекло' }
|
||||
|
||||
|
||||
var i_bort: int = 0
|
||||
var addr_left: String
|
||||
var addr_right: String
|
||||
|
||||
|
||||
func get_result_string(result: Result):
|
||||
return RESULT_STRINGS[result] if RESULT_STRINGS.has(result) else '<неизвестный код результата HTTPRequest - %d>' % result
|
||||
|
||||
|
||||
func _ready():
|
||||
addr_left = ProjectSettings.get_setting('application/config/unit_afsp_left_bort')
|
||||
addr_right = ProjectSettings.get_setting('application/config/unit_afsp_right_bort')
|
||||
|
||||
|
||||
func _on_request_timer():
|
||||
var addr = [addr_left, addr_right][i_bort]
|
||||
var rc = request(addr)
|
||||
if rc != Error.OK:
|
||||
var s: String = '%s: %s' % [error_string(rc), addr]
|
||||
log.error('ошибка: %s' % s)
|
||||
i_bort = (i_bort + 1) % 2
|
||||
1
scenes/pribor-afsp/request.gd.uid
Normal file
1
scenes/pribor-afsp/request.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bux47vkw71w1t
|
||||
Reference in New Issue
Block a user