diff --git a/blue.png b/blue.png new file mode 100644 index 0000000..ae2e1ed Binary files /dev/null and b/blue.png differ diff --git a/blue.png.import b/blue.png.import new file mode 100644 index 0000000..8c0f404 --- /dev/null +++ b/blue.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cvd6pg533qd7r" +path="res://.godot/imported/blue.png-4d748ed6429caf8afc2e9d3803eadf6e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://blue.png" +dest_files=["res://.godot/imported/blue.png-4d748ed6429caf8afc2e9d3803eadf6e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/fs.gd b/fs.gd new file mode 100644 index 0000000..3ff3e6c --- /dev/null +++ b/fs.gd @@ -0,0 +1,299 @@ +extends Node + +const btn_txr0: Texture2D = preload('res://green.png') +const btn_txr1: Texture2D = preload('res://grey.png') +const btn_txr2: Texture2D = preload('res://blue.png') +const btn_txr3: Texture2D = preload('res://red.png') + +const BANDS: Array = [[400, 1200], + [1200, 2000], + [2000, 2800], + [2800, 3600], + [3600, 4400], + [4400, 5200], + [5200, 6000] + ] +const SECTORS: Array = [[314.5, 44.5], + [44.5, 134.5], + [134.5, 224.5], + [224.5, 314.5] + ] +const LBLS_SEC: Array = ['315° ... 44°', '45° ... 134°', '135° ... 224°', '225° ... 314°'] +const LBLS_LIT: Array = ['1К', '2Н', '3Н', '4В', '5В', '6К', '7К'] +const LBLS_PARAM: Array = [ + 'Номер модуля ФС: ', + 'Номер сектора: ', + 'Номер литеры: ', + 'Мощность излучения: ', + 'Частота: ', + 'Ширина полосы: ', + 'Индекс назначенной помехи: ', + 'Исправность модуля ФС: ', + ] +const OPT_BTN_TEXT: Array = ['не исправно', 'исправно', 'не определено'] +# [номер сектора, номер литеры, номер ФС, координата x, координата y] +const FS_PARAM = [ + [1, 1, 17, 0, 0], + [1, 2, 19, 50, 0], + [1, 3, 18, 100, 0], + [1, 4, 20, 150, 0], + [1, 5, 21, 200, 0], + [1, 6, 22, 250, 0], + [1, 7, 31, 300, 0], + [2, 1, 33, 0, 50], + [2, 2, 34, 50, 50], + [2, 3, 35, 100, 50], + [2, 4, 36, 150, 50], + [2, 5, 37, 200, 50], + [2, 6, 38, 250, 50], + [2, 7, 47, 300, 50], + [3, 1, 49, 0, 100], + [3, 2, 51, 50, 100], + [3, 3, 50, 100, 100], + [3, 4, 52, 150, 100], + [3, 5, 53, 200, 100], + [3, 6, 54, 250, 100], + [3, 7, 63, 300, 100], + [4, 1, 65, 0, 150], + [4, 2, 66, 50, 150], + [4, 3, 67, 100, 150], + [4, 4, 68, 150, 150], + [4, 5, 69, 200, 150], + [4, 6, 70, 250, 150], + [4, 7, 87, 300, 150], +] +const MSG8_DATA = [ + ['roll','Крен корабля, градусы:'], + ['trim','Дифферент корабля, градусы:'], + ['year','Корабельное время, год:'], + ['month','Корабельное время, месяц:'], + ['day','Корабельное время, день:'], + ['hour','Корабельное время, час:'], + ['minute','Корабельное время, минуты:'], + ['second','Корабельное время, секунды:'], + ['long','Долгота, градусы:'], + ['lat','Широта, градусы:'], + ['course','Курс корабля, градусы:'], + ['speed','Скорость корабля, узлы:'], +] + +var lbls_param_val: Array = [] +var g_opt_btn: OptionButton = OptionButton.new() +var g_fs_dict: Dictionary = {} +var g_active_fs: Fs +var g_fs_rect: ReferenceRect +var g_msg8_data: Dictionary = {} + +var x0 = 875 # x координата первой кнопки модуля ФС +var y0 = 40 # y координата первой кнопки модуля ФС + +# Called when the node enters the scene tree for the first time. +class Fs: + var nmfs: int + var btn: TextureButton + var isg: int + var pow + var freq + var width + var sector: int + var litera: int + var interfer = null + + func _init(sec, lit, id): + nmfs = id + litera = lit + sector = sec + isg = 1 + + func fs_off(): + freq = '' + pow = '' + width = '' + interfer = null + if isg == 0: + btn.set_texture_normal(btn_txr3) + elif isg == 1: + btn.set_texture_normal(btn_txr0) + elif isg == 2: + btn.set_texture_normal(btn_txr1) + + +func init_lbls(tab, x0, y0): + for i in range(len(LBLS_SEC)): + var lbl_sec = Label.new() + tab.add_child(lbl_sec) + lbl_sec.position = Vector2(x0 - 100, y0 - 5 + i * 50) + lbl_sec.text = LBLS_SEC[i] + + for i in range(len(LBLS_LIT)): + var lbl_lit = Label.new() + tab.add_child(lbl_lit) + lbl_lit.position = Vector2(x0 -5 + i * 50, y0 - 25) + lbl_lit.text = LBLS_LIT[i] + + for i in range(len(LBLS_PARAM)): + var lbl_param = Label.new() + tab.add_child(lbl_param) + lbl_param.position = Vector2(x0 + 350, y0 - 25 + i * 25) + lbl_param.text = LBLS_PARAM[i] + + for i in range(len(LBLS_PARAM) - 1): + var lbl_param_val = Label.new() + tab.add_child(lbl_param_val) + lbls_param_val.append(lbl_param_val) + lbl_param_val.position = Vector2(x0 + 600, y0 - 25 + i * 25) + lbl_param_val.text = '' + + tab.add_child(g_opt_btn) + g_opt_btn.position = Vector2(x0 + 550, y0 - 5 + 150) + for opt in OPT_BTN_TEXT: + g_opt_btn.add_item(opt) + g_opt_btn.visible = false + g_opt_btn.connect('item_selected', Callable(self, 'on_item_selected')) + + for i in range(len(MSG8_DATA)): + var lbl_msg8_head = Label.new() + tab.add_child(lbl_msg8_head) + lbl_msg8_head.position = Vector2(x0 + 350, y0 + 200 + i * 25) + lbl_msg8_head.text = MSG8_DATA[i][1] + var lbl_msg8 = Label.new() + tab.add_child(lbl_msg8) + lbl_msg8.position = Vector2(x0 + 600, y0 +200 + i * 25) + lbl_msg8.text = '' + g_msg8_data[MSG8_DATA[i][0]] = lbl_msg8 + + +func init_fs(tab, fs_rect): + for item in fs.FS_PARAM: + var block_fs = fs.Fs.new(item[0], item[1], item[2]) + g_fs_dict[item[2]] = block_fs + var btn = TextureButton.new() + block_fs.btn = btn + tab.add_child(btn) + btn.position = Vector2(x0 + item[3], y0 + item[4]) + btn.size = Vector2(10,10) + btn.set_texture_normal(btn_txr0) + btn.connect('pressed', Callable(self, 'on_btn_fs').bind(block_fs)) + fs.init_lbls(tab, x0, y0) + g_fs_rect = fs_rect + fs_rect.visible = false + + +func on_item_selected(item_num): + g_active_fs.isg = item_num + if g_active_fs.isg == 0: + fs_off(g_active_fs) + elif g_active_fs.isg == 1: + g_active_fs.btn.set_texture_normal(btn_txr0) + elif g_active_fs.isg == 2: + g_active_fs.btn.set_texture_normal(btn_txr1) + on_btn_fs(g_active_fs) + + +func fs_off(block_fs): + block_fs.fs_off() + if g_active_fs == block_fs: + on_btn_fs(g_active_fs) + + +func on_btn_fs(block_fs: Fs): + g_active_fs = block_fs + g_opt_btn.visible = true + lbls_param_val[0].text = str(block_fs.nmfs) + lbls_param_val[1].text = str(block_fs.sector) + lbls_param_val[2].text = str(block_fs.litera) + if block_fs.interfer == null: + lbls_param_val[3].text = '' + lbls_param_val[4].text = '' + lbls_param_val[5].text = '' + lbls_param_val[6].text = '' + else: + lbls_param_val[3].text = str(block_fs.interfer['options']['powp']) + lbls_param_val[4].text = str(block_fs.interfer.get_val('freq')) + lbls_param_val[5].text = str(block_fs.interfer.get_val('width')) + lbls_param_val[6].text = str(block_fs.interfer['options']['ispp']) + g_opt_btn.select(block_fs.isg) + g_fs_rect.visible = true + g_fs_rect.position = Vector2(g_active_fs.btn.position[0] - 1, g_active_fs.btn.position[1] - 1) + + +func set_fs(interfer: Interfers.Interfer): + var sec: int + var lit: int + var freq = interfer.get_val('freq') + var width = interfer.get_val('width') + if (freq == '') or (width == ''): + fs_of_old(interfer) + return 2 + for i in range(len(BANDS)): + if (float(freq) >= BANDS[i][0]) and (float(freq) <= BANDS[i][1]): + lit = i+1 + + if (float(interfer.options['kni']) < 0) or (float(interfer.options['kni'] > 360)): + fs_of_old(interfer) + return 2 + for i in range(len(SECTORS)): + if i < 1: + if (float(interfer.options['kni']) >= SECTORS[i][0]) or (float(interfer.options['kni']) <= SECTORS[i][1]): + sec = i+1 + else: + if (float(interfer.options['kni']) >= SECTORS[i][0]) and (float(interfer.options['kni']) <= SECTORS[i][1]): + sec = i+1 + var fs_arr: Array + fs_arr = FS_PARAM.filter(func(item): return item[0] == sec) + fs_arr = fs_arr.filter(func(item): return item[1] == lit) + if len(fs_arr) > 0: + var fs_num = fs_arr[0][2] + if g_fs_dict[fs_num].isg == 1: + if g_fs_dict[fs_num].interfer == null: + g_fs_dict[fs_num].interfer = interfer + if (interfer.active_fs != g_fs_dict[fs_num]) and (interfer.active_fs != null): + fs_off(interfer.active_fs) + interfer.active_fs = g_fs_dict[fs_num] + g_fs_dict[fs_num].pow = float(interfer.options['powp']) + g_fs_dict[fs_num].freq = float(freq) + g_fs_dict[fs_num].width = float(width) + update_fs(g_fs_dict[fs_num], float(interfer.options['powp']), float(freq), float(width)) + g_fs_dict[fs_num].btn.set_texture_normal(btn_txr2) + if g_active_fs == g_fs_dict[fs_num]: + on_btn_fs(g_active_fs) + return 1 + elif g_fs_dict[fs_num].interfer == interfer: + update_fs(g_fs_dict[fs_num], float(interfer.options['powp']), float(freq), float(width)) + if g_active_fs == g_fs_dict[fs_num]: + on_btn_fs(g_active_fs) + return 1 + else: + fs_of_old(interfer) + return 3 + else: + fs_of_old(interfer) + return 4 + else: + fs_of_old(interfer) + return 2 + + +func fs_of_old(interfer): + if interfer.active_fs != null: + fs_off(interfer.active_fs) + interfer.active_fs.btn.set_texture_normal(btn_txr0) + + +func update_fs(block_fs, pow, freq, width): + block_fs.pow = pow + block_fs.freq = freq + block_fs.width = width + + +func on_receive_msg8(data): + for key in data: + if g_msg8_data.has(key): + g_msg8_data[key].text = str(data[key]) + pass + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + diff --git a/green.png b/green.png new file mode 100644 index 0000000..0e32cec Binary files /dev/null and b/green.png differ diff --git a/green.png.import b/green.png.import new file mode 100644 index 0000000..e5e1125 --- /dev/null +++ b/green.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bv0uw0tjpu66a" +path="res://.godot/imported/green.png-5db815cc8219d4fb24db6968e2796f87.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://green.png" +dest_files=["res://.godot/imported/green.png-5db815cc8219d4fb24db6968e2796f87.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/grey.png b/grey.png new file mode 100644 index 0000000..6c17fe8 Binary files /dev/null and b/grey.png differ diff --git a/grey.png.import b/grey.png.import new file mode 100644 index 0000000..e1c21d4 --- /dev/null +++ b/grey.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bkk12hf70kvyg" +path="res://.godot/imported/grey.png-300e15b90e9535e161f2cc76adec7125.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://grey.png" +dest_files=["res://.godot/imported/grey.png-300e15b90e9535e161f2cc76adec7125.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/interfers.gd b/interfers.gd new file mode 100644 index 0000000..fb03399 --- /dev/null +++ b/interfers.gd @@ -0,0 +1,211 @@ +extends Node + +var id_array: Array # Массив id целей +var interfers : Dictionary # Словарь целей +var msg_counter : int = 0 # Счётчик отправленных пакетов +var g_table # таблица с помехами + + +const TableCellType1 = preload('res://ячейка-1.tscn') +const TableCellType2 = preload('res://кнопка-3.tscn') +const TableCellType3 = preload('res://кнопка-4.tscn') +const TableCellType4 = preload('res://заголовок.tscn') +const TableCellType5 = preload('res://ячейка-2.tscn') +const TableCellType6 = preload('res://кнопка-5.tscn') +const TableHeader = preload('res://table/header.tscn') + +# Индекс колонки: 0 1 2 3 4 5 6 +const TABLE_HEADERS = [ 'Индекс', 'Состояние', 'Помеха', 'Мощность', 'Кур. уг.', 'Частота', 'Ш. диап.'] +const TABLE_HEADER_TYPES = [ TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader] +const TABLE_HEADER_ALIGNMENTS = [ HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] +const TABLE_ROW_TYPES = [ TableCellType1, TableCellType6, TableCellType1, TableCellType1, TableCellType1, TableCellType1, TableCellType1] +const TABLE_ROW_ALIGNMENTS = [ HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] +const TABLE_COLUMN_SIZES = [ 82, 150, 82, 100, 82, 90, 150] + +const COLUMN_ISPP = 0 # Индекс сейанса постановки помехи +const COLUMN_SVK = 1 # Состояние выполнения помехи +const COLUMN_KRP = 2 # Помеха +const COLUMN_POWP = 3 # Мощность излучения +const COLUMN_KNI = 4 # Курсовой угол +const COLUMN_FREQ = 5 # Частота +const COLUMN_WIDTH = 6 # Ширина диапазона + + +# Индексы колонок, которым можно задавать выравнивание текста +const TABLE_ALLIGNED_COLUMNS = [ + COLUMN_ISPP, + COLUMN_KRP, + COLUMN_POWP, + COLUMN_KNI, + COLUMN_FREQ, + COLUMN_WIDTH, ] + +# Состояние выполнения команды поставновки помехи +const SVK = ['Подготовка', 'Выполнено', 'Ошибка', 'Занято', 'Неисправно'] + +# Номера колонок +const COLUMN_OPT = [[COLUMN_SVK, SVK]] +const COLUMN_OPT_BTN = [COLUMN_SVK] + +# Помеха +class Interfer: + # параметры цели, второе значение, разрешение отправки. + var get_data: Dictionary = { + 'fpga_ver ': '', + 'brd_ver': '', + 'mcu_ver': '', + 'soc_temp': '', + 'rf_temp': '', + 'psu_temp': '', + } + var options: Dictionary = { + 'ispp': 0, + 'krp': '', + 'powp': 0.0, + 'kni': 0.0, + 'params': {}, + 'get': [], + } + var svk: int = 0 + var row_id: int + var active_fs: fs.Fs + + func _init(data: Dictionary): + options.merge(data, true) + + func update_row(): + var new_row: Array = [] + new_row.append(str(options['ispp'])) + new_row.append(str(SVK[svk])) + new_row.append(str(options['krp'])) + new_row.append(str(options['powp'])) + new_row.append(str(options['kni'])) + new_row.append(get_val('freq')) + new_row.append(get_val('width')) + return new_row + + func get_val(val): + if options['params'].has(val) : + return str(options['params'][val]) + else: + return '' + + func update_interfer(data: Dictionary): + options.merge(data, true) + + +func set_interfer(data): + if interfers.has(data['ispp']): + interfers[data['ispp']].update_interfer(data) + var new_row = interfers[data['ispp']].update_row() + g_table.set_row_text(interfers[data['ispp']].row_id, new_row) + else: + var new_interfer = Interfer.new(data) + interfers[data['ispp']] = new_interfer + on_row_add(g_table, interfers[data['ispp']]) + var cmd_state: int = fs.set_fs(interfers[data['ispp']]) + interfers[data['ispp']].svk = cmd_state + var cell = g_table.get_node2(COLUMN_SVK, interfers[data['ispp']].row_id) + cell.select(cmd_state) + + +func init_table(table: Table, sizes: Array): + for i_row in table.get_rows_count(): + table.set_nodes_min_size(i_row, sizes) + + +func init_opt_btns(row : int, table): + for item in COLUMN_OPT: + var i_col = item[0] + var opt_arr = item[1] + var cell = table.get_node2(i_col, row) + for opt in opt_arr: + cell.add_item(opt) + cell.select(0) + + +func init_pomehi(table): # Инициализация вкладки с целями + g_table = table + g_table.set_header(TABLE_HEADER_TYPES) + g_table.set_header_text(TABLE_HEADERS) + init_table(g_table, TABLE_COLUMN_SIZES) + g_table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(g_table)) + + +func on_row_add(table, interfer): + var row = interfer.update_row() + table.add_row(TABLE_ROW_TYPES) + table.set_row_text(table.get_rows_count()-1, row) + table.set_columns_min_size(TABLE_COLUMN_SIZES) + table.set_node_user_data(0, table.get_rows_count()-1, interfer) + interfer.row_id = table.get_rows_count()-1 + init_opt_btns(table.get_rows_count()-1, table) + table.connect_columns(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, []) + + +func on_item_selected(item_num, node): + var optbtn_text = node[0].text + var indexis = g_table.get_key_indexes(node[0].name) + var row_i = indexis[1] + var col_i = indexis[0] + var cell = g_table.get_node2(0,row_i) + var interfer = g_table.get_node_user_data(0, row_i) + interfer.svk = item_num + + +func get_msg7_data(): + var data_to_json : Dictionary + data_to_json['ts'] = 7 + msg_counter += 1 + data_to_json['ss'] = msg_counter + data_to_json['sa'] = 1 + data_to_json['msfs'] = [] + data_to_json['msrr'] = [] + data_to_json['ret'] = [] + data_to_json['retss'] = 0 + for key in fs.g_fs_dict: + var block_fs: fs.Fs = fs.g_fs_dict[key] + var fs_param: Dictionary = {} + fs_param['nmfs'] = int(block_fs.nmfs) + fs_param['isg'] = int(block_fs.isg) + if block_fs.pow is float: + fs_param['pow'] = str(block_fs.pow) + if block_fs.freq is float: + fs_param['freq'] = str(block_fs.freq) + if block_fs.width is float: + fs_param['width'] = str(block_fs.width) + data_to_json['msfs'].append(fs_param) + var json = JSON.new().stringify(data_to_json) + var pac = json.to_utf8_buffer() + return pac + + +func on_row_pressed(i_row: int, table): + pass + + +func off_interfer(json_data): + if not interfers.has(json_data['ispp']): return + var row_id = interfers[json_data['ispp']].row_id + if interfers[json_data['ispp']] != null: + if interfers[json_data['ispp']].active_fs != null: + fs.fs_off(interfers[json_data['ispp']].active_fs) + if g_table.get_rows_count() > row_id: + interfers.erase(json_data['ispp']) + g_table.remove_row(row_id) + for i in g_table.get_rows_count(): + var interfer = g_table.get_node_user_data(0, i) + interfer.row_id = i + + +func check_interfers_state(): + for interfer in interfers.values(): + if interfer.active_fs != null: + fs.fs_off(interfer.active_fs) + interfer.active_fs = null + for interfer in interfers.values(): + var cmd_state: int = fs.set_fs(interfer) + if interfer.svk == 3: + interfer.svk = cmd_state + var cell = g_table.get_node2(COLUMN_SVK, interfer.row_id) + cell.select(cmd_state) diff --git a/main.gd b/main.gd index aca178b..17e80a3 100644 --- a/main.gd +++ b/main.gd @@ -13,7 +13,8 @@ func _ready(): sock.bind(Consts.MAIN_ADDR[1], Consts.MAIN_ADDR[0]) sock.set_dest_address(Consts.DST_ADDR[0], Consts.DST_ADDR[1]) Threats.init_treats(table_threads, btn_add_threads, btn_del_threads, btn_save_threads) - Pomehi.init_pomehi(table_pomehi) + Interfers.init_pomehi(table_pomehi) + fs.init_fs($tabs/pomehi, $tabs/pomehi/fs_rect) var timer = Timer.new() timer.connect('timeout', Callable(self, 'on_timeout').bind()) add_child(timer) #to process @@ -22,8 +23,47 @@ func _ready(): func on_timeout(): sock.put_packet(Threats.get_threats_data()) + Interfers.check_interfers_state() + + +func on_receive(data): + var json_conv: = JSON.new() + var utf8_data = data.get_string_from_utf8() + if Error.OK == json_conv.parse(utf8_data): + var json_data = json_conv.get_data() + if not (json_data is Dictionary): return + if not json_data.has('ts'): return + if not ((json_data['ts'] is int) or (json_data['ts'] is float)): return + if json_data['ts'] == 6: + if not json_data.has('ispp'): return + if not ((json_data['ispp'] is int) or (json_data['ispp'] is float)): return + if not json_data.has('krp'): return + if not json_data.has('ss'): return + if not ((json_data['ss'] is int) or (json_data['ss'] is float)): return + if json_data['krp'] == 'off': + Interfers.off_interfer(json_data) + sock.put_packet(Interfers.get_msg7_data()) + return + if not json_data.has('powp'): return + if not json_data.has('kni'): return + if not json_data.has('params'): return + if not json_data.has('get'): return + Interfers.set_interfer(json_data) + sock.put_packet(Interfers.get_msg7_data()) + elif json_data['ts'] == 8: + fs.on_receive_msg8(json_data) + # Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass +func _process(delta): + while sock.get_available_packet_count() > 0: + var data: = sock.get_packet() + var addr: = sock.get_packet_ip() + var port: = sock.get_packet_port() + var addr_port: = [addr, port] + on_receive(data) + + + + diff --git a/main.tscn b/main.tscn index f6ac35a..a5597d6 100644 --- a/main.tscn +++ b/main.tscn @@ -1,14 +1,14 @@ [gd_scene load_steps=7 format=3 uid="uid://87gtvqd7bbje"] -[ext_resource type="Script" path="res://main.gd" id="1_cvm0h"] -[ext_resource type="Script" path="res://table/table.gd" id="2_su0xk"] -[ext_resource type="Texture2D" uid="uid://cex4jiu1pcj3x" path="res://edit-add-0.png" id="3_lumft"] -[ext_resource type="Texture2D" uid="uid://cx746np1wexnd" path="res://edit-add-1.png" id="4_gd6ts"] -[ext_resource type="Texture2D" uid="uid://blpkoi7s8qugp" path="res://document-save-0.png" id="5_hmvq3"] -[ext_resource type="Texture2D" uid="uid://wh7p3t4frxf" path="res://disconnect.png" id="6_2646i"] +[ext_resource type="Script" path="res://main.gd" id="1_jt2ds"] +[ext_resource type="Script" path="res://table/table.gd" id="2_61iss"] +[ext_resource type="Texture2D" uid="uid://cex4jiu1pcj3x" path="res://edit-add-0.png" id="3_0aqi0"] +[ext_resource type="Texture2D" uid="uid://cx746np1wexnd" path="res://edit-add-1.png" id="4_s8cxp"] +[ext_resource type="Texture2D" uid="uid://blpkoi7s8qugp" path="res://document-save-0.png" id="5_8l4uh"] +[ext_resource type="Texture2D" uid="uid://wh7p3t4frxf" path="res://disconnect.png" id="6_hj3vd"] [node name="main" type="Node2D"] -script = ExtResource("1_cvm0h") +script = ExtResource("1_jt2ds") [node name="tabs" type="TabContainer" parent="."] offset_right = 1594.0 @@ -28,7 +28,7 @@ offset_right = 1.0 offset_bottom = 10.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("2_su0xk") +script = ExtResource("2_61iss") node_type_file = "res://ячейка-1.tscn" [node name="btn_add" type="TextureButton" parent="tabs/threats"] @@ -37,8 +37,8 @@ offset_left = 1533.0 offset_top = -2.0 offset_right = 1581.0 offset_bottom = 46.0 -texture_normal = ExtResource("3_lumft") -texture_pressed = ExtResource("4_gd6ts") +texture_normal = ExtResource("3_0aqi0") +texture_pressed = ExtResource("4_s8cxp") [node name="btn_save" type="TextureButton" parent="tabs/threats"] layout_mode = 0 @@ -46,7 +46,7 @@ offset_left = 1442.0 offset_top = -1.0 offset_right = 1490.0 offset_bottom = 47.0 -texture_normal = ExtResource("5_hmvq3") +texture_normal = ExtResource("5_8l4uh") [node name="btn_del" type="TextureButton" parent="tabs/threats"] layout_mode = 0 @@ -55,7 +55,7 @@ offset_top = 1.0 offset_right = 1547.0 offset_bottom = 67.0 scale = Vector2(0.62, 0.62) -texture_normal = ExtResource("6_2646i") +texture_normal = ExtResource("6_hj3vd") [node name="pomehi" type="Panel" parent="tabs"] visible = false @@ -63,8 +63,18 @@ layout_mode = 2 [node name="table_p" type="GridContainer" parent="tabs/pomehi"] layout_mode = 0 -offset_top = 100.0 +offset_top = 30.0 offset_right = 1587.0 -offset_bottom = 861.0 -script = ExtResource("2_su0xk") +offset_bottom = 886.0 +script = ExtResource("2_61iss") node_type_file = "res://ячейка-1.tscn" + +[node name="fs_rect" type="ReferenceRect" parent="tabs/pomehi"] +layout_mode = 0 +offset_left = 1000.0 +offset_top = 91.0 +offset_right = 1012.0 +offset_bottom = 103.0 +border_color = Color(1, 1, 0, 1) +border_width = 2.4 +editor_only = false diff --git a/pomehi.gd b/pomehi.gd deleted file mode 100644 index 1e1f441..0000000 --- a/pomehi.gd +++ /dev/null @@ -1,118 +0,0 @@ -extends Node - -var id_array: Array # Массив id целей -var pomehi : Dictionary # Словарь целей -var msg_counter : int = 0 # Счётчик отправленных пакетов - -const TableCellType1 = preload('res://ячейка-1.tscn') -const TableCellType2 = preload('res://кнопка-3.tscn') -const TableCellType3 = preload('res://кнопка-4.tscn') -const TableCellType4 = preload('res://заголовок.tscn') -const TableCellType5 = preload('res://ячейка-2.tscn') -const TableCellType6 = preload('res://кнопка-5.tscn') -const TableHeader = preload('res://table/header.tscn') - -# Индекс колонки: 0 1 2 3 4 5 6 -const TABLE_HEADERS = [ 'Индекс', 'Состояние', 'Помеха', 'Мощность', 'Кур. уг.', 'Частота', 'Ш. диап.'] -const TABLE_HEADER_TYPES = [ TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader] -const TABLE_HEADER_ALIGNMENTS = [ HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] -const TABLE_ROW_TYPES = [ TableCellType1, TableCellType6, TableCellType1, TableCellType1, TableCellType1, TableCellType1, TableCellType1] -const TABLE_ROW_ALIGNMENTS = [ HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] -const TABLE_COLUMN_SIZES = [ 82, 120, 82, 100, 82, 90, 150] - -const COLUMN_ISPP = 0 # Индекс сейанса постановки помехи -const COLUMN_SVK = 1 # Состояние выполнения помехи -const COLUMN_KRP = 2 # Помеха -const COLUMN_POWP = 3 # Мощность излучения -const COLUMN_KNI = 4 # Курсовой угол -const COLUMN_FREQ = 5 # Частота -const COLUMN_WIDTH = 6 # Ширина диапазона - - -# Индексы колонок, которым можно задавать выравнивание текста -const TABLE_ALLIGNED_COLUMNS = [ - COLUMN_ISPP, - COLUMN_KRP, - COLUMN_POWP, - COLUMN_KNI, - COLUMN_FREQ, - COLUMN_WIDTH, ] - - -# Состояние выполнения команды поставновки помехи -const SVK = ['<неопр.>', 'fhss', 'lfm', 'const'] - - -# Номера колонок -const COLUMN_OPT = [[COLUMN_SVK, SVK]] -const COLUMN_OPT_BTN = [COLUMN_SVK] -const ID_ARRAY_LEN = 100 # Размер пула номеров целей - -# Помеха -class Pomeha: - # параметры цели, второе значение, разрешение отправки. - var ispp : String - var svk : int - var krp : String - var powp : String - var kni : String - var freq : String - var width : String - - func _init(args : Array): - ispp = '%s' % args[0] - krp = '%s' % args[1] - powp = '%s' % args[2] - kni = '%s' % args[3] - freq = '%s' % args[4] - width = '%s' % args[5] - - func update_rows(): - var new_rows: Array = [] - new_rows.append('%s' % ispp) - new_rows.append('%s' % svk) - new_rows.append('%s' % krp) - new_rows.append('%s' % powp) - new_rows.append('%s' % kni) - new_rows.append('%s' % freq) - new_rows.append('%s' % width) - return new_rows - - -func init_table(table: Table, sizes: Array): - for i_row in table.get_rows_count(): - table.set_nodes_min_size(i_row, sizes) - - -func init_opt_btns(row : int, table): - for item in COLUMN_OPT: - var i_col = item[0] - var opt_arr = item[1] - var cell = table.get_node2(i_col, row) - for opt in opt_arr: - cell.add_item(opt) - cell.select(0) - - -func init_pomehi(table): # Инициализация вкладки с целями - table.set_header(TABLE_HEADER_TYPES) - table.set_header_text(TABLE_HEADERS) - on_btn_add(table) - init_table(table, TABLE_COLUMN_SIZES) - table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table)) - table.connect_columns(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [table]) - - -func on_btn_add(table): - var pomeha : = Pomeha.new([1,2,3,4,5,6]) - pomehi['%d' % 1] = pomeha - var row = pomeha.update_rows() - table.add_row(TABLE_ROW_TYPES) - table.set_row_text(table.get_rows_count()-1, row) - table.set_columns_min_size(TABLE_COLUMN_SIZES) - init_opt_btns(table.get_rows_count()-1, table) - table.connect_columns(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, []) - - -func on_row_pressed(i_row: int, table): - pass diff --git a/project.godot b/project.godot index 507241e..51ee6b8 100644 --- a/project.godot +++ b/project.godot @@ -12,16 +12,17 @@ config_version=5 config/name="Imi Skysens" run/main_scene="res://main.tscn" -config/features=PackedStringArray("4.1") +config/features=PackedStringArray("4.2") config/icon="res://icon.png" [autoload] Consts="*res://consts.gd" Threats="*res://threats.gd" -Pomehi="*res://pomehi.gd" Tools="*res://tools.gd" Table="*res://table/table.gd" +Interfers="*res://interfers.gd" +fs="*res://fs.gd" [display] diff --git a/red.png b/red.png new file mode 100644 index 0000000..0e8aa72 Binary files /dev/null and b/red.png differ diff --git a/red.png.import b/red.png.import new file mode 100644 index 0000000..b5c4920 --- /dev/null +++ b/red.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b6lkwjysawepu" +path="res://.godot/imported/red.png-13f6abb0e0c70056504666ed9c349d99.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://red.png" +dest_files=["res://.godot/imported/red.png-13f6abb0e0c70056504666ed9c349d99.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/threats.gd b/threats.gd index 2847ac1..f24faa0 100644 --- a/threats.gd +++ b/threats.gd @@ -6,6 +6,7 @@ var msg_counter : int = 0 # Счётчик отправленных п var g_table: GridContainer + const TableCellType1 = preload('res://ячейка-1.tscn') const TableCellType2 = preload('res://кнопка-3.tscn') const TableCellType3 = preload('res://кнопка-4.tscn') @@ -446,6 +447,11 @@ func get_threats_data(): msg_counter += 1 data_to_json['ss'] = msg_counter data_to_json['msvk'] = [] + for item in Interfers.interfers.values(): + var msvk = {} + msvk['ispp'] = item.options['ispp'] + msvk['svk'] = item.svk + data_to_json['msvk'].append(msvk) data_to_json['mis'] = [] for key in treats: var treat = treats[key] diff --git a/кнопка-4.tscn b/кнопка-4.tscn index afb4789..d2ba6e5 100644 --- a/кнопка-4.tscn +++ b/кнопка-4.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://ccxre8mwhndjk"] -[ext_resource type="Texture2D" uid="uid://dag8n0gknjwak" path="res://индикатор-1-0.png" id="1_ha0ig"] -[ext_resource type="Texture2D" uid="uid://b3ext3w4ftgg2" path="res://индикатор-1-1.png" id="2_gmc7h"] +[ext_resource type="Texture2D" uid="uid://dag8n0gknjwak" path="res://индикатор-1-0.png" id="1_vc7pt"] +[ext_resource type="Texture2D" uid="uid://b3ext3w4ftgg2" path="res://индикатор-1-1.png" id="2_tp80w"] [node name="indicator_1" type="TextureButton"] modulate = Color(1, 0.596078, 0.4, 1) @@ -9,5 +9,5 @@ offset_right = 35.0 offset_bottom = 29.0 toggle_mode = true button_mask = 0 -texture_normal = ExtResource("1_ha0ig") -texture_pressed = ExtResource("2_gmc7h") +texture_normal = ExtResource("1_vc7pt") +texture_pressed = ExtResource("2_tp80w")