From 827c85fa9ea8e233a72b6b53bf985f2327253ce7 Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 20 Dec 2024 14:40:01 +0300 Subject: [PATCH] add device --- PRD_MP550.tscn | 6 +++--- ems_g.gd | 26 ++++++++++++++++++++++++-- scripts/PRD.gd | 9 +++++---- scripts/constants.gd | 2 +- scripts/switch.gd | 2 +- table/node.tscn | 10 ++++++++-- table/socket_status.tscn | 4 ++++ table/switch.tscn | 8 +++++--- 8 files changed, 51 insertions(+), 16 deletions(-) diff --git a/PRD_MP550.tscn b/PRD_MP550.tscn index 9077846..b118d9c 100644 --- a/PRD_MP550.tscn +++ b/PRD_MP550.tscn @@ -15,7 +15,7 @@ [ext_resource type="PackedScene" uid="uid://p2suppildvq0" path="res://table/элемент-в.tscn" id="11_fg7ul"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eib3t"] -bg_color = Color(0.356863, 0.278431, 0.356863, 1) +bg_color = Color(0.223529, 0.168627, 0.223529, 1) border_width_bottom = 6 border_color = Color(0.228592, 0.173062, 0.22863, 1) border_blend = true @@ -453,9 +453,9 @@ metadata/_edit_lock_ = true [node name="lbl_control" type="Label" parent="TabContainer/ControlPanel"] layout_mode = 0 -offset_left = 636.0 +offset_left = 4.0 offset_top = 21.0 -offset_right = 1256.0 +offset_right = 624.0 offset_bottom = 52.0 theme_override_font_sizes/font_size = 22 text = "Контроль исправности прибора ПРД-Н" diff --git a/ems_g.gd b/ems_g.gd index 7ff3296..03e4319 100644 --- a/ems_g.gd +++ b/ems_g.gd @@ -100,9 +100,10 @@ func _on_data_received(data_from_yau_07): process_sockets_vert(in_blank, in_imp, 16, 1, parent_node2) process_sockets_horizon(out_blank, out_imp, 16, 2, parent_node2) + func process_sockets_horizon(blank: int, imp: int, count: int, col: int, parent_node2: Node): for i in count: - var socket_status = node_select1.get_node2(col+i, shift).get_child(0, false) + var socket_status = node_select1.get_node2(col+i, shift).get_child(1, false) var frame_type = Constants.Frame.WORK if (blank & (1 << i)) != 0: @@ -126,7 +127,7 @@ func process_sockets_horizon(blank: int, imp: int, count: int, col: int, parent_ func process_sockets_vert(blank: int, imp: int, count: int, col: int, parent_node2: Node): for i in count: - var socket_status = node_select1.get_node2(col, i + shift+1).get_child(0, false) + var socket_status = node_select1.get_node2(col, i + shift+1).get_child(1, false) var frame_type = Constants.Frame.WORK if (blank & (1 << i)) != 0: @@ -176,12 +177,33 @@ func create_link_button(node, count_rows_sart: int, count_rows_end: int, coln_st for i_row in range(count_rows_sart, count_rows_end): for i_col in range (coln_start, coln_end): var chk_node = node.get_node2(i_col, i_row) + var mouse_area = chk_node.get_child(0, false) var chk_btn = chk_node.get_child(1, false) + mouse_area.connect('mouse_entered', Callable(self, 'on_mouse_entered').bind(chk_btn)) + chk_btn.connect('mouse_entered', Callable(self, 'on_mouse_entered').bind(chk_btn)) chk_btn.connect('toggled', Callable(self, '_on_btn_connect').bind(chk_btn)) chk_btn.set_meta('device', META_EMS_G[count_register]) count_register += 1 +func on_mouse_entered(meta_area): + var device = meta_area.get_meta('device') + var y = device[0] + 1 + var x = device[1] - 45 + + for i_y in 18: + for i_x in 18: + if i_y <= y and i_x <= x and i_y == y: + var chest = $table1.get_node2(i_x, i_y+1).get_child(0, false) + chest.color = Color(0.45, 0.36, 0.36, 0.5) + elif i_y <= y and i_x <= x and i_x == x: + var chest = $table1.get_node2(i_x, i_y+1).get_child(0, false) + chest.color = Color(0.45, 0.36, 0.36, 0.5) + else: + var black = $table1.get_node2(i_x, i_y+1).get_child(0, false) + black.color = Color(0, 0, 0, 0.0) + + func on_mode_link(mode, list): ## Формирование команды для выбора устройства var meta = list.get_meta('device') diff --git a/scripts/PRD.gd b/scripts/PRD.gd index 8b23e5a..9c8c917 100644 --- a/scripts/PRD.gd +++ b/scripts/PRD.gd @@ -2,6 +2,8 @@ extends Node2D signal read_ems_g_start() signal read_ems_g_finish() +signal change_device(meta_device) + var flag_mode = Constants.ADDRESSES[0][3] var broadcast_packet: PackedByteArray var node_select1: Node @@ -128,10 +130,10 @@ func _on_data_received(data_from_yau_07): var j = int(not(dry_contact & (1 << i) == 0 and flag_yau_control)) if j == 0: node_power_ind[i].button_pressed = true + node_power_ind[i].disabled = false else: node_power_ind[i].button_pressed = false - - + node_power_ind[i].disabled = true #node_select1.set_node_text(3, 0, '%d' % DKM) ## УКП @@ -184,8 +186,7 @@ func on_btn_select(intem_from_sector): var node_select_device = $TabContainer/PRD/select_dev/select_dev var get_select_device = node_select_device.get_node2(1, 0) var meta = get_select_device.get_item_metadata(intem_from_sector) - Network.address = meta[0] - Network.port = meta[1] + emit_signal('change_device', meta) flag_mode = meta[2] diff --git a/scripts/constants.gd b/scripts/constants.gd index 76da37e..26e507a 100644 --- a/scripts/constants.gd +++ b/scripts/constants.gd @@ -86,7 +86,7 @@ const OUT_x128: Array = [ 'К', '0', '1',] -## [Номер входа, Номер выхода] + enum MODE { PRD_K, diff --git a/scripts/switch.gd b/scripts/switch.gd index 47eeb11..4c4d69f 100644 --- a/scripts/switch.gd +++ b/scripts/switch.gd @@ -5,7 +5,7 @@ func _ready() -> void: var style = get('theme_override_styles/panel') style.bg_color = Color(0, 0, 0, 0.5) set('theme_override_styles/panel', style) - + func _process(_delta: float) -> void: pass diff --git a/table/node.tscn b/table/node.tscn index 7a4b8f4..7472d01 100644 --- a/table/node.tscn +++ b/table/node.tscn @@ -18,8 +18,8 @@ anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 offset_top = -103.0 -offset_right = -477.0 -offset_bottom = -714.0 +offset_right = 75.0 +offset_bottom = 137.0 grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 3 @@ -34,3 +34,9 @@ alignment = 1 editable = false caret_blink = true caret_blink_interval = 0.5 + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 0 +offset_right = 1933.0 +offset_bottom = 1088.0 +color = Color(1, 1, 1, 0) diff --git a/table/socket_status.tscn b/table/socket_status.tscn index 74732cb..ae21dbe 100644 --- a/table/socket_status.tscn +++ b/table/socket_status.tscn @@ -40,6 +40,10 @@ offset_bottom = 66.0 theme_override_styles/panel = SubResource("StyleBoxFlat_q1ixs") metadata/_edit_lock_ = true +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 2 +color = Color(0, 0, 0, 0.195) + [node name="SZI_x" type="AnimatedSprite2D" parent="."] position = Vector2(40, 11) scale = Vector2(1.2, 1.2) diff --git a/table/switch.tscn b/table/switch.tscn index 75a4a35..6a79c95 100644 --- a/table/switch.tscn +++ b/table/switch.tscn @@ -14,20 +14,22 @@ [node name="PanelContainer" type="PanelContainer"] offset_right = 186.0 -offset_bottom = 40.0 +offset_bottom = 44.0 +mouse_default_cursor_shape = 6 theme_override_styles/panel = SubResource("StyleBoxFlat_r5cym") script = ExtResource("1_h0k6p") [node name="ColorRect" type="ColorRect" parent="."] layout_mode = 2 -color = Color(0, 0, 0, 0.011) +color = Color(0, 0, 0, 0) [node name="CheckButton" type="CheckButton" parent="."] layout_mode = 2 size_flags_horizontal = 4 +size_flags_vertical = 4 +tooltip_text = "Соединить. Отсоединить" mouse_default_cursor_shape = 2 theme_override_styles/focus = SubResource("StyleBoxTexture_b6sp7") theme_override_styles/hover = SubResource("StyleBoxTexture_bc33d") theme_override_styles/pressed = SubResource("StyleBoxTexture_46fou") theme_override_styles/normal = SubResource("StyleBoxTexture_o64tc") -metadata/_edit_lock_ = true