@@ -33,13 +33,6 @@ func _ready() -> void:
$ Background / notice / bind_addr . text = ' /Базовый адресс: %s ' % Constants . UNICAST_ADDRESS
$ Background / notice / bind_port . text = ' /Базовый порт: %s ' % Constants . UNICAST_PORT
# Считывание аргументов с консоли (путь сохранения)
#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
draw_tabl ( node_select1 , Constants . ROWS_REGS_DATA , Constants . ROWS_REGS_DATA . size ( ) )
@@ -325,6 +318,17 @@ func add_signs_scene():
node_select_yau_07b_2 . get_node2 ( 1 , 4 ) . add_item ( key )
func _on_yau_status ( addr : String ) :
if addr != ' ' :
$ TabContainer / PRD / status_yau . modulate = Color . AQUAMARINE
for check in Constants . ADDRESSES :
if check [ 1 ] == addr :
$ TabContainer / PRD / status_yau . text = ' ЯУ-07Б: ' + check [ 0 ]
else :
$ TabContainer / PRD / status_yau . modulate = Color . CRIMSON
$ TabContainer / PRD / status_yau . text = ' ЯУ-07Б: нет связи '
func _on_read_isa ( unit_isa_ports : Dictionary ) - > void :
isa_from_yau07b = unit_isa_ports
var isa_data : Dictionary = { }
@@ -382,21 +386,33 @@ 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 . MODUL_UM_1 :
if tmp_device_mode == Constants . META . MODUL_UM_1 : ## Синхронизация с Модуляцией У М лиетры 1
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_1 / yau07b_control . get_node2 ( 1 , 2 ) . select ( select )
if tmp_device_mode == Constants . META . MODUL_UM_2 :
if select == 1 :
$ TabContainer / PRD / body_grid / litera_1 / PSK3 / ray_litera_1 . material . set ( ' shader_parameter/color_signal ' , Color . RED )
else :
$ TabContainer / PRD / body_grid / litera_1 / PSK3 / ray_litera_1 . material . set ( ' shader_parameter/color_signal ' , Color . DARK_ORANGE )
if tmp_device_mode == Constants . META . MODUL_UM_2 : ## Синхронизация с Модуляцией У М лиетры 2, 4, 6
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 == Constants . META . MODUL_UM_ 3:
if select == 3:
$ TabContainer / PRD / body_grid / litera_2_4_6 / PSK / ray_1 . material . set ( ' shader_parameter/color_signal ' , Color . RED )
else :
$ TabContainer / PRD / body_grid / litera_2_4_6 / PSK / ray_1 . material . set ( ' shader_parameter/color_signal ' , Color . DARK_ORANGE )
if tmp_device_mode == Constants . META . MODUL_UM_3 : ## Синхронизация с Модуляцией У М лиетры 3, 5, 7
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 select == 3 :
$ TabContainer / PRD / body_grid / litera_3_5_7 / PSK2 / ray_2 . material . set ( ' shader_parameter/color_signal ' , Color . RED )
else :
$ TabContainer / PRD / body_grid / litera_3_5_7 / PSK2 / ray_2 . material . set ( ' shader_parameter/color_signal ' , Color . DARK_ORANGE )
if tmp_device_mode == Constants . META . FGOZ_4 :
var data_dict = Constants . EMS_G_PORT_DATA_HOLDER [ index ] [ 1 ]
if Constants . BASE_PORTS . EMS_G + 8 in data_dict :
@@ -489,12 +505,12 @@ func _on_data_fs_3(fs_3_data):
node_select_fs_3 . set_node_text ( 2 , 5 , ' Включен ' )
node_select_fs_3 . get_node2 ( 2 , 5 ) . modulate = Color . AQUAMARINE
node_select_fs_3 . get_node2 ( 1 , 5 ) . get_child ( 1 ) . button_pressed = true
#$ TabContainer/PRD/ body_grid/ litera_3_5_7/PSK2/ray_2.material.set(' shader_parameter/speed', 2.5)
$ TabContainer/ PRD / body_grid/ litera_1 / PSK3 / ray_litera_1 . material . set ( ' shader_parameter/speed' , 2.5 )
else :
node_select_fs_3 . set_node_text ( 2 , 5 , ' Отключен ' )
node_select_fs_3 . get_node2 ( 2 , 5 ) . modulate = Color . CRIMSON
node_select_fs_3 . get_node2 ( 1 , 5 ) . get_child ( 1 ) . button_pressed = false
#$ TabContainer/PRD/ body_grid/ litera_3_5_7/PSK2/ray_2.material.set(' shader_parameter/speed', 0.0)
$ TabContainer/ PRD / body_grid/ litera_1 / PSK3 / ray_litera_1 . material . set ( ' shader_parameter/speed' , 0.0 )
Constants . CMD . BASE_GET_CURRENT_TEMP :
if GRP == Constants . GROUP . BASE :
node_select_fs_3 . set_node_text ( 2 , 0 , ' %.2f ' % fs_3_data . decode_float ( 0xC ) + ' °C ' )
@@ -581,18 +597,12 @@ func set_frame(node: Node, val: int): node.set_frame(val)
func _on_save_config ( ) :
var da = DirAccess . open ( save_path )
if da == null :
return
else :
da . dir_exists ( save_path )
da . make_dir_recursive ( save_path )
var file_dialog = FileDialog . new ( )
file_dialog . access = FileDialog . ACCESS_USERDATA
file_dialog . title = " Сохранить файл как "
file_dialog . set_size ( Vector2 ( 600 , 400 ) )
file_dialog . mode = FileDialog . FILE_MODE_SAVE_FILE
file_dialog . current_dir = save_path
file_dialog . set_current_file ( " ЭМС-Г " )
file_dialog . current_dir = ' user://saves '
file_dialog . connect ( " file_selected " , Callable ( self , " _save_selected_file " ) )
add_child ( file_dialog )
file_dialog . popup_centered ( )
@@ -608,14 +618,13 @@ func _save_selected_file(file_path: String):
for key in item [ 1 ] :
if key in need_port :
regist [ key ] = item [ 1 ] [ key ]
print ( regist )
param_ems_g [ item [ 0 ] ] = regist
# Сохранение данных ЭМС-Г
var file = FileAccess . open ( file_path , FileAccess . WRITE )
if file != null :
file . store_string ( JSON . stringify ( param_ems_g ) )
file . close ( )
$ Background / notice / load_notice . text = ' ✅ Файл %s записан успешно! ' % file_path
$ Background / notice / load_notice . text = ' ✅ Файл %s записан успешно! ' % ProjectSettings . globalize_path ( file_path)
$ Background / notice / load_notice . visible = true
await get_tree ( ) . create_timer ( 2.0 ) . timeout
$ Background / notice / load_notice . visible = false
@@ -623,17 +632,18 @@ func _save_selected_file(file_path: String):
func _on_load_config ( ) :
var file_dialog = FileDialog . new ( )
file_dialog . access = FileDialog . ACCESS_USERDATA
file_dialog . set_title ( " Выберите файл " )
file_dialog . set_size ( Vector2 ( 600 , 400 ) )
file_dialog . mode = FileDialog . FILE_MODE_OPEN_FILE
file_dialog . current_dir = save_path
file_dialog . current_dir = ' user://saves '
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 ]
func _load_selected_file ( file_path : String ) :
var file = FileAccess . open ( file_path , FileAccess . READ )
# Проверка на открытие/чтение файла
if file == null :
@@ -652,29 +662,20 @@ func _load_selected_file():
await get_tree ( ) . create_timer ( 2.0 ) . timeout
$ Background / notice / load_notice . visible = false
else :
print( " Несоответствующий тип данных! " )
print_debug ( " Несоответствующий тип данных! " )
else :
print( " JSON Parse Error: " , json . get_error_message ( ) , " in " , file_content , " at line " , json . get_error_line ( ) )
print_debug ( " 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 ) ] )
if int ( key ) < 17 :
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 + 0xA , data_to_ems_g [ key ] [ str ( Constants. BASE_PORTS. EMS_G + 0xA ) ] )
if int ( key ) > 46 :
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 :
@@ -735,6 +736,7 @@ func _on_modul_um(item_from_ray_1: int, node: Node):
Network . write_port_isa ( Constants . BASE_PORTS . EMS_G + 2 , current_meta [ index ] )
Network . write_port_isa ( Constants . BASE_PORTS . EMS_G + 8 , modul_um [ index ] )
Network . read_port_isa ( [ Constants . BASE_PORTS . EMS_G + 8 ] )
else :
return
@@ -1067,7 +1069,7 @@ func save_settings(to_att_change: float, mode: int):
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 )
var file = FileAccess . open ( " user ://saves/fs_setting" , FileAccess . WRITE )
if file :
file . store_var ( Constants . FS_ATT )
file . close ( )