add mode ems g

This commit is contained in:
2024-12-13 16:14:51 +03:00
parent 3fa0b072bf
commit 1065d20553
8 changed files with 220 additions and 119 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
extends Panel
var node_select1: Node
var shift: int = 2
var input_status: Dictionary = {}
func _ready() -> void:
@@ -11,7 +12,6 @@ func _ready() -> void:
for out_colum in Constants.OUT_EMS_G.size()+shift:
if out_colum > 1 and i_row ==0:
column.append(Constants.TableList)
elif out_colum > 1 and i_row > 2:
column.append(Constants.Switch)
elif (out_colum == 1 and i_row > 2) or (out_colum > 1 and i_row == 2):
@@ -22,26 +22,33 @@ func _ready() -> void:
draw_tabl(node_select1, EMS_G_TABLE, EMS_G_TABLE.size())
node_select1.get_node2(1, 1).text = 'x3 : OUT'
node_select1.get_node2(0, 2).text = 'x3 : IN'
node_select1.get_node2(1, 1).text = 'x3_OUT:GND'
node_select1.get_node2(0, 2).text = 'x3_IN:GND'
for i in Constants.INPUT_EMS_G.size():
node_select1.get_node2(0, i+shift+1).text = Constants.INPUT_EMS_G[i]
for i in Constants.OUT_EMS_G.size():
node_select1.get_node2(i+shift, 1).text = Constants.OUT_EMS_G[i]
node_select1.get_node2(i+shift, 1).text = Constants.OUT_EMS_G[i][1]
for i in EMS_G_TABLE[0].size()-shift:
var list = node_select1.get_node2(i+shift, 0)
list.set_meta('device', Constants.OUT_EMS_G[i][0])
list.connect('item_selected', Callable(self, 'on_mode_link').bind(list))
for k in Constants.OUT_x128.size():
list.add_item(Constants.OUT_x128[k])
var columns_min_size: Array
for i in EMS_G_TABLE[0].size():
columns_min_size.append(70)
if i < 2:
columns_min_size.append(110)
else:
columns_min_size.append(80)
node_select1.set_columns_min_size(columns_min_size)
Network.connect('_yau_receive', Callable(self, '_on_data_received'))
create_link_button(node_select1, 3, 19, 2, 18)
func draw_tabl(tbl, row: Array, count_row: int):
for i_row in count_row:
@@ -73,8 +80,68 @@ func _on_data_received(data_from_yau_07):
set_frame(socket_status, Constants.Frame.WORK)
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
pass
func set_frame(node: Node, val: int): node.set_frame(val)
func set_init():
pass
## Создает связь между кнопками
func create_link_button(node, count_rows_sart: int, count_rows_end: int, coln_start: int, coln_end: int):
## META_EMS_G[[Номер входа, Номер выхода]]
var META_EMS_G: Array = []
for i_row in 16:
var INPUT = 1
var OUTPUT = 47
for i_colum in 16:
META_EMS_G.append([INPUT+i_row, OUTPUT+i_colum])
input_status[OUTPUT+i_colum] = 0
var count_register = 0
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 chk_btn = chk_node.get_child(1, false)
chk_btn.connect('toggled', Callable(self, 'on_btn_connect').bind(chk_node, chk_btn))
chk_btn.set_meta('device', META_EMS_G[count_register])
count_register += 1
func on_mode_link(mode, list):
## Формирование команды для выбора устройства
var meta = list.get_meta('device')
var address_port_wr = 0x122
var ports_wr: Dictionary = {address_port_wr : meta}
Network.send_array.append(ports_wr) # Отправка команды
## Формирование команды для отправкы команды на устройство
ports_wr = {}
address_port_wr = 0x128
ports_wr[address_port_wr] = 0x0000 if mode == 0 else 0x2000 if mode == 1 else 0x4000 if mode == 2 else 0x8000
Network.send_array.append(ports_wr)
func on_btn_connect(toggled_on: bool, chk_node: Node, chk_btn: Node):
## Формирование команды для выбора устройства
var meta = chk_btn.get_meta('device')
var address_port_wr = 0x122
var ports_wr: Dictionary = {address_port_wr : meta[1]}
Network.send_array.append(ports_wr) # Отправка команды
## Формирование команды для отправкы команды на устройство
var color_chk_btn = chk_node.get_child(0, false)
if toggled_on:
color_chk_btn.color = Color.WEB_GREEN
input_status[meta[1]] += 1 << meta[0]-1
else:
color_chk_btn.color = Color.BLACK
input_status[meta[1]] -= 1 << meta[0]-1
ports_wr = {}
address_port_wr = 0x124
ports_wr[address_port_wr] = input_status[meta[1]]
Network.send_array.append(ports_wr)

View File

@@ -70,6 +70,9 @@ func _on_yau_status(yau_status):
func _on_read_isa(unit_isa_ports):
var isa: Array = []
for i in unit_isa_ports:
isa.append('%x: %x' % [i, unit_isa_ports[i]])
$ISA.text = 'ISA: ' + str(unit_isa_ports)
@@ -79,7 +82,7 @@ func draw_tabl(tbl, row: Array, count_row: int):
tbl.add_row(row[i_row])
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
pass
@@ -201,16 +204,6 @@ func _on_data_received(data_from_yau_07):
func set_frame(node: Node, val: int): node.set_frame(val)
#func dec2bin(decimal_value, number_bit):
#var binary_string = ''
#var count = number_bit
#while(count >= 0):
#var temp: int = decimal_value >> count
#binary_string += '%d' % (temp & 1)
#count -= 1
#return binary_string
func _on_prd_select() -> void:
$TabContainer.current_tab = 1
$Background/side_panel/select_prd.button_pressed = true

View File

@@ -68,44 +68,45 @@ const EMS_G: Array = [
['Нет Х3:14(Модуляция)', 'Есть Х3:14(Модуляция)'],
['Нет Х3:27(ФГОЗ)', 'Есть Х3:27(ФГОЗ)']]
const INPUT_EMS_G: Array = [
'01/:34',
'02/:35',
'03/:36',
'04/:37',
'05/:38',
'06/:39',
'07/:40',
'08/:41',
'18/:42',
'19/:43',
'20/:44',
'21/:45',
'22/:46',
'23/:47',
'24/:48',
'25/:49',]
'01 :34',
'02 :35',
'03 :36',
'04 :37',
'05 :38',
'06 :39',
'07 :40',
'08 :41',
'18 :42',
'19 :43',
'20 :44',
'21 :45',
'22 :46',
'23 :47',
'24 :48',
'25 :49',]
const OUT_EMS_G: Array = [
'10/:34',
'11/:35',
'12/:36',
'13/:37',
'14/:38',
'15/:39',
'16/:40',
'17/:41',
'26/:42',
'27/:43',
'28/:44',
'29/:45',
'30/:46',
'31/:47',
'32/:48',
'33/:49',]
[47, '10 :34'],
[48, '11 :35'],
[49, '12 :36'],
[50, '13 :37'],
[51, '14 :38'],
[52, '15 :39'],
[53, '16 :40'],
[54, '17 :41'],
[55, '26 :42'],
[56, '27 :43'],
[57, '28 :44'],
[58, '29 :45'],
[59, '30 :46'],
[60, '31 :47'],
[61, '32 :48'],
[62, '33 :49']]
const OUT_x128 = [
'Р',
'К',
'0',
'1',]
## [Номер входа, Номер выхода]
enum MODE {
PRD_K,

11
scripts/switch.gd Normal file
View File

@@ -0,0 +1,11 @@
extends PanelContainer
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

View File

@@ -1,10 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://cef6gtuc60ggg"]
[gd_scene load_steps=2 format=3 uid="uid://cef6gtuc60ggg"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q1ixs"]
bg_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hrhif"]
bg_color = Color(0, 0, 0, 1)
bg_color = Color(0, 0, 0, 0.490196)
border_width_bottom = 2
border_color = Color(0.223529, 0.168627, 0.223529, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
[node name="Label" type="LineEdit"]
texture_filter = 2
@@ -26,7 +29,7 @@ mouse_default_cursor_shape = 0
theme_override_colors/font_uneditable_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 17
theme_override_styles/read_only = SubResource("StyleBoxFlat_q1ixs")
theme_override_styles/normal = SubResource("StyleBoxFlat_hrhif")
theme_override_styles/normal = SubResource("StyleBoxFlat_q1ixs")
alignment = 1
editable = false
caret_blink = true

View File

@@ -4,8 +4,14 @@
[ext_resource type="Texture2D" uid="uid://b15flrfytxkop" path="res://эмс-бланк-пост.png" id="2_b2kjm"]
[ext_resource type="Texture2D" uid="uid://ijdfo2mml54" path="res://эмс-бланк-перем.png" id="3_odpjv"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jkmds"]
bg_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q1ixs"]
bg_color = Color(0, 0, 0, 0.490196)
border_width_bottom = 2
border_color = Color(0.223529, 0.168627, 0.223529, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
[sub_resource type="SpriteFrames" id="SpriteFrames_a7q1i"]
animations = [{
@@ -28,11 +34,14 @@ animations = [{
}]
[node name="PanelContainer" type="PanelContainer"]
offset_right = 73.0
offset_bottom = 38.0
theme_override_styles/panel = SubResource("StyleBoxFlat_jkmds")
offset_left = -3.0
offset_right = 319.0
offset_bottom = 66.0
theme_override_styles/panel = SubResource("StyleBoxFlat_q1ixs")
metadata/_edit_lock_ = true
[node name="SZI_x" type="AnimatedSprite2D" parent="."]
position = Vector2(35, 11)
scale = Vector2(0.777778, 0.777778)
position = Vector2(40, 11)
scale = Vector2(1.2, 1.2)
sprite_frames = SubResource("SpriteFrames_a7q1i")
metadata/_edit_lock_ = true

View File

@@ -1,14 +1,32 @@
[gd_scene load_steps=2 format=3 uid="uid://dhg1syshfaem2"]
[gd_scene load_steps=7 format=3 uid="uid://dhg1syshfaem2"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kwqxa"]
bg_color = Color(0, 0, 0, 1)
[ext_resource type="Script" path="res://scripts/switch.gd" id="1_h0k6p"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r5cym"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_b6sp7"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_bc33d"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_46fou"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_o64tc"]
[node name="PanelContainer" type="PanelContainer"]
offset_right = 186.0
offset_bottom = 40.0
theme_override_styles/panel = SubResource("StyleBoxFlat_kwqxa")
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.490196)
[node name="CheckButton" type="CheckButton" parent="."]
layout_mode = 2
size_flags_horizontal = 4
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")