672 lines
31 KiB
GDScript
672 lines
31 KiB
GDScript
extends Node2D
|
||
|
||
signal read_ems_g_start()
|
||
signal read_ems_g_finish()
|
||
|
||
var flag_mode = Constants.ADDRESSES[0][3]
|
||
var broadcast_packet: PackedByteArray
|
||
var node_select1: Node
|
||
var node_select2: Node
|
||
var CONTROL_TABLE: Array
|
||
var isa_from_yau07b: Dictionary = {}
|
||
var JSOON = JSON.new()
|
||
var status_pribor = null
|
||
var save_path = "D://PRD-TU-MP550//"
|
||
var need_port: Array = [
|
||
0x122,
|
||
0x124,
|
||
0x126,
|
||
0x128,
|
||
0x12A
|
||
]
|
||
|
||
func _ready() -> void:
|
||
# Считывание аргументов с консоли (путь сохранения)
|
||
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
|
||
node_select1 = $TabContainer/PRD/body_grid/litera_2_4_6/table_ukp_1
|
||
draw_tabl(node_select1, Constants.ROWS_REGS_DATA, Constants.ROWS_REGS_DATA.size())
|
||
node_select1.set_columns_min_size([120, 120])
|
||
node_select1.set_node_text(0, 0, 'Мощность')
|
||
node_select1.set_node_text(1, 0, 'Температура')
|
||
|
||
# Таблица УКП_2
|
||
node_select2 = $TabContainer/PRD/body_grid/litera_3_5_7/table_ukp_2
|
||
draw_tabl(node_select2, Constants.ROWS_REGS_DATA, Constants.ROWS_REGS_DATA.size())
|
||
node_select2.set_columns_min_size([120, 120])
|
||
node_select2.set_node_text(0, 0, 'Мощность')
|
||
node_select2.set_node_text(1, 0, 'Температура')
|
||
|
||
# Таблица ЯУ-07б
|
||
var node_select_yau_07b = $TabContainer/PRD/body_grid/litera_2_4_6/yau07b_control
|
||
draw_tabl(node_select_yau_07b, Constants.ROWS_YAU_07B_1, Constants.ROWS_YAU_07B_1.size())
|
||
node_select_yau_07b.set_columns_min_size([160, 120])
|
||
node_select_yau_07b.set_node_text(0, 0, 'ПРД-Н')
|
||
node_select_yau_07b.set_node_text(1, 0, 'Литера 2')
|
||
node_select_yau_07b.set_node_text(0, 1, 'Запрет СИ 2')
|
||
node_select_yau_07b.set_node_text(0, 2, 'Модуляция УМ')
|
||
node_select_yau_07b.set_node_text(0, 3, 'Положение луча')
|
||
node_select_yau_07b.set_node_text(0, 4, 'Аттенюатор УМ')
|
||
node_select_yau_07b.set_node_text(0, 6, 'СИ 2 в УФ')
|
||
node_select_yau_07b.set_node_text(0, 7, 'СЗИ 2 от УФ')
|
||
|
||
var node_select_yau_07b_2 = $TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control
|
||
draw_tabl(node_select_yau_07b_2, Constants.ROWS_YAU_07B_2, Constants.ROWS_YAU_07B_2.size())
|
||
node_select_yau_07b_2.set_columns_min_size([160, 120])
|
||
node_select_yau_07b_2.set_node_text(0, 0, 'ПРД-Н')
|
||
node_select_yau_07b_2.set_node_text(1, 0, 'Литера 3')
|
||
node_select_yau_07b_2.set_node_text(0, 1, 'Запрет СИ 3')
|
||
node_select_yau_07b_2.set_node_text(0, 2, 'Модуляция УМ')
|
||
node_select_yau_07b_2.set_node_text(0, 3, 'Положение луча')
|
||
node_select_yau_07b_2.set_node_text(0, 4, 'Аттенюатор УМ')
|
||
node_select_yau_07b_2.set_node_text(0, 5, 'ФГОЗ 3')
|
||
node_select_yau_07b_2.set_node_text(0, 6, 'СИ 3 в УФ')
|
||
node_select_yau_07b_2.set_node_text(0, 7, 'СЗИ 3 от УФ')
|
||
|
||
#Таблица ФС
|
||
var node_select_fs_1 = $TabContainer/PRD/body_grid/litera_2_4_6/fs_control
|
||
draw_tabl(node_select_fs_1, Constants.ROWS_FS, Constants.ROWS_FS.size())
|
||
node_select_fs_1.set_columns_min_size([150, 120, 150])
|
||
node_select_fs_1.set_node_text(0, 0, 'Модуль ФС')
|
||
node_select_fs_1.set_node_text(1, 0, 'Литера 2')
|
||
node_select_fs_1.set_node_text(0, 1, 'Состояние')
|
||
node_select_fs_1.set_node_text(0, 2, 'Частота')
|
||
node_select_fs_1.get_node2(1, 2).placeholder_text = 'в МГц'
|
||
node_select_fs_1.get_node2(1, 2).editable = true
|
||
node_select_fs_1.set_node_text(0, 3, 'Аттенюатор')
|
||
node_select_fs_1.get_node2(1, 3).placeholder_text = 'в dB'
|
||
node_select_fs_1.get_node2(1, 3).editable = true
|
||
node_select_fs_1.set_node_text(0, 4, 'Модуляция')
|
||
node_select_fs_1.get_node2(1, 4).add_item('Const')
|
||
node_select_fs_1.get_node2(1, 4).add_item('MSK')
|
||
node_select_fs_1.set_node_text(0, 5, 'Генератор ФС')
|
||
node_select_fs_1.set_node_text(0, 6, 'СИ 2 от ФС')
|
||
node_select_fs_1.set_node_text(0, 7, 'Фильтр CAN')
|
||
node_select_fs_1.get_node2(1, 7).placeholder_text = 'в МГц'
|
||
node_select_fs_1.get_node2(1, 7).editable = true
|
||
node_select_fs_1.set_node_text(0, 8, 'Статус CAN')
|
||
|
||
var node_select_fs_2 = $TabContainer/PRD/body_grid/litera_3_5_7/fs_control
|
||
draw_tabl(node_select_fs_2, Constants.ROWS_FS, Constants.ROWS_FS.size())
|
||
node_select_fs_2.set_columns_min_size([150, 120, 150])
|
||
node_select_fs_2.set_node_text(0, 0, 'Модуль ФС')
|
||
node_select_fs_2.set_node_text(1, 0, 'Литера 3')
|
||
node_select_fs_2.set_node_text(0, 1, 'Состояние')
|
||
node_select_fs_2.set_node_text(0, 2, 'Частота ФС')
|
||
node_select_fs_2.get_node2(1, 2).placeholder_text = 'в МГц'
|
||
node_select_fs_2.get_node2(1, 2).editable = true
|
||
node_select_fs_2.set_node_text(0, 3, 'Аттенюатор ФС')
|
||
node_select_fs_2.get_node2(1, 3).placeholder_text = 'в dB'
|
||
node_select_fs_2.get_node2(1, 3).editable = true
|
||
node_select_fs_2.set_node_text(0, 4, 'Модуляция')
|
||
node_select_fs_2.get_node2(1, 4).add_item('Const')
|
||
node_select_fs_2.get_node2(1, 4).add_item('MSK')
|
||
node_select_fs_2.set_node_text(0, 5, 'Генератор ФС')
|
||
node_select_fs_2.set_node_text(0, 6, 'СИ 3 от ФС')
|
||
node_select_fs_2.set_node_text(0, 7, 'Фильтр CAN')
|
||
node_select_fs_2.get_node2(1, 7).placeholder_text = 'в МГц'
|
||
node_select_fs_2.get_node2(1, 7).editable = true
|
||
node_select_fs_2.set_node_text(0, 8, 'Статус CAN')
|
||
|
||
# Выбор прибора для подключения
|
||
var node_select_device = $TabContainer/PRD/select_dev
|
||
draw_tabl(node_select_device, Constants.SELECT_DEVICE, Constants.SELECT_DEVICE.size())
|
||
var get_select_device = node_select_device.get_node2(1, 0)
|
||
get_select_device.connect('item_selected', Callable(self, 'on_device_selected'))
|
||
|
||
# Заполнение адресов
|
||
for i_addr in Constants.ADDRESSES.size():
|
||
get_select_device.add_item(Constants.ADDRESSES[i_addr][0])
|
||
get_select_device.set_item_metadata(i_addr, Constants.ADDRESSES[i_addr].slice(1,7))
|
||
get_select_device.connect('item_selected', Callable(self, 'on_btn_select'))
|
||
node_select_device.get_node2(0,0).text = 'ПРИБОР'
|
||
node_select_device.set_columns_min_size([100, 100])
|
||
|
||
# Получение выбранного прибора при загрузке
|
||
if Constants.ADDRESSES.size() > 0:
|
||
get_select_device.select(0)
|
||
status_pribor = get_select_device.get_item_text(0).strip_edges().substr(4)
|
||
|
||
## Заполненение списка модуляции УМ
|
||
for key in Constants.OUT_x128:
|
||
node_select_yau_07b.get_node2(1, 2).add_item(key)
|
||
node_select_yau_07b_2.get_node2(1, 2).add_item(key)
|
||
|
||
## Заполненение списка направления луча
|
||
for key in Constants.RAY_DICT:
|
||
node_select_yau_07b.get_node2(1, 3).add_item(key)
|
||
node_select_yau_07b_2.get_node2(1, 3).add_item(key)
|
||
|
||
## Заполненение списка аттенюатора
|
||
for key in Constants.ATT_DICT:
|
||
node_select_yau_07b.get_node2(1, 4).add_item(key)
|
||
node_select_yau_07b_2.get_node2(1, 4).add_item(key)
|
||
|
||
Network.connect('yau_status_line', Callable(self, '_on_yau_status'))
|
||
Network.connect('yau_receive', Callable(self, '_on_data_received'))
|
||
Network.connect('yau_read_isa', Callable(self, '_on_read_isa'))
|
||
Network.connect('port_fs_opened_1', _on_port_changed_fs_1.bind(Color.AQUAMARINE))
|
||
Network.connect('port_fs_closed_1', _on_port_changed_fs_1.bind(Color.CRIMSON))
|
||
Network.connect('port_fs_opened_2', _on_port_changed_fs_2.bind(Color.AQUAMARINE))
|
||
Network.connect('port_fs_closed_2', _on_port_changed_fs_2.bind(Color.CRIMSON))
|
||
Network.connect('data_from_fs_1', _on_data_fs_1)
|
||
Network.connect('data_from_fs_2', _on_data_fs_2)
|
||
|
||
## Yau-07b 1
|
||
node_select_yau_07b.get_node2(1, 1).get_child(1, false).connect('toggled', Callable(self, '_on_zapret1'))
|
||
node_select_yau_07b.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um_1'))
|
||
node_select_yau_07b.get_node2(1, 3).connect('item_selected', Callable(self, '_on_btn_ray_1'))
|
||
node_select_yau_07b.get_node2(1, 4).connect('item_selected', Callable(self, '_on_attenuator_1'))
|
||
## Yau-07b 2
|
||
node_select_yau_07b_2.get_node2(1, 1).get_child(1, false).connect('toggled', Callable(self, '_on_zapret2'))
|
||
node_select_yau_07b_2.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um_2'))
|
||
node_select_yau_07b_2.get_node2(1, 3).connect('item_selected', Callable(self, '_on_btn_ray_2'))
|
||
node_select_yau_07b_2.get_node2(1, 4).connect('item_selected', Callable(self, '_on_attenuator_2'))
|
||
node_select_yau_07b_2.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_fgos_2'))
|
||
## FS 1
|
||
node_select_fs_1.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_1'))
|
||
node_select_fs_1.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_1'))
|
||
node_select_fs_1.get_node2(1, 4).connect('item_selected', Callable(self, '_on_modul_fs_1'))
|
||
node_select_fs_1.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_get_status_1'))
|
||
node_select_fs_1.get_node2(1, 7).connect('text_submitted', Callable(self, '_on_set_base_can_macro'))
|
||
node_select_fs_1.get_node2(1, 8).get_child(1, false).connect('toggled', Callable(self, '_on_status_can_macro_1'))
|
||
## FS 2
|
||
node_select_fs_2.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_2'))
|
||
node_select_fs_2.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_2'))
|
||
node_select_fs_2.get_node2(1, 4).connect('item_selected', Callable(self, '_on_modul_fs_2'))
|
||
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'))
|
||
|
||
|
||
func on_device_selected(selected_index: int) -> void:
|
||
var get_select_device = $TabContainer/PRD/select_dev.get_node2(1, 0)
|
||
status_pribor = get_select_device.get_item_text(selected_index).strip_edges().substr(4)
|
||
|
||
|
||
func _on_read_isa(unit_isa_ports: Dictionary) -> void:
|
||
isa_from_yau07b = unit_isa_ports
|
||
var isa_data: Dictionary = {}
|
||
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)
|
||
|
||
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])
|
||
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))
|
||
|
||
$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)))
|
||
|
||
if isa_data.has(Constants.BASE_PORTS.UG+6):
|
||
if (isa_data[Constants.BASE_PORTS.UG+6] & 0x7) < 7:
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/yau07b_control.get_node2(1, 3).select(isa_data[Constants.BASE_PORTS.UG+6] & 0x7)
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/yau07b_control.get_node2(1, 4).select((isa_data[Constants.BASE_PORTS.UG+6] & 0x38)>> 3)
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/PSK/ray_1.material.set('shader_parameter/turn', 0.735 + 0.025 * (isa_data[Constants.BASE_PORTS.UG+6] & 0x7))
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/PSK/ray_1.material.set('shader_parameter/inner_radius', 0.8 - 0.01 * (isa_data[Constants.BASE_PORTS.UG+6] & 0x38))
|
||
if isa_data.has(Constants.BASE_PORTS.UG+8):
|
||
if (isa_data[Constants.BASE_PORTS.UG+8] & 0x7) < 7:
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control.get_node2(1, 3).select(isa_data[Constants.BASE_PORTS.UG+8] & 0x7)
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control.get_node2(1, 4).select((isa_data[Constants.BASE_PORTS.UG+8] & 0x38)>>3)
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/PSK2/ray_2.material.set('shader_parameter/turn', 0.735 + 0.025 * (isa_data[Constants.BASE_PORTS.UG+8] & 0x7))
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/PSK2/ray_2.material.set('shader_parameter/inner_radius', 0.8 - 0.01 * (isa_data[Constants.BASE_PORTS.UG+8] & 0x38))
|
||
|
||
for index in Constants.EMS_G_PORT_DATA_HOLDER.size():
|
||
var tmp_device_mode = Constants.EMS_G_PORT_DATA_HOLDER[index][0]
|
||
if tmp_device_mode == 48:
|
||
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_2_4_6/yau07b_control.get_node2(1,1).get_child(1).button_pressed = data_dict[Constants.BASE_PORTS.EMS_G+8] >> 14
|
||
if tmp_device_mode == 49:
|
||
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 == 51:
|
||
var data_dict = Constants.EMS_G_PORT_DATA_HOLDER[index][1]
|
||
if Constants.BASE_PORTS.EMS_G+8 in data_dict:
|
||
var select = data_dict[Constants.BASE_PORTS.EMS_G+8] >> 13 if data_dict[Constants.BASE_PORTS.EMS_G+8] >> 13 < 3 else 3
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/yau07b_control.get_node2(1,2).select(select)
|
||
if tmp_device_mode == 52:
|
||
var data_dict = Constants.EMS_G_PORT_DATA_HOLDER[index][1]
|
||
if Constants.BASE_PORTS.EMS_G+8 in data_dict:
|
||
var select = data_dict[Constants.BASE_PORTS.EMS_G+8] >> 13 if data_dict[Constants.BASE_PORTS.EMS_G+8] >> 13 < 3 else 3
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control.get_node2(1,2).select(select)
|
||
if tmp_device_mode == 56:
|
||
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,5).get_child(1).button_pressed = data_dict[Constants.BASE_PORTS.EMS_G+8] >> 13
|
||
|
||
|
||
func _on_data_fs_1(fs_1_data):
|
||
var node_select_fs_1: GDTable = $TabContainer/PRD/body_grid/litera_2_4_6/fs_control
|
||
var GRP = fs_1_data.decode_u8(0x0)
|
||
var CMD = fs_1_data.decode_u8(0x1)
|
||
match CMD:
|
||
Constants.CMD.READ_CARRIER:
|
||
if GRP == Constants.GROUP.BASE:
|
||
node_select_fs_1.set_node_text(2, 2, str(fs_1_data.decode_u64(0xC) / 1_000_000) + ' МГц')
|
||
Constants.CMD.READ_ATT:
|
||
if GRP == Constants.GROUP.RF:
|
||
node_select_fs_1.set_node_text(2, 3, str(fs_1_data.decode_float(0x18)) + ' dB')
|
||
Constants.CMD.READ_GEN_STATUS:
|
||
if GRP == Constants.GROUP.GENERATOR:
|
||
if fs_1_data.decode_u32(0xC) == 0:
|
||
node_select_fs_1.set_node_text(2, 5, 'Включен')
|
||
node_select_fs_1.get_node2(2, 5).modulate = Color.AQUAMARINE
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/PSK/ray_1.material.set('shader_parameter/speed', 2.5)
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/fs_control.get_node2(1, 5).get_child(1).button_pressed = true
|
||
else:
|
||
node_select_fs_1.set_node_text(2, 5, 'Отключен')
|
||
node_select_fs_1.get_node2(2, 5).modulate = Color.CRIMSON
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/PSK/ray_1.material.set('shader_parameter/speed', 0.0)
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/fs_control.get_node2(1, 5).get_child(1).button_pressed = false
|
||
Constants.CMD.BASE_GET_CURRENT_TEMP:
|
||
if GRP == Constants.GROUP.BASE:
|
||
node_select_fs_1.set_node_text(2, 0, '%.2f' % fs_1_data.decode_float(0xC) + ' °C')
|
||
Constants.CMD.BASE_CAN_MACRO_READ:
|
||
if GRP == Constants.GROUP.BASE:
|
||
node_select_fs_1.set_node_text(2, 7, str(fs_1_data.decode_u16(0x20)) + ' МГц')
|
||
|
||
|
||
func _on_data_fs_2(fs_2_data):
|
||
var node_select_fs_2: GDTable = $TabContainer/PRD/body_grid/litera_3_5_7/fs_control
|
||
var GRP = fs_2_data.decode_u8(0x0)
|
||
var CMD = fs_2_data.decode_u8(0x1)
|
||
match CMD:
|
||
Constants.CMD.READ_CARRIER:
|
||
if GRP == Constants.GROUP.BASE:
|
||
node_select_fs_2.set_node_text(2, 2, str(fs_2_data.decode_u64(0xC) / 1_000_000) + ' МГц')
|
||
Constants.CMD.READ_ATT:
|
||
if GRP == Constants.GROUP.RF:
|
||
node_select_fs_2.set_node_text(2, 3, str(fs_2_data.decode_float(0x18)) + ' dB')
|
||
Constants.CMD.READ_GEN_STATUS:
|
||
if GRP == Constants.GROUP.GENERATOR:
|
||
if fs_2_data.decode_u32(0xC) == 0:
|
||
node_select_fs_2.set_node_text(2, 5, 'Включен')
|
||
node_select_fs_2.get_node2(2, 5).modulate = Color.AQUAMARINE
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/PSK2/ray_2.material.set('shader_parameter/speed', 2.5)
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/fs_control.get_node2(1, 5).get_child(1).button_pressed = true
|
||
else:
|
||
node_select_fs_2.set_node_text(2, 5, 'Отключен')
|
||
node_select_fs_2.get_node2(2, 5).modulate = Color.CRIMSON
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/PSK2/ray_2.material.set('shader_parameter/speed', 0.0)
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/fs_control.get_node2(1, 5).get_child(1).button_pressed = false
|
||
Constants.CMD.BASE_GET_CURRENT_TEMP:
|
||
if GRP == Constants.GROUP.BASE:
|
||
node_select_fs_2.set_node_text(2, 0, '%.2f' % fs_2_data.decode_float(0xC) + ' °C')
|
||
Constants.CMD.BASE_CAN_MACRO_READ:
|
||
if GRP == Constants.GROUP.BASE:
|
||
node_select_fs_2.set_node_text(2, 7, str(fs_2_data.decode_u16(0x20)) + ' МГц')
|
||
|
||
|
||
## Рисует таблицу
|
||
func draw_tabl(tbl: Node, row: Array, count_row: int):
|
||
for i_row in count_row:
|
||
tbl.add_row(row[i_row])
|
||
|
||
|
||
func _on_data_received(data_from_yau_07):
|
||
## УКП
|
||
for i in range(6): ## Мощность от УКП_1
|
||
var power_ukp_1 = data_from_yau_07.decode_u16(Constants.DataIndices.POWER_UKP_1 + 2 * i)
|
||
node_select1.set_node_text(0, i+1, '%d' % power_ukp_1)
|
||
|
||
for i in range(6): ## Температура от УКП_1
|
||
var temperature_ukp_1 = data_from_yau_07.decode_u16(Constants.DataIndices.TEMPERATURE_UKP_1 + 2 * i)
|
||
var TMP = Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_1) * Constants.TEMP
|
||
node_select1.set_node_text(1, i+1, '%d °С' % TMP)
|
||
|
||
for i_pow in range(6): ## Мощность от УКП_2
|
||
if len(data_from_yau_07) > Constants.DataIndices.POWER_UKP_2 + 2 * i_pow:
|
||
var power_ukp_2 = data_from_yau_07.decode_u16(Constants.DataIndices.POWER_UKP_2 + 2 * i_pow)
|
||
node_select2.set_node_text(0, i_pow+1, '%d' % power_ukp_2)
|
||
|
||
for row in range(6): ## Температура от УКП_2
|
||
if len(data_from_yau_07) > Constants.DataIndices.TEMPERATURE_UKP_2 + 2 * row:
|
||
var temperature_ukp_2 = data_from_yau_07.decode_u16(Constants.DataIndices.TEMPERATURE_UKP_2 + 2 * row)
|
||
var TMP = Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_2) * Constants.TEMP
|
||
node_select2.set_node_text(1, row+1, '%d °С' % TMP)
|
||
|
||
|
||
func set_frame(node: Node, val: int): node.set_frame(val)
|
||
|
||
|
||
func _on_prd_select() -> void:
|
||
set_tab_and_buttons(0, 'select_prd')
|
||
|
||
|
||
func _on_control_button() -> void:
|
||
$TabContainer/ControlPanel._on_start_super_control()
|
||
set_tab_and_buttons(1, 'select_control')
|
||
|
||
|
||
func _on_emsg_select() -> void:
|
||
emit_signal('read_ems_g_start')
|
||
set_tab_and_buttons(2, 'select_ems_g')
|
||
|
||
|
||
func _on_mfs_select() -> void:
|
||
set_tab_and_buttons(3, 'select_fs')
|
||
|
||
|
||
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)
|
||
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.connect("file_selected", Callable(self, "_save_selected_file"))
|
||
add_child(file_dialog)
|
||
file_dialog.popup_centered()
|
||
|
||
|
||
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 = {}
|
||
regist[0x122] = item[0]
|
||
for key in item[1]:
|
||
if key in need_port:
|
||
regist[key] = item[1][key]
|
||
else:
|
||
other_data[key] = item[1]
|
||
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)
|
||
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
|
||
|
||
|
||
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
|
||
add_child(file_dialog)
|
||
file_dialog.popup_centered()
|
||
|
||
|
||
func set_tab_and_buttons(tab_index: int, button_name: String) -> void:
|
||
$TabContainer.current_tab = tab_index
|
||
var side_panel = $Background/side_panel
|
||
|
||
for button in side_panel.get_children():
|
||
if button is Button:
|
||
button.button_pressed = (button.name == button_name)
|
||
|
||
|
||
func on_btn_select(intem_from_sector: int) -> void:
|
||
Network.send_array = []
|
||
var node_select_device: GDTable = $TabContainer/PRD/select_dev
|
||
var get_select_device = node_select_device.get_node2(1, 0)
|
||
var meta = get_select_device.get_item_metadata(intem_from_sector)
|
||
Constants.CURRENT_MODE = meta[2]
|
||
Network.on_command_change_device(meta)
|
||
Network.read_port_isa([Constants.BASE_PORTS.UG+8, Constants.BASE_PORTS.UG+6])
|
||
_on_start_fs_1()
|
||
_on_start_fs_2()
|
||
|
||
|
||
func _on_zapret1(toggled_on: bool) -> void:
|
||
var meta = 48
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
|
||
var zapret_mode = 0x4000 if toggled_on else 0x0
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, zapret_mode)
|
||
|
||
|
||
func _on_zapret2(toggled_on: bool) -> void:
|
||
var meta = 49
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
|
||
var zapret_mode = 0x4000 if toggled_on else 0x0
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, zapret_mode)
|
||
|
||
|
||
func _on_modul_um_1(item_from_ray_1: int):
|
||
var meta = 51
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
|
||
var modul_um_values = {
|
||
1: 0x2000,
|
||
2: 0x4000,
|
||
3: 0x8000
|
||
}
|
||
|
||
var modul_um = modul_um_values.get(item_from_ray_1, 0)
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
|
||
|
||
|
||
func _on_modul_um_2(item_from_ray_1: int):
|
||
var meta = 52
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
|
||
var modul_um_values = {
|
||
1: 0x2000,
|
||
2: 0x4000,
|
||
3: 0x8000,
|
||
}
|
||
var modul_um = modul_um_values.get(item_from_ray_1, 0)
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
|
||
|
||
|
||
## Включение/отключение сигнала ФГОЗ
|
||
func _on_fgos_2(toggled_on: bool):
|
||
var meta = 56
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
|
||
var modul_um = 0x2000 if toggled_on else 0x0
|
||
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
|
||
|
||
|
||
## Регулировка положением луча 1
|
||
func _on_btn_ray_1(item_from_ray_1: int) -> void:
|
||
if isa_from_yau07b.has(Constants.BASE_PORTS.UG+6):
|
||
var mask = 0x7
|
||
Network.write_port_isa(Constants.BASE_PORTS.UG+6, set_bits(isa_from_yau07b[Constants.BASE_PORTS.UG+6], item_from_ray_1, mask))
|
||
Network.read_port_isa([Constants.BASE_PORTS.UG+6])
|
||
else:
|
||
print_debug('В ISA отсутствует данные в \"%x\" порту' % (Constants.BASE_PORTS.UG+0x6))
|
||
|
||
|
||
## Регулировка положением луча 2
|
||
func _on_btn_ray_2(item_from_ray_2: int) -> void:
|
||
if isa_from_yau07b.has(Constants.BASE_PORTS.UG+8):
|
||
var mask = 0x7
|
||
Network.write_port_isa(Constants.BASE_PORTS.UG+8, set_bits(isa_from_yau07b[Constants.BASE_PORTS.UG+8], item_from_ray_2, mask))
|
||
Network.read_port_isa([Constants.BASE_PORTS.UG+8])
|
||
else:
|
||
print_debug('В ISA отсутствует данные в \"%x\" порту' % (Constants.BASE_PORTS.UG+0x8))
|
||
|
||
|
||
## Регулировка аттенюатора луча 1
|
||
func _on_attenuator_1(item_from_att_1: int) -> void:
|
||
if isa_from_yau07b.has(Constants.BASE_PORTS.UG+6):
|
||
var mask = 0x38
|
||
Network.write_port_isa(Constants.BASE_PORTS.UG+6, set_bits(isa_from_yau07b[Constants.BASE_PORTS.UG+6], item_from_att_1 << 3, mask))
|
||
Network.read_port_isa([Constants.BASE_PORTS.UG+6])
|
||
else:
|
||
print_debug('В ISA отсутствует данные в \"%x\" порту' % (Constants.BASE_PORTS.UG+0x6))
|
||
|
||
|
||
## Регулировка аттенюатора луча 2
|
||
func _on_attenuator_2(item_from_att_1: int) -> void:
|
||
if isa_from_yau07b.has(Constants.BASE_PORTS.UG+8):
|
||
var mask = 0x38
|
||
Network.write_port_isa(Constants.BASE_PORTS.UG+8, set_bits(isa_from_yau07b[Constants.BASE_PORTS.UG+8], item_from_att_1 << 3, mask))
|
||
Network.read_port_isa([Constants.BASE_PORTS.UG+8])
|
||
else:
|
||
print_debug('В ISA отсутствует данные в \"%x\" порту' % (Constants.BASE_PORTS.UG+0x8))
|
||
|
||
|
||
func _on_read_isa_pressed() -> void:
|
||
Network.read_port_isa([Constants.BASE_PORTS.EMS_G+2, Constants.BASE_PORTS.EMS_G+4, Constants.BASE_PORTS.EMS_G+8])
|
||
|
||
|
||
## Устанавливает биты в соответствии с маской
|
||
## [param v] - Прежние значения бит
|
||
## [param a] - Новые значения бит
|
||
## [param m] - Маска изменяемых бит
|
||
func set_bits(v, a, m):
|
||
return (~m) & v | a & m
|
||
|
||
|
||
## 1 ФС
|
||
func _on_port_changed_fs_1(port_name: String, color: Color) -> void:
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/fs_control.set_node_text(1, 1, port_name)
|
||
$TabContainer/PRD/body_grid/litera_2_4_6/fs_control.get_node2(1,1).modulate = color
|
||
|
||
|
||
func _on_start_fs_1():
|
||
Network.start_work_fs()
|
||
|
||
|
||
func _on_modul_fs_1(modulation_select_1) -> void:
|
||
if modulation_select_1 == 0:
|
||
Network.set_configure_gen_const_1()
|
||
elif modulation_select_1 == 1:
|
||
Network.set_configure_gen_msk_1()
|
||
|
||
|
||
func _on_get_status_1(toggled_btn):
|
||
var inverted_state = not toggled_btn
|
||
Network.get_fs_gen_status(inverted_state)
|
||
|
||
|
||
func _on_set_ferq_1(freq: String):
|
||
# Проверка на наличие символов в строке freq
|
||
var regex = RegEx.new()
|
||
regex.compile("^[0-9]+$")
|
||
if not regex.search(freq):
|
||
print_debug('Ошибка: частота должна быть числом без букв')
|
||
return
|
||
# Преобразование строки в число
|
||
var freq_int = int(freq) * 1_000_000
|
||
|
||
# Проверка на диапазон
|
||
if freq_int < 370 * 1_000_000 or freq_int > 6100 * 1_000_000:
|
||
print_debug('Некорректная частота')
|
||
return
|
||
|
||
Network.set_fs_ferq_carrier(freq_int)
|
||
|
||
|
||
func _on_set_att_1(att: String):
|
||
Network.set_fs_attenuation(float(att))
|
||
|
||
|
||
func _on_set_base_can_macro(can_freq: String):
|
||
Network.set_can_macro(int(can_freq))
|
||
|
||
|
||
func _on_status_can_macro_1(toggled_btn: bool):
|
||
Network.status_can_macro_1(toggled_btn)
|
||
|
||
|
||
## 2 ФС
|
||
func _on_port_changed_fs_2(port_name: String, color: Color) -> void:
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/fs_control.set_node_text(1, 1, port_name)
|
||
$TabContainer/PRD/body_grid/litera_3_5_7/fs_control.get_node2(1, 1).modulate = color
|
||
|
||
|
||
func _on_start_fs_2():
|
||
Network.start_work_fs_2()
|
||
|
||
|
||
func _on_get_status_2(toggled_btn):
|
||
var inverted_state = not toggled_btn
|
||
Network.get_fs_gen_status_2(inverted_state)
|
||
|
||
|
||
func _on_set_ferq_2(freq: String):
|
||
# Проверка на наличие символов в строке freq
|
||
var regex = RegEx.new()
|
||
regex.compile("^[0-9]+$")
|
||
if not regex.search(freq):
|
||
print_debug('Ошибка: частота должна быть числом без букв')
|
||
return
|
||
# Преобразование строки в число
|
||
var freq_int = int(freq) * 1_000_000
|
||
|
||
# Проверка на диапазон
|
||
if freq_int < 370 * 1_000_000 or freq_int > 6100 * 1_000_000:
|
||
print_debug('Некорректная частота')
|
||
return
|
||
Network.set_fs_ferq_carrier_2(freq_int)
|
||
|
||
|
||
func _on_set_att_2(att: String):
|
||
Network.set_fs_attenuation_2(float(att))
|
||
|
||
|
||
func _on_set_base_can_macro_2(can_freq: String):
|
||
Network.set_can_macro_2(int(can_freq))
|
||
|
||
|
||
func _on_status_can_macro_2(toggled_btn: bool):
|
||
Network.status_can_macro_2(toggled_btn)
|
||
|
||
|
||
func _on_modul_fs_2(modulation_select_2) -> void:
|
||
if modulation_select_2 == 0:
|
||
Network.set_configure_gen_const_2()
|
||
elif modulation_select_2 == 1:
|
||
Network.set_configure_gen_msk_2()
|