diff --git a/data/connect.png b/data/connect.png new file mode 100644 index 00000000..d815ce5c Binary files /dev/null and b/data/connect.png differ diff --git a/data/connect.png.import b/data/connect.png.import new file mode 100644 index 00000000..b11a93f1 --- /dev/null +++ b/data/connect.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://7h55yvh84cve" +path="res://.godot/imported/connect.png-46d08dc9ed7a37b7aaccaa5d321236c8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://data/connect.png" +dest_files=["res://.godot/imported/connect.png-46d08dc9ed7a37b7aaccaa5d321236c8.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/project.godot b/project.godot index dba11e78..f8acada9 100644 --- a/project.godot +++ b/project.godot @@ -31,6 +31,8 @@ capsrpb="*res://scripts/capsrpb.gd" Table="*res://table/table.gd" Threats="*res://scripts/threats.gd" YemsDevs="*res://scripts/yems_devs.gd" +Yemsboards="*res://scripts/yemsboards.gd" +YemsConsts="*res://scripts/yems_consts.gd" [debug] diff --git a/scenes/button_flat.tscn b/scenes/button_flat.tscn index 29f05f64..cec9f916 100644 --- a/scenes/button_flat.tscn +++ b/scenes/button_flat.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=9 format=3 uid="uid://da7w3vkhadfwe"] -[ext_resource type="Script" path="res://scenes/nine-patch-button.gd" id="1_wpbps"] -[ext_resource type="Texture2D" uid="uid://ct0ajcwno03h7" path="res://data/кнопка-квадрат-0.png" id="2_1xr6o"] +[ext_resource type="Script" path="res://scenes/nine-patch-button.gd" id="1_ugn6y"] +[ext_resource type="Texture2D" uid="uid://ct0ajcwno03h7" path="res://data/кнопка-квадрат-0.png" id="2_aupr1"] [sub_resource type="StyleBoxEmpty" id="1"] @@ -19,13 +19,13 @@ offset_right = 30.0 offset_bottom = 30.0 theme_override_styles/panel = SubResource("1") -script = ExtResource("1_wpbps") +script = ExtResource("1_ugn6y") toggle_mode = true [node name="state" type="NinePatchRect" parent="."] show_behind_parent = true layout_mode = 2 -texture = ExtResource("2_1xr6o") +texture = ExtResource("2_aupr1") patch_margin_left = 10 patch_margin_top = 10 patch_margin_right = 10 diff --git a/scenes/file_table.gd b/scenes/file_table.gd index c6c25368..a3b6a0d4 100644 --- a/scenes/file_table.gd +++ b/scenes/file_table.gd @@ -9,30 +9,30 @@ var FILES_ROWS_ALIGNMENT = [ HORIZONTAL_ALIGNMENT_LEFT, HORIZONTAL_ALIGNM func fill_files_table(tbl: Table, folder: String, rows_types: Array): - var dir: = DirAccess.open(folder) - if dir == null: - return - var files: = [] - var exclude_names: = ['.', '..'] - dir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547 - while true: - var file: = dir.get_next() - if file == '': - break - if file in exclude_names: - continue - var file_name = folder + '/' + file - var fd = FileAccess.open(file_name, FileAccess.READ) - if not fd: - continue - var glob_path = ProjectSettings.globalize_path(file_name) - var sz = fd.get_length() - var ut = fd.get_modified_time(file_name) - fd.close() - var mt = Time.get_datetime_dict_from_unix_time(ut) - var file_row = [file, '%d' % sz, '%d-%02d-%02d %02d:%02d' % [mt.year, mt.month, mt.day, mt.hour, mt.minute]] - tbl.add_row(rows_types) - var i_row = tbl.get_rows_count() - 1 - tbl.set_row_text(i_row, file_row) - tbl.set_node_meta(0, i_row, 'file_path', glob_path) - dir.list_dir_end() + var dir: = DirAccess.open(folder) + if dir == null: + return + var files: = [] + var exclude_names: = ['.', '..'] + dir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547 + while true: + var file: = dir.get_next() + if file == '': + break + if file in exclude_names: + continue + var file_name = folder + '/' + file + var fd = FileAccess.open(file_name, FileAccess.READ) + if not fd: + continue + var glob_path = ProjectSettings.globalize_path(file_name) + var sz = fd.get_length() + var ut = fd.get_modified_time(file_name) + fd.close() + var mt = Time.get_datetime_dict_from_unix_time(ut) + var file_row = [file, '%d' % sz, '%d-%02d-%02d %02d:%02d' % [mt.year, mt.month, mt.day, mt.hour, mt.minute]] + tbl.add_row(rows_types) + var i_row = tbl.get_rows_count() - 1 + tbl.set_row_text(i_row, file_row) + tbl.set_node_meta(0, i_row, 'file_path', glob_path) + dir.list_dir_end() diff --git a/scenes/line_edit_empty.tscn b/scenes/line_edit_empty.tscn new file mode 100644 index 00000000..97fb39a0 --- /dev/null +++ b/scenes/line_edit_empty.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=4 format=3 uid="uid://c480ipkjckkdn"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_00xmt"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_mla3y"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xp0rn"] + +[node name="LineEdit" type="LineEdit"] +offset_right = 58.0 +offset_bottom = 33.0 +theme_override_colors/font_color = Color(1, 0.596078, 0.4, 1) +theme_override_colors/font_uneditable_color = Color(1, 0.596078, 0.4, 1) +theme_override_styles/normal = SubResource("StyleBoxEmpty_00xmt") +theme_override_styles/focus = SubResource("StyleBoxEmpty_mla3y") +theme_override_styles/read_only = SubResource("StyleBoxEmpty_xp0rn") +alignment = 1 +context_menu_enabled = false +shortcut_keys_enabled = false +middle_mouse_paste_enabled = false +selecting_enabled = false +deselect_on_focus_loss_enabled = false +caret_blink = true +caret_blink_interval = 0.1 diff --git a/scenes/nine-patch-button.gd b/scenes/nine-patch-button.gd index 28e964c5..09a921af 100644 --- a/scenes/nine-patch-button.gd +++ b/scenes/nine-patch-button.gd @@ -6,28 +6,28 @@ extends PanelContainer @export var texture_state0: Texture2D = preload('res://data/кнопка-квадрат-0.png'): - set(val): $state.set_texture(val) + set(val): $state.set_texture(val) @export var texture_state1: Texture2D = preload('res://data/кнопка-квадрат-1.png'): - set(val): $state.set_texture(val) + set(val): $state.set_texture(val) @export var text: String = '': - set(val): $button.set_text(val) - get: return $button.get_text() + set(val): $button.set_text(val) + get: return $button.get_text() @export var pressed: bool = false: - set(val): $button.set_pressed(val) - get: return $button.is_pressed() + set(val): $button.set_pressed(val) + get: return $button.is_pressed() @export var toggle_mode: bool = false: - set(val): - if is_inside_tree(): - $button.set_toggle_mode(val) - get: return $button.is_toggle_mode() + set(val): + if is_inside_tree(): + $button.set_toggle_mode(val) + get: return $button.is_toggle_mode() func set_text (val: String): $button.set_text(val) @@ -35,8 +35,8 @@ func set_pressed (val: bool): $button.set_pressed(val) func set_toggle_mode (val: bool): - if is_inside_tree(): - $button.set_toggle_mode(val) + if is_inside_tree(): + $button.set_toggle_mode(val) func get_text(): return $button.get_text() @@ -45,9 +45,9 @@ func is_toggle_mode(): return $button.is_toggle_mode() func _on_button_toggled(val: bool): - if val: $state.set_texture(texture_state1) - else: $state.set_texture(texture_state0) + if val: $state.set_texture(texture_state1) + else: $state.set_texture(texture_state0) func button_connect(button_signal: String, proc: Callable): - $button.connect(button_signal, proc) + $button.connect(button_signal, proc) diff --git a/scenes/tab_switch.tscn b/scenes/tab_switch.tscn index 46db2b10..7b666cbd 100644 --- a/scenes/tab_switch.tscn +++ b/scenes/tab_switch.tscn @@ -1,27 +1,27 @@ [gd_scene load_steps=6 format=3 uid="uid://3slb0i3pvowc"] -[ext_resource type="Script" path="res://scenes/tab_switch.gd" id="1_33fiq"] -[ext_resource type="PackedScene" uid="uid://b276iygic5itk" path="res://scenes/работа.tscn" id="1_uow82"] -[ext_resource type="PackedScene" uid="uid://lwmw4egynmd1" path="res://scenes/контроль.tscn" id="2_83m7a"] -[ext_resource type="PackedScene" uid="uid://trt0q8th3bn2" path="res://scenes/журнал.tscn" id="3_hgnup"] -[ext_resource type="PackedScene" path="res://scenes/ЭМС.tscn" id="4_2bmbm"] +[ext_resource type="Script" path="res://scenes/tab_switch.gd" id="1_siu2d"] +[ext_resource type="PackedScene" uid="uid://b276iygic5itk" path="res://scenes/работа.tscn" id="2_c0cdr"] +[ext_resource type="PackedScene" uid="uid://lwmw4egynmd1" path="res://scenes/контроль.tscn" id="3_44o58"] +[ext_resource type="PackedScene" uid="uid://trt0q8th3bn2" path="res://scenes/журнал.tscn" id="4_vpsr1"] +[ext_resource type="PackedScene" uid="uid://dab6loryocc73" path="res://scenes/ЭМС.tscn" id="5_jlo8o"] [node name="tab_switch" type="TabContainer"] offset_right = 1600.0 offset_bottom = 1200.0 -script = ExtResource("1_33fiq") +script = ExtResource("1_siu2d") -[node name="работа" parent="." instance=ExtResource("1_uow82")] +[node name="работа" parent="." instance=ExtResource("2_c0cdr")] layout_mode = 2 -[node name="контроль" parent="." instance=ExtResource("2_83m7a")] +[node name="контроль" parent="." instance=ExtResource("3_44o58")] visible = false layout_mode = 2 -[node name="журнал" parent="." instance=ExtResource("3_hgnup")] +[node name="журнал" parent="." instance=ExtResource("4_vpsr1")] visible = false layout_mode = 2 -[node name="ЭМС" parent="." instance=ExtResource("4_2bmbm")] +[node name="ЭМС" parent="." instance=ExtResource("5_jlo8o")] visible = false layout_mode = 2 diff --git a/scenes/ЭМС.gd b/scenes/ЭМС.gd index bd6c2343..279a5549 100644 --- a/scenes/ЭМС.gd +++ b/scenes/ЭМС.gd @@ -1,187 +1,272 @@ extends Panel -var TableHeader = preload('res://table/header.tscn') -var TableNode = preload('res://scenes/ячейка-1.tscn') -var CellYemsButton = preload('res://scenes/кнопка-эмс.tscn') -var CellLineEdit = preload('res://scenes/ячейка-2.tscn') -var CellState = preload('res://scenes/состояния-эмс.tscn') -var CellOptBtn = preload('res://scenes/кнопка-5.tscn') - -# Таблица с данными для входов, первое значение - индекс устройства в ячейке КЭМС -const INPUT_ROWS = [ - [1,['НРЛС МР-231S, УИЗП', 'X31', '0', '0']], - [2,['НРЛС МР-231S, Строб ЭМС', 'X32', '0', '0']], - [3,['НРЛС МР-231-3, УИЗП', 'X34', '0', '0']], - [4,['НРЛС МР-231-3, Строб ЭМС', 'X35', '0', '0']], - [5,['ЦИСВС-1010, УИЗП', 'X43', '0', '0']], - [8,['4302-01, 4302-04, УИЗП', 'X46', '0', '0']], - [11,['НРЛС МР-231S, УИЗП', 'X51', '0', '0']], - [12,['НРЛС МР-231S, Строб ЭМС', 'X52', '0', '0']], - [13,['НРЛС МР-231-3, УИЗП', 'X54', '0', '0']], - [14,['НРЛС МР-231-3, Строб ЭМС', 'X55', '0', '0']], - [15,['ЦИСВС-1010, УИЗП', 'X23', '0', '0']], - [21,['НРЛС МР-231S, УИЗП', 'X21', '0', '0']], - [22,['НРЛС МР-231S, Строб ЭМС', 'X22', '0', '0']], - [23,['НРЛС МР-231-3, УИЗП', 'X24', '0', '0']], - [24,['НРЛС МР-231-3, Строб ЭМС', 'X25', '0', '0']], - [25,['ЦИСВС-1010, УИЗП', 'X23', '0', '0']]] - -# Таблица с данными для выходов, первое значение - индекс устройства в ячейке КЭМС -const OUTPUT_ROWS = [ - [41,['НРЛС МР-231S, БИ', 'X61', '0', '0']], - [42,['НРЛС МР-231S', 'X62', '0', '0']], - [43,['НРЛС МР-231-3, БИ', 'X64', '0', '0']], - [44,['НРЛС МР-231-3', 'X65', '0', '0']], - [45,['ЦИСВС-1010, БИ', 'X63', '0', '0']], - [46,['4302-01, 4302-04, БИ', 'X66', '0', '0']], - [48,['НРЛС 11111111', 'X69', '0', '0']], - [49,['НРЛС-222222, БИ', 'X62', '0', '0']]] +const TableHeader = preload('res://table/header.tscn') +const TableNode = preload('res://scenes/ячейка-1.tscn') +const CellYemsButton = preload('res://scenes/кнопка-эмс.tscn') +const CellLineEdit = preload('res://scenes/ячейка-2.tscn') +const CellState = preload('res://scenes/состояния-эмс.tscn') +const CellOptBtn = preload('res://scenes/кнопка-5.tscn') +const CellLEEmpty = preload('res://scenes/line_edit_empty.tscn') # Режимы работы выходов const OUT_MODE: Array = ['Работа', 'Контроль', '1', '0'] -const COLUMN_OPTS_BTN: Array = [6] +const COLUMN_OPTS_BTN: Array = [5] +const TABLE_ENTRY_COLUMNS: Array = [2,3] +const OUT_SET_ROW: Array = [CellLineEdit, CellLEEmpty, CellLEEmpty, CellLEEmpty, CellLEEmpty, CellLEEmpty] +const IN_SET_ROW: Array = [CellLineEdit, CellLEEmpty, CellLEEmpty, CellLEEmpty, CellLEEmpty] -const TABLE_ENTRY_COLUMNS: Array = [2,3,5] +var g_boards: Dictionary # Список плат -var g_in_devices : Dictionary # Словарь с входными устройствами КЭМС -var g_out_devices : Dictionary # Словарь с выходными устройствами КЭМС - -var posx: int = 50 # Позиция элементов по x -var posy: int = 80 # Позиция элементов по y +var posx: int = 35 # Позиция элементов по x +var posy: int = 60 # Позиция элементов по y func _ready() -> void: - $tbl_in.set_position(Vector2(posx,posy)) - $tbl_out.set_position(Vector2(posx,len(INPUT_ROWS)*33+posy+10)) - $tbl_files.set_position(Vector2(posx + 890,len(INPUT_ROWS)*33+posy+300)) - $btn_new.set_position(Vector2(posx + 1270,len(INPUT_ROWS)*33+posy+294)) - $btn_save.set_position(Vector2(posx + 1270,len(INPUT_ROWS)*33+posy+344)) - $btn_edit.set_position(Vector2(posx + 1270,len(INPUT_ROWS)*33+posy+394)) - $lbl_online.set_position(Vector2(posx,posy-40)) - $marker_in.set_position(Vector2(posx-15,posy+35)) - $marker_out.set_position(Vector2(posx-15,len(INPUT_ROWS)*33+posy+45)) - $btn_flash_read.set_position(Vector2(posx+1400,posy)) - $btn_flash_write.set_position(Vector2(posx+1400,posy+35)) - call_deferred('init_tbl_out') - call_deferred('init_tbl_in') - call_deferred('init_tbl_files') - $btn_flash_read.button_connect('pressed', Callable(self, 'on_btn_flash_read').bind($btn_flash_read)) - $btn_flash_write.button_connect('pressed', Callable(self, 'on_btn_flash_write').bind($btn_flash_write)) - $tbl_in.connect('row_pressed', Callable(self, 'on_row_pressed')) - $tbl_out.connect('row_pressed', Callable(self, 'on_row_pressed')) + call_deferred('init_boards') -func on_btn_flash_read(btn): - await get_tree().create_timer(0.1).timeout - btn.pressed = false +func init_boards(): + $scrollin.set_position(Vector2(posx,posy)) + $scrollout.set_position(Vector2(posx+650,posy)) + $scrl_in_set.set_position(Vector2(posx,posy + 700)) + $scrl_out_set.set_position(Vector2(posx+650,posy + 700)) + #$tbl_files.set_position(Vector2(posx + 890,len(INPUT_ROWS)*33+posy+300)) + #$btn_new.set_position(Vector2(posx + 1270,len(INPUT_ROWS)*33+posy+294)) + #$btn_save.set_position(Vector2(posx + 1270,len(INPUT_ROWS)*33+posy+344)) + #$btn_copy.set_position(Vector2(posx + 1270,len(INPUT_ROWS)*33+posy+394)) + $lbl_online.set_position(Vector2(posx,posy-60)) + $btn_flash_read.set_position(Vector2(posx+1400,posy)) + $btn_flash_write.set_position(Vector2(posx+1400,posy+35)) + $btn_connect.set_position(Vector2(posx+590,posy-25)) + g_boards['КЭМС'] = Yemsboards.EmsBoard.new('КЭМС', 0x130, YemsConsts.INPUT_ROWS0, YemsConsts.OUTPUT_ROWS0) + g_boards['П5-28'] = Yemsboards.EmsBoard.new('П5-28', 0x140, YemsConsts.INPUT_ROWS1, YemsConsts.OUTPUT_ROWS1) + init_tbls_in() + $scrollin/tbl_in.pin_header($scrollin, self) + init_tbls_out() + $scrollout/tbl_out.pin_header($scrollout, self) + $scrl_in_set/tbl_in_set.pin_header($scrl_in_set, self) + $scrl_out_set/tbl_out_set.pin_header($scrl_out_set, self) + $btn_connect.connect('pressed', Callable(self, 'on_btn_connect')) -func on_btn_flash_write(btn): - await get_tree().create_timer(0.1).timeout - btn.pressed = false +func init_tbls_in(): + var header_type: Array = [TableHeader, TableHeader, TableHeader, TableHeader, TableHeader] + var header_text: Array = ['Входы', 'Соединитель', 'мкс', 'мкс', 'Состояние'] + var row_type: Array = [CellLineEdit, CellLineEdit, CellLineEdit, CellLineEdit, CellState] + var yams_alligment_in: Array = [ HORIZONTAL_ALIGNMENT_LEFT, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] + var column_size: Array = [250, 100, 70, 70, 50] + $scrollin/tbl_in.set_header(header_type) + $scrollin/tbl_in.set_header_text(header_text) + $scrollin/tbl_in.set_columns_alignments(yams_alligment_in) + for board in g_boards: + for item in g_boards[board].in_tbl: + $scrollin/tbl_in.add_row(row_type) + var row_index : int = $scrollin/tbl_in.get_rows_count() - 1 + var params : Array = item[1] + var in_dev: YemsDevs.InDev = YemsDevs.InDev.new(item[0], params, row_index) + in_dev.board = board + for i in range(len(row_type)): + if i < len(params): + var node = $scrollin/tbl_in.get_node2(i, row_index) + node.text = params[i] + node.editable = false + $scrollin/tbl_in.set_node_user_data(i, row_index, [in_dev, board]) + $scrollin/tbl_in.set_columns_min_size(column_size) + $scrollin/tbl_in.connect('row_pressed', Callable(self, 'on_row_pressed_in')) + $scrollin/tbl_in.connect('selected_changed', Callable(self, 'on_selected_changed_in')) -func on_row_pressed(i_row: int): - $tbl_in.set_row_selected(i_row, false) + header_text[0] = 'Вход' + $scrl_in_set/tbl_in_set.set_header(header_type) + $scrl_in_set/tbl_in_set.set_header_text(header_text) + $scrl_in_set/tbl_in_set.set_columns_alignments(yams_alligment_in) + $scrl_in_set/tbl_in_set.set_columns_min_size(column_size) + + $scrl_in_set/tbl_in_set.connect('row_pressed', Callable(self, 'on_row_pressed_si')) + $scrl_in_set/tbl_in_set.connect('selected_changed', Callable(self, 'on_selected_changed_si')) -func init_tbl_files(): - $tbl_files.set_header([TableHeader, TableHeader, TableHeader]) - $tbl_files.set_header_text(['Имя файла', 'Размер', 'Дата']) - $tbl_files.set_columns_min_size([200, 70, 100]) +func on_selected_changed_in(i_row: int): + var selecter_rows: Array = [] + $scrollin/tbl_in.get_selected_rows(selecter_rows) + var user_data = $scrollin/tbl_in.get_node_user_data(0, i_row) + var dev = user_data[0] + var board = user_data[1] + set_in_dev(board, dev) -func init_tbl_out(): - var header_text = ['Выходы', 'Разъём', 'мкс', 'мкс', 'Состояние', 'Частота, Мгц', 'Режим'] - $tbl_out.set_header([TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader]) - $tbl_out.set_header_text(header_text) - for item in OUTPUT_ROWS: - $tbl_out.add_row([TableNode, TableNode, CellLineEdit, CellLineEdit, CellState, CellLineEdit, CellOptBtn]) - var row_index : int = $tbl_out.get_rows_count() - 1 - var params : Array = item[1] - var out_dev = YemsDevs.OutDev.new(item[0], params, row_index) - g_out_devices[item[0]] = out_dev - for i in range(len(header_text)): - if i < len(params): - var cell = $tbl_out.get_node2(i, row_index) - cell.text = params[i] - $tbl_out.set_node_user_data(i, row_index, out_dev) - if i in COLUMN_OPTS_BTN: - var cell = $tbl_out.get_node2(i, row_index) - for opt in OUT_MODE: - cell.add_item(opt) - cell.select(0) - $tbl_out.set_columns_min_size([270, 100, 70, 70, 100, 100, 100]) - $tbl_out.connect_columns(self, 'text_submitted', 'on_edit_entry_in', TABLE_ENTRY_COLUMNS, []) - $tbl_out.connect_columns(self, 'item_selected', 'on_item_selected', COLUMN_OPTS_BTN, []) +func on_row_pressed_in(i_row: int): + on_row_pressed(i_row, $scrollin/tbl_in) + on_selected_changed_in(i_row) -func init_tbl_in(): - var header_type: Array = [TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader] - var header_text: Array = ['Входы', 'Разъём', 'мкс', 'мкс', 'Состояние', 'Частота, Мгц',' '] - var row_type: Array = [TableNode, TableNode, CellLineEdit, CellLineEdit, CellState, CellLineEdit, TableNode] - var yams_alligment_in: Array = [ HORIZONTAL_ALIGNMENT_LEFT, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] - var column_size: Array = [270, 100, 70, 70, 100, 100, 300] - var dot_collums: Array = [] - var column_offset: int = 7 - for i in range(len(OUTPUT_ROWS)): - header_type.append(TableHeader) - header_text.append('...') - row_type.append(CellYemsButton) - yams_alligment_in.append(HORIZONTAL_ALIGNMENT_LEFT) - column_size.append(25) - dot_collums.append(column_offset+i) - $tbl_in.set_header(header_type) - $tbl_in.set_header_text(header_text) - $tbl_in.set_columns_alignments(yams_alligment_in) - for item in INPUT_ROWS: - $tbl_in.add_row(row_type) - var row_index : int = $tbl_in.get_rows_count() - 1 - var params : Array = item[1] - var in_dev: YemsDevs.InDev = YemsDevs.InDev.new(item[0], params, row_index) - g_in_devices[item[0]] = in_dev - for i in range(len(row_type)): - if i < len(params): - var node = $tbl_in.get_node2(i, row_index) - node.text = params[i] - if i in dot_collums: - var btn = $tbl_in.get_node2(i, row_index) - var out_dev = g_out_devices[OUTPUT_ROWS[i-column_offset][0]] - in_dev.out_dots = [btn, out_dev] - btn.button_connect('pressed', Callable(self, 'on_dot_button').bind(btn, i, row_index)) - btn.connect('mouse_entered', Callable(self, 'on_mouse_entered').bind(btn, i - dot_collums[0], row_index)) - $tbl_in.set_node_user_data(i, row_index, in_dev) - $tbl_in.set_columns_min_size(column_size) - $tbl_in.connect_columns(self, 'text_submitted', 'on_edit_entry_in', TABLE_ENTRY_COLUMNS, []) +func set_in_dev(_board, dev): + var row_type: Array = [CellLineEdit, CellLineEdit, CellLineEdit, CellLineEdit, CellState] + set_dev($scrl_in_set/tbl_in_set, dev, row_type, IN_SET_ROW, 'Список соединённых выходов :') -func on_dot_button(btn, i: int, j: int): - """ Вызывается при нажатии на кнопку-точку (соединение) - i - индекс входа, j - индекс выхода """ - print('on_dot_button(%d, %d)' % [i, j]) +func on_selected_changed_si(i_row: int): + if i_row < 2: + return + var out_user_data = $scrl_in_set/tbl_in_set.get_node_user_data(0, i_row) + var dev = out_user_data[0] + var dev_name = dev.dev_name + for i in range($scrollout/tbl_out.get_rows_count()): + var node = $scrollout/tbl_out.get_node2(0, i) + if dev_name == node.text: + on_row_pressed_out(i) -func on_edit_entry_in(text : String, entry): - var indexis = $tbl_in.get_key_indexes(entry[0].name) - var row_i = indexis[1] - var col_i = indexis[0] - print('ЭМС.gd -> on_edit_entry_in', text, row_i, col_i) +func on_row_pressed_si(i_row: int): + if i_row < 2: + return + on_row_pressed(i_row, $scrl_in_set/tbl_in_set) + on_selected_changed_si(i_row) -func on_edit_entry_out(text : String, entry): - var indexis = $tbl_out.get_key_indexes(entry[0].name) - var row_i = indexis[1] - var col_i = indexis[0] - print('ЭМС.gd -> on_edit_entry_out', text, row_i, col_i) +func init_tbls_out(): + var header_text = ['Выходы', 'Соединитель', 'мкс', 'мкс', 'Состояние', 'Режим'] + $scrollout/tbl_out.set_header([TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader]) + $scrollout/tbl_out.set_header_text(header_text) + for board in g_boards: + for item in g_boards[board].out_tbl: + $scrollout/tbl_out.add_row([CellLineEdit, CellLineEdit, CellLineEdit, CellLineEdit, CellState, CellLineEdit]) + var row_index : int = $scrollout/tbl_out.get_rows_count() - 1 + var params : Array = item[1] + var out_dev = YemsDevs.OutDev.new(item[0], params, row_index) + out_dev.board = board + for i in range(len(header_text)): + var cell = $scrollout/tbl_out.get_node2(i, row_index) + if i < len(params): + cell.text = params[i] + cell.editable = false + $scrollout/tbl_out.set_node_user_data(i, row_index, [out_dev, board]) + if i in COLUMN_OPTS_BTN: + cell.text = out_dev.mode + $scrollout/tbl_out.set_columns_min_size([250, 100, 70, 70, 70, 100]) + $scrollout/tbl_out.connect('row_pressed', Callable(self, 'on_row_pressed_out')) + $scrollout/tbl_out.connect('selected_changed', Callable(self, 'on_selected_changed_out')) + + header_text[0] = 'Выход' + $scrl_out_set/tbl_out_set.set_header([TableHeader, TableHeader, TableHeader, TableHeader, TableHeader, TableHeader]) + $scrl_out_set/tbl_out_set.set_header_text(header_text) + $scrl_out_set/tbl_out_set.set_columns_min_size([250, 100, 70, 70, 70, 100]) + $scrl_out_set/tbl_out_set.connect('row_pressed', Callable(self, 'on_row_pressed_so')) + $scrl_out_set/tbl_out_set.connect('selected_changed', Callable(self, 'on_selected_changed_so')) -func on_item_selected(item_num, node): - var optbtn_text = node[0].text - var indexis = $tbl_out.get_key_indexes(node[0].name) - var row_i = indexis[1] - var col_i = indexis[0] - print('ЭМС.gd -> on_item_selected row: %d col: %d text: %s' %[row_i, col_i, optbtn_text]) +func on_selected_changed_so(i_row: int): + if i_row < 2: + return + var in_user_data = $scrl_out_set/tbl_out_set.get_node_user_data(0, i_row) + var dev = in_user_data[0] + var dev_name = dev.dev_name + for i in range($scrollin/tbl_in.get_rows_count()): + var node = $scrollin/tbl_in.get_node2(0, i) + if dev_name == node.text: + on_row_pressed_in(i) -func on_mouse_entered(btn, i, j): - $marker_in.position.y = $tbl_in.position.y + btn.position.y + btn.size.y / 2 - $marker_out.position.y = $tbl_out.position.y + (btn.size.y + 4) * i + btn.size.y / 2 +func on_row_pressed_so(i_row: int): + if i_row < 2: + return + on_row_pressed(i_row, $scrl_out_set/tbl_out_set) + on_selected_changed_so(i_row) + + +func on_selected_changed_out(i_row: int): + var selecter_rows: Array = [] + $scrollout/tbl_out.get_selected_rows(selecter_rows) + var user_data = $scrollout/tbl_out.get_node_user_data(0, i_row) + var dev = user_data[0] + var board = user_data[1] + set_out_dev(board, dev) + + +func on_row_pressed_out(i_row: int): + on_row_pressed(i_row, $scrollout/tbl_out) + on_selected_changed_out(i_row) + + +func set_out_dev(_board, dev): + var row_type: Array = [CellLineEdit, CellLineEdit, CellLineEdit, CellLineEdit, CellState, CellOptBtn] + set_dev($scrl_out_set/tbl_out_set, dev, row_type, OUT_SET_ROW, 'Список соединённых входов :') + var mode = $scrl_out_set/tbl_out_set.get_node2(5, 0) + for opt in OUT_MODE: + mode.add_item(opt) + var mode_index: int = OUT_MODE.find(dev.mode) + if mode_index != -1: + mode.select(mode_index) + + +func set_dev(tbl, dev, row_type, row_type_conn, lbl_text): + tbl.clear_rows() + tbl.add_row(row_type) + var le_name: LineEdit = tbl.get_node2(0, 0) + le_name.editable = false + le_name.text = dev.dev_name + var connector: LineEdit = tbl.get_node2(1, 0) + connector.editable = false + connector.text = dev.connector + var delay: LineEdit = tbl.get_node2(2, 0) + delay.text = '%4.2f'%dev.delay + var offset: LineEdit = tbl.get_node2(3, 0) + offset.text = '%4.2f'%dev.offset + var state = tbl.get_node2(4, 0) + state.set_frame(dev.state) + + tbl.add_row(row_type_conn) + var lbl: LineEdit = tbl.get_node2(0, 1) + lbl.text = lbl_text + for i in len(row_type_conn): + var le: LineEdit = tbl.get_node2(i, 1) + le.editable = false + + for i in dev.connect_devs: + var dev_con = dev.connect_devs[i][0] + tbl.add_row(row_type_conn) + var node_index: Array = [0, tbl.get_rows_count() -1] + var le_name_out: LineEdit = tbl.get_node2(node_index[0], node_index[1]) + disable_edit(tbl, len(row_type_conn), node_index[1]) + le_name_out.text = dev_con.dev_name + tbl.set_node_user_data(node_index[0], node_index[1], dev.connect_devs[i]) + + +func on_btn_connect(): + var in_row_index: Array = [] + var out_row_index: Array = [] + $scrollin/tbl_in.get_selected_rows(in_row_index) + $scrollout/tbl_out.get_selected_rows(out_row_index) + if len(in_row_index) and len(out_row_index): + var in_user_data = $scrollin/tbl_in.get_node_user_data(0, in_row_index[0]) + var out_user_data = $scrollout/tbl_out.get_node_user_data(0, out_row_index[0]) + var in_dev = in_user_data[0] + var out_dev = out_user_data[0] + add_connection_dev($scrl_out_set/tbl_out_set, in_dev, out_dev, OUT_SET_ROW, in_user_data) + add_connection_dev($scrl_in_set/tbl_in_set, out_dev, in_dev, IN_SET_ROW, out_user_data) + + +func add_connection_dev(tbl, dev1, dev2, set_row, user_data): + if not dev1.dev_name in dev2.connect_devs: + tbl.add_row(set_row) + var node_index: Array = [0, tbl.get_rows_count() -1] + var le_name: LineEdit = tbl.get_node2(node_index[0], node_index[1]) + le_name.text = dev1.dev_name + disable_edit(tbl, len(set_row), node_index[1]) + tbl.set_node_user_data(node_index[0], node_index[1], user_data) + dev2.connect_devs[dev1.dev_name] = user_data + + +func disable_edit(tbl, num_col: int, i_row: int): + for col in range(num_col): + var node: LineEdit = tbl.get_node2(col, i_row) + node.editable = false + + +func on_row_pressed(i_row: int, tbl): + tbl.clear_rows_selected() + var is_row_selected = tbl.is_row_selected(i_row) + tbl.set_row_selected(i_row, not is_row_selected) + + +func _process(_delta): + pass diff --git a/scenes/ЭМС.tscn b/scenes/ЭМС.tscn index 75923421..7b40320d 100644 --- a/scenes/ЭМС.tscn +++ b/scenes/ЭМС.tscn @@ -1,17 +1,17 @@ -[gd_scene load_steps=8 format=3 uid="uid://c6uls7q4e2m4h"] +[gd_scene load_steps=8 format=3 uid="uid://dab6loryocc73"] -[ext_resource type="Script" path="res://scenes/ЭМС.gd" id="1_t1s35"] -[ext_resource type="Script" path="res://table/table.gd" id="2_6x8yw"] -[ext_resource type="Texture2D" uid="uid://dahjma3aqkfc0" path="res://data/эмс-указатель.png" id="3_j3w75"] -[ext_resource type="PackedScene" uid="uid://da7w3vkhadfwe" path="res://scenes/button_flat.tscn" id="4_v64lt"] -[ext_resource type="Texture2D" uid="uid://dd60btbqnpiqw" path="res://data/document-new-0.png" id="5_osu07"] -[ext_resource type="Texture2D" uid="uid://coqg6wsftvtxr" path="res://data/document-save-0.png" id="6_8684b"] -[ext_resource type="Texture2D" uid="uid://cywuevvpkxl7v" path="res://data/edit-copy-0.png" id="7_85ydm"] +[ext_resource type="Script" path="res://scenes/ЭМС.gd" id="1_ei0cy"] +[ext_resource type="Script" path="res://table/table.gd" id="2_n0fa5"] +[ext_resource type="PackedScene" uid="uid://da7w3vkhadfwe" path="res://scenes/button_flat.tscn" id="3_htu6q"] +[ext_resource type="Texture2D" uid="uid://dd60btbqnpiqw" path="res://data/document-new-0.png" id="4_udjkh"] +[ext_resource type="Texture2D" uid="uid://coqg6wsftvtxr" path="res://data/document-save-0.png" id="5_cwv76"] +[ext_resource type="Texture2D" uid="uid://cywuevvpkxl7v" path="res://data/edit-copy-0.png" id="6_hr8ru"] +[ext_resource type="Texture2D" uid="uid://7h55yvh84cve" path="res://data/connect.png" id="7_8mn17"] [node name="ЭМС" type="Panel"] offset_right = 1598.0 offset_bottom = 1201.0 -script = ExtResource("1_t1s35") +script = ExtResource("1_ei0cy") [node name="lbl_online" type="Label" parent="."] layout_mode = 0 @@ -22,41 +22,15 @@ offset_bottom = 30.0 theme_override_colors/font_color = Color(1, 0, 0, 1) text = "Ячейка не на связи" -[node name="tbl_in" type="GridContainer" parent="."] -layout_mode = 0 -offset_left = 30.0 -offset_top = 46.0 -offset_right = 825.0 -offset_bottom = 182.0 -script = ExtResource("2_6x8yw") - -[node name="tbl_out" type="GridContainer" parent="."] -layout_mode = 0 -offset_left = 46.0 -offset_top = 588.0 -offset_right = 598.0 -offset_bottom = 688.0 -script = ExtResource("2_6x8yw") - [node name="tbl_files" type="GridContainer" parent="."] layout_mode = 0 offset_left = 1050.0 offset_top = 993.0 offset_right = 1602.0 offset_bottom = 1093.0 -script = ExtResource("2_6x8yw") +script = ExtResource("2_n0fa5") -[node name="marker_in" type="Sprite2D" parent="."] -modulate = Color(0.964706, 0.490196, 0, 1) -position = Vector2(19, 37) -texture = ExtResource("3_j3w75") - -[node name="marker_out" type="Sprite2D" parent="."] -modulate = Color(0.964706, 0.490196, 0, 1) -position = Vector2(19, 77) -texture = ExtResource("3_j3w75") - -[node name="btn_flash_read" parent="." instance=ExtResource("4_v64lt")] +[node name="btn_flash_read" parent="." instance=ExtResource("3_htu6q")] layout_mode = 0 offset_left = 1446.0 offset_top = 55.0 @@ -64,7 +38,7 @@ offset_right = 1583.0 offset_bottom = 85.0 text = "Прочитать" -[node name="btn_flash_write" parent="." instance=ExtResource("4_v64lt")] +[node name="btn_flash_write" parent="." instance=ExtResource("3_htu6q")] layout_mode = 0 offset_left = 1446.0 offset_top = 99.0 @@ -81,7 +55,7 @@ offset_bottom = 1016.0 focus_mode = 0 shortcut_feedback = false shortcut_in_tooltip = false -icon = ExtResource("5_osu07") +icon = ExtResource("4_udjkh") [node name="btn_save" type="Button" parent="."] layout_mode = 0 @@ -90,13 +64,67 @@ offset_top = 1017.0 offset_right = 1509.0 offset_bottom = 1073.0 focus_mode = 0 -icon = ExtResource("6_8684b") +icon = ExtResource("5_cwv76") -[node name="btn_edit" type="Button" parent="."] +[node name="btn_copy" type="Button" parent="."] layout_mode = 0 offset_left = 1454.0 offset_top = 1074.0 offset_right = 1510.0 offset_bottom = 1130.0 focus_mode = 0 -icon = ExtResource("7_85ydm") +icon = ExtResource("6_hr8ru") + +[node name="btn_connect" type="Button" parent="."] +layout_mode = 0 +offset_left = 627.0 +offset_top = 55.0 +offset_right = 683.0 +offset_bottom = 111.0 +focus_mode = 0 +theme_override_colors/icon_normal_color = Color(1, 1, 1, 1) +icon = ExtResource("7_8mn17") + +[node name="scrollin" type="ScrollContainer" parent="."] +layout_mode = 0 +offset_left = 56.0 +offset_top = 52.0 +offset_right = 641.0 +offset_bottom = 679.0 + +[node name="tbl_in" type="GridContainer" parent="scrollin"] +layout_mode = 2 +script = ExtResource("2_n0fa5") + +[node name="scrollout" type="ScrollContainer" parent="."] +layout_mode = 0 +offset_left = 657.0 +offset_top = 50.0 +offset_right = 1351.0 +offset_bottom = 679.0 + +[node name="tbl_out" type="GridContainer" parent="scrollout"] +layout_mode = 2 +script = ExtResource("2_n0fa5") + +[node name="scrl_in_set" type="ScrollContainer" parent="."] +layout_mode = 0 +offset_left = 120.0 +offset_top = 776.0 +offset_right = 689.0 +offset_bottom = 942.0 + +[node name="tbl_in_set" type="GridContainer" parent="scrl_in_set"] +layout_mode = 2 +script = ExtResource("2_n0fa5") + +[node name="scrl_out_set" type="ScrollContainer" parent="."] +layout_mode = 0 +offset_left = 719.0 +offset_top = 773.0 +offset_right = 1437.0 +offset_bottom = 924.0 + +[node name="tbl_out_set" type="GridContainer" parent="scrl_out_set"] +layout_mode = 2 +script = ExtResource("2_n0fa5") diff --git a/scenes/кнопка-5.tscn b/scenes/кнопка-5.tscn index 5648d543..a23176ff 100644 --- a/scenes/кнопка-5.tscn +++ b/scenes/кнопка-5.tscn @@ -1,3 +1,6 @@ -[gd_scene format=3 uid="uid://dwcol6jg2syof"] +[gd_scene load_steps=2 format=3 uid="uid://dwcol6jg2syof"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ftyvw"] [node name="OptionButton" type="OptionButton"] +theme_override_styles/focus = SubResource("StyleBoxEmpty_ftyvw") diff --git a/scenes/контроль.tscn b/scenes/контроль.tscn index 629fa1aa..21f7ddaf 100644 --- a/scenes/контроль.tscn +++ b/scenes/контроль.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=7 format=3 uid="uid://lwmw4egynmd1"] -[ext_resource type="Script" path="res://scenes/контроль.gd" id="1_i5eo5"] -[ext_resource type="Texture2D" uid="uid://bar8k5qef7kch" path="res://data/УФ.png" id="2_drana"] -[ext_resource type="Texture2D" uid="uid://dkqlvd750pplc" path="res://data/СПТ.png" id="3_v54hc"] -[ext_resource type="Texture2D" uid="uid://b4isaggma6q3" path="res://data/Грани22.png" id="4_kwlmx"] -[ext_resource type="Texture2D" uid="uid://d2jxmtd6n5jd1" path="res://data/Щ3.png" id="5_8abdt"] -[ext_resource type="Texture2D" uid="uid://bos68thpqqvn" path="res://data/ПРД.png" id="6_sgnkf"] +[ext_resource type="Script" path="res://scenes/контроль.gd" id="1_x5d6w"] +[ext_resource type="Texture2D" uid="uid://bar8k5qef7kch" path="res://data/УФ.png" id="2_0nvm1"] +[ext_resource type="Texture2D" uid="uid://dkqlvd750pplc" path="res://data/СПТ.png" id="3_hhadv"] +[ext_resource type="Texture2D" uid="uid://b4isaggma6q3" path="res://data/Грани22.png" id="4_l0nc7"] +[ext_resource type="Texture2D" uid="uid://d2jxmtd6n5jd1" path="res://data/Щ3.png" id="5_kvnex"] +[ext_resource type="Texture2D" uid="uid://bos68thpqqvn" path="res://data/ПРД.png" id="6_i1yfn"] [node name="Контроль" type="Panel"] anchors_preset = 15 @@ -13,7 +13,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_i5eo5") +script = ExtResource("1_x5d6w") metadata/_edit_lock_ = true [node name="pribor_uf" type="TextureButton" parent="."] @@ -24,7 +24,7 @@ offset_right = 1191.0 offset_bottom = 657.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("2_drana") +texture_normal = ExtResource("2_0nvm1") stretch_mode = 4 [node name="pribor_rtr" type="TextureButton" parent="."] @@ -35,7 +35,7 @@ offset_right = 1198.0 offset_bottom = 361.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("3_v54hc") +texture_normal = ExtResource("3_hhadv") stretch_mode = 4 [node name="pribor_afsp_l" type="TextureButton" parent="."] @@ -47,7 +47,7 @@ offset_bottom = 860.0 scale = Vector2(0.2, 0.2) size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("4_kwlmx") +texture_normal = ExtResource("4_l0nc7") stretch_mode = 4 [node name="pribor_afsp_r" type="TextureButton" parent="."] @@ -59,7 +59,7 @@ offset_bottom = 865.0 scale = Vector2(0.2, 0.2) size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("4_kwlmx") +texture_normal = ExtResource("4_l0nc7") stretch_mode = 4 [node name="pribor_sch3" type="TextureButton" parent="."] @@ -70,7 +70,7 @@ offset_right = 1208.0 offset_bottom = 951.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("5_8abdt") +texture_normal = ExtResource("5_kvnex") stretch_mode = 4 [node name="pribor_spt_l" type="TextureButton" parent="."] @@ -81,7 +81,7 @@ offset_right = 1053.0 offset_bottom = 951.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("3_v54hc") +texture_normal = ExtResource("3_hhadv") stretch_mode = 4 [node name="pribor_spt_r" type="TextureButton" parent="."] @@ -92,7 +92,7 @@ offset_right = 1353.0 offset_bottom = 951.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("3_v54hc") +texture_normal = ExtResource("3_hhadv") stretch_mode = 4 [node name="pribor_prd_v_2" type="TextureButton" parent="."] @@ -103,7 +103,7 @@ offset_right = 872.0 offset_bottom = 377.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 [node name="pribor_prd_n_2" type="TextureButton" parent="."] @@ -114,7 +114,7 @@ offset_right = 827.0 offset_bottom = 553.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 [node name="pribor_prd_k_2" type="TextureButton" parent="."] @@ -125,7 +125,7 @@ offset_right = 952.0 offset_bottom = 555.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 [node name="pribor_prd_v_3" type="TextureButton" parent="."] @@ -136,7 +136,7 @@ offset_right = 1494.0 offset_bottom = 896.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 flip_h = true @@ -148,7 +148,7 @@ offset_right = 1417.0 offset_bottom = 721.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 flip_h = true @@ -160,7 +160,7 @@ offset_right = 1537.0 offset_bottom = 721.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 flip_h = true @@ -172,7 +172,7 @@ offset_right = 1522.0 offset_bottom = 391.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 flip_h = true @@ -184,7 +184,7 @@ offset_right = 1412.0 offset_bottom = 553.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 flip_h = true @@ -196,7 +196,7 @@ offset_right = 1537.0 offset_bottom = 562.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 flip_h = true @@ -208,7 +208,7 @@ offset_right = 882.0 offset_bottom = 896.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 [node name="pribor_prd_n_4" type="TextureButton" parent="."] @@ -219,7 +219,7 @@ offset_right = 827.0 offset_bottom = 723.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 [node name="pribor_prd_k_4" type="TextureButton" parent="."] @@ -230,7 +230,7 @@ offset_right = 962.0 offset_bottom = 723.0 size_flags_horizontal = 15 size_flags_vertical = 15 -texture_normal = ExtResource("6_sgnkf") +texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 [node name="pribor_sch" type="Panel" parent="."] diff --git a/scenes/переключатель-эмс.tscn b/scenes/переключатель-эмс.tscn index c2a6b61b..25d81523 100644 --- a/scenes/переключатель-эмс.tscn +++ b/scenes/переключатель-эмс.tscn @@ -1,24 +1,24 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=6 format=3 uid="uid://cmtgncelo01jh"] -[sub_resource type="StyleBoxEmpty" id=1] +[sub_resource type="StyleBoxEmpty" id="3"] -[sub_resource type="StyleBoxEmpty" id=2] +[sub_resource type="StyleBoxEmpty" id="5"] -[sub_resource type="StyleBoxEmpty" id=3] +[sub_resource type="StyleBoxEmpty" id="1"] -[sub_resource type="StyleBoxEmpty" id=4] +[sub_resource type="StyleBoxEmpty" id="2"] -[sub_resource type="StyleBoxEmpty" id=5] +[sub_resource type="StyleBoxEmpty" id="4"] [node name="Node2D" type="OptionButton"] -self_modulate = Color( 1, 0.596078, 0.4, 1 ) +self_modulate = Color(1, 0.596078, 0.4, 1) +custom_minimum_size = Vector2(60, 0) offset_right = 70.0 offset_bottom = 23.0 -custom_minimum_size = Vector2( 60, 0 ) size_flags_horizontal = 15 size_flags_vertical = 15 -theme_override_styles/hover = SubResource( 1 ) -theme_override_styles/pressed = SubResource( 2 ) -theme_override_styles/focus = SubResource( 3 ) -theme_override_styles/disabled = SubResource( 4 ) -theme_override_styles/normal = SubResource( 5 ) +theme_override_styles/focus = SubResource("3") +theme_override_styles/normal = SubResource("5") +theme_override_styles/hover = SubResource("1") +theme_override_styles/pressed = SubResource("2") +theme_override_styles/disabled = SubResource("4") diff --git a/scenes/работа.gd b/scenes/работа.gd index e2840f24..f39576de 100644 --- a/scenes/работа.gd +++ b/scenes/работа.gd @@ -50,11 +50,11 @@ func on_threats_changed(threats: Dictionary, th: Object): $count_all_pad/count_a ## Производит инициализацию func _ready(): - $btn_strobe.button_connect('pressed', Callable(self, 'on_button_strobe_pressed')) - $btn_off.set_pressed(true) - strob_center = $canvas.get_strob_center() - on_button_strobe_pressed() - drag_fsm = DragFSM.OFF + $btn_strobe.button_connect('pressed', Callable(self, 'on_button_strobe_pressed')) + $btn_off.set_pressed(true) + strob_center = $canvas.get_strob_center() + on_button_strobe_pressed() + drag_fsm = DragFSM.OFF var nodes: = get_tree().get_nodes_in_group('группа-режим-помехи') nodes.any(func(btn): btn.button_connect('pressed', Callable(self, 'on_button_pressed').bind(btn, nodes))) Threats.connect('threat_lost', Callable(self, 'on_threat_lost')) @@ -89,7 +89,6 @@ func on_threat_new(threats: Dictionary, th: Object): map_threat_to_bip(th, bip) add_child(bip) - ## Обработчик сигнала потери цели func on_threat_lost(threats: Dictionary, th: Object): var bip = get_node('%d' % th.id) @@ -99,17 +98,17 @@ func on_threat_lost(threats: Dictionary, th: Object): ## Обработчик нажатия кнопки "Строб". Управляет отображением строба func on_button_strobe_pressed(): - if $btn_strobe.is_pressed(): - $canvas.set_strob_visible(true) - drag_fsm = DragFSM.IDLE - else: - $canvas.set_strob_visible(false) - drag_fsm = DragFSM.OFF + if $btn_strobe.is_pressed(): + $canvas.set_strob_visible(true) + drag_fsm = DragFSM.IDLE + else: + $canvas.set_strob_visible(false) + drag_fsm = DragFSM.OFF ## Поведение радиокнопок в группе. Управляет состоянием кнопок в радиогруппе func on_button_pressed(btn_this, btn_others): - for btn_other in btn_others: btn_other.set_pressed(btn_this == btn_other) + for btn_other in btn_others: btn_other.set_pressed(btn_this == btn_other) ## Возвращает ширину строба по направлению @@ -121,9 +120,9 @@ func get_strob_width(pos: Vector2, prev: float) -> float: ## Возвращает ширину строба по частоте func get_strob_band(pos: Vector2, prev: float) -> float: - var strob_dir_band: float = prev - (drag_pos_begin.y - pos.y) * drag_scale_band - strob_dir_band = Tools.clip_value(strob_dir_band, strob_min_band, strob_max_band) - return strob_dir_band + var strob_dir_band: float = prev - (drag_pos_begin.y - pos.y) * drag_scale_band + strob_dir_band = Tools.clip_value(strob_dir_band, strob_min_band, strob_max_band) + return strob_dir_band ## Устанавливает центр строба по частоте и направлению @@ -159,23 +158,23 @@ func _on_drag_begin(event): ## Обработчик событий вввода. Вызывается godot func _input(event): - if event is InputEventMouseMotion: - if drag_fsm == DragFSM.DRAG: - emit_signal('drag_continue', event) - elif event is InputEventMouseButton: - drag_button = event.button_index - if event.pressed: - if drag_fsm == DragFSM.IDLE: - drag_fsm = DragFSM.DRAG - emit_signal('drag_begin', event) - else: - drag_fsm = DragFSM.IDLE - emit_signal('drag_end', event) - elif event is InputEventKey: - if event.pressed and event.physical_keycode == KEY_F11: - emit_signal('full_screen') - elif event.physical_keycode == KEY_SHIFT: - shift_pressed = event.pressed + if event is InputEventMouseMotion: + if drag_fsm == DragFSM.DRAG: + emit_signal('drag_continue', event) + elif event is InputEventMouseButton: + drag_button = event.button_index + if event.pressed: + if drag_fsm == DragFSM.IDLE: + drag_fsm = DragFSM.DRAG + emit_signal('drag_begin', event) + else: + drag_fsm = DragFSM.IDLE + emit_signal('drag_end', event) + elif event is InputEventKey: + if event.pressed and event.physical_keycode == KEY_F11: + emit_signal('full_screen') + elif event.physical_keycode == KEY_SHIFT: + shift_pressed = event.pressed ## Переключает режим окна программы полный - обычный экран diff --git a/scenes/состояния-эмс.gd b/scenes/состояния-эмс.gd index 39a0d965..2854dfb9 100644 --- a/scenes/состояния-эмс.gd +++ b/scenes/состояния-эмс.gd @@ -3,3 +3,5 @@ var align : get = get_align, set = set_align var _align: int = 0 func set_align(val: int): _align = val func get_align(): return _align +func set_frame(val: int): $sprite.set_frame(val) +func get_frame(): return $sprite.get_frame() diff --git a/scenes/состояния-эмс.tscn b/scenes/состояния-эмс.tscn index e9def59f..12f344ed 100644 --- a/scenes/состояния-эмс.tscn +++ b/scenes/состояния-эмс.tscn @@ -1,25 +1,25 @@ [gd_scene load_steps=7 format=3 uid="uid://by22sta8tt8dn"] -[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="1_0wisd"] -[ext_resource type="Script" path="res://scenes/состояния-эмс.gd" id="1_vw38j"] -[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="2_nbah5"] -[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="3_vsgfs"] -[ext_resource type="Texture2D" uid="uid://dvl3sq036gn75" path="res://data/эмс-бланк-замыкание.png" id="4_qu3c5"] +[ext_resource type="Script" path="res://scenes/состояния-эмс.gd" id="1_ak0xd"] +[ext_resource type="Texture2D" uid="uid://belwchvdktrw0" path="res://data/эмс-бланк.png" id="2_1bili"] +[ext_resource type="Texture2D" uid="uid://bwddxs24es81u" path="res://data/эмс-бланк-пост.png" id="3_yw5yv"] +[ext_resource type="Texture2D" uid="uid://pfoscstbm025" path="res://data/эмс-бланк-перем.png" id="4_1fli0"] +[ext_resource type="Texture2D" uid="uid://dvl3sq036gn75" path="res://data/эмс-бланк-замыкание.png" id="5_sbva1"] [sub_resource type="SpriteFrames" id="SpriteFrames_ow7xh"] animations = [{ "frames": [{ "duration": 1.0, -"texture": ExtResource("1_0wisd") +"texture": ExtResource("2_1bili") }, { "duration": 1.0, -"texture": ExtResource("2_nbah5") +"texture": ExtResource("3_yw5yv") }, { "duration": 1.0, -"texture": ExtResource("3_vsgfs") +"texture": ExtResource("4_1fli0") }, { "duration": 1.0, -"texture": ExtResource("4_qu3c5") +"texture": ExtResource("5_sbva1") }], "loop": true, "name": &"default", @@ -33,7 +33,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_vw38j") +script = ExtResource("1_ak0xd") [node name="sprite" type="AnimatedSprite2D" parent="."] position = Vector2(14, 9) diff --git a/scenes/ячейка-2.tscn b/scenes/ячейка-2.tscn index 0bd9fe8a..ac0ba0b0 100644 --- a/scenes/ячейка-2.tscn +++ b/scenes/ячейка-2.tscn @@ -1,11 +1,18 @@ -[gd_scene format=3 uid="uid://dspa16ufrpanp"] +[gd_scene load_steps=2 format=3 uid="uid://dspa16ufrpanp"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_mla3y"] [node name="LineEdit" type="LineEdit"] offset_right = 58.0 offset_bottom = 33.0 theme_override_colors/font_color = Color(1, 0.596078, 0.4, 1) +theme_override_colors/font_uneditable_color = Color(1, 0.596078, 0.4, 1) +theme_override_styles/focus = SubResource("StyleBoxEmpty_mla3y") +alignment = 1 context_menu_enabled = false shortcut_keys_enabled = false middle_mouse_paste_enabled = false +selecting_enabled = false +deselect_on_focus_loss_enabled = false caret_blink = true -caret_blink_interval = 0.13 +caret_blink_interval = 0.1 diff --git a/scripts/repnetwork.gd b/scripts/repnetwork.gd index 68a00672..cba6c8f2 100644 --- a/scripts/repnetwork.gd +++ b/scripts/repnetwork.gd @@ -15,46 +15,46 @@ var logger_page: Node func create_socket(nm) -> Socket: - var addr = REPSettings.UnitProfiles[nm][1] - var port = REPSettings.UnitProfiles[nm][2] - var broad = REPSettings.UnitProfiles[nm][3] - var bind = REPSettings.UnitProfiles[nm][4] - var sock: = Socket.new() - sock.set_broadcast_enabled(broad) - var rc = Error.OK if not bind else sock.bind(port, addr) - var errlevel = Log.INFO if rc == Error.OK else Log.ERROR - Log.message(errlevel, '%s: сокет:%s:%d привязанный:%s %s' % [nm, addr, port, ['нет', 'да'][int(bind)], error_string(rc)]) - return sock + var addr = REPSettings.UnitProfiles[nm][1] + var port = REPSettings.UnitProfiles[nm][2] + var broad = REPSettings.UnitProfiles[nm][3] + var bind = REPSettings.UnitProfiles[nm][4] + var sock: = Socket.new() + sock.set_broadcast_enabled(broad) + var rc = Error.OK if not bind else sock.bind(port, addr) + var errlevel = Log.INFO if rc == Error.OK else Log.ERROR + Log.message(errlevel, '%s: сокет:%s:%d привязанный:%s %s' % [nm, addr, port, ['нет', 'да'][int(bind)], error_string(rc)]) + return sock func _ready() -> void: - Log.info('Сетевой модуль готов') + Log.info('Сетевой модуль готов') poll_sockets.append(create_socket('уарэп-яу07-частный')) - poll_sockets.append(create_socket('уарэп-яу07-общий')) - poll_sockets.append(create_socket('уарэп-капсрпб-пол')) + poll_sockets.append(create_socket('уарэп-яу07-общий')) + poll_sockets.append(create_socket('уарэп-капсрпб-пол')) sock_unicast = poll_sockets[0] for unit_name in REPSettings.UnitProfiles: - var setting = REPSettings.UnitProfiles[unit_name] - var proto = setting[0] - if proto in PROTOCOL_TYPES: - var unit = PROTOCOL_TYPES[proto].new(unit_name) - var unit_key = REPSettings.get_unit_key(unit_name) - units[unit_key] = unit - unit.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key)) - unit.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key)) + var setting = REPSettings.UnitProfiles[unit_name] + var proto = setting[0] + if proto in PROTOCOL_TYPES: + var unit = PROTOCOL_TYPES[proto].new(unit_name) + var unit_key = REPSettings.get_unit_key(unit_name) + units[unit_key] = unit + unit.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key)) + unit.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key)) for key in units: Log.info('%s %s:%d' % [units[key].name, key[0], key[1]]) func poll_receive(sock: Socket) -> bool: - 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] - if addr_port in units: units[addr_port].parse(data) + 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] + if addr_port in units: units[addr_port].parse(data) return false diff --git a/scripts/threats.gd b/scripts/threats.gd index 072c07bb..e450ab50 100644 --- a/scripts/threats.gd +++ b/scripts/threats.gd @@ -27,10 +27,10 @@ class Threat: var width: float ## Ширина занимаемого диапазона частот, МГц. var id: int ## Идентификатор цели. - func _init(): Tools.get_members_names(self).any(func(vn): fflags[vn] = false) + func _init(): Tools.get_members_names(self).any(func(vn): fflags[vn] = false) func _to_string() -> String: return 'номер:%d пеленг:%0.1f частота:%0.1f МГц' % [id, aoa, freq] - func set_from_dic(dic_vals: Dictionary): + func set_from_dic(dic_vals: Dictionary): var items: = fflags.keys().filter(func(vn): return vn in dic_vals) items.any(func(vn): set(vn, dic_vals[vn]); fflags[vn] = true; return false) @@ -43,12 +43,12 @@ var threats = {} ## Список целей. Индекс - <источник func _ready() -> void: - Log.info('Модуль обработки целей готов') - var unit_key = REPSettings.get_unit_key('уарэп-капсрпб-отп') + Log.info('Модуль обработки целей готов') + #var unit_key = REPSettings.get_unit_key('уарэп-капсрпб-отп') var unit = REPNetwork.units[unit_key] var timer_check_lost: = Timer.new() add_child(timer_check_lost) - unit.connect('data_received', Callable(self, 'on_data_capsrpb_received')) + #unit.connect('data_received', Callable(self, 'on_data_capsrpb_received')) timer_check_lost.connect('timeout', Callable(self, 'on_timer_check_lost').bind(unit, REPSettings.ThreatParams.time_lost[0])) timer_check_lost.start(REPSettings.ThreatParams.time_lost[0] / 2.0) @@ -63,7 +63,7 @@ func on_timer_check_lost(unit, time_lost: int): ## Приём целей func on_data_capsrpb_received(unit: capsrpb.CapsRpb): - if 'mis' not in unit.json_dic: + if 'mis' not in unit.json_dic: return var mis = unit.json_dic['mis'] for dic_th in mis: diff --git a/scripts/yems_consts.gd b/scripts/yems_consts.gd new file mode 100644 index 00000000..daf82982 --- /dev/null +++ b/scripts/yems_consts.gd @@ -0,0 +1,65 @@ +extends Node + + +# Таблица с данными для входов, первое значение - индекс устройства в ячейке КЭМС +const INPUT_ROWS0 = [ + [1,['1111 МР-231S, УИЗП', 'X31', '0.00', '0.00']], + [2,['2222 МР-231S, Строб ЭМС', 'X32', '0.00', '0.00']], + [3,['3НРЛС МР-231-3, УИЗП', 'X34', '0.00', '0.00']], + [4,['4НРЛС МР-231-3, Строб ЭМС', 'X35', '0.00', '0.00']], + [5,['5ЦИСВС-1010, УИЗП', 'X43', '0.00', '0.00']], + [8,['64302-01, 4302-04, УИЗП', 'X46', '0.00', '0.00']], + [11,['7НРЛС МР-231S, УИЗП', 'X51', '0.00', '0.00']], + [22,['8222 МР-231S, Строб ЭМС', 'X32', '0.00', '0.00']], + [23,['9РЛС МР-231-3, УИЗП', 'X34', '0.00', '0.00']], + [24,['10НРЛС МР-231-3, Строб ЭМС', 'X35', '0.00', '0.00']], + [25,['11ЦИСВС-1010, УИЗП', 'X43', '0.00', '0.00']], + [28,['124302-01, 4302-04, УИЗП', 'X46', '0.00', '0.00']], + [21,['13НРЛС МР-231S, УИЗП', 'X51', '0.00', '0.00']]] + +# Таблица с данными для выходов, первое значение - индекс устройства в ячейке КЭМС +const OUTPUT_ROWS0 = [ + [41,['15НРЛС МР-231S, БИ', 'X61', '0.00', '0.00']], + [42,['16НРЛС МР-231S', 'X62', '0.00', '0.00']], + [43,['17НРЛС МР-231-3, БИ', 'X64', '0.00', '0.00']], + [44,['18НРЛС МР-231-3', 'X65', '0.00', '0.00']], + [45,['19ЦИСВС-1010, БИ', 'X63', '0.00', '0.00']], + [46,['204302-01, 4302-04, БИ', 'X66', '0.00', '0.00']], + [48,['21НРЛС 11111111', 'X69', '0.00', '0.00']], + [52,['22НРЛС МР-231S', 'X62', '0.00', '0.00']], + [53,['23НРЛС МР-231-3, БИ', 'X64', '0.00', '0.00']], + [54,['24НРЛС МР-231-3', 'X65', '0.00', '0.00']], + [55,['25ЦИСВС-1010, БИ', 'X63', '0.00', '0.00']], + [56,['264302-01, 4302-04, БИ', 'X66', '0.00', '0.00']], + [58,['27НРЛС 11111111', 'X69', '0.00', '0.00']]] + +const INPUT_ROWS1 = [ + [12,['283333 МР-231S, Строб ЭМС', 'X52', '0.00', '0.00']], + [13,['29НРЛС МР-231-3, УИЗП', 'X54', '0.00', '0.00']], + [14,['30НРЛС МР-231-3, Строб ЭМС', 'X55', '0.00', '0.00']], + [15,['31ЦИСВС-1010, УИЗП', 'X23', '0.00', '0.00']], + [21,['32НРЛС МР-231S, УИЗП', 'X21', '0.00', '0.00']], + [22,['33НРЛС МР-231S, Строб ЭМС', 'X22', '0.00', '0.00']], + [23,['34НРЛС МР-231-3, УИЗП', 'X24', '0.00', '0.00']], + [32,['352222 МР-231S, Строб ЭМС', 'X32', '0.00', '0.00']], + [33,['36НРЛС МР-231-3, УИЗП', 'X34', '0.00', '0.00']], + [34,['37НРЛС МР-231-3, Строб ЭМС', 'X35', '0.00', '0.00']], + [35,['38ЦИСВС-1010, УИЗП', 'X43', '0.00', '0.00']], + [38,['394302-01, 4302-04, УИЗП', 'X46', '0.00', '0.00']], + [31,['40НРЛС МР-231S, УИЗП', 'X51', '0.00', '0.00']]] + +# Таблица с данными для выходов, первое значение - индекс устройства в ячейке КЭМС +const OUTPUT_ROWS1 = [ + [41,['41НРЛС МР-231S, БИ', 'X61', '0.00', '0.00']], + [42,['42НРЛС МР-231S', 'X62', '0.00', '0.00']], + [43,['43НРЛС МР-231-3, БИ', 'X64', '0.00', '0.00']], + [44,['44НРЛС МР-231-3', 'X65', '0.00', '0.00']], + [45,['45ЦИСВС-1010, БИ', 'X63', '0.00', '0.00']], + [46,['464302-01, 4302-04, БИ', 'X66', '0.00', '0.00']], + [48,['47НРЛС 11111111', 'X69', '0.00', '0.00']], + [62,['48НРЛС МР-231S', 'X62', '0.00', '0.00']], + [63,['49НРЛС МР-231-3, БИ', 'X64', '0.00', '0.00']], + [64,['50НРЛС МР-231-3', 'X65', '0.00', '0.00']], + [65,['51ЦИСВС-1010, БИ', 'X63', '0.00', '0.00']], + [66,['524302-01, 4302-04, БИ', 'X66', '0.00', '0.00']], + [68,['53НРЛС 11111111', 'X69', '0.00', '0.00']]] diff --git a/scripts/yems_devs.gd b/scripts/yems_devs.gd index cf8e1f2a..6b621b98 100644 --- a/scripts/yems_devs.gd +++ b/scripts/yems_devs.gd @@ -2,43 +2,36 @@ extends Node class InDev: - var id: int # Идентификатор индекс устройства - var dev_name: String # Имя подключаемого комплекса - var connector: String # Номер разъёма в приборе - var delay: float # Задержка фронта импульса - var offset: float # Смещение фронта импульса - var state: int # Состояние входа - var freq: int # Предполагаемая частота на которой работает комплекс - var ports_data: Dictionary # Словарь состояния портов устройства - var tbl_row_id: int # Индекс устройства в таблице входов - var out_dots: Array # Список выходных устройств в порядке, как в таблице и точки матрицы - - func _init(dev_id : int, params : Array, row_id : int): - id = dev_id - dev_name = String(params[0]) - connector = String(params[1]) - delay = float(params[2]) - offset = float(params[3]) - tbl_row_id = row_id - - -class OutDev: - var id: int # Идентификатор индекс устройства - var dev_name: String # Имя подключаемого комплекса - var connector: String # Номер разъёма в приборе - var delay: float # Задержка фронта импульса - var offset: float # Смещение фронта импульса - var state: int # Состояние входа - var freq: int # Предполагаемая частота на которой работает комплекс - var ports_data: Dictionary # Словарь состояния портов устройства - var tbl_row_id: int # Индекс устройства в таблице выходов - var mode: int # Режим работы выхода - - func _init(dev_id : int, params : Array, row_id : int): - id = dev_id - dev_name = String(params[0]) - connector = String(params[1]) - delay = float(params[2]) - offset = float(params[3]) - tbl_row_id = row_id - mode = 0 + var id: int # Идентификатор индекс устройства + var dev_name: String # Имя подключаемого комплекса + var connector: String # Номер разъёма в приборе + var delay: float # Задержка фронта импульса + var offset: float # Смещение фронта импульса + var state: int # Состояние входа + var freq: int # Предполагаемая частота на которой работает комплекс + var ports_data: Dictionary # Словарь состояния портов устройства + var tbl_row_id: int # Индекс устройства в таблице выходов + var out_dots: Array # Список выходных устройств в порядке, как в таблице и точки матрицы + var connect_devs: Dictionary # Список присоединённых устройств + var board: String # Плата в которой находится устройство + + func _init(dev_id : int, params : Array, row_id : int): + id = dev_id + dev_name = String(params[0]) + connector = String(params[1]) + delay = float(params[2]) + offset = float(params[3]) + tbl_row_id = row_id + + +class OutDev extends InDev: + var mode: String # Режим работы выхода + + func _init(dev_id : int, params : Array, row_id : int): + id = dev_id + dev_name = String(params[0]) + connector = String(params[1]) + delay = float(params[2]) + offset = float(params[3]) + tbl_row_id = row_id + mode = 'Работа' diff --git a/scripts/yemsboards.gd b/scripts/yemsboards.gd new file mode 100644 index 00000000..cd0c60bb --- /dev/null +++ b/scripts/yemsboards.gd @@ -0,0 +1,15 @@ +extends Node + +class EmsBoard: + var id_board: String + var in_devs: Dictionary # Словарь с входными устройствами + var out_devs: Dictionary # Словарь с выходными устройствами + var base_addr_isa: int # Базовый адрес ячейки isa + var in_tbl: Array + var out_tbl: Array + + func _init(id, base_addr, in_table, out_table): + id_board = id + in_tbl = in_table + out_tbl = out_table + base_addr_isa = base_addr diff --git a/table/table.gd b/table/table.gd index dfe2a8cb..3c9b9b19 100644 --- a/table/table.gd +++ b/table/table.gd @@ -41,13 +41,13 @@ func _assert_meta(i_col: int, i_row: int, pname: String, node): assert(node.has_ func pin_header(scrl: ScrollContainer, prnt: Control): - scrl.remove_child(header) - prnt.add_child(header) - # TODO: Это значение следует получить из темы - var v_separation: = 3.0 - header.position = scrl.position - Vector2(0, header.size.y + v_separation) - scroll = scrl - scroll_adj = scrl.position + scrl.remove_child(header) + prnt.add_child(header) + # TODO: Это значение следует получить из темы + var v_separation: = 3.0 + header.position = scrl.position - Vector2(0, header.size.y + v_separation) + scroll = scrl + scroll_adj = scrl.position func selector_up(): @@ -278,30 +278,30 @@ func set_node_user_data(i_col: int, i_row: int, user_data: Object) -> void: func add_row(row_types: Array) -> void: - assert(row_types.size() < MAX_INDEX, 'ошибка: слишком много колонок, больше %d' % (MAX_INDEX + 1)) - if columns == 1: - set_columns(row_types.size()) - else: - assert(columns == row_types.size(), 'ошибка: %s количество колонок установлено ранее - %d, но требуется %d' % [self, columns, row_types.size()]) - var i_row: int = get_rows_count() - assert(i_row < MAX_INDEX, 'ошибка: слишком много рядов, больше %d' % (MAX_INDEX + 1)) - for i_col in columns: - var node = row_types[i_col].instantiate() - var head = nodes[HEAD_KEY_FORMAT % [0, i_col]] - node.custom_minimum_size.x = head.custom_minimum_size.x - node.size.x = head.size.x - var node_key: String = NODE_KEY_FORMAT % [i_row, i_col] - node.name = node_key - add_child(node) - nodes[node_key] = node - var conn = Callable(self, '_on_focus_entered').bind(node) + assert(row_types.size() < MAX_INDEX, 'ошибка: слишком много колонок, больше %d' % (MAX_INDEX + 1)) + if columns == 1: + set_columns(row_types.size()) + else: + assert(columns == row_types.size(), 'ошибка: %s количество колонок установлено ранее - %d, но требуется %d' % [self, columns, row_types.size()]) + var i_row: int = get_rows_count() + assert(i_row < MAX_INDEX, 'ошибка: слишком много рядов, больше %d' % (MAX_INDEX + 1)) + for i_col in columns: + var node = row_types[i_col].instantiate() + var head = nodes[HEAD_KEY_FORMAT % [0, i_col]] + node.custom_minimum_size.x = head.custom_minimum_size.x + node.set_deferred('size.x', head.size.x) + var node_key: String = NODE_KEY_FORMAT % [i_row, i_col] + node.name = node_key + add_child(node) + nodes[node_key] = node + var conn = Callable(self, '_on_focus_entered').bind(node) node.connect('focus_entered', conn) set_node_meta(i_col, i_row, 'callable_focus_entered', conn) func _on_focus_entered(node): - var indexes = get_key_indexes(node.name) - emit_signal('row_pressed', indexes[1]) + var indexes = get_key_indexes(node.name) + emit_signal('row_pressed', indexes[1]) func set_header(header_types: Array): @@ -353,7 +353,7 @@ func remove_row(i_row: int): if nodes.has(sel_key): var selector = nodes[sel_key] var prnt = selector.get_parent() - prnt.remove_child(selector) + prnt.remove_child(selector) selector.queue_free() nodes.erase(sel_key) @@ -372,8 +372,8 @@ func remove_row(i_row: int): if nodes.has(conn_key): conn = nodes[conn_key] - node.disconnect('pressed', conn) - nodes.erase(conn_key) + node.disconnect('pressed', conn) + nodes.erase(conn_key) remove_child(node) nodes.erase(node_key) @@ -398,9 +398,9 @@ func swap_nodes(nodes_copy, node_key_format, i0, i1) -> void: func rehash(): """ Переназначает ключи в соответствии с размерами таблицы. После вызова swaps содержит массив пар [<прежний ключ>, <текущий ключ>] """ - var i_node: = [Vector2i()] - var i_hdr: = [Vector2i()] - var i_slct: = [Vector2i()] + var i_node: = [Vector2i()] + var i_hdr: = [Vector2i()] + var i_slct: = [Vector2i()] var i_conn: = [Vector2i()] var i_data: = [Vector2i()] var nodes_copy = {} @@ -409,21 +409,21 @@ func rehash(): var i0 = Vector2(iv[0], iv[1]) if HEAD_PREFIX in key: swap_nodes(nodes_copy, HEAD_KEY_FORMAT, i0, i_hdr[0]) - next_index(i_hdr) + next_index(i_hdr) elif NODE_PREFIX in key: swap_nodes(nodes_copy, NODE_KEY_FORMAT, i0, i_node[0]) next_index(i_node) elif SLCT_PREFIX in key: - swap_nodes(nodes_copy, ROW_SELECTOR_KEY_FORMAT, i0, i_slct[0]) - next_index(i_slct) + swap_nodes(nodes_copy, ROW_SELECTOR_KEY_FORMAT, i0, i_slct[0]) + next_index(i_slct) elif CONN_PREFIX in key: swap_nodes(nodes_copy, CONNECTED_KEY_FORMAT, i0, i_conn[0]) next_index(i_conn) elif DATA_PREFIX in key: swap_nodes(nodes_copy, DATA_KEY_FORMAT, i0, i_data[0]) next_index(i_data) - nodes.clear() - nodes.merge(nodes_copy) + nodes.clear() + nodes.merge(nodes_copy) func clear_rows() -> void: