сохранение/загрузка в эмс-г на доработке

This commit is contained in:
2025-03-11 18:47:53 +03:00
parent 05143f6f45
commit 228d1dfd19
12 changed files with 257 additions and 220 deletions

View File

@@ -2,6 +2,7 @@ extends Node2D
signal read_ems_g_start()
signal read_ems_g_finish()
signal write_ems_g_start()
var timer_modul_um: Timer = Timer.new()
@@ -21,7 +22,7 @@ var att_fs_1: float
var att_fs_2: float
var att_fs_3: float
var status_pribor = null
var save_path = "D://PRD-TU-MP550//"
var save_path = "res://saves/"
const need_port: Array = [0x122, 0x124, 0x126, 0x128, 0x12A]
var current_meta: Array = [Constants.META.MODUL_UM_1, Constants.META.MODUL_UM_2, Constants.META.MODUL_UM_3, Constants.META.MODUL_UM_28]
var modul_um: Array = [0, 0, 0, 0]
@@ -31,11 +32,11 @@ func _ready() -> void:
$Background/lbl_commit.text = commit.VCS_HEAD
# Считывание аргументов с консоли (путь сохранения)
var args = OS.get_cmdline_user_args()
for i in range(args.size()):
if args[i] == "testsave-path" and i + 1 < args.size():
save_path = args[i + 1]
break
#var args = OS.get_cmdline_user_args()
#for i in range(args.size()):
#if args[i] == "testsave-path" and i + 1 < args.size():
#save_path = args[i + 1]
#break
# Таблица 1 УКП-1 (Температура, Мощность)
node_select1 = $TabContainer/PRD/body_grid/litera_2_4_6/table_ukp_1
@@ -209,7 +210,6 @@ func _ready() -> void:
node_select_fs_2.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_get_status_2'))
node_select_fs_2.get_node2(1, 7).connect('text_submitted', Callable(self, '_on_set_base_can_macro_2'))
node_select_fs_2.get_node2(1, 8).get_child(1, false).connect('toggled', Callable(self, '_on_status_can_macro_2'))
## FS 3
node_select_fs_3.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_3'))
node_select_fs_3.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_3'))
@@ -229,6 +229,7 @@ func _ready() -> void:
self.add_child(timer_modul_um)
timer_modul_um.connect('timeout', Callable(self, '_on_timer_modul_um'))
self.connect('write_ems_g_start', _on_write_ems_g)
func add_signs_scene():
@@ -324,21 +325,23 @@ func _on_read_isa(unit_isa_ports: Dictionary) -> void:
for key in unit_isa_ports.keys():
isa_data[key] = unit_isa_ports[key]
if isa_data.has(Constants.BASE_PORTS.EMS_G+2):
var tmp = isa_data[Constants.BASE_PORTS.EMS_G+2]
isa_data.erase(Constants.BASE_PORTS.EMS_G+2)
if isa_data.has(Constants.BASE_PORTS.EMS_G+2):
var tmp = isa_data[Constants.BASE_PORTS.EMS_G+2]
isa_data.erase(Constants.BASE_PORTS.EMS_G+2)
var found = false
for i in range(Constants.EMS_G_PORT_DATA_HOLDER.size()):
if Constants.EMS_G_PORT_DATA_HOLDER[i][0] == tmp:
Constants.EMS_G_PORT_DATA_HOLDER[i][1] = isa_data
found = true
break
if not found:
Constants.EMS_G_PORT_DATA_HOLDER.append([tmp, isa_data])
var found = false
for i in range(Constants.EMS_G_PORT_DATA_HOLDER.size()):
if Constants.EMS_G_PORT_DATA_HOLDER[i][0] == tmp:
Constants.EMS_G_PORT_DATA_HOLDER[i][1] = isa_data
found = true
break
if not found:
Constants.EMS_G_PORT_DATA_HOLDER.append([tmp, isa_data])
$load_status_yau.value += 1
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))
$load_status_yau.visible = false
$TabContainer/EMS_G/load_boadr/win_load.material.set('shader_parameter/dot_color_end', Color(0.8, 0.5, 1.0, 1.0 - 0.05 * len(Constants.EMS_G_PORT_DATA_HOLDER)))
@@ -373,10 +376,6 @@ func _on_read_isa(unit_isa_ports: Dictionary) -> void:
var data_dict = Constants.EMS_G_PORT_DATA_HOLDER[index][1]
if Constants.BASE_PORTS.EMS_G+8 in data_dict:
$TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control.get_node2(1,1).get_child(1).button_pressed = data_dict[Constants.BASE_PORTS.EMS_G+8] >> 14
if tmp_device_mode == Constants.META.CI_3_B_UF:
var data_dict = Constants.EMS_G_PORT_DATA_HOLDER[index][1]
if Constants.BASE_PORTS.EMS_G+8 in data_dict:
$TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control.get_node2(1,1).get_child(1).button_pressed = data_dict[Constants.BASE_PORTS.EMS_G+8] >> 13
if tmp_device_mode == Constants.META.MODUL_UM_1:
var data_dict = Constants.EMS_G_PORT_DATA_HOLDER[index][1]
if Constants.BASE_PORTS.EMS_G+8 in data_dict:
@@ -500,9 +499,9 @@ func _on_data_fs_3(fs_3_data):
func _process(_delta: float) -> void:
# FS 1
var node_freq_fs_1 = node_select_fs_1.get_node2(1, 2)
var node_freq_fs_1 = node_select_fs_1.get_node2(1, 2).get_text()
var node_freq_fs_1_mod = node_select_fs_1.get_node2(0, 2)
if (int(node_freq_fs_1.get_text()) != freq_fs_1) and node_freq_fs_1.get_text() != '':
if (int(node_freq_fs_1) != freq_fs_1) and node_freq_fs_1 != '':
node_freq_fs_1_mod.modulate = Color.AQUAMARINE
node_freq_fs_1_mod.text = 'Частота*'
else:
@@ -577,18 +576,17 @@ func set_frame(node: Node, val: int): node.set_frame(val)
func _on_save_config():
var da = DirAccess.open(save_path)
var base_path = save_path + "save//"
if da == null:
return
else:
da.dir_exists(base_path)
da.make_dir_recursive(base_path)
da.dir_exists(save_path)
da.make_dir_recursive(save_path)
var file_dialog = FileDialog.new()
file_dialog.title = "Сохранить файл как"
file_dialog.set_size(Vector2(600, 400))
file_dialog.mode = FileDialog.FILE_MODE_SAVE_FILE
file_dialog.current_dir = base_path
file_dialog.set_current_file("ЭМС-Г" + "-" + status_pribor)
file_dialog.current_dir = save_path
file_dialog.set_current_file("ЭМС-Г")
file_dialog.connect("file_selected", Callable(self, "_save_selected_file"))
add_child(file_dialog)
file_dialog.popup_centered()
@@ -597,7 +595,6 @@ func _on_save_config():
func _save_selected_file(file_path: String):
var data = Constants.EMS_G_PORT_DATA_HOLDER
var param_ems_g: Dictionary = {}
var other_data: Dictionary = {}
# Формируем словари
for item in data:
var regist: Dictionary = {}
@@ -605,60 +602,75 @@ func _save_selected_file(file_path: String):
for key in item[1]:
if key in need_port:
regist[key] = item[1][key]
else:
other_data[key] = item[1]
print(regist)
param_ems_g[item[0]] = regist
# Переменные для сохранения
var ems_g_file = file_path
var other_name = "others" + "-" + status_pribor
var other_path = save_path + other_name
var other_names = other_name
var other_counter = 1
var dir = DirAccess.open(file_path.get_base_dir())
# Сохранение данных ЭМС-Г
var file = FileAccess.open(ems_g_file, FileAccess.WRITE)
var file = FileAccess.open(file_path, FileAccess.WRITE)
if file != null:
file.store_string(JSON.stringify(param_ems_g))
file.close()
# Сохранение данных других
var save_other = $save_other.is_pressed()
if save_other:
while dir.file_exists(other_names):
other_names = other_name + "_" + str(other_counter)
other_path = save_path + other_names
other_counter += 1
var other_file = FileAccess.open(other_path, FileAccess.WRITE)
if other_file != null:
other_file.store_string(JSON.stringify(other_data))
other_file.close()
func _on_file_selected(file_path: String):
var file = FileAccess.open(file_path, FileAccess.READ)
# Проверка на открытие/чтение файла
if file != OK:
return
var file_content = file.get_as_text()
file.close()
var json = JSON.new()
var data = json.parse(file_content)
# Проверка на разбор содержимого файла
if data.error != OK:
return
Constants.EMS_G_PORT_DATA_HOLDER = data.result
$Background/switch_panel/save_config/notice.visible = true
$Background/switch_panel/save_config/notice.text = '✅ Файл %s записан успешно!' % file_path
await get_tree().create_timer(2.0).timeout
$Background/switch_panel/save_config/notice.visible = false
func _on_load_config():
var file_dialog = FileDialog.new()
var base_path = save_path + "save//"
file_dialog.set_title("Выберите файл")
file_dialog.set_size(Vector2(600, 400))
file_dialog.access = FileDialog.ACCESS_FILESYSTEM
file_dialog.current_dir = base_path
file_dialog.mode = FileDialog.FILE_MODE_OPEN_FILE
file_dialog.current_dir = save_path
file_dialog.connect("file_selected", Callable(self, "_load_selected_file"))
add_child(file_dialog)
file_dialog.popup_centered()
func _load_selected_file():
var file_path: String = 'res://saves/%s' % Constants.ADDRESSES[$TabContainer/PRD/select_dev.get_node2(1, 0).get_selected_id()][0]
var file = FileAccess.open(file_path, FileAccess.READ)
# Проверка на открытие/чтение файла
if file == null:
return
var file_content: String = file.get_as_text()
file.close()
var json: JSON = JSON.new()
var error = json.parse(file_content)
if error == OK:
var data_received: Dictionary = json.data
if typeof(data_received) == TYPE_DICTIONARY:
$Background/switch_panel/load_config/notice.visible = true
$Background/switch_panel/load_config/notice.text = '✅ Файл %s прочитан успешно' % file_path
await get_tree().create_timer(2.0).timeout
$Background/switch_panel/load_config/notice.visible = false
emit_signal('write_ems_g_start', data_received)
else:
print("Несоответствующий тип данных!")
else:
print("JSON Parse Error: ", json.get_error_message(), " in ", file_content, " at line ", json.get_error_line())
func _on_write_ems_g(data_to_ems_g: Dictionary):
for key in data_to_ems_g.keys():
#if int(key) < 17:
#print('Constants.BASE_PORTS.EMS_G+2: ', data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x2)])
#print('Constants.BASE_PORTS.EMS_G+0xA: ', data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0xA)])
#Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x2)])
#Network.write_port_isa(Constants.BASE_PORTS.EMS_G+0xA, data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0xA)])
#Network.read_port_isa([Constants.BASE_PORTS.EMS_G+0xA])
if int(key) > 46:
print('Constants.BASE_PORTS.EMS_G+2: ', data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x2)])
#print('Constants.BASE_PORTS.EMS_G+8', data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x8)])
print('Constants.BASE_PORTS.EMS_G+4: ', data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x4)])
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x2)])
#Network.write_port_isa(Constants.BASE_PORTS.EMS_G+4, data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x8)])
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+4, data_to_ems_g[key][str(Constants.BASE_PORTS.EMS_G+0x4)])
#Network.read_port_isa([Constants.BASE_PORTS.EMS_G+4, Constants.BASE_PORTS.EMS_G+8])
func on_mode_select(intem_from_sector: int) -> void:
var node_select_device: GDTable = $TabContainer/PRD/select_dev
var get_select_device = node_select_device.get_node2(1, 0)
@@ -667,12 +679,13 @@ func on_mode_select(intem_from_sector: int) -> void:
add_signs_scene()
Network.on_command_change_device(meta)
Network.read_port_isa([Constants.BASE_PORTS.UG+8, Constants.BASE_PORTS.UG+6, Constants.BASE_PORTS.UG+0xA])
Network.start_work_fs()
Network.start_work_fs_2()
Network.start_work_fs_1(Constants.ADDRESSES[intem_from_sector][0])
Network.start_work_fs_2(Constants.ADDRESSES[intem_from_sector][0])
if meta[2] == Constants.MODE.PRD_K:
Network.start_work_fs_3()
Network.start_work_fs_3(Constants.ADDRESSES[intem_from_sector][0])
$load_status_yau.value = 0
emit_signal('read_ems_g_start')
#_on_read_isa(Network.unit.isa_ports)
$load_status_yau.visible = true
func _on_zapret_1(toggled_on: bool) -> void:
@@ -726,11 +739,9 @@ func _on_modul_um(item_from_ray_1: int, node: Node):
## Таймер для модуляции УМ
func _on_timer_modul_um():
print('Модуляция вызывается')
if modul_um.has(0x2000):
for i in range(3):
if modul_um[i] == 0x2000:
print('Модуляция есть ', modul_um)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G + 2, current_meta[i])
Network.write_port_isa(Constants.BASE_PORTS.EMS_G + 8, modul_um[i])
@@ -864,6 +875,7 @@ func _on_set_ferq_1(freq: String):
func _on_set_att_1(att: String):
Network.set_fs_attenuation(float(att))
save_settings(float(att), 0)
func _on_set_base_can_macro(can_freq: String):
@@ -901,6 +913,7 @@ func _on_set_ferq_2(freq: String):
func _on_set_att_2(att: String):
Network.set_fs_attenuation_2(float(att))
save_settings(float(att), 1)
func _on_set_base_can_macro_2(can_freq: String):
@@ -945,6 +958,7 @@ func _on_set_ferq_3(freq: String):
func _on_set_att_3(att: String):
Network.set_fs_attenuation_3(float(att))
save_settings(float(att), 2)
func _on_set_base_can_macro_3(can_freq: String):
@@ -964,6 +978,7 @@ func _on_modul_fs_3(modulation_select_3) -> void:
## Switch panel
func _on_prd_select() -> void:
$load_status_yau.value = 0
emit_signal('read_ems_g_start')
set_tab_and_buttons(0, 'select_prd', 'texture_prd')
Network.get_gen_state_1()
@@ -976,6 +991,7 @@ func _on_control_button() -> void:
func _on_emsg_select() -> void:
$load_status_yau.value = 0
emit_signal('read_ems_g_start')
set_tab_and_buttons(2, 'select_ems_g', 'texture_ems_g')
@@ -1027,32 +1043,27 @@ func set_tab_and_buttons(tab_index: int, button_name: String, txt_button_name: S
if button is Button or TextureButton:
if button.name != 'burgerButton':
button.button_pressed = (button.name == button_name or button.name == txt_button_name)
if button.name == 'select_control' or button.name == 'texture_control':
if button_name == 'select_control' or button_name == 'texture_control':
$load_status_yau.visible = false
else:
$load_status_yau.visible = true
func _on_connect_prd_pressed() -> void:
on_mode_select($TabContainer/PRD/select_dev.get_node2(1, 0).get_selected_id())
func save_settings():
var settings = {
"test": 1,
"test2": 2,
"test3": 303,
}
var file = FileAccess.open("res://saves/fs_setting.txt", FileAccess.WRITE)
if file:
file.store_var(settings)
file.close()
func read_file():
var file = FileAccess.open("res://saves/fs_setting.txt", FileAccess.READ)
func save_settings(to_att_change: float, mode: int):
if Constants.ADDRESSES[$TabContainer/PRD/select_dev.get_node2(1, 0).get_selected_id()][0] in Constants.FS_ATT:
var read_temp = Constants.FS_ATT[Constants.ADDRESSES[$TabContainer/PRD/select_dev.get_node2(1, 0).get_selected_id()][0]]
read_temp[mode] = to_att_change
Constants.FS_ATT[Constants.ADDRESSES[$TabContainer/PRD/select_dev.get_node2(1, 0).get_selected_id()][0]] = read_temp
else:
return
var file = FileAccess.open("res://saves/fs_setting", FileAccess.WRITE)
if file:
var settings = file.get_var()
file.store_var(Constants.FS_ATT)
file.close()
if 'test3' in settings:
var read_test = settings['test3']
print(read_test)
else:
print('var not found in file')
Constants.read_file()

View File

@@ -1,5 +1,4 @@
extends Node
var file = FileAccess.open("user://constants.txt", FileAccess.READ)
const UNICAST_PORT: int = 50003
const UNICAST_ADDRESS: String = '10.1.1.3'
const BROADCAST_PORT: int = 50000
@@ -409,31 +408,28 @@ enum FS_FREQ {
f7 = 4750,
}
enum FS_ATT {
att_1_prd_H1 = 18,
att_2_prd_H1 = 19,
att_1_prd_H2 = 18,
att_2_prd_H2 = 19,
att_1_prd_H3 = 18,
att_2_prd_H4 = 19,
att_1_prd_B1 = 17,
att_2_prd_B1 = 16,
att_1_prd_B2 = 17,
att_2_prd_B2 = 16,
att_1_prd_B3 = 17,
att_2_prd_B3 = 16,
att_1_prd_B4 = 17,
att_2_prd_B4 = 16,
att_1_prd_K1 = 15,
att_2_prd_K1 = 10,
att_3_prd_K1 = 0,
att_1_prd_K2 = 17,
att_2_prd_K2 = 16,
att_3_prd_K2 = 19,
att_1_prd_K3 = 17,
att_2_prd_K3 = 18,
att_3_prd_K3 = 19,
att_1_prd_K4 = 17,
att_2_prd_K4 = 18,
att_3_prd_K4 = 19,
var FS_ATT: Dictionary = {
"ПРД-Н1": [18, 18],
"ПРД-Н2": [18, 18],
"ПРД-Н3": [18, 18],
"ПРД-Н4": [18, 18],
"ПРД-В1": [19, 19],
"ПРД-В2": [19, 19],
"ПРД-В3": [19, 19],
"ПРД-В4": [19, 19],
"ПРД-К1": [17, 17, 17],
"ПРД-К2": [17, 17, 17],
"ПРД-К3": [17, 17, 17],
"ПРД-К4": [17, 17, 17]
}
func _ready() -> void:
read_file()
func read_file():
var file = FileAccess.open("res://saves/fs_setting", FileAccess.READ)
if file.get_length() > 0:
FS_ATT = file.get_var()
file.close()

View File

@@ -21,7 +21,9 @@ var flag_dkm: bool = false
var flag_ug: bool = false
var flag_modul_on_1: bool = false
var flag_modul_on_2: bool = false
var flag_modul_litera_1: bool = false
var flag_start: bool = false
var flag_continue_control: bool = false
var prep_set_ug: int = 0
@@ -124,6 +126,8 @@ func _ready() -> void:
func _process(_delta: float) -> void:
if not flag_continue_control:
return
if flag_dkm and flag_ug:
emit_signal('signal_on_modul_um')
if flag_modul_on_1 and flag_modul_on_2 and flag_start:
@@ -242,6 +246,8 @@ func _draw_control_panel_prd(pribor):
func fs_1_setup(freq: int, att: float):
if not flag_continue_control:
return
await get_tree().create_timer(0.1).timeout
Network.set_fs_gen_status(true) ## отключен на true
await get_tree().create_timer(0.1).timeout
@@ -258,6 +264,8 @@ func fs_1_setup(freq: int, att: float):
func fs_2_setup(freq: int, att: float):
if not flag_continue_control:
return
await get_tree().create_timer(0.8).timeout
Network.set_fs_gen_status_2(true) ## отключен = true
await get_tree().create_timer(0.1).timeout
@@ -274,7 +282,9 @@ func fs_2_setup(freq: int, att: float):
func fs_3_setup(freq: int, att: float):
await get_tree().create_timer(1.5).timeout
if not flag_continue_control:
return
await get_tree().create_timer(1.8).timeout
Network.set_fs_gen_status_3(true) ## отключен = true
await get_tree().create_timer(0.1).timeout
Network.get_gen_state_3()
@@ -283,13 +293,15 @@ func fs_3_setup(freq: int, att: float):
Network.set_fs_attenuation_3(float(att)) # Для литеры 1
Network.set_can_macro_3(freq)
Network.status_can_macro_3(true)
await get_tree().create_timer(0.1).timeout
await get_tree().create_timer(0.2).timeout
Network.set_fs_gen_status_3(false) ## отключен = true
await get_tree().create_timer(0.1).timeout
Network.get_gen_state_3()
func yau_07b_setup(angle_and_att: int):
if not flag_continue_control:
return
Network.write_port_isa(Constants.BASE_PORTS.UG+0x6, angle_and_att)
Network.write_port_isa(Constants.BASE_PORTS.UG+0x8, angle_and_att)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.MODUL_UM_2)
@@ -319,13 +331,10 @@ func _on_data_fs(fs_data:PackedByteArray, fs_name: String):
if GRP == Constants.GROUP.GENERATOR:
if fs_data.decode_u32(0xC) == 0:
if fs_name == 'ФС-1':
logger.info('✅ Состояние генератора %s: Включен' % fs_name)
$Kasseta_FS/ref_A1.state = Constants.STATE_VAL.GOOD
elif fs_name == 'ФС-2':
logger.info('✅ Состояние генератора %s: Включен' % fs_name)
$Kasseta_FS/ref_A2.state = Constants.STATE_VAL.GOOD
elif fs_name == 'ФС-3':
logger.info('✅ Состояние генератора %s: Включен' % fs_name)
$Kasseta_FS/FS_PRD_K.state = Constants.STATE_VAL.GOOD
else:
if fs_name == 'ФС-1':
@@ -341,7 +350,7 @@ func _on_data_fs(fs_data:PackedByteArray, fs_name: String):
func _on_yau_received(status_yau):
if flag_control_add:
if flag_control_add and flag_continue_control:
# Сбор урожая с УКП-1
var arr_power_ukp_1: Array = []
var numbre_scrape = 7 if Constants.CURRENT_MODE == Constants.MODE.PRD_K else 6
@@ -374,7 +383,7 @@ func _on_yau_received(status_yau):
func _on_yau_feedback_receive(_status_yau):
if logger:
if logger and flag_continue_control:
## Флаг для проверки настройки угла и аттенюации на двух литерах
if Network.unit.isa_ports.has(Constants.BASE_PORTS.UG+6) and Network.unit.isa_ports.has(Constants.BASE_PORTS.UG+8):
if Network.unit.isa_ports[Constants.BASE_PORTS.UG+6] == prep_set_ug and Network.unit.isa_ports[Constants.BASE_PORTS.UG+8] == prep_set_ug:
@@ -404,15 +413,20 @@ func _on_yau_feedback_receive(_status_yau):
if Constants.CURRENT_MODE == Constants.MODE.PRD_K:
if Network.unit.isa_ports.has(Constants.BASE_PORTS.EMS_G+8) and Network.unit.isa_ports.has(Constants.BASE_PORTS.EMS_G+2):
if Network.unit.isa_ports[Constants.BASE_PORTS.EMS_G+2] == Constants.META.MODUL_UM_1:
if Network.unit.isa_ports[Constants.BASE_PORTS.EMS_G+8] == 0x2000:
print('Yes ')
elif Network.unit.isa_ports[Constants.BASE_PORTS.EMS_G+8] == 0x4000:
print('NO')
if Network.unit.isa_ports[Constants.BASE_PORTS.EMS_G+8] == 0x2000 and (not flag_modul_litera_1):
flag_modul_litera_1 = true
logger.info('✅ Модуляция УМ 1 включена!')
elif Network.unit.isa_ports[Constants.BASE_PORTS.EMS_G+8] == 0x4000 and flag_modul_litera_1:
flag_modul_litera_1 = false
logger.info('🛈 Модуляция УМ 1 отключена!')
func _on_start_super_control():
$lbl_control.text = 'Контроль запущен'
$lbl_control.modulate = Color.LIGHT_GRAY
$log_array/await.visible = true
logger = Logger.new(get_node('log_array'))
flag_continue_control = true
if (past_pribor != Constants.CURRENT_MODE):
_draw_control_panel_prd(Constants.CURRENT_MODE)
@@ -435,14 +449,13 @@ func _on_start_super_control():
var TMP_2 = Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_2) * Constants.TEMP + 3
if TMP_1 > 70:
um_cell_ind[i_temperature].value0 = TMP_1
um_cell_ind[i_temperature].state = 2
um_cell_ind[i_temperature].state = Constants.STATE_VAL.ERROR
_on_contol_err()
#timer.start(5)
else:
um_cell_ind[i_temperature].value0 = TMP_1
if TMP_2 > 70:
um_cell_ind[i_temperature+6].value0 = TMP_2
um_cell_ind[i_temperature+6].state = 2
um_cell_ind[i_temperature+6].state = Constants.STATE_VAL.ERROR
_on_contol_err()
else:
um_cell_ind[i_temperature+6].value0 = TMP_2
@@ -477,26 +490,29 @@ func _on_start_super_control():
var fs_att_3: float
if Constants.CURRENT_MODE == Constants.MODE.PRD_H:
fs_freq.append(Constants.FS_FREQ.f2)
fs_att_1 = Constants.FS_ATT.att_1_prd_K1
fs_att_1 = Constants.FS_ATT['ПРД-Н1'][0]
fs_freq.append(Constants.FS_FREQ.f3)
fs_att_2 = Constants.FS_ATT.att_1_prd_K1
fs_att_2 = Constants.FS_ATT['ПРД-Н1'][1]
elif Constants.CURRENT_MODE == Constants.MODE.PRD_B:
fs_freq.append(Constants.FS_FREQ.f4)
fs_att_1 = Constants.FS_ATT['ПРД-В1'][0]
fs_freq.append(Constants.FS_FREQ.f5)
fs_att_2 = Constants.FS_ATT['ПРД-В1'][1]
elif Constants.CURRENT_MODE == Constants.MODE.PRD_K:
fs_freq.append(Constants.FS_FREQ.f6)
fs_att_1 = Constants.FS_ATT.att_1_prd_K1
fs_att_1 = Constants.FS_ATT['ПРД-К1'][0]
fs_freq.append(Constants.FS_FREQ.f7)
fs_att_2 = Constants.FS_ATT.att_2_prd_K1
fs_att_2 = Constants.FS_ATT['ПРД-К1'][1]
fs_freq.append(Constants.FS_FREQ.f1)
fs_att_3 = Constants.FS_ATT.att_3_prd_K1
fs_att_3 = Constants.FS_ATT['ПРД-К1'][2]
fs_3_setup(fs_freq[2], fs_att_3)
logger.info('🛈 Настройка модулей ФС %s Гц, %s, %s АТТ' % [str(fs_freq), str(fs_att_1), str(fs_att_2)])
logger.info('🛈 Настройка модулей ФС %s Гц, [%s / %s / %s] АТТ' % [str(fs_freq), str(fs_att_1), str(fs_att_2), str(fs_att_3)])
fs_1_setup(fs_freq[0], fs_att_1) # Гц
fs_2_setup(fs_freq[1], fs_att_2) # Гц
else:
logger.info('❌ Настройка модулей ФС')
_on_contol_err()
func _status_cell(status):
@@ -511,6 +527,7 @@ func _status_cell(status):
else:
node_cell_ind[i].state = Constants.STATE_VAL.ERROR
logger.error("%s : Нет связи" % node_cell_ind[i].get('fname'))
_on_contol_err()
#dry_contact
if (node_cell_ind[2].state == Constants.STATE_VAL.GOOD):
@@ -526,6 +543,7 @@ func _status_cell(status):
else:
node_cell_ind[i_node].state = Constants.STATE_VAL.ERROR
logger.error("%s : Нет связи" % node_cell_ind[i_node].get('fname'))
_on_contol_err()
if node_cell_ind[3].state == Constants.STATE_VAL.GOOD:
var mask: int = 0x7
@@ -543,6 +561,7 @@ func _status_cell(status):
yau_07b_setup(prep_set_ug)
else:
logger.error('%s: Нет на связи, не буду продолжать' % node_cell_ind[2].get('fname'))
_on_contol_err()
else:
for i_node_unknow in range(5, 13):
@@ -562,16 +581,16 @@ func _on_timer():
func _on_fs_status(META:int):
if logger:
if logger and flag_continue_control:
if META == Constants.META.CI_2_OT_FS or META == Constants.META.CI_4_OT_FS or META == Constants.META.CI_6_OT_FS:
flag_fs_1_ready = true
logger.info('ФС - 1 READY')
logger.info('✅ Состояние генератора ФС-1: Включен')
elif META == Constants.META.CI_3_OT_FS or META == Constants.META.CI_5_OT_FS or META == Constants.META.CI_7_OT_FS:
flag_fs_2_ready = true
logger.info('ФС - 2 READY')
logger.info('✅ Состояние генератора ФС-2: Включен')
elif META == Constants.META.CI_1_OT_FS:
flag_fs_3_ready = true
logger.info('ФС - 3 READY')
logger.info('✅ Состояние генератора ФС-3: Включен')
if flag_fs_1_ready and flag_fs_2_ready:
@@ -676,6 +695,8 @@ func _on_fs_status(META:int):
func _on_modul_um():
if not flag_continue_control:
return
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.MODUL_UM_2)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, 0x8000)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.MODUL_UM_3)
@@ -691,15 +712,16 @@ func _on_modul_um():
func _on_start_timer_03():
count_packet = 0
flag_start = false
flag_control_add = true
timer_03.wait_time = 0.3
timer_03.one_shot = true
count_packet = 0
flag_control_add = true
timer_03.start()
func _on_timer_03():
flag_control_add = false
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.MODUL_UM_2)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, 0x4000)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.MODUL_UM_3)
@@ -716,18 +738,17 @@ func _on_timer_03():
Network.set_fs_gen_status_3(true) ## отключен = true
Network.get_gen_state_3()
flag_control_add = false
await get_tree().create_timer(1.0).timeout
logger.info('Количество принятых пакетов от ЯУ-07Б: %s пкт.' % count_packet)
logger.info('Максимальные значения мощностей от УКП-1: %s ' % str(array_pow_1))
logger.info('Максимальные значения мощности от УКП-2: %s ' % str(array_pow_2))
_on_contol_err()
logger.info('🛈 Количество принятых пакетов от ЯУ-07Б: %s пкт.' % count_packet)
logger.info('🛈 Максимальные значения мощностей от УКП-1: %s ' % str(array_pow_1))
logger.info('🛈 Максимальные значения мощности от УКП-2: %s ' % str(array_pow_2))
_status_prd()
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.CZI_1)
func _on_contol_err():
logger.warning('❌❌❌')
$log_array/await.visible = false
flag_continue_control = false
_status_prd()
#timer.start(5)
@@ -748,8 +769,7 @@ func _status_prd():
var pribor_ispraven: bool = false
var min_dopusk: int = 40
var status_need = count_cell-7 if Constants.CURRENT_MODE != Constants.MODE.PRD_K else count_cell-4
var status_need = count_cell-7 if Constants.CURRENT_MODE != Constants.MODE.PRD_K else count_cell+1
if (status == status_need):
pribor_ispraven = true
@@ -786,8 +806,9 @@ func _status_prd():
array_pow_2 = []
if pribor_ispraven:
$lbl_control.text = 'Прибор %s исправен' % Constants.ADDRESSES[Constants.CURRENT_MODE * 4][0]
$lbl_control.text = 'Прибор %s исправен' % Constants.ADDRESSES[self.get_parent().get_child(0).get_child(1).get_node2(1, 0).get_selected_id()][0]
$lbl_control.modulate = Color.AQUAMARINE
else:
$lbl_control.text = 'Прибор %s неисправен' % Constants.ADDRESSES[Constants.CURRENT_MODE * 4][0]
$lbl_control.text = 'Прибор %s неисправен' % Constants.ADDRESSES[self.get_parent().get_child(0).get_child(1).get_node2(1, 0).get_selected_id()][0]
$lbl_control.modulate = Color.CRIMSON
$log_array/await.visible = false

View File

@@ -79,7 +79,7 @@ func poll_receive_yau07(sock: Socket) -> bool: ## Приёмник
return false
func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: String):
func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: String): ## Приемник ФС
client.poll()
var peer = peerstream.get_stream_peer()
# Проверяем, существует ли соединение
@@ -87,18 +87,11 @@ func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: Strin
emit_signal("port_error", ip_fs)
return
# Проверяем состояние подключения
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
emit_signal("port_fs_closed", ip_fs)
return
# Проверяем состояние подключения
#if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
#if client == client_fs_1:
#emit_signal("port_fs_closed", ip_fs)
#elif client == client_fs_2:
#emit_signal("port_fs_closed", ip_fs)
#elif client == client_fs_3:
#emit_signal("port_fs_closed", ip_fs)
#return
while peer.get_available_bytes() > 0:
var rx_data: PackedByteArray
rx_data.append_array(peer.get_data(peer.get_available_bytes())[1])
@@ -136,7 +129,6 @@ func _ready() -> void:
set_config()
func set_config():
write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.CI_2_B_UF)
read_port_isa([Constants.BASE_PORTS.EMS_G+8])
@@ -151,13 +143,13 @@ func set_config():
connect_fs_1()
connect_fs_2()
connect_fs_3()
start_work_fs()
start_work_fs_2()
start_work_fs_3()
start_work_fs_1(Constants.ADDRESSES[0][0])
start_work_fs_2(Constants.ADDRESSES[0][0])
if Constants.CURRENT_MODE == Constants.MODE.PRD_K:
start_work_fs_3(Constants.ADDRESSES[0][0])
func _process(delta: float) -> void:
last_update_time_yau07 += delta
last_update_time_fs += delta
@@ -197,9 +189,10 @@ func state_machine_yau07():
## Режим записи в ИСА
Constants.STATE.WRITE_ISA:
if fl_done:
var ports_write = send_array.pop_front()
var key = ports_write[1].keys()
unit.send_isa(unit.CmdCode.WRITE_ISA, [key[0], ports_write[1][key[0]]])
var ports_write: Array = send_array.pop_front()
if ports_write[0] == 'wr':
var key = ports_write[1].keys()
unit.send_isa(unit.CmdCode.WRITE_ISA, [key[0], ports_write[1][key[0]]])
state = Constants.STATE.WAIT
Constants.STATE.DONE:
if fl_done:
@@ -278,7 +271,7 @@ func connect_fs_1():
peerstream_fs_1.set_stream_peer(client_fs_1)
func start_work_fs():
func start_work_fs_1(currecnt_mode_att):
counter_fs_1 = 0
unit_fs.start_session(counter_fs_1, client_fs_1)
counter_fs_1 += 1
@@ -292,11 +285,13 @@ func start_work_fs():
var set_freq = Constants.FS_FREQ.f2 if Constants.CURRENT_MODE == Constants.MODE.PRD_H else Constants.FS_FREQ.f4 if Constants.CURRENT_MODE == Constants.MODE.PRD_B else Constants.FS_FREQ.f6
unit_fs.set_carrier(set_freq * 1_000_000, counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.set_att_batch(Constants.FS_ATT.att_1_prd_H1, counter_fs_1, client_fs_1)
unit_fs.set_att_batch(Constants.FS_ATT[currecnt_mode_att][0], counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.set_base_can_macro(set_freq, counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.get_att_batch(counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.get_carrier(counter_fs_1, client_fs_1)
@@ -379,7 +374,7 @@ func connect_fs_2():
peerstream_fs_2.set_stream_peer(client_fs_2)
func start_work_fs_2():
func start_work_fs_2(currecnt_mode_att):
counter_fs_2 = 0
unit_fs.start_session(counter_fs_2, client_fs_2)
counter_fs_2 += 1
@@ -395,7 +390,8 @@ func start_work_fs_2():
var set_freq = Constants.FS_FREQ.f3 if Constants.CURRENT_MODE == Constants.MODE.PRD_H else Constants.FS_FREQ.f5 if Constants.CURRENT_MODE == Constants.MODE.PRD_B else Constants.FS_FREQ.f7
unit_fs.set_carrier(set_freq * 1_000_000, counter_fs_2, client_fs_2)
counter_fs_2 += 1
unit_fs.set_att_batch(Constants.FS_ATT.att_2_prd_H1, counter_fs_2, client_fs_2)
unit_fs.set_att_batch(Constants.FS_ATT[currecnt_mode_att][1], counter_fs_2, client_fs_2)
counter_fs_2 += 1
unit_fs.set_base_can_macro(set_freq, counter_fs_2, client_fs_2)
counter_fs_2 += 1
@@ -486,7 +482,7 @@ func connect_fs_3():
peerstream_fs_3.set_stream_peer(client_fs_3)
func start_work_fs_3():
func start_work_fs_3(currecnt_mode_att):
counter_fs_3 = 0
unit_fs.start_session(counter_fs_3, client_fs_3)
counter_fs_3 += 1
@@ -500,8 +496,10 @@ func start_work_fs_3():
var set_freq = Constants.FS_FREQ.f1
unit_fs.set_carrier(set_freq * 1_000_000, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.set_att_batch(Constants.FS_ATT.att_3_prd_K1, counter_fs_3, client_fs_3)
unit_fs.set_att_batch(Constants.FS_ATT[currecnt_mode_att][2], counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.set_base_can_macro(set_freq, counter_fs_3, client_fs_3)
counter_fs_3 += 1