full sync ems g

This commit is contained in:
2024-12-18 14:49:24 +03:00
parent 4575a4ba18
commit 38e958adac
4 changed files with 105 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=48 format=3 uid="uid://cvor2jm4xk3ha"]
[gd_scene load_steps=50 format=3 uid="uid://cvor2jm4xk3ha"]
[ext_resource type="Script" path="res://scripts/PRD.gd" id="1_v273n"]
[ext_resource type="Script" path="res://table/table.gd" id="2_vmbyo"]
@@ -9,6 +9,7 @@
[ext_resource type="Texture2D" uid="uid://b15flrfytxkop" path="res://эмс-бланк-пост.png" id="8_eaogg"]
[ext_resource type="Script" path="res://ems_g.gd" id="9_g1wia"]
[ext_resource type="Texture2D" uid="uid://ijdfo2mml54" path="res://эмс-бланк-перем.png" id="9_nctgk"]
[ext_resource type="Shader" path="res://load.gdshader" id="10_lf1xh"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eib3t"]
bg_color = Color(0.356863, 0.278431, 0.356863, 1)
@@ -143,6 +144,8 @@ shader_parameter/turn = 0.785
[sub_resource type="GradientTexture2D" id="GradientTexture2D_0pk2o"]
gradient = SubResource("Gradient_ki0n7")
fill_from = Vector2(0.474359, 0.5)
metadata/_snap_enabled = true
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_tn8m6"]
@@ -171,6 +174,18 @@ animations = [{
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4xm3m"]
bg_color = Color(0, 0, 0, 0.415686)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_slcfo"]
shader = ExtResource("10_lf1xh")
shader_parameter/frequency = 5.0
shader_parameter/amplitude = 200.0
shader_parameter/speed = 5.0
shader_parameter/direction = -1.0
shader_parameter/color1 = Color(0, 0, 0, 1)
shader_parameter/color2 = Color(0.235294, 0.180392, 0.235294, 0.439216)
shader_parameter/color3 = Color(0.356863, 0.278431, 0.356863, 1)
shader_parameter/color4 = Color(0, 0, 0, 0)
shader_parameter/opacity = 0.471
[node name="Node2D" type="Node2D"]
script = ExtResource("1_v273n")
@@ -549,6 +564,30 @@ theme_override_styles/hover = SubResource("StyleBoxFlat_4xm3m")
text = "Синхронизация"
metadata/_edit_lock_ = true
[node name="load_boadr" type="ColorRect" parent="TabContainer/EMS_G"]
layout_mode = 0
offset_left = 27.0
offset_top = 148.0
offset_right = 1596.0
offset_bottom = 717.0
color = Color(0, 0, 0, 0.596078)
[node name="Load_text" type="Label" parent="TabContainer/EMS_G/load_boadr"]
layout_mode = 0
offset_left = 679.0
offset_top = 243.0
offset_right = 776.0
offset_bottom = 278.0
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 28
text = "Загрузка ..."
[node name="load" type="Sprite2D" parent="TabContainer/EMS_G/load_boadr"]
material = SubResource("ShaderMaterial_slcfo")
position = Vector2(791, 284.5)
scale = Vector2(21.8765, 8.89063)
texture = SubResource("GradientTexture2D_0pk2o")
[connection signal="pressed" from="Background/side_panel/select_prd" to="." method="_on_prd_select"]
[connection signal="pressed" from="Background/side_panel/select_control" to="." method="_on_control_button"]
[connection signal="pressed" from="Background/side_panel/select_ems_g" to="." method="_on_emsg_select"]

View File

@@ -16,26 +16,25 @@ func _on_read_ems_g():
func _on_sync():
if flag_sync_ems_g:
for index in 32:
var tmp_device_mode = Constants.EMS_G_PORT_DATA_HOLDER[index][0]
if tmp_device_mode > 46:
var port0x124: int
var port0x128: int
for key in Constants.EMS_G_PORT_DATA_HOLDER[index][1].keys():
if key == 0x124:
port0x124 = Constants.EMS_G_PORT_DATA_HOLDER[index][1][key]
for row in 16:
if (port0x124 & (1 << row)) != 0:
var chk_btn = node_select1.get_node2(tmp_device_mode-45, row+3).get_child(1, false)
chk_btn.button_pressed =true
if key == 0x128:
port0x128 = Constants.EMS_G_PORT_DATA_HOLDER[index][1][key]
var list = node_select1.get_node2(tmp_device_mode-45, 0)
var select = 0 if port0x128 == 0 else 1 if port0x128 == 0x2000 else 2 if port0x128 == 0x4000 else 3
list.select(select)
for index in 32:
var tmp_device_mode = Constants.EMS_G_PORT_DATA_HOLDER[index][0]
if tmp_device_mode > 46:
var port0x124: int
var port0x128: int
for key in Constants.EMS_G_PORT_DATA_HOLDER[index][1].keys():
if key == 0x124:
port0x124 = Constants.EMS_G_PORT_DATA_HOLDER[index][1][key]
for row in 16:
if (port0x124 & (1 << row)) != 0:
var chk_btn = node_select1.get_node2(tmp_device_mode-45, row+3).get_child(1, false)
chk_btn.button_pressed =true
if key == 0x128:
port0x128 = Constants.EMS_G_PORT_DATA_HOLDER[index][1][key]
var list = node_select1.get_node2(tmp_device_mode-45, 0)
var select = 0 if port0x128 == 0 else 1 if port0x128 == 0x2000 else 2 if port0x128 == 0x4000 else 3
list.select(select)
$load_boadr.visible = false
func _ready() -> void:
node_select1 = $table1
@@ -79,8 +78,9 @@ func _ready() -> void:
columns_min_size.append(80)
node_select1.set_columns_min_size(columns_min_size)
var parrent = get_parent().get_parent()
parrent.connect('read_ems_g', Callable(self, '_on_read_ems_g'))
var parrent_NODE2 = get_parent().get_parent()
parrent_NODE2.connect('read_ems_g_start', Callable(self, '_on_read_ems_g'))
parrent_NODE2.connect('read_ems_g_finish', Callable(self, '_on_sync'))
Network.connect('yau_receive', Callable(self, '_on_data_received'))
create_link_button(node_select1, shift+1, 16+shift+1, shift, 16+shift)
@@ -116,8 +116,7 @@ func _on_data_received(data_from_yau_07):
func _process(_delta: float) -> void:
if Constants.EMS_G_PORT_DATA_HOLDER.size() == 32:
flag_sync_ems_g = true
pass
func set_frame(node: Node, val: int): node.set_frame(val)

35
load.gdshader Normal file
View File

@@ -0,0 +1,35 @@
shader_type canvas_item;
// Parameters for the sine wave
uniform float frequency = 1.5;
uniform float amplitude = 1000.0;
uniform float speed = 10.0;
uniform float direction: hint_range(-1.0, 1.0) = 1.0;
// Uniforms for colors
uniform vec4 color1: source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform vec4 color2: source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform vec4 color3: source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform vec4 color4: source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform float opacity: hint_range(0.0, 1.0) = 1.0;
void fragment() {
vec2 uv = FRAGCOORD.xy;
float sine_wave = sin(UV.x * frequency + TIME * speed * direction) * amplitude;
uv.y += sine_wave;
float t = sin(UV.x * frequency + TIME * speed * direction);
vec4 final_color;
if (t < -0.5) {
final_color = color1;
} else if (t < 0.0) {
final_color = color2;
} else if (t < 0.5) {
final_color = color3;
} else {
final_color = color4;
}
final_color *= vec4(1.0, 1.0, 1.0, opacity);
COLOR = final_color;
}

View File

@@ -1,6 +1,7 @@
extends Node2D
signal read_ems_g()
signal read_ems_g_start()
signal read_ems_g_finish()
#var unit = Yau07.YaU07.new('ЯУ07')
var flag_mode = Constants.ADDRESSES[0][3]
var broadcast_packet: PackedByteArray
@@ -86,6 +87,8 @@ func _on_read_isa(unit_isa_ports):
break
if not found:
Constants.EMS_G_PORT_DATA_HOLDER.append([tmp, isa_data])
if len(Constants.EMS_G_PORT_DATA_HOLDER) == 32:
emit_signal('read_ems_g_finish')
$ISA.text = 'ISA: ' + str(len(Constants.EMS_G_PORT_DATA_HOLDER))
@@ -218,21 +221,21 @@ func set_frame(node: Node, val: int): node.set_frame(val)
func _on_prd_select() -> void:
$TabContainer.current_tab = 1
$TabContainer.current_tab = 0
$Background/side_panel/select_prd.button_pressed = true
$Background/side_panel/select_control.button_pressed = false
$Background/side_panel/select_ems_g.button_pressed = false
func _on_control_button() -> void:
$TabContainer.current_tab = 0
$TabContainer.current_tab = 1
$Background/side_panel/select_control.button_pressed = true
$Background/side_panel/select_prd.button_pressed = false
$Background/side_panel/select_ems_g.button_pressed = false
func _on_emsg_select() -> void:
emit_signal('read_ems_g')
emit_signal('read_ems_g_start')
$TabContainer.current_tab = 2
$Background/side_panel/select_ems_g.button_pressed = true
$Background/side_panel/select_control.button_pressed = false