diff --git a/README.md b/README.md index cf5a99c..6562d51 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ - Запустить скрипт `build.sh` -# Взаимодействие с 5p28 +# Взаимодействие с 5П-28 - Для получения навигационных данных, должно быть настроено дублирование udp-пакетов приходящих на соответствующий порт. Скрипт `ip-tables-navigation.sh` выполняет diff --git a/project.godot b/project.godot index 31c3bfb..348f45a 100644 --- a/project.godot +++ b/project.godot @@ -84,6 +84,7 @@ gdscript/warnings/integer_division=0 window/size/viewport_width=1600 window/size/viewport_height=1200 +window/size/mode=3 window/subwindows/embed_subwindows=false window/stretch/mode="canvas_items" window/dpi/allow_hidpi=false diff --git a/scenes/diagram/diagram.gd b/scenes/diagram/diagram.gd index 7be13d4..008dcd3 100644 --- a/scenes/diagram/diagram.gd +++ b/scenes/diagram/diagram.gd @@ -29,9 +29,17 @@ func get_radius_outter() -> float: return material.get('shader_parameter/radius func get_radius_inner_0() -> float: return material.get('shader_parameter/radius_inner_0') func get_radius_inner_1() -> float: return material.get('shader_parameter/radius_inner_1') -func set_view_mode(val: int): material.set('shader_parameter/mode', val); func set_band_colors(val: Array): material.set('shader_parameter/ant_band_c', val) + +func set_view_mode(val: int): + if val == 1: + $строб.hide() + else: + $строб.show() + material.set('shader_parameter/mode', val) + + ## Закрашивание по умолчанию блоков ФС цветами из настроек. func set_def_colors(): var color0: Vector3 = ProjectSettings.get_setting('application/interfer/default_color0', Vector3(0.38, 0.47, 0.51)) diff --git a/scenes/pribor-prd-k/kasseta-fs-kd.tscn b/scenes/pribor-prd-k/kasseta-fs-kd.tscn index dd269f6..9bab5bf 100644 --- a/scenes/pribor-prd-k/kasseta-fs-kd.tscn +++ b/scenes/pribor-prd-k/kasseta-fs-kd.tscn @@ -22,7 +22,7 @@ offset_left = 5.0 offset_top = 7.0 offset_right = 303.0 offset_bottom = 33.0 -text = "Кассета" +text = "Кассета ФС-КД" horizontal_alignment = 1 vertical_alignment = 1 @@ -31,23 +31,23 @@ offset_left = 5.0 offset_top = 33.0 offset_right = 55.0 offset_bottom = 183.0 -fname = "Модуль ФС" -rname = "A1" +fname = "Блок ФС-1" +rname = "A4" [node name="ref_A3" parent="." instance=ExtResource("3_kqnvt")] offset_left = 55.0 offset_top = 33.0 offset_right = 105.0 offset_bottom = 183.0 -fname = "Блок ФС-1" -rname = "A4" +fname = "Модуль ФС" +rname = "A1" [node name="ref_A4" parent="." instance=ExtResource("3_kqnvt")] offset_left = 105.0 offset_top = 33.0 offset_right = 155.0 offset_bottom = 183.0 -fname = "Модуль ФС" +fname = "Блок ФС-2" rname = "A2" [node name="ref_A6" parent="." instance=ExtResource("3_kqnvt")] @@ -55,7 +55,7 @@ offset_left = 155.0 offset_top = 33.0 offset_right = 205.0 offset_bottom = 183.0 -fname = "Блок ФС-6" +fname = "Модуль ФС" rname = "A5" [node name="ref_A5" parent="." instance=ExtResource("3_kqnvt")] @@ -71,5 +71,5 @@ offset_left = 255.0 offset_top = 33.0 offset_right = 305.0 offset_bottom = 183.0 -fname = "Блок ФС-2" +fname = "Блок ФС-6" rname = "A6" diff --git a/scenes/pribor-prd-k/pribor-prd-k.tscn b/scenes/pribor-prd-k/pribor-prd-k.tscn index 8dfe864..ca1858b 100644 --- a/scenes/pribor-prd-k/pribor-prd-k.tscn +++ b/scenes/pribor-prd-k/pribor-prd-k.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=11 format=3 uid="uid://m5s87q7m66lj"] [ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="1_8dmgr"] -[ext_resource type="Script" uid="uid://6m053dpg2lbh" path="res://scenes/контроль/прибор.gd" id="1_ufjwe"] +[ext_resource type="Script" uid="uid://cwvikiygf8b1m" path="res://scenes/pribor-prd-k/pribor_prd_k.gd" id="1_tpdyp"] [ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="2_14h25"] [ext_resource type="PackedScene" uid="uid://cm5jd4gjrrpba" path="res://scenes/контроль/кассета-у-5-к.tscn" id="2_tb85r"] [ext_resource type="Script" uid="uid://dow4nqi6hbak8" path="res://scenes/контроль/кассета-у-5.gd" id="3_wip3a"] @@ -18,7 +18,7 @@ offset_left = 15.0 offset_top = 30.0 offset_right = 15.0 offset_bottom = 30.0 -script = ExtResource("1_ufjwe") +script = ExtResource("1_tpdyp") [node name="kasseta_u5" parent="." instance=ExtResource("2_tb85r")] layout_mode = 0 @@ -36,7 +36,7 @@ offset_top = 907.0 offset_right = 652.0 offset_bottom = 949.0 fname = "MAA2000" -rname = "A27" +rname = "A28" [node name="dou2_A7" parent="." instance=ExtResource("1_8dmgr")] layout_mode = 0 @@ -54,7 +54,7 @@ offset_top = 907.0 offset_right = 175.0 offset_bottom = 949.0 fname = "MAA2000" -rname = "A28" +rname = "A27" [node name="dou2_A8" parent="." instance=ExtResource("1_8dmgr")] layout_mode = 0 @@ -95,12 +95,6 @@ offset_left = 485.0 offset_top = 242.0 offset_right = 652.0 offset_bottom = 337.0 -value0 = 28.0 -value1 = 70.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -114,12 +108,6 @@ offset_left = 485.0 offset_top = 337.0 offset_right = 652.0 offset_bottom = 432.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -133,12 +121,6 @@ offset_left = 485.0 offset_top = 432.0 offset_right = 652.0 offset_bottom = 527.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -152,12 +134,6 @@ offset_left = 485.0 offset_top = 527.0 offset_right = 652.0 offset_bottom = 622.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -171,12 +147,6 @@ offset_left = 485.0 offset_top = 622.0 offset_right = 652.0 offset_bottom = 717.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -190,12 +160,6 @@ offset_left = 485.0 offset_top = 717.0 offset_right = 652.0 offset_bottom = 812.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -209,12 +173,6 @@ offset_left = 485.0 offset_top = 812.0 offset_right = 652.0 offset_bottom = 907.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -228,12 +186,6 @@ offset_left = 8.0 offset_top = 242.0 offset_right = 175.0 offset_bottom = 337.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -247,12 +199,6 @@ offset_left = 8.0 offset_top = 337.0 offset_right = 173.0 offset_bottom = 432.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -266,12 +212,6 @@ offset_left = 8.0 offset_top = 432.0 offset_right = 175.0 offset_bottom = 527.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -285,12 +225,6 @@ offset_left = 8.0 offset_top = 527.0 offset_right = 175.0 offset_bottom = 622.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -304,12 +238,6 @@ offset_left = 8.0 offset_top = 622.0 offset_right = 175.0 offset_bottom = 717.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -323,12 +251,6 @@ offset_left = 8.0 offset_top = 717.0 offset_right = 175.0 offset_bottom = 812.0 -value0 = 28.0 -value1 = 57.0 -max_value0 = 99.0 -max_value1 = 99.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -363,8 +285,8 @@ offset_left = 9.0 offset_top = 33.0 offset_right = 59.0 offset_bottom = 183.0 -fname = "ИП12-50" -rname = "A26" +fname = "ИП9-50" +rname = "A23" [node name="ref_A23" parent="kasseta_p_1" instance=ExtResource("8_la5yt")] offset_left = 59.0 @@ -379,8 +301,8 @@ offset_left = 109.0 offset_top = 33.0 offset_right = 159.0 offset_bottom = 183.0 -fname = "ИП9-50" -rname = "A23" +fname = "ИП12-50" +rname = "A26" [node name="lbl_fname" type="Label" parent="kasseta_p_1"] self_modulate = Color(1, 1, 1, 0.62) diff --git a/scenes/pribor-prd-k/pribor_prd_k.gd b/scenes/pribor-prd-k/pribor_prd_k.gd new file mode 100644 index 0000000..0a10721 --- /dev/null +++ b/scenes/pribor-prd-k/pribor_prd_k.gd @@ -0,0 +1,32 @@ +@tool +extends "res://scenes/контроль/прибор.gd" + +enum STATE_VAL { + NONE = 0, + GOOD = 1, + ERROR = 2 } + + +func _ready() -> void: + pass + #var unit_key = settings.get_unit_key(get_meta('unit_name')[0]) + #var unit_prd = network.units[unit_key] + #unit_prd.connect('data_received', Callable(self, 'on_data_received')) + #unit_prd.connect('line_changed', Callable(self, 'on_line_changed')) + #set_default_state() + + +func set_default_state(): + $utm80_A9.state = STATE_VAL.NONE + $um1535_A10.state = STATE_VAL.NONE + $um1535_A11.state = STATE_VAL.NONE + $um1535_A12.state = STATE_VAL.NONE + $um1535_A13.state = STATE_VAL.NONE + $um1535_A14.state = STATE_VAL.NONE + $um1535_A15.state = STATE_VAL.NONE + $um1535_A16.state = STATE_VAL.NONE + $um1535_A17.state = STATE_VAL.NONE + $um1535_A18.state = STATE_VAL.NONE + $um1535_A19.state = STATE_VAL.NONE + $um1535_A20.state = STATE_VAL.NONE + $um1535_A21.state = STATE_VAL.NONE diff --git a/scenes/pribor-prd-k/pribor_prd_k.gd.uid b/scenes/pribor-prd-k/pribor_prd_k.gd.uid new file mode 100644 index 0000000..3493cb8 --- /dev/null +++ b/scenes/pribor-prd-k/pribor_prd_k.gd.uid @@ -0,0 +1 @@ +uid://cwvikiygf8b1m diff --git a/scenes/pribor-prd-n/kasseta-fs-nd.tscn b/scenes/pribor-prd-n/kasseta-fs-nd.tscn index 1af690c..b69f57e 100644 --- a/scenes/pribor-prd-n/kasseta-fs-nd.tscn +++ b/scenes/pribor-prd-n/kasseta-fs-nd.tscn @@ -22,7 +22,7 @@ offset_left = 5.0 offset_top = 7.0 offset_right = 303.0 offset_bottom = 33.0 -text = "Кассета" +text = "Кассета ФС-ВД" horizontal_alignment = 1 vertical_alignment = 1 @@ -31,16 +31,16 @@ offset_left = 55.0 offset_top = 32.0 offset_right = 105.0 offset_bottom = 182.0 -fname = "Модуль ФС" -rname = "A1" +fname = "Блок ФС-3" +rname = "A3" [node name="ref_A3" parent="." instance=ExtResource("2_mkgdh")] offset_left = 105.0 offset_top = 32.0 offset_right = 155.0 offset_bottom = 182.0 -fname = "Блок ФС-3" -rname = "A3" +fname = "Модуль ФС" +rname = "A1" [node name="ref_A4" parent="." instance=ExtResource("2_mkgdh")] offset_left = 155.0 diff --git a/scenes/pribor-prd-n/pribor-prd-n.tscn b/scenes/pribor-prd-n/pribor-prd-n.tscn index 718c338..f97936e 100644 --- a/scenes/pribor-prd-n/pribor-prd-n.tscn +++ b/scenes/pribor-prd-n/pribor-prd-n.tscn @@ -1,13 +1,38 @@ -[gd_scene load_steps=9 format=3 uid="uid://dnuexoef2nnv5"] +[gd_scene load_steps=14 format=3 uid="uid://dnuexoef2nnv5"] -[ext_resource type="Script" uid="uid://6m053dpg2lbh" path="res://scenes/контроль/прибор.gd" id="1_mcea3"] -[ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="2_lpj3d"] -[ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="4_i1no5"] -[ext_resource type="PackedScene" uid="uid://bk1655p4e8y4u" path="res://scenes/контроль/кассета-у-5-нв.tscn" id="5_ej152"] -[ext_resource type="Script" uid="uid://dow4nqi6hbak8" path="res://scenes/контроль/кассета-у-5.gd" id="5_hne5j"] -[ext_resource type="Script" uid="uid://crpedygm3gohi" path="res://scenes/контроль/кассета.gd" id="6_b1cob"] -[ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="7_dqc3e"] -[ext_resource type="PackedScene" uid="uid://bkxblfoj7ejv0" path="res://scenes/контроль/блок-а.tscn" id="8_u7eqo"] +[ext_resource type="Script" uid="uid://cto2r4ipew65m" path="res://scenes/pribor-prd-n/pribor_prd_n.gd" id="1_bnnv3"] +[ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="2_is25t"] +[ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="3_meukj"] +[ext_resource type="PackedScene" uid="uid://bk1655p4e8y4u" path="res://scenes/контроль/кассета-у-5-нв.tscn" id="4_xkifg"] +[ext_resource type="Script" uid="uid://dow4nqi6hbak8" path="res://scenes/контроль/кассета-у-5.gd" id="5_1wf07"] +[ext_resource type="Script" uid="uid://crpedygm3gohi" path="res://scenes/контроль/кассета.gd" id="6_b5wvk"] +[ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="7_eoqf2"] +[ext_resource type="PackedScene" uid="uid://bkxblfoj7ejv0" path="res://scenes/контроль/блок-а.tscn" id="8_sia5h"] +[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="9_k1x0o"] +[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="10_7dcjd"] +[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="11_ius1v"] + +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_bnnv3"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_xkifg"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("9_k1x0o") +}, { +"duration": 1.0, +"texture": ExtResource("10_7dcjd") +}, { +"duration": 1.0, +"texture": ExtResource("11_ius1v") +}, { +"duration": 1.0, +"texture": null +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] [node name="pribor_prd_n" type="Control"] layout_mode = 3 @@ -16,27 +41,9 @@ offset_left = 15.0 offset_top = 30.0 offset_right = 15.0 offset_bottom = 30.0 -script = ExtResource("1_mcea3") +script = ExtResource("1_bnnv3") -[node name="maa2000_A22" parent="." instance=ExtResource("2_lpj3d")] -layout_mode = 2 -offset_left = 485.0 -offset_top = 877.0 -offset_right = 652.0 -offset_bottom = 949.0 -fname = "MAA2000" -rname = "A22" - -[node name="dou2_A5" parent="." instance=ExtResource("2_lpj3d")] -layout_mode = 2 -offset_left = 485.0 -offset_top = 812.0 -offset_right = 652.0 -offset_bottom = 877.0 -fname = "ДОУ-2" -rname = "A5" - -[node name="maa2000_A23" parent="." instance=ExtResource("2_lpj3d")] +[node name="maa2000_A23" parent="." instance=ExtResource("2_is25t")] layout_mode = 2 offset_left = 8.0 offset_top = 877.0 @@ -45,7 +52,25 @@ offset_bottom = 949.0 fname = "MAA2000" rname = "A23" -[node name="dou2_A6" parent="." instance=ExtResource("2_lpj3d")] +[node name="maa2000_A22" parent="." instance=ExtResource("2_is25t")] +layout_mode = 2 +offset_left = 485.0 +offset_top = 877.0 +offset_right = 652.0 +offset_bottom = 949.0 +fname = "MAA2000" +rname = "A22" + +[node name="dou2_A5" parent="." instance=ExtResource("2_is25t")] +layout_mode = 2 +offset_left = 485.0 +offset_top = 812.0 +offset_right = 652.0 +offset_bottom = 877.0 +fname = "ДОУ-2" +rname = "A5" + +[node name="dou2_A6" parent="." instance=ExtResource("2_is25t")] layout_mode = 2 offset_left = 8.0 offset_top = 812.0 @@ -60,7 +85,7 @@ offset_left = 175.0 offset_top = 812.0 offset_right = 485.0 offset_bottom = 949.0 -texture = ExtResource("4_i1no5") +texture = ExtResource("3_meukj") patch_margin_left = 16 patch_margin_top = 16 patch_margin_right = 16 @@ -78,13 +103,13 @@ text = "Панель horizontal_alignment = 1 vertical_alignment = 1 -[node name="kasseta_U5" parent="." instance=ExtResource("5_ej152")] +[node name="kasseta_U5" parent="." instance=ExtResource("4_xkifg")] layout_mode = 0 offset_left = 175.0 offset_top = 242.0 offset_right = 485.0 offset_bottom = 432.0 -script = ExtResource("5_hne5j") +script = ExtResource("5_1wf07") fname = "Кассета У5" [node name="kasseta_FS_ND" type="NinePatchRect" parent="."] @@ -93,12 +118,12 @@ offset_left = 175.0 offset_top = 432.0 offset_right = 485.0 offset_bottom = 622.0 -texture = ExtResource("4_i1no5") +texture = ExtResource("3_meukj") patch_margin_left = 16 patch_margin_top = 16 patch_margin_right = 16 patch_margin_bottom = 16 -script = ExtResource("6_b1cob") +script = ExtResource("6_b5wvk") fname = "Кассета ФС-НД" metadata/Fname = "" @@ -113,23 +138,23 @@ text = "Кассета ФС-НД" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ref_A2" parent="kasseta_FS_ND" instance=ExtResource("7_dqc3e")] +[node name="ref_A3" parent="kasseta_FS_ND" instance=ExtResource("7_eoqf2")] offset_left = 55.0 offset_top = 32.0 offset_right = 105.0 offset_bottom = 182.0 -fname = "Модуль ФС" -rname = "A1" +fname = "Блок ФС-3" +rname = "A3" -[node name="ref_A3" parent="kasseta_FS_ND" instance=ExtResource("7_dqc3e")] +[node name="ref_A1" parent="kasseta_FS_ND" instance=ExtResource("7_eoqf2")] offset_left = 105.0 offset_top = 32.0 offset_right = 155.0 offset_bottom = 182.0 -fname = "Блок ФС-2" -rname = "A3" +fname = "Модуль ФС" +rname = "A1" -[node name="ref_A4" parent="kasseta_FS_ND" instance=ExtResource("7_dqc3e")] +[node name="ref_A2" parent="kasseta_FS_ND" instance=ExtResource("7_eoqf2")] offset_left = 155.0 offset_top = 32.0 offset_right = 205.0 @@ -137,12 +162,12 @@ offset_bottom = 182.0 fname = "Модуль ФС" rname = "A2" -[node name="ref_A6" parent="kasseta_FS_ND" instance=ExtResource("7_dqc3e")] +[node name="ref_A4" parent="kasseta_FS_ND" instance=ExtResource("7_eoqf2")] offset_left = 205.0 offset_top = 32.0 offset_right = 255.0 offset_bottom = 182.0 -fname = "Блок ФС-3" +fname = "Блок ФС-2" rname = "A4" [node name="kasseta_P_1" type="NinePatchRect" parent="."] @@ -151,23 +176,23 @@ offset_left = 175.0 offset_top = 622.0 offset_right = 485.0 offset_bottom = 812.0 -texture = ExtResource("4_i1no5") +texture = ExtResource("3_meukj") patch_margin_left = 16 patch_margin_top = 16 patch_margin_right = 16 patch_margin_bottom = 16 -script = ExtResource("6_b1cob") +script = ExtResource("6_b5wvk") fname = "Кассета П-1" -[node name="ref_A26" parent="kasseta_P_1" instance=ExtResource("7_dqc3e")] +[node name="ref_A21" parent="kasseta_P_1" instance=ExtResource("7_eoqf2")] offset_left = 9.0 offset_top = 33.0 offset_right = 59.0 offset_bottom = 183.0 -fname = "ИП9-50" -rname = "A19" +fname = "ИП12-50" +rname = "A21" -[node name="ref_A23" parent="kasseta_P_1" instance=ExtResource("7_dqc3e")] +[node name="ref_A20" parent="kasseta_P_1" instance=ExtResource("7_eoqf2")] offset_left = 59.0 offset_top = 33.0 offset_right = 109.0 @@ -175,13 +200,13 @@ offset_bottom = 183.0 fname = "ИП9-50" rname = "A20" -[node name="ref_A24" parent="kasseta_P_1" instance=ExtResource("7_dqc3e")] +[node name="ref_A19" parent="kasseta_P_1" instance=ExtResource("7_eoqf2")] offset_left = 109.0 offset_top = 33.0 offset_right = 159.0 offset_bottom = 183.0 -fname = "ИП12-50" -rname = "A21" +fname = "ИП9-50" +rname = "A19" [node name="lbl_fname" type="Label" parent="kasseta_P_1"] self_modulate = Color(1, 1, 1, 0.62) @@ -194,16 +219,12 @@ text = "Кассета П-1" horizontal_alignment = 1 vertical_alignment = 1 -[node name="um1535_A7" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A7" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 485.0 offset_top = 242.0 offset_right = 652.0 offset_bottom = 337.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -211,16 +232,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A7" -[node name="um1535_A8" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A8" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 485.0 offset_top = 337.0 offset_right = 652.0 offset_bottom = 432.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -228,16 +245,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A8" -[node name="um1535_A9" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A9" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 485.0 offset_top = 432.0 offset_right = 652.0 offset_bottom = 527.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -245,16 +258,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A9" -[node name="um1535_A10" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A10" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 485.0 offset_top = 527.0 offset_right = 652.0 offset_bottom = 622.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -262,16 +271,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A10" -[node name="um1535_A11" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A11" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 485.0 offset_top = 622.0 offset_right = 652.0 offset_bottom = 717.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -279,16 +284,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A11" -[node name="um1535_A12" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A12" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 485.0 offset_top = 717.0 offset_right = 652.0 offset_bottom = 812.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -296,18 +297,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A12" -[node name="um1535_A13" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A13" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 8.0 offset_top = 242.0 offset_right = 175.0 offset_bottom = 337.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -315,16 +310,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A13" -[node name="um1535_A14" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 8.0 offset_top = 337.0 offset_right = 175.0 offset_bottom = 432.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -332,16 +323,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A14" -[node name="um1535_A15" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 8.0 offset_top = 432.0 offset_right = 175.0 offset_bottom = 527.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -349,16 +336,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A15" -[node name="um1535_A16" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A16" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 8.0 offset_top = 527.0 offset_right = 175.0 offset_bottom = 622.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -366,16 +349,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A16" -[node name="um1535_A17" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A17" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 8.0 offset_top = 622.0 offset_right = 175.0 offset_bottom = 717.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -383,19 +362,88 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A17" -[node name="um1535_A18" parent="." instance=ExtResource("8_u7eqo")] +[node name="um1535_A18" parent="." groups=["power_amplifier"] instance=ExtResource("8_sia5h")] layout_mode = 0 offset_left = 8.0 offset_top = 717.0 offset_right = 175.0 offset_bottom = 812.0 -value0 = 27.0 -value1 = 56.0 -max_value0 = 100.0 -max_value1 = 100.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A18" + +[node name="Monitoring_panel" type="Panel" parent="."] +visible = false +layout_mode = 0 +theme_override_styles/panel = SubResource("StyleBoxTexture_bnnv3") + +[node name="in_fs_1" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(454, 577) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_xkifg") + +[node name="in_fs_1" type="Label" parent="Monitoring_panel/in_fs_1"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "In FS 1" +horizontal_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="in_fs_2" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(207, 577) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_xkifg") + +[node name="in_fs_2" type="Label" parent="Monitoring_panel/in_fs_2"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "In FS 2" +horizontal_alignment = 1 + +[node name="out_ems_1" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(454, 465) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_xkifg") + +[node name="Out_ems_1" type="Label" parent="Monitoring_panel/out_ems_1"] +anchors_preset = -1 +anchor_left = 0.0185185 +anchor_right = 0.0185185 +anchor_bottom = 0.555556 +offset_left = -18.5 +offset_top = 14.0 +offset_right = 17.5 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "Out +ems 1" +horizontal_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="out_ems_2" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(207, 465) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_xkifg") + +[node name="Out_ems_1" type="Label" parent="Monitoring_panel/out_ems_2"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "Out +ems 2" +horizontal_alignment = 1 diff --git a/scenes/pribor-prd-n/pribor_prd_n.gd b/scenes/pribor-prd-n/pribor_prd_n.gd new file mode 100644 index 0000000..6f822dd --- /dev/null +++ b/scenes/pribor-prd-n/pribor_prd_n.gd @@ -0,0 +1,186 @@ +@tool +extends "res://scenes/контроль/прибор.gd" + +const IN_BLANK_PRD: int = 1 +const OUT_BLANK_PRD: int = 13 +const CI_2_OT_FS: int = 9 +const CI_3_OT_FS: int = 10 +const CI_2_B_UF: int = 1 +const CI_3_B_UF: int = 2 +const POWER_UKP_1: int = 31 +const POWER_UKP_2: int = 63 + +var timer_03: Timer = Timer.new() +var count_packet_1:int = 0 +var power_array_1: Array = [] +var count_packet_2:int = 0 +var power_array_2: Array = [] + +enum STATE_VAL { + NONE = 0, + GOOD = 1, + ERROR = 2 } + + +func _ready() -> void: + var unit_key = settings.get_unit_key(get_meta('unit_name')[0]) + var unit_prd = network.units[unit_key] + unit_prd.connect('data_received', Callable(self, 'on_data_received')) + unit_prd.connect('line_changed', Callable(self, 'on_line_changed')) + set_default_state() + self.add_child(timer_03) + timer_03.connect('timeout', Callable(self, 'on_timer_03')) + #on_timer_03(unit_key) + + +func set_default_state() -> void: + for group in get_tree().get_nodes_in_group('power_amplifier'): + group.state = STATE_VAL.NONE + + +func on_line_changed(unit_prd: Object) -> void: + if not unit_prd.online: + set_default_state() + + +func on_data_received(unit_prd: Object) -> void: + if not is_inside_tree(): + return + + check_block_ip(unit_prd.status) + check_temperature_um(unit_prd.status) + + ## Контроль ЭМС + #_process_ems_data(unit_prd) + + var in_blank: int = unit_prd.status.decode_u16(IN_BLANK_PRD) + var out_blank: int = unit_prd.status.decode_u16(OUT_BLANK_PRD) + + $Monitoring_panel/in_fs_1.frame = (in_blank >> CI_2_OT_FS) & 1 + $Monitoring_panel/in_fs_2.frame = (in_blank >> CI_3_OT_FS) & 1 + + $Monitoring_panel/out_ems_1.frame = (out_blank >> CI_2_B_UF) & 1 + $Monitoring_panel/out_ems_2.frame = (out_blank >> CI_3_B_UF) & 1 + + ## Мощность УМ от УКП 1 + if (in_blank >> CI_2_OT_FS) & 1: + const bit_dkm_1: int = 1 + check_dkm(unit_prd.status, bit_dkm_1) + + var arr_power_ukp_1: Array = [] + + if (unit_prd.status[0] >> 2) & 1: + for i_power in range(6): + var power_ukp_1 = unit_prd.status.decode_u16(POWER_UKP_1 + 2 * i_power) + arr_power_ukp_1.append(power_ukp_1) + + if count_packet_1 == 0: + power_array_1 = arr_power_ukp_1 + else: + for i in arr_power_ukp_1.size(): + if arr_power_ukp_1[i] > power_array_1[i]: + power_array_1[i] = arr_power_ukp_1[i] + + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + for i in 6: + power_amplifier[i].value1 = '%d' % power_array_1[i] + + count_packet_1 += 1 + + ## Мощность УМ от УКП 2 + if (in_blank >> CI_3_OT_FS) & 1: + const bit_dkm_2: int = 2 + check_dkm(unit_prd.status, bit_dkm_2) + + var arr_power_ukp_2: Array = [] + + if (unit_prd.status[0] >> 2) & 1: + for i_power in range(6): + var power_ukp_2 = unit_prd.status.decode_u16(POWER_UKP_2 + 2 * i_power) + arr_power_ukp_2.append(power_ukp_2) + + if count_packet_2 == 0: + power_array_2 = arr_power_ukp_2 + else: + for i in arr_power_ukp_2.size(): + if arr_power_ukp_2[i] > power_array_2[i]: + power_array_2[i] = arr_power_ukp_2[i] + + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + for i in 6: + power_amplifier[i+6].value1 = '%d' % power_array_2[i] + + count_packet_2 += 1 + + +## Проверка касет П1 и ИП МА2000 +func check_block_ip(status_prd: PackedByteArray) -> void : + var ug_online: bool = (status_prd[0] >> 1) & 1 + if ug_online: + const BYTE_DRY_CONTACT: int = 27 + const BIT_MAA2000_1: int = 0 + const BIT_MAA2000_2: int = 1 + const BIT_IP9_50_1: int = 2 + const BIT_IP9_50_2: int = 3 + const BIT_IP12_50_1: int = 4 + + var maa2000_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_MAA2000_1 & 1 + var maa2000_2 = status_prd[BYTE_DRY_CONTACT] >> BIT_MAA2000_2 & 1 + var ip9_50_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP9_50_1 & 1 + var ip9_50_2 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP9_50_2 & 1 + var ip12_50_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP12_50_1 & 1 + + $maa2000_A23.state = STATE_VAL.ERROR if maa2000_1 else STATE_VAL.GOOD + $maa2000_A22.state = STATE_VAL.ERROR if maa2000_2 else STATE_VAL.GOOD + $kasseta_P_1/ref_A20.state = STATE_VAL.ERROR if ip9_50_1 else STATE_VAL.GOOD + $kasseta_P_1/ref_A21.state = STATE_VAL.ERROR if ip9_50_2 else STATE_VAL.GOOD + $kasseta_P_1/ref_A19.state = STATE_VAL.ERROR if ip12_50_1 else STATE_VAL.GOOD + else: + $maa2000_A23.state = STATE_VAL.NONE + $maa2000_A22.state = STATE_VAL.NONE + $kasseta_P_1/ref_A19.state = STATE_VAL.NONE + $kasseta_P_1/ref_A20.state = STATE_VAL.NONE + $kasseta_P_1/ref_A21.state = STATE_VAL.NONE + + +## Проверка температур УМ от УКП +func check_temperature_um(status_prd: PackedByteArray) -> void: + const CONST_MIN_TEMP: int = -25 + const MAXIMUM_CODE_ADC: int = 3796 + const MINIMUM_CODE_AD: int = 2660 + const TEMP: float = 115.0 / (MAXIMUM_CODE_ADC - MINIMUM_CODE_AD) + const TEMPERATURE_UKP_1: int = 47 + const TEMPERATURE_UKP_2: int = 79 + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + + var ukp1_online: int = (status_prd[0] >> 2) & 1 + if ukp1_online: + for i_temp in range(6): + var temperature_ukp_1: int = status_prd.decode_u16(TEMPERATURE_UKP_1 + 2 * i_temp) + var tmp_1: int = round(CONST_MIN_TEMP + (MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3) + power_amplifier[i_temp].value0 = tmp_1 + + var ukp2_online = (status_prd[0] >> 3) & 1 + if ukp2_online: + for i_temp in range(6): + var temperature_ukp_2: int = status_prd.decode_u16(TEMPERATURE_UKP_2 + 2 * i_temp) + var tmp_2: int = round(CONST_MIN_TEMP + (MAXIMUM_CODE_ADC - temperature_ukp_2) * TEMP + 3) + power_amplifier[i_temp+6].value0 = tmp_2 + + +## Проверка ДКМ +func check_dkm(status_prd: PackedByteArray, bit_dkm: int) -> void: + const DKM: int = 28 + + var status_dkm = status_prd[DKM] >> bit_dkm & 1 + + if bit_dkm == 1: + $dou2_A5.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + $kasseta_FS_ND/ref_A4.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + elif bit_dkm == 2: + $dou2_A6.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + $kasseta_FS_ND/ref_A3.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + + +#func on_timer_03(unit_name): + #print(unit_name) diff --git a/scenes/pribor-prd-n/pribor_prd_n.gd.uid b/scenes/pribor-prd-n/pribor_prd_n.gd.uid new file mode 100644 index 0000000..b3c223e --- /dev/null +++ b/scenes/pribor-prd-n/pribor_prd_n.gd.uid @@ -0,0 +1 @@ +uid://cto2r4ipew65m diff --git a/scenes/pribor-prd-v/pribor-prd-v.tscn b/scenes/pribor-prd-v/pribor-prd-v.tscn index 31a0b30..fa34230 100644 --- a/scenes/pribor-prd-v/pribor-prd-v.tscn +++ b/scenes/pribor-prd-v/pribor-prd-v.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://cvskpe1ti3p45"] +[gd_scene load_steps=15 format=3 uid="uid://cvskpe1ti3p45"] [ext_resource type="Script" uid="uid://cvuosuvjaci1h" path="res://scenes/pribor-prd-v/pribor_prd_v.gd" id="1_c20s6"] [ext_resource type="PackedScene" uid="uid://d3iqb5e4g81m5" path="res://scenes/контроль/элемент-г.tscn" id="2_xpo4b"] @@ -9,8 +9,33 @@ [ext_resource type="Script" uid="uid://crpedygm3gohi" path="res://scenes/контроль/кассета.gd" id="6_os4mt"] [ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://scenes/контроль/элемент-в.tscn" id="7_38u2b"] [ext_resource type="PackedScene" uid="uid://bkxblfoj7ejv0" path="res://scenes/контроль/блок-а.tscn" id="7_e22c6"] +[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="10_4e87c"] +[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="11_g8fvp"] +[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="12_gsby4"] -[node name="pribor_prd_n" type="Control"] +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_vxfkm"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_s5gcy"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("10_4e87c") +}, { +"duration": 1.0, +"texture": ExtResource("11_g8fvp") +}, { +"duration": 1.0, +"texture": ExtResource("12_gsby4") +}, { +"duration": 1.0, +"texture": null +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[node name="pribor_prd_v" type="Control"] layout_mode = 3 anchors_preset = 0 offset_left = 15.0 @@ -110,7 +135,7 @@ patch_margin_bottom = 16 script = ExtResource("6_os4mt") fname = "Кассета П-1В" -[node name="ref_A26" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] +[node name="ref_A19" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] offset_left = 9.0 offset_top = 33.0 offset_right = 59.0 @@ -118,7 +143,7 @@ offset_bottom = 183.0 fname = "ИП9-50" rname = "A19" -[node name="ref_A23" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] +[node name="ref_A20" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] offset_left = 59.0 offset_top = 33.0 offset_right = 109.0 @@ -126,7 +151,7 @@ offset_bottom = 183.0 fname = "ИП9-50" rname = "A20" -[node name="ref_A24" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] +[node name="ref_A21" parent="kasseta_P_1" instance=ExtResource("7_38u2b")] offset_left = 109.0 offset_top = 33.0 offset_right = 159.0 @@ -145,16 +170,12 @@ text = "Кассета П-1В" horizontal_alignment = 1 vertical_alignment = 1 -[node name="um1535_A7" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A7" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 242.0 offset_right = 652.0 offset_bottom = 337.0 -value0 = 91.0 -value1 = 22.0 -max_value0 = 100.0 -max_value1 = 100.0 step0 = 1.0 step1 = 1.0 value_name0 = "°C" @@ -164,18 +185,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A7" -[node name="um1535_A8" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A8" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 337.0 offset_right = 652.0 offset_bottom = 432.0 -value0 = 91.0 -value1 = 22.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -183,18 +198,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A8" -[node name="um1535_A9" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A9" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 432.0 offset_right = 652.0 offset_bottom = 527.0 -value0 = 91.0 -value1 = 22.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -202,18 +211,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A9" -[node name="um1535_A10" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A10" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 527.0 offset_right = 652.0 offset_bottom = 622.0 -value0 = 91.0 -value1 = 22.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -221,18 +224,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A10" -[node name="um1535_A11" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A11" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 622.0 offset_right = 652.0 offset_bottom = 717.0 -value0 = 91.0 -value1 = 22.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -240,18 +237,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A11" -[node name="um1535_A12" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A12" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 485.0 offset_top = 717.0 offset_right = 652.0 offset_bottom = 812.0 -value0 = 91.0 -value1 = 22.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -259,18 +250,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A12" -[node name="um1535_A13" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A13" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 242.0 offset_right = 175.0 offset_bottom = 337.0 -value0 = 91.0 -value1 = 33.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -278,18 +263,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A13" -[node name="um1535_A14" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A14" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 337.0 offset_right = 175.0 offset_bottom = 432.0 -value0 = 91.0 -value1 = 33.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -297,18 +276,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A14" -[node name="um1535_A15" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A15" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 432.0 offset_right = 175.0 offset_bottom = 527.0 -value0 = 91.0 -value1 = 33.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -316,18 +289,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A15" -[node name="um1535_A16" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A16" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 527.0 offset_right = 175.0 offset_bottom = 622.0 -value0 = 91.0 -value1 = 33.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -335,18 +302,12 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A16" -[node name="um1535_A17" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A17" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 622.0 offset_right = 175.0 offset_bottom = 717.0 -value0 = 91.0 -value1 = 33.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) @@ -354,21 +315,87 @@ name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A17" -[node name="um1535_A18" parent="." instance=ExtResource("7_e22c6")] +[node name="um1535_A18" parent="." groups=["power_amplifier"] instance=ExtResource("7_e22c6")] layout_mode = 0 offset_left = 8.0 offset_top = 717.0 offset_right = 175.0 offset_bottom = 812.0 -value0 = 91.0 -value1 = 33.0 -max_value0 = 100.0 -max_value1 = 100.0 -step0 = 1.0 -step1 = 1.0 value_name0 = "°C" value_name1 = "P, %" name_min_size0 = Vector2i(35, 20) name_min_size1 = Vector2i(35, 20) fname = "УМ1535А" rname = "A18" + +[node name="Monitoring_panel" type="Panel" parent="."] +layout_mode = 0 +theme_override_styles/panel = SubResource("StyleBoxTexture_vxfkm") + +[node name="in_fs_1" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(454, 577) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="in_fs_1" type="Label" parent="Monitoring_panel/in_fs_1"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "In FS 1" +horizontal_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="in_fs_2" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(207, 577) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="in_fs_2" type="Label" parent="Monitoring_panel/in_fs_2"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "In FS 2" +horizontal_alignment = 1 + +[node name="out_ems_1" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(454, 465) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="Out_ems_1" type="Label" parent="Monitoring_panel/out_ems_1"] +anchors_preset = -1 +anchor_left = 0.0185185 +anchor_right = 0.0185185 +anchor_bottom = 0.555556 +offset_left = -18.5 +offset_top = 14.0 +offset_right = 17.5 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "Out +ems 1" +horizontal_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="out_ems_2" type="AnimatedSprite2D" parent="Monitoring_panel"] +position = Vector2(207, 465) +scale = Vector2(1.2, 1.2) +sprite_frames = SubResource("SpriteFrames_s5gcy") + +[node name="Out_ems_1" type="Label" parent="Monitoring_panel/out_ems_2"] +offset_left = -15.1667 +offset_top = 14.0 +offset_right = 14.8333 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(0.890196, 0.486275, 0.196078, 1) +theme_override_font_sizes/font_size = 10 +text = "Out +ems 2" +horizontal_alignment = 1 diff --git a/scenes/pribor-prd-v/pribor_prd_v.gd b/scenes/pribor-prd-v/pribor_prd_v.gd index 5fcc0fd..7a94735 100644 --- a/scenes/pribor-prd-v/pribor_prd_v.gd +++ b/scenes/pribor-prd-v/pribor_prd_v.gd @@ -1,11 +1,28 @@ +@tool extends "res://scenes/контроль/прибор.gd" +const IN_BLANK_PRD: int = 1 +const OUT_BLANK_PRD: int = 13 +const CI_4_OT_FS: int = 11 +const CI_5_OT_FS: int = 12 +const CI_4_B_UF: int = 1 +const CI_5_B_UF: int = 2 +const POWER_UKP_1: int = 31 +const POWER_UKP_2: int = 63 +const bit_dkm_3: int = 3 +const bit_dkm_4: int = 4 + +var count_packet_1:int = 0 +var power_array_1: Array = [] +var count_packet_2:int = 0 +var power_array_2: Array = [] + enum STATE_VAL { NONE = 0, GOOD = 1, ERROR = 2 } -# Called when the node enters the scene tree for the first time. + func _ready() -> void: var unit_key = settings.get_unit_key(get_meta('unit_name')[0]) var unit_prd = network.units[unit_key] @@ -14,31 +31,104 @@ func _ready() -> void: set_default_state() -func set_default_state(): - $um1535_A7.state = STATE_VAL.NONE - $um1535_A8.state = STATE_VAL.NONE - $um1535_A9.state = STATE_VAL.NONE - $um1535_A10.state = STATE_VAL.NONE - $um1535_A11.state = STATE_VAL.NONE - $um1535_A12.state = STATE_VAL.NONE - $um1535_A13.state = STATE_VAL.NONE - $um1535_A14.state = STATE_VAL.NONE - $um1535_A15.state = STATE_VAL.NONE - $um1535_A16.state = STATE_VAL.NONE - $um1535_A17.state = STATE_VAL.NONE - $um1535_A18.state = STATE_VAL.NONE +func set_default_state() -> void: + for group in get_tree().get_nodes_in_group('power_amplifier'): + group.state = STATE_VAL.NONE -func on_line_changed(unit_prd): +func on_line_changed(unit_prd: Object) -> void: if not unit_prd.online: set_default_state() -func on_data_received(unit_prd): - var ukp1_online = (unit_prd.status[0] >> 2) & 1 - var ukp2_online = (unit_prd.status[0] >> 3) & 1 - var ug_online = (unit_prd.status[0] >> 1) & 1 +func on_data_received(unit_prd: Object) -> void: + if not is_inside_tree(): + return + + check_block_ip(unit_prd.status) + check_temperature_um(unit_prd.status) + + ## Контроль ЭМС + var in_blank: int = unit_prd.status.decode_u16(IN_BLANK_PRD) + var out_blank: int = unit_prd.status.decode_u16(OUT_BLANK_PRD) + + $Monitoring_panel/in_fs_1.frame = (in_blank >> CI_4_OT_FS) & 1 + $Monitoring_panel/in_fs_2.frame = (in_blank >> CI_5_OT_FS) & 1 + + $Monitoring_panel/out_ems_1.frame = (out_blank >> CI_4_B_UF) & 1 + $Monitoring_panel/out_ems_2.frame = (out_blank >> CI_5_B_UF) & 1 + + ## Мощность УМ от УКП 1 + if (in_blank >> CI_4_OT_FS) & 1: + check_dkm(unit_prd.status, bit_dkm_3) + + ## Мощность УМ от УКП 2 + if (in_blank >> CI_5_OT_FS) & 1: + check_dkm(unit_prd.status, bit_dkm_4) + + +## Проверка касет П1 и ИП МА2000 +func check_block_ip(status_prd: PackedByteArray) -> void : + var ug_online: bool = (status_prd[0] >> 1) & 1 if ug_online: - pass + const BYTE_DRY_CONTACT: int = 27 + const BIT_MAA2000_1: int = 0 + const BIT_MAA2000_2: int = 1 + const BIT_IP9_50_1: int = 2 + const BIT_IP9_50_2: int = 3 + const BIT_IP12_50_1: int = 4 + + var maa2000_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_MAA2000_1 & 1 + var maa2000_2 = status_prd[BYTE_DRY_CONTACT] >> BIT_MAA2000_2 & 1 + var ip9_50_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP9_50_1 & 1 + var ip9_50_2 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP9_50_2 & 1 + var ip12_50_1 = status_prd[BYTE_DRY_CONTACT] >> BIT_IP12_50_1 & 1 + + $maa2000_A23.state = STATE_VAL.ERROR if maa2000_1 else STATE_VAL.GOOD + $maa2000_A22.state = STATE_VAL.ERROR if maa2000_2 else STATE_VAL.GOOD + $kasseta_P_1/ref_A19.state = STATE_VAL.ERROR if ip9_50_1 else STATE_VAL.GOOD + $kasseta_P_1/ref_A20.state = STATE_VAL.ERROR if ip9_50_2 else STATE_VAL.GOOD + $kasseta_P_1/ref_A21.state = STATE_VAL.ERROR if ip12_50_1 else STATE_VAL.GOOD else: - pass + $maa2000_A23.state = STATE_VAL.NONE + $maa2000_A22.state = STATE_VAL.NONE + $kasseta_P_1/ref_A19.state = STATE_VAL.NONE + $kasseta_P_1/ref_A20.state = STATE_VAL.NONE + $kasseta_P_1/ref_A21.state = STATE_VAL.NONE + + +## Проверка температур УМ от УКП +func check_temperature_um(status_prd: PackedByteArray) -> void: + const CONST_MIN_TEMP: int = -25 + const MAXIMUM_CODE_ADC: int = 3796 + const MINIMUM_CODE_AD: int = 2660 + const TEMP: float = 115.0 / (MAXIMUM_CODE_ADC - MINIMUM_CODE_AD) + const TEMPERATURE_UKP_1: int = 47 + const TEMPERATURE_UKP_2: int = 79 + var power_amplifier: Array = get_tree().get_nodes_in_group('power_amplifier') + + var ukp1_online: int = (status_prd[0] >> 2) & 1 + if ukp1_online: + for i_temp in range(6): + var temperature_ukp_1: int = status_prd.decode_u16(TEMPERATURE_UKP_1 + 2 * i_temp) + var tmp_1: int = round(CONST_MIN_TEMP + (MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3) + power_amplifier[i_temp].value0 = tmp_1 + + var ukp2_online = (status_prd[0] >> 3) & 1 + if ukp2_online: + for i_temp in range(6): + var temperature_ukp_2: int = status_prd.decode_u16(TEMPERATURE_UKP_2 + 2 * i_temp) + var tmp_2: int = round(CONST_MIN_TEMP + (MAXIMUM_CODE_ADC - temperature_ukp_2) * TEMP + 3) + power_amplifier[i_temp+6].value0 = tmp_2 + + +## Проверка ДКМ +func check_dkm(status_prd: PackedByteArray, bit_dkm: int) -> void: + const DKM: int = 28 + var status_dkm = status_prd[DKM] >> bit_dkm & 1 + if bit_dkm == bit_dkm_3: + $dou4_A5.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + $kasseta_FS_VD/ref_A6.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + elif bit_dkm == bit_dkm_4: + $dou5_A6.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR + $kasseta_FS_VD/ref_A2.state = STATE_VAL.GOOD if status_dkm else STATE_VAL.ERROR diff --git a/scenes/pribor-uyep/sch3-view.gd b/scenes/pribor-uyep/sch3-view.gd index 3346f3a..9fe5654 100644 --- a/scenes/pribor-uyep/sch3-view.gd +++ b/scenes/pribor-uyep/sch3-view.gd @@ -17,7 +17,7 @@ extends 'res://scenes/контроль/элемент-я.gd' var regs_input: = {} ## Регистры входные var regs_holding: = {} ## Регистры хранения var switches_sync: = false ## Флаг. Если установлен, то можно переключать - +var external_ctl: = false ## Флаг внешнего управления func on_error(msg, unit_sch3): if unit_sch3.online: @@ -42,7 +42,7 @@ func on_line_changed_sch3(unit_sch3): func on_settings_changed(): - var external_ctl = ProjectSettings.get_setting('application/config/Внешнее управление', false) + external_ctl = ProjectSettings.get_setting('application/config/Внешнее управление', false) if not external_ctl: return var items = get_tree().get_nodes_in_group('bits_items_switch') @@ -100,6 +100,7 @@ func _exit_tree() -> void: var unit_sch3 = network.units[unit_key] unit_sch3.disconnect('read', on_read.bind(unit_sch3)) unit_sch3.disconnect('read_input', on_input.bind(unit_sch3)) + external_ctl = ProjectSettings.get_setting('application/config/Внешнее управление', false) unit_sch3.disconnect('error', on_error) unit_sch3.disconnect('line_changed', on_line_changed_sch3) @@ -114,6 +115,10 @@ func on_read(base_addr: int, data: Array, unit_sch3): regs_holding[base_addr + i] = data[i] # Разрешить работу выключателей только когда прочитано их реальное состояние if not switches_sync: + if not external_ctl: + if regs_holding.has(0) and regs_holding.has(2): + regs_holding[0] = regs_holding[0] | 1 + regs_holding[2] = regs_holding[2] & 0xffe switches_sync = true for item in get_tree().get_nodes_in_group('bits_items_switch'): var bits = item.get_meta('bits') diff --git a/scenes/tilemap/dot.png b/scenes/tilemap/dot.png new file mode 100644 index 0000000..2ad2af7 Binary files /dev/null and b/scenes/tilemap/dot.png differ diff --git a/scenes/tilemap/dot.png.import b/scenes/tilemap/dot.png.import new file mode 100644 index 0000000..fcf1bed --- /dev/null +++ b/scenes/tilemap/dot.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cgqo5gucd2be0" +path="res://.godot/imported/dot.png-e35f44878005aaa12b3432f2608ddde5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/tilemap/dot.png" +dest_files=["res://.godot/imported/dot.png-e35f44878005aaa12b3432f2608ddde5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/tilemap/mark.gd b/scenes/tilemap/mark.gd new file mode 100644 index 0000000..210759d --- /dev/null +++ b/scenes/tilemap/mark.gd @@ -0,0 +1,4 @@ +extends Control + +func set_text(t: String): + $Label.text = t diff --git a/scenes/tilemap/mark.gd.uid b/scenes/tilemap/mark.gd.uid new file mode 100644 index 0000000..9d2b2bd --- /dev/null +++ b/scenes/tilemap/mark.gd.uid @@ -0,0 +1 @@ +uid://u811i0l1cvsd diff --git a/scenes/tilemap/mark.tscn b/scenes/tilemap/mark.tscn new file mode 100644 index 0000000..3eb0386 --- /dev/null +++ b/scenes/tilemap/mark.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=2 format=3 uid="uid://ce5mtxqd1ndru"] + +[ext_resource type="Texture2D" uid="uid://cgqo5gucd2be0" path="res://scenes/tilemap/dot.png" id="2_rq0y0"] + +[node name="rect" type="TextureRect"] +anchors_preset = -1 +offset_left = -16.0 +offset_top = -16.0 +offset_right = 16.0 +offset_bottom = 16.0 +pivot_offset = Vector2(16, 16) +texture = ExtResource("2_rq0y0") +expand_mode = 1 diff --git a/scenes/tilemap/tilemap.gd b/scenes/tilemap/tilemap.gd index 5884b2f..4e4ec18 100644 --- a/scenes/tilemap/tilemap.gd +++ b/scenes/tilemap/tilemap.gd @@ -13,7 +13,7 @@ class_name MercatorTileMap _clean_all() queue_redraw() -@export var zoom_step: float = 0.025 +@export var zoom_step: float = 0.1 @export var tile_width: float = 256.0 @export var tile_height: float = 256.0 @export_range(1, 1000, 1) var max_concurrent_requests:int = 5 @@ -24,8 +24,8 @@ class_name MercatorTileMap @export_color_no_alpha() var back_color: = Color.BLACK const default_size: = 400.0 var is_centered: = false -var is_anim_playng: = false - +var is_out_border1: = true +var is_out_border2: = true @export var animation_time: float = 0.1: set(val): @@ -65,7 +65,7 @@ var is_anim_playng: = false return _xyz.z -var _xyz: Vector3 = Vector3(0, 0, min_zoom_level) +var _xyz: Vector3 = Vector3(0, 0, 0) var _cache: Dictionary = {} var _queue: Dictionary = {} var _dragging: bool = false @@ -78,9 +78,9 @@ var image: = Image.new() var image_load_proc: Callable var now: = 0 var visible_marks_count: = 0 -var mouse_wheel_count: = 0 var map_server_available: = false - +var border1: ImageTexture +var border2: ImageTexture ## Вызывается после того, как загрузка плиток завершена signal load_completed() @@ -112,6 +112,15 @@ func get_marks_count(): return _marks.size() func _ready() -> void: + var img: = Image.create(1, 2, false, Image.FORMAT_RGBA8) + img.set_pixel(0, 0, Color.CORAL) + img.set_pixel(0, 1, Color(1, 1, 1, 0)) + border1 = ImageTexture.create_from_image(img) + img.set_pixel(0, 0, Color(1, 1, 1, 0)) + img.set_pixel(0, 1, Color.CORAL) + border2 = ImageTexture.create_from_image(img) + + _xyz.z = min_zoom_level image_type = 'png' $canvas.connect('mouse_entered', func(): _rollover = true) $canvas.connect('mouse_exited', func(): _rollover = false) @@ -142,16 +151,12 @@ func _on_resize() -> void: ## Создаёт новую отметку из координат экрана -func add_mark_from_screen_pos(id: int, x: float, y: float, mark: Node) -> bool: +func add_mark_from_screen_pos(id: int, scr_xy: Vector2, mark: Node) -> bool: if _marks.has(id): return false - var wrld_pos = screen_to_world(_xyz, x, y) - var p = world_to_tile(wrld_pos.x, wrld_pos.y, _xyz.z) - var tile_index = xyz_to_idx(p.x, p.y, _xyz.z) - var dot = { 'position': wrld_pos, 'tile_index': tile_index, 'mark': mark } - _marks[id] = dot + var wrld_pos = screen_to_world(_xyz, scr_xy) + _marks[id] = { 'position': wrld_pos, 'mark': mark, 'gap_size': 0.0 } add_child(mark) - fix_mark_position(dot) return true @@ -169,9 +174,7 @@ func add_mark_from_lon_lat(id: int, lon: float, lat: float, mark: Node, gap_size if _marks.has(id): return false var wrld_pos = lonlat_to_world(lon, lat) - var scr_pos = world_to_screen(wrld_pos.x, wrld_pos.y) - mark.set_global_position(scr_pos) - _marks[id] = {'position': wrld_pos, 'mark': mark, 'gap_size': gap_size } + _marks[id] = {'position': wrld_pos, 'mark': mark, 'gap_size': gap_size} add_child(mark) queue_redraw() return true @@ -189,106 +192,109 @@ func fix_mark_position(dot) -> void: func is_mark_visible(dot) -> bool: - var screen_pos = world_to_screen(dot.position.x, dot.position.y) + var screen_pos = world_to_screen(dot.position) return screen_pos.x > 0 and screen_pos.x < $canvas.size.x func _input(e) -> void: var lmp = get_local_mouse_position() if not _rollover: + _dragging = false return if e is InputEventMouseButton: if e.pressed: if e.button_index == MOUSE_BUTTON_WHEEL_DOWN: - mouse_wheel_count -= 1 - queue_redraw() + if (not is_out_border1) and (not is_out_border2): + increment_zoom(-zoom_step, lmp) + queue_redraw() elif e.button_index == MOUSE_BUTTON_WHEEL_UP: - mouse_wheel_count += 1 + increment_zoom( zoom_step, lmp) queue_redraw() - if e.button_index == MOUSE_BUTTON_LEFT: _dragging = e.pressed - _drag_pos = screen_to_world(_xyz, lmp.x, lmp.y) - + _drag_pos = screen_to_world(_xyz, lmp) elif e is InputEventMouseMotion: if _dragging: - var wp = screen_to_world(_xyz, lmp.x, lmp.y) + var wp = screen_to_world(_xyz, lmp) var diff = _drag_pos - wp _xyz.x += diff.x - _xyz.y += diff.y + + if (not is_out_border1) and diff.y >= 0: + _xyz.y += diff.y + if is_out_border1 and diff.y <= 0: + _xyz.y += diff.y + + if is_out_border2 and diff.y >= 0: + _xyz.y += diff.y + if (not is_out_border2) and diff.y <= 0: + _xyz.y += diff.y + queue_redraw() if diff.length() > 0: signaller.emmit(signaller.map_user_panning) -## Возвращает true, если видна область за краем карты -func is_border_visible(): - var z = min(max_zoom_level, _xyz.z) - return screen_to_tile(0, 0, z).y != 0 - - func multiply_zoom(multiplier: float, pivot: Vector2) -> void: - var p1: = screen_to_world(_xyz, pivot.x, pivot.y) + var p1: = screen_to_world(_xyz, pivot) _xyz.z = clampf(_xyz.z * multiplier, min_zoom_level, max_zoom_level) - var p2: = screen_to_world(_xyz, pivot.x, pivot.y) + var p2: = screen_to_world(_xyz, pivot) _xyz.x -= p2.x - p1.x _xyz.y -= p2.y - p1.y -func set_zoom(zoom: float, pivot=null) -> void: - if pivot == null: - pivot = $canvas.size / 2.0 +func increment_zoom(increment: float, pivot: Vector2) -> void: + var p1: = screen_to_world(_xyz, pivot) + _xyz.z = clampf(_xyz.z + increment, min_zoom_level, max_zoom_level) + var p2: = screen_to_world(_xyz, pivot) + _xyz.x -= p2.x - p1.x + _xyz.y -= p2.y - p1.y - var p1: = screen_to_world(_xyz, pivot.x, pivot.y) + +func set_zoom(zoom: float, pivot: Vector2) -> void: + var p1: = screen_to_world(_xyz, pivot) _xyz.z = clampf(zoom, max_zoom_level, min_zoom_level) - var p2: = screen_to_world(_xyz, pivot.x, pivot.y) + var p2: = screen_to_world(_xyz, pivot) _xyz.x -= p2.x - p1.x _xyz.y -= p2.y - p1.y func _draw() -> void: - - var lmp = get_local_mouse_position() - if mouse_wheel_count > 0: - multiply_zoom(1.0 + zoom_step, lmp) - mouse_wheel_count -= 1 - elif mouse_wheel_count < 0: - multiply_zoom(1.0 - zoom_step, lmp) - mouse_wheel_count += 1 - + # Рисование плиток var z = min(max_zoom_level, _xyz.z) - var t1 = screen_to_tile(0, 0, z) - var t2 = screen_to_tile($canvas.size.x, $canvas.size.y, z) - for tx in range(t1.x, t2.x + 1): - for ty in range(t1.y, t2.y + 1): + var t1 = screen_to_tile(Vector2(0, 0), z) + var t2 = screen_to_tile($canvas.size, z) + Vector2(1, 1) + is_out_border1 = true + is_out_border2 = true + for tx in range(t1.x, t2.x): + for ty in range(t1.y, t2.y): _draw_tile(tx, ty, z) - + # Рисование отметок var n = pow(2, z) var dx = n * tile_width - var c = $canvas.size / 2.0 - var r = min($canvas.size.x, $canvas.size.y) / 2.0 + var c: Vector2 = $canvas.size / 2.0 + var r = c.length() visible_marks_count = 0 for dot in _marks.values(): - var pos = world_to_screen(dot.position.x, dot.position.y) - if pos.x >= 0: - pos.x = fmod(pos.x, dx) - else: - pos.x = -pos.x - 1 - pos.x = int(dx - 1) - fmod(pos.x, dx) - dot.mark.position = pos - dot.mark.visible = c.distance_to(pos) < (r - dot.gap_size) + var scr_pos = world_to_screen(dot.position) + scr_pos.x = posmod(scr_pos.x, dx) + dot.mark.position = scr_pos + dot.mark.visible = c.distance_to(scr_pos) < (r - dot.gap_size) visible_marks_count += int(dot.mark.visible) + # Рисование границ + var p1 = $canvas.position + var p2 = $canvas.size / Vector2(1, 20) + if is_out_border1 and _dragging: + draw_texture_rect(border1, Rect2(p1, p2), false, Color.WHITE, false) + p1.y = p1.y + $canvas.size.y - p2.y + if is_out_border2 and _dragging: + draw_texture_rect(border2, Rect2(p1, p2), false, Color.WHITE, false) func _clean_all() -> void: _queue.clear() _cache.clear() - _marks.clear() _req_count = 0 - for c in get_children().filter(func (item): return not item.is_in_group('gui_items')): - remove_child(c) - c.queue_free() # get the tile from queue with the newest timestamp @@ -301,7 +307,6 @@ func get_next_in_queue() -> Tile: return tile -# delete oldest tiles from cache func _clean_cache() -> void: var overflow = _cache.size() - max_cached_tiles if overflow <= 0: @@ -316,7 +321,7 @@ func _clean_cache() -> void: func _process(delta) -> void: now += delta - # if cache is overflowing - clean it + # Если кэш переполнен - очистить его. if not _last_cache_check or now - _last_cache_check > 5: _last_cache_check = now _clean_cache() @@ -371,11 +376,9 @@ func _response(result, code, _headers: Array, body: PackedByteArray, req, tile: push_error('не удалось получить изображение (неверный формат?) из \"%s\"' % tile.url) return - # create texture from image and add it to the cache tile.texture = ImageTexture.create_from_image(image) _cache[tile.i] = tile - # redraw the map queue_redraw() @@ -401,28 +404,37 @@ func _draw_subtile(tx: int, ty: int, tz: int, origx: int, origy: int, origz: flo var rect = Rect2(xrat1 * tile_width, yrat1 * tile_height, xwidth * tile_width, yheight * tile_height) if subtile.texture: + check_borders(p1, p2, $canvas.size.y) draw_texture_rect_region(subtile.texture, Rect2(p1, p2 - p1), rect) return true return false +func check_borders(p1, p2, h): + if p1.y < 0: + is_out_border1 = false + if p1.y + (p2 - p1).y > h: + is_out_border2 = false + + func _draw_tile(tx: int, ty: int, z: float) -> void: - var tz = floor(z) - var p1 = tile_to_screen(tx, ty, z) - var p2 = tile_to_screen(tx + 1, ty + 1, z) - var tile = get_tile(tx, ty, tz) + var tz: float = floor(z) + var p1: = tile_to_screen(tx, ty, z) + var p2: = tile_to_screen(tx + 1, ty + 1, z) + var tile: = get_tile(tx, ty, tz) if tile: if tile.texture: + check_borders(p1, p2, $canvas.size.y) draw_texture_rect(tile.texture, Rect2(p1, p2 - p1), false, Color.WHITE, false) else: - var zzz = tz - var txx = tx - var tyy = ty + var zzz: float = tz + var txx: = tx + var tyy: = ty while zzz > 1: zzz -= 1 txx = floor(txx / 2.0) tyy = floor(tyy / 2.0) - if _draw_subtile(txx, tyy, zzz, tx, ty,z): + if _draw_subtile(txx, tyy, zzz, tx, ty, z): break @@ -437,7 +449,7 @@ func lonlat_to_world(lon: float, lat: float) -> Vector2: ## convert lon/lat to screen coords func lonlat_to_screen(lon: float, lat: float) -> Vector2: var w = lonlat_to_world(lon, lat) - return world_to_screen(w.x, w.y) + return world_to_screen(w) ## convert lon/lat to tile coords @@ -454,8 +466,8 @@ func world_to_lonlat(wx: float, wy: float) -> Vector2: ## convert screen coords to lon/lat -func screen_to_lonlat(sx: float, sy: float) -> Vector2: - var w = screen_to_world(_xyz, sx, sy) +func screen_to_lonlat(scr_xy: Vector2) -> Vector2: + var w = screen_to_world(_xyz, scr_xy) return world_to_lonlat(w.x, w.y) @@ -466,12 +478,12 @@ func tile_to_lonlat(tx: float, ty: float, tz: float) -> Vector2: ## convert screen coords to world coords -func screen_to_world(xyz: Vector3, sx: float, sy: float) -> Vector2: +func screen_to_world(xyz: Vector3, s: Vector2) -> Vector2: var n = pow(2.0, xyz.z) var span_w = n * tile_width var span_h = n * tile_height - var px = sx - $canvas.size.x / 2 + span_w / 2 - var py = sy - $canvas.size.y / 2 + span_h / 2 + var px = s.x - $canvas.size.x / 2 + span_w / 2 + var py = s.y - $canvas.size.y / 2 + span_h / 2 var xr = px / span_w var yr = py / span_h var x = (xr * 2.0 - 1.0) + xyz.x @@ -480,15 +492,15 @@ func screen_to_world(xyz: Vector3, sx: float, sy: float) -> Vector2: ## convert screen coords to tile coords -func screen_to_tile(sx: float, sy: float, z: float) -> Vector2: - var world = screen_to_world(_xyz, sx, sy) +func screen_to_tile(scr_xy: Vector2, z: float) -> Vector2: + var world = screen_to_world(_xyz, scr_xy) return world_to_tile(world.x, world.y, z) ## convert tile coords to screen coords func tile_to_screen(tx: float, ty: float, tz: float) -> Vector2: var w = tile_to_world(tx, ty, tz) - return world_to_screen(w.x, w.y) + return world_to_screen(w) ## convert tile coords to world coords @@ -501,34 +513,28 @@ func tile_to_world(tx: float, ty: float, tz: float) -> Vector2: ## convert world coords to tile coords func world_to_tile(wx: float, wy: float, z: float) -> Vector2: - var n: = pow(2.0, floor(z)) - var tx: = ((wx + 1.0) / 2.0) * n - var ty: = ((-wy + 1.0) / 2.0) * n - tx = floor(tx) - ty = floor(ty) + var n: float = pow(2.0, floor(z)) + var tx: float = floor(((wx + 1.0) / 2.0) * n) + var ty: float = floor(((-wy + 1.0) / 2.0) * n) return Vector2(tx, ty) ## convert world coords to screen coords -func world_to_screen(wx: float, wy: float) -> Vector2: +func world_to_screen(pos: Vector2) -> Vector2: var n: = pow(2.0, _xyz.z) - var w: = n * tile_width - var h: = n * tile_height - var xr: = ((wx - _xyz.x) + 1.0) / 2.0 - var yr: = (-(wy - _xyz.y) + 1.0) / 2.0 - var x = w * xr - w / 2.0 + $canvas.size.x / 2.0 - var y = h * yr - h / 2.0 + $canvas.size.y / 2.0 - return Vector2(x, y) + var wh: = Vector2(n * tile_width, n * tile_height) + var rxy: = Vector2(((pos.x - _xyz.x) + 1.0) / 2.0, (-(pos.y - _xyz.y) + 1.0) / 2.0) + return wh * rxy + ($canvas.size - wh) / 2.0 ## get the tile index from xyz tile coords func xyz_to_idx(x: float, y: float, z: float) -> int: var i: = (pow(4.0, z) - 1.0) / 3.0 - var n: = pow(2.0, z) + var n: = pow(2.0, z) return int(i + (y * n + x)) -func get_tile(x: int, y: int, z: int, create: bool = true) -> Tile: +func get_tile(x: int, y: int, z: int) -> Tile: var n = pow(2, z) if x >= 0: @@ -560,13 +566,11 @@ func get_tile(x: int, y: int, z: int, create: bool = true) -> Tile: return tile var queue_size: = _queue.size() - if create and (not $canvas/player.is_playing()): - if not tile: - tile = Tile.new(idx, x, y, z) - tile.url = base_url.replace('{x}', str(x)).replace('{y}', str(y)).replace('{z}', str(z)) - tile.t = now - if z <= max_zoom_level_server: - _queue[idx] = tile + tile = Tile.new(idx, x, y, z) + tile.url = base_url.replace('{x}', str(x)).replace('{y}', str(y)).replace('{z}', str(z)) + tile.t = now + if z <= max_zoom_level_server: + _queue[idx] = tile if queue_size == 0 and _queue.size(): emit_signal('load_started') @@ -616,7 +620,7 @@ func haversine_m(lat1: float, lon1: float, lat2: float, lon2: float) -> float: var rlon1: = deg_to_rad(lon1) var rlat2: = deg_to_rad(lat2) var rlon2: = deg_to_rad(lon2) - # вычисления длины большого круга + # вычисление длины большого круга var cl1: = cos(rlat1) var cl2: = cos(rlat2) var sl1: = sin(rlat1) @@ -645,7 +649,7 @@ func find_at_screen_position(screen_pos: Vector2) -> Node: var closest_dot = null var closest_distance = INF for mark in _marks.values(): - var dot_screen_pos = world_to_screen(mark.position.x, mark.position.y) + var dot_screen_pos = world_to_screen(mark.position) var distance = dot_screen_pos.distance_to(screen_pos) if distance < closest_distance: closest_distance = distance diff --git a/scenes/tilemap/tilemap.tscn b/scenes/tilemap/tilemap.tscn index aa619a9..40e8eb5 100644 --- a/scenes/tilemap/tilemap.tscn +++ b/scenes/tilemap/tilemap.tscn @@ -28,10 +28,8 @@ size = Vector2(400, 400) [node name="tilemap" type="CanvasGroup" groups=["gui_items"]] script = ExtResource("1_l64tp") -base_url = "http://192.168.11.105:8001/osm_tiles/{z}/{x}/{y}.png" -max_zoom_level = 15 -max_zoom_level_server = 10 -az = 2.0 +border_scene = "uid://bumg0moa26skt" +zoom_step = 0.1 [node name="canvas" type="TextureRect" parent="." groups=["gui_items"]] clip_contents = true diff --git a/scenes/контроль/блок-а.tscn b/scenes/контроль/блок-а.tscn index 896525f..37af25a 100644 --- a/scenes/контроль/блок-а.tscn +++ b/scenes/контроль/блок-а.tscn @@ -219,7 +219,7 @@ vertical_alignment = 1 layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 6 -theme_override_font_sizes/font_size = 22 +theme_override_font_sizes/font_size = 18 horizontal_alignment = 2 vertical_alignment = 1 @@ -231,10 +231,12 @@ size_flags_vertical = 6 layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +max_value = 100.0 [node name="indicator1" parent="margin/vbox/grid1" instance=ExtResource("5_3i5am")] layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +max_value = 3000.0 [connection signal="pressed" from="button" to="." method="_on_button_pressed"] diff --git a/scenes/контроль/кассета-п-2.tscn b/scenes/контроль/кассета-п-2.tscn index bfa0835..077b080 100644 --- a/scenes/контроль/кассета-п-2.tscn +++ b/scenes/контроль/кассета-п-2.tscn @@ -19,16 +19,16 @@ offset_left = 10.0 offset_top = 30.0 offset_right = 60.0 offset_bottom = 180.0 -fname = "ИП12-50" -rname = "A25" +fname = "ИП9-50" +rname = "A22" [node name="ref_A23" parent="." instance=ExtResource("3_4a27g")] offset_left = 60.0 offset_top = 30.0 offset_right = 110.0 offset_bottom = 180.0 -fname = "ИП9-50" -rname = "A22" +fname = "ИП12-50" +rname = "A25" [node name="lbl_fname" type="Label" parent="."] self_modulate = Color(1, 1, 1, 0.62) diff --git a/scenes/контроль/кассета-у-5-к.tscn b/scenes/контроль/кассета-у-5-к.tscn index 5f117cc..19d0607 100644 --- a/scenes/контроль/кассета-у-5-к.tscn +++ b/scenes/контроль/кассета-у-5-к.tscn @@ -21,11 +21,11 @@ offset_left = 5.0 offset_top = 7.0 offset_right = 305.0 offset_bottom = 35.0 -text = "Кассета" +text = "Кассета У5" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ref_A31" parent="." instance=ExtResource("3_wtlpi")] +[node name="ref_A24" parent="." instance=ExtResource("3_wtlpi")] offset_left = 5.0 offset_top = 32.0 offset_right = 55.0 @@ -33,7 +33,7 @@ offset_bottom = 182.0 fname = "ИП5-25" rname = "A31" -[node name="ref_A37" parent="." instance=ExtResource("3_wtlpi")] +[node name="ref_A30" parent="." instance=ExtResource("3_wtlpi")] offset_left = 55.0 offset_top = 32.0 offset_right = 105.0 @@ -41,7 +41,7 @@ offset_bottom = 182.0 fname = "ЯУ-07Б" rname = "A37" -[node name="ref_A33" parent="." instance=ExtResource("3_wtlpi")] +[node name="ref_A26" parent="." instance=ExtResource("3_wtlpi")] offset_left = 105.0 offset_top = 32.0 offset_right = 155.0 @@ -49,7 +49,7 @@ offset_bottom = 182.0 fname = "ЭМС-Г" rname = "A33" -[node name="ref_A34" parent="." instance=ExtResource("3_wtlpi")] +[node name="ref_A27" parent="." instance=ExtResource("3_wtlpi")] offset_left = 155.0 offset_top = 32.0 offset_right = 205.0 @@ -57,18 +57,18 @@ offset_bottom = 182.0 fname = "УГ" rname = "A34" -[node name="ref_A35" parent="." instance=ExtResource("3_wtlpi")] +[node name="ref_A28" parent="." instance=ExtResource("3_wtlpi")] offset_left = 205.0 offset_top = 32.0 offset_right = 255.0 offset_bottom = 182.0 fname = "УКП" -rname = "A36" +rname = "A35" -[node name="ref_A36" parent="." instance=ExtResource("3_wtlpi")] +[node name="ref_A29" parent="." instance=ExtResource("3_wtlpi")] offset_left = 254.0 offset_top = 32.0 offset_right = 304.0 offset_bottom = 182.0 fname = "УКП" -rname = "A35" +rname = "A36" diff --git a/scenes/контроль/кассета-у-5-нв.tscn b/scenes/контроль/кассета-у-5-нв.tscn index d1ed6ce..21c75f4 100644 --- a/scenes/контроль/кассета-у-5-нв.tscn +++ b/scenes/контроль/кассета-у-5-нв.tscn @@ -21,11 +21,11 @@ offset_left = 5.0 offset_top = 7.0 offset_right = 305.0 offset_bottom = 35.0 -text = "Кассета" +text = "Кассета У5" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ref_A31" parent="." instance=ExtResource("3_picsk")] +[node name="ref_A24" parent="." instance=ExtResource("3_picsk")] offset_left = 5.0 offset_top = 32.0 offset_right = 55.0 @@ -33,7 +33,7 @@ offset_bottom = 182.0 fname = "ИП5-25" rname = "A24" -[node name="ref_A37" parent="." instance=ExtResource("3_picsk")] +[node name="ref_A30" parent="." instance=ExtResource("3_picsk")] offset_left = 55.0 offset_top = 32.0 offset_right = 105.0 @@ -41,7 +41,7 @@ offset_bottom = 182.0 fname = "ЯУ-07Б" rname = "A30" -[node name="ref_A33" parent="." instance=ExtResource("3_picsk")] +[node name="ref_A26" parent="." instance=ExtResource("3_picsk")] offset_left = 105.0 offset_top = 32.0 offset_right = 155.0 @@ -49,7 +49,7 @@ offset_bottom = 182.0 fname = "ЭМС-Г" rname = "A26" -[node name="ref_A34" parent="." instance=ExtResource("3_picsk")] +[node name="ref_A27" parent="." instance=ExtResource("3_picsk")] offset_left = 155.0 offset_top = 32.0 offset_right = 205.0 @@ -57,18 +57,18 @@ offset_bottom = 182.0 fname = "УГ" rname = "A27" -[node name="ref_A35" parent="." instance=ExtResource("3_picsk")] +[node name="ref_A28" parent="." instance=ExtResource("3_picsk")] offset_left = 205.0 offset_top = 32.0 offset_right = 255.0 offset_bottom = 182.0 fname = "УКП" -rname = "A29" +rname = "A28" -[node name="ref_A36" parent="." instance=ExtResource("3_picsk")] +[node name="ref_A29" parent="." instance=ExtResource("3_picsk")] offset_left = 254.0 offset_top = 32.0 offset_right = 304.0 offset_bottom = 182.0 fname = "УКП" -rname = "A28" +rname = "A29" diff --git a/scenes/контроль/кассета-у-5.gd b/scenes/контроль/кассета-у-5.gd index bf45fa1..252cc41 100644 --- a/scenes/контроль/кассета-у-5.gd +++ b/scenes/контроль/кассета-у-5.gd @@ -1,3 +1,4 @@ +@tool extends "res://scenes/контроль/кассета.gd" enum STATE_VAL { @@ -15,12 +16,12 @@ func _ready() -> void: func set_default_state(): - $ref_A37.state = STATE_VAL.ERROR - $ref_A31.state = STATE_VAL.NONE - $ref_A33.state = STATE_VAL.NONE - $ref_A34.state = STATE_VAL.NONE - $ref_A35.state = STATE_VAL.NONE - $ref_A36.state = STATE_VAL.NONE + $ref_A30.state = STATE_VAL.ERROR # ЯУ-07Б + $ref_A24.state = STATE_VAL.NONE # ИП5-25 + $ref_A26.state = STATE_VAL.NONE # ЭМС-Г + $ref_A27.state = STATE_VAL.NONE # УГ + $ref_A28.state = STATE_VAL.NONE # УКП + $ref_A29.state = STATE_VAL.NONE # УКП func on_line_changed(unit_prd): @@ -29,16 +30,19 @@ func on_line_changed(unit_prd): func on_data_received(unit_prd): - $ref_A37.state = STATE_VAL.GOOD + $ref_A30.state = STATE_VAL.GOOD var ems_online = unit_prd.status[0] & 1 var bit_load = 4 var ems_load = (unit_prd.status[0] >> bit_load) & 1 var ug_online = (unit_prd.status[0] >> 1) & 1 - $ref_A33.state = STATE_VAL.GOOD if ems_online and ems_load else STATE_VAL.ERROR - $ref_A34.state = STATE_VAL.GOOD if ug_online else STATE_VAL.ERROR - $ref_A35.state = STATE_VAL.GOOD if (unit_prd.status[0] >> 2) & 1 else STATE_VAL.ERROR - $ref_A36.state = STATE_VAL.GOOD if (unit_prd.status[0] >> 3) & 1 else STATE_VAL.ERROR + $ref_A26.state = STATE_VAL.GOOD if ems_online and ems_load else STATE_VAL.ERROR + $ref_A27.state = STATE_VAL.GOOD if ug_online else STATE_VAL.ERROR + $ref_A28.state = STATE_VAL.GOOD if (unit_prd.status[0] >> 2) & 1 else STATE_VAL.ERROR + $ref_A29.state = STATE_VAL.GOOD if (unit_prd.status[0] >> 3) & 1 else STATE_VAL.ERROR if ug_online: - $ref_A31.state = STATE_VAL.GOOD if (unit_prd.status[27] >> 7) & 1 else STATE_VAL.ERROR + var byte_dry_contact: int = 27 + var bit_ip5_25: int = 7 + var ip5_25 = unit_prd.status[byte_dry_contact] >> bit_ip5_25 & 1 + $ref_A24.state = STATE_VAL.ERROR if ip5_25 else STATE_VAL.GOOD else: - $ref_A31.state = STATE_VAL.NONE + $ref_A24.state = STATE_VAL.NONE diff --git a/scenes/контроль/элемент-в.tscn b/scenes/контроль/элемент-в.tscn index 702b757..f0ab41b 100644 --- a/scenes/контроль/элемент-в.tscn +++ b/scenes/контроль/элемент-в.tscn @@ -89,7 +89,7 @@ layout_mode = 0 offset_top = 8.0 offset_right = 50.0 offset_bottom = 34.0 -theme_override_font_sizes/font_size = 22 +theme_override_font_sizes/font_size = 18 text = "A1" horizontal_alignment = 1 vertical_alignment = 1 @@ -97,9 +97,9 @@ vertical_alignment = 1 [node name="lbl_fname" type="Label" parent="."] self_modulate = Color(1, 1, 1, 0.627451) layout_mode = 0 -offset_top = 111.0 +offset_top = 119.0 offset_right = 84.0 -offset_bottom = 161.0 +offset_bottom = 169.0 rotation = -1.5708 theme_override_font_sizes/font_size = 17 text = "Ячейка" diff --git a/scenes/работа/работа.gd b/scenes/работа/работа.gd index 1c0d2ba..292b023 100644 --- a/scenes/работа/работа.gd +++ b/scenes/работа/работа.gd @@ -29,7 +29,7 @@ var shift_pressed: bool ## Кнопка SHIFT нажата. var strob_band_begin: float ## Ширина строба в момент начала перетаскивания. var strob_dir_begin: float ## Направление антенны в момент начала перетаскивания. var strob_width_begin: float ## Ширина строба по углу в момент начала перетаскивания. - +var view_mode: MapViewMode ## Режим отображения карты signal drag_begin ## Вызывается в момент начала перетаскивания. signal drag_continue ## Вызывается во время продолжения перетаскивания. @@ -59,6 +59,13 @@ enum BtnSel { } +## Режим отображения карты +enum MapViewMode { + RTO = 0, ## Режим приоритет РТО (малая карта, широкие секторы) + RLS = 1 ## Режим приоритет РЛС (большая карта, узкие секторы) + } + + const VAL_TO_EVENT = { false: 'manual_control', ## Выбор целей и установка помех вручную. true: 'full_auto' } ## Выбор целей и установка помех автоматически. @@ -86,6 +93,7 @@ func on_button_view_toggled(toggled: bool): var s = map_sizes[int(toggled)] $tilemap.size = s.size $tilemap.position = s.position + view_mode = MapViewMode.RLS if toggled else MapViewMode.RTO ## Встроенный обратный вызов. @@ -379,7 +387,7 @@ func _on_drag_begin(event) -> void: ## Обработчик событий ввода. Вызывается godot. func _input(event) -> void: if not is_visible_in_tree(): return - if event is InputEventMouseMotion: + if (event is InputEventMouseMotion) and (view_mode == MapViewMode.RTO): if drag_fsm == DragFSM.DRAG: emit_signal('drag_continue', event) elif event is InputEventMouseButton: diff --git a/scenes/работа/работа.tscn b/scenes/работа/работа.tscn index 9a75da6..442c2dc 100644 --- a/scenes/работа/работа.tscn +++ b/scenes/работа/работа.tscn @@ -84,6 +84,9 @@ metadata/_edit_lock_ = true [node name="tilemap" parent="." instance=ExtResource("10_gtwyg")] self_modulate = Color(1, 1, 1, 0.415686) position = Vector2(360, 360) +min_zoom_level = 3 +max_zoom_level_server = 11 +az = 3.0 [node name="player" type="AnimationPlayer" parent="tilemap"] libraries = { @@ -285,6 +288,6 @@ texture_pressed = ExtResource("13_ggrwd") [connection signal="drag_continue" from="." to="." method="_on_drag_continue"] [connection signal="toggled" from="btn_view" to="." method="on_button_view_toggled"] [connection signal="toggled" from="chk_auto" to="." method="on_value_changed"] -[connection signal="toggled" from="btn_activate" to="." method="on_btn_activate"] [connection signal="toggled" from="btn_activate" to="." method="on_btn_activate_toggled"] +[connection signal="toggled" from="btn_activate" to="." method="on_btn_activate"] [connection signal="toggled" from="btn_center" to="." method="on_btn_center_toggled"] diff --git a/scripts/prd.gd b/scripts/prd.gd index 51f58cc..733fee0 100644 --- a/scripts/prd.gd +++ b/scripts/prd.gd @@ -53,7 +53,7 @@ const PRD_NAMES: Array = [ 'уарэп-яу07-4в', 'уарэп-яу07-4к', ] -## Соответствие модулей ФС их нахождуению в приборе ПРД и номеру от КАПС РПБ +## Соответствие модулей ФС их нахождению в приборе ПРД и номеру от КАПС РПБ const FS_PRD: Dictionary = { 0: ['уарэп-яу07-1к', 17], 1: ['уарэп-яу07-4к', 65], @@ -79,10 +79,10 @@ const FS_PRD: Dictionary = { 21: ['уарэп-яу07-4к', 70], 22: ['уарэп-яу07-3к', 54], 23: ['уарэп-яу07-2к', 38], - 24: ['уарэп-яу07-1к', 31], - 25: ['уарэп-яу07-4к', 87], - 26: ['уарэп-яу07-3к', 63], - 27: ['уарэп-яу07-2к', 47], } + 24: ['уарэп-яу07-1к', 23], + 25: ['уарэп-яу07-4к', 71], + 26: ['уарэп-яу07-3к', 55], + 27: ['уарэп-яу07-2к', 39], } var fs_dict: Dictionary ## Словарь с модулями ФС var prd_dict: Dictionary ## Словарь с приборами ПРД @@ -318,19 +318,12 @@ func update_fs_state(ecms): get_fs_index(ecm, fs_ids) for fs_index in fs_ids: var fs = fs_dict[fs_index] - fs.set_modulation(ecm.modulation) fs.set_um_code(ecm.um) for prd_module in prd_dict.values(): ## Отправка команды на исполнение в ПРД if prd_module.state != PrdState.WORK: continue if not prd_module.unit_yau07.online: continue var um_data_array: Array = [] for fs in prd_module.fs_dic.values(): - var dev_mode = prd_module.yemsg_board.get_dev_mode(fs.index) - var fs_state = 2 - if fs.modulation: - fs_state = 3 - if (dev_mode != fs_state) or (fs_state == 3): - fs.emit_signal('update_modulation') if not prd_module.ug_online: continue if prd_module.set_ug_state: fs.set_um_data(um_data_array, prd_module.unit_yau07) @@ -350,10 +343,10 @@ func check_dir(): ## Производит приём состояния модулей ФС. -func on_data_capsrpb_received(unit: capsrpb.CapsRpb): - if not unit.json_dic.has('ts'): return - if unit.json_dic['ts'] != 7: return - if not unit.json_dic.has('msfs'): return +func on_data_capsrpb_received(unit0: capsrpb.CapsRpb): + if not unit0.json_dic.has('ts'): return + if unit0.json_dic['ts'] != 7: return + if not unit0.json_dic.has('msfs'): return var msfs = unit.json_dic['msfs'] for fs in msfs: