Доработка. У приборов АФСП и РТР один общий скрипт для загрузки результатов контроля
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[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/контроль/request.gd" id="2_4vyhj"]
|
||||
[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"]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[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_tfses"]
|
||||
[ext_resource type="Script" uid="uid://bux47vkw71w1t" path="res://scenes/контроль/request.gd" id="2_miwrd"]
|
||||
[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"]
|
||||
|
||||
@@ -49,7 +49,6 @@ func _on_request_rtr_request_completed(result, _response_code, headers, body: Pa
|
||||
push_error('разбор json прерван - \"%s\" (%s)' % [err, headers])
|
||||
return
|
||||
|
||||
|
||||
var pp = ['DeviceDescripton', 'DeviceName']
|
||||
var ppp = []
|
||||
map_solid_to_array(prefix_path, ppp)
|
||||
@@ -60,13 +59,8 @@ func _on_request_rtr_request_completed(result, _response_code, headers, body: Pa
|
||||
push_error('путь %s не найден (%s)' % [pp_copy, ret_val[2]])
|
||||
return
|
||||
|
||||
var bort_rtr_name_left: StringName = $left.get_meta('DeviceName', '')
|
||||
var bort_rtr_name_right: StringName = $right.get_meta('DeviceName', '')
|
||||
var bb = {bort_rtr_name_left: $left, bort_rtr_name_right: $right}
|
||||
if not bb.has(ret_val[0]):
|
||||
return
|
||||
|
||||
var bort_rtr = bb[ret_val[0]]
|
||||
var bort_rtr_name: StringName = get_meta('DeviceName', '')
|
||||
var bort_rtr = self
|
||||
for child in bort_rtr.get_node('konverter/grid').get_children():
|
||||
map_value_to_item(json_conv.data, child, 'value0')
|
||||
map_value_to_item(json_conv.data, child, 'value1')
|
||||
|
||||
3
scenes/pribor-afsp/pribor-rtr.gd
Normal file
3
scenes/pribor-afsp/pribor-rtr.gd
Normal file
@@ -0,0 +1,3 @@
|
||||
class_name pribor_rtr extends 'res://scenes/контроль/прибор.gd'
|
||||
|
||||
@export var prefix_path: String = ''
|
||||
1
scenes/pribor-afsp/pribor-rtr.gd.uid
Normal file
1
scenes/pribor-afsp/pribor-rtr.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d0jwv5opi3mrk
|
||||
175
scenes/pribor-afsp/pribor-rtr.tscn
Normal file
175
scenes/pribor-afsp/pribor-rtr.tscn
Normal file
@@ -0,0 +1,175 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://5uv1idl3lqea"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0jwv5opi3mrk" path="res://scenes/pribor-afsp/pribor-rtr.gd" id="1_soedq"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="2_pspup"]
|
||||
[ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="3_gh777"]
|
||||
|
||||
[node name="pribor_rtr" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = 115.0
|
||||
offset_top = 150.0
|
||||
offset_right = 115.0
|
||||
offset_bottom = 150.0
|
||||
script = ExtResource("1_soedq")
|
||||
|
||||
[node name="yach_svyzi" parent="." instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
offset_left = 40.0
|
||||
offset_top = 535.0
|
||||
offset_right = 560.0
|
||||
offset_bottom = 605.0
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Модуль электропитания"
|
||||
rname = "G1"
|
||||
|
||||
[node name="blok_bpo_a1" parent="." instance=ExtResource("2_pspup")]
|
||||
layout_mode = 0
|
||||
offset_left = 40.0
|
||||
offset_top = 135.0
|
||||
offset_right = 560.0
|
||||
offset_bottom = 330.0
|
||||
show_state = false
|
||||
fname = "Блок БПО"
|
||||
rname = "А1"
|
||||
|
||||
[node name="grid_bpo_a1" type="GridContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 50.0
|
||||
offset_top = 175.0
|
||||
offset_right = 498.0
|
||||
offset_bottom = 320.0
|
||||
columns = 4
|
||||
|
||||
[node name="a1_kanal1" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 1"
|
||||
|
||||
[node name="a1_kanal2" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 2"
|
||||
|
||||
[node name="a1_kanal3" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 3"
|
||||
|
||||
[node name="a1_kanal4" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 4"
|
||||
|
||||
[node name="a1_kanal5" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 5"
|
||||
|
||||
[node name="a1_kanal6" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 6"
|
||||
|
||||
[node name="a1_kanal7" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 7"
|
||||
|
||||
[node name="a1_kanal8" parent="grid_bpo_a1" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 8"
|
||||
|
||||
[node name="yas_bpo_a1" parent="." instance=ExtResource("3_gh777")]
|
||||
offset_left = 500.0
|
||||
offset_top = 175.0
|
||||
offset_right = 550.0
|
||||
offset_bottom = 320.0
|
||||
show_rname = false
|
||||
self_size = Vector2i(50, 145)
|
||||
fname = "Яч. связи"
|
||||
|
||||
[node name="blok_bpo_a2" parent="." instance=ExtResource("2_pspup")]
|
||||
layout_mode = 0
|
||||
offset_left = 40.0
|
||||
offset_top = 335.0
|
||||
offset_right = 560.0
|
||||
offset_bottom = 530.0
|
||||
show_state = false
|
||||
fname = "Блок БПО"
|
||||
rname = "А2"
|
||||
|
||||
[node name="grid_bpo_a2" type="GridContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 50.0
|
||||
offset_top = 375.0
|
||||
offset_right = 498.0
|
||||
offset_bottom = 520.0
|
||||
columns = 4
|
||||
|
||||
[node name="a1_kanal1" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 1"
|
||||
|
||||
[node name="a1_kanal2" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 2"
|
||||
|
||||
[node name="a1_kanal3" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 3"
|
||||
|
||||
[node name="a1_kanal4" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 4"
|
||||
|
||||
[node name="a1_kanal5" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 5"
|
||||
|
||||
[node name="a1_kanal6" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 6"
|
||||
|
||||
[node name="a1_kanal7" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 7"
|
||||
|
||||
[node name="a1_kanal8" parent="grid_bpo_a2" instance=ExtResource("2_pspup")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 8"
|
||||
|
||||
[node name="yas_bpo_a2" parent="." instance=ExtResource("3_gh777")]
|
||||
offset_left = 500.0
|
||||
offset_top = 375.0
|
||||
offset_right = 550.0
|
||||
offset_bottom = 520.0
|
||||
show_rname = false
|
||||
self_size = Vector2i(50, 145)
|
||||
fname = "Яч. связи"
|
||||
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