Доработка. Режим "Контроль". Отображение состояния на связи для TCP подключений
This commit is contained in:
@@ -19,6 +19,7 @@ offset_right = 70.0
|
||||
offset_bottom = 30.0
|
||||
scale = Vector2(1, 0.9)
|
||||
script = ExtResource("1_151rh")
|
||||
unit_name = &"уарэп-афсп-левый"
|
||||
metadata/DeviceName = &"Устройство РР левого борта"
|
||||
|
||||
[node name="request" type="HTTPRequest" parent="."]
|
||||
|
||||
@@ -19,6 +19,7 @@ offset_right = 81.0
|
||||
offset_bottom = 108.0
|
||||
scale = Vector2(1, 0.9)
|
||||
script = ExtResource("1_tfses")
|
||||
unit_name = &"уарэп-афсп-правый"
|
||||
metadata/DeviceName = &"Устройство РР правого борта"
|
||||
|
||||
[node name="request" type="HTTPRequest" parent="."]
|
||||
|
||||
@@ -2,25 +2,39 @@
|
||||
class_name pribor_afsp extends 'res://scenes/контроль/прибор.gd'
|
||||
|
||||
@export var prefix_path: String = 'DeviceDescripton[DeviceName]'
|
||||
@export var unit_name: StringName= ''
|
||||
|
||||
static var json_conv: JSON = JSON.new()
|
||||
static var node_maper = load('res://scenes/контроль/node-maper.gd')
|
||||
|
||||
|
||||
func _on_request_completed(result, _response_code, headers, body: PackedByteArray):
|
||||
|
||||
var unit_instance = network.get_unit_instance(unit_name)
|
||||
|
||||
if result != 0:
|
||||
var rs = $request.get_result_string(result)
|
||||
log.error('\"%s\"' % rs)
|
||||
if unit_instance.online:
|
||||
unit_instance.online = false
|
||||
unit_instance.emit_signal('line_changed', unit_instance)
|
||||
return
|
||||
|
||||
var json_str: String = body.get_string_from_utf8()
|
||||
if not json_str:
|
||||
push_error('не удаётся получить строку utf8 из данных (%s)' % headers)
|
||||
if unit_instance.online:
|
||||
unit_instance.online = false
|
||||
unit_instance.emit_signal('line_changed', unit_instance)
|
||||
return
|
||||
|
||||
var rc = json_conv.parse(json_str)
|
||||
if rc != Error.OK:
|
||||
var err = json_conv.get_error_message()
|
||||
push_error('разбор json прерван - \"%s\" (%s)' % [err, headers])
|
||||
if unit_instance.online:
|
||||
unit_instance.online = false
|
||||
unit_instance.emit_signal('line_changed', unit_instance)
|
||||
return
|
||||
|
||||
var pp = []
|
||||
@@ -38,6 +52,10 @@ func _on_request_completed(result, _response_code, headers, body: PackedByteArra
|
||||
if this_afsp_name != received_afsp_name:
|
||||
return
|
||||
|
||||
if not unit_instance.online:
|
||||
unit_instance.online = true
|
||||
unit_instance.emit_signal('line_changed', unit_instance)
|
||||
|
||||
for child in $bort.get_node('konverter/grid').get_children():
|
||||
node_maper.map_value_to_item(json_conv.data, child, 'value0')
|
||||
node_maper.map_value_to_item(json_conv.data, child, 'value1')
|
||||
|
||||
Reference in New Issue
Block a user