Исправления. ЭМС, приём и отправка пакетов чтения/записи устройств.

This commit is contained in:
MaD_CaT
2024-11-05 15:19:54 +03:00
parent b39d5654fb
commit f879a2034f
7 changed files with 362 additions and 95 deletions

View File

@@ -19,6 +19,7 @@ const IN_SET_ROW: Array = [CellLineEdit, CellLEEmpty, CellLEEmpty, CellLEEmpty,
var g_boards: Dictionary ## Словарь плат ЭМС.
var active_board = null ## Активная плата ЭМС
var posx: int = 125 ## Позиция элементов по x.
var posy: int = 70 ## Позиция элементов по y.
@@ -29,6 +30,9 @@ func _ready() -> void:
## Инициализация основных элементов экрана ЭМС.
func init_boards():
var unit_key = settings.get_unit_key('уарэп-эмс')
var unit_ems = network.units[unit_key]
# Выставление позиций элементов ЭМС на экране
$scrollin.set_position(Vector2(posx,posy))
$scrollout.set_position(Vector2(posx + 650,posy))
@@ -40,9 +44,11 @@ func init_boards():
$btn_connect.set_position(Vector2(posx + 590,posy - 25))
$btn_disconnect.set_position(Vector2(posx + 587,posy + 675))
g_boards['КЭМС-Б'] = yemsboards.EmsBoard.new(0, 0x130, yemsconsts.INPUT_KEMS, yemsconsts.OUTPUT_KEMS)
g_boards['ЭМС-Б1'] = yemsboards.EmsBoard.new(1, 0x110, yemsconsts.INPUT_EMS1, yemsconsts.OUTPUT_EMS1)
g_boards['ЭМС-Б2'] = yemsboards.EmsBoard.new(2, 0x120, yemsconsts.INPUT_EMS2, yemsconsts.OUTPUT_EMS2)
g_boards['КЭМС-Б'] = yemsboards.EmsBoard.new(0, 0x130, yemsconsts.INPUT_KEMS, yemsconsts.OUTPUT_KEMS, unit_ems)
g_boards['ЭМС-Б1'] = yemsboards.EmsBoard.new(1, 0x110, yemsconsts.INPUT_EMS1, yemsconsts.OUTPUT_EMS1, unit_ems)
g_boards['ЭМС-Б2'] = yemsboards.EmsBoard.new(2, 0x120, yemsconsts.INPUT_EMS2, yemsconsts.OUTPUT_EMS2, unit_ems)
active_board = g_boards['КЭМС-Б']
init_tbl_in()
$scrollin/tbl_in.pin_header($scrollin, self)
@@ -53,9 +59,8 @@ func init_boards():
init_tbl_files()
$scrl_files/tbl_files.pin_header($scrl_files, self)
var unit_key = settings.get_unit_key('уарэп-эмс')
var unit = network.units[unit_key]
unit.connect('data_received', Callable(self, 'on_data_ems_received'))
unit_ems.connect('data_received', Callable(self, 'on_data_ems_received'))
unit_ems.connect('command_done', Callable(self, 'on_data_ems_received'))
$btn_connect.connect('pressed', Callable(self, 'on_btn_connect'))
$btn_disconnect.connect('pressed', Callable(self, 'on_btn_disconnect'))
$btn_flash_read.button_connect('pressed', Callable(self, 'on_btn_flash_read').bind($btn_flash_read))
@@ -126,9 +131,8 @@ func init_tbl_in():
$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)
var in_dev: yemsdevs.InDev = yemsdevs.InDev.new(item[0], params, row_index, g_boards[board].base_addr_isa)
in_dev.board = board
in_dev.isa_addr = g_boards[board].base_addr_isa
for i in range(len(row_type)):
if i < len(params):
var node = $scrollin/tbl_in.get_node2(i, row_index)
@@ -209,9 +213,9 @@ func init_tbl_out():
$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)
var out_dev = yemsdevs.OutDev.new(item[0], params, row_index, g_boards[board].base_addr_isa)
out_dev.set_default_mode()
out_dev.board = board
out_dev.isa_addr = g_boards[board].base_addr_isa
for i in range(len(header_text)):
var cell = $scrollout/tbl_out.get_node2(i, row_index)
if i < len(params):
@@ -219,7 +223,7 @@ func init_tbl_out():
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
cell.text = OUT_MODE[out_dev.mode]
$scrollout/tbl_out.set_columns_min_size([250, 100, 70, 70, 70, 100])
$scrollout/tbl_out.set_columns_alignments(yams_alligment_out)
$scrollout/tbl_out.connect('row_pressed', Callable(self, 'on_row_pressed_out'))
@@ -277,9 +281,7 @@ func set_out_dev(dev):
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)
mode.select(dev.mode)
## Выбор входного или выходного устройства.[br]
@@ -375,6 +377,11 @@ func on_row_pressed(i_row: int, tbl):
func on_data_ems_received(unit):
for board in g_boards.values():
board.set_status(unit.status)
if active_board.state_read == active_board.WAIT:
if board.online and not board.read_done:
active_board = board
active_board.state_read = active_board.READ
active_board.start_rw_kems(true)
for i_row in range($scrollin/tbl_in.get_rows_count()):
var state_pic = ($scrollin/tbl_in.get_node2(4, i_row))
var dev = $scrollin/tbl_in.get_node_user_data(4, i_row)[0]
@@ -383,3 +390,7 @@ func on_data_ems_received(unit):
var state_pic = ($scrollout/tbl_out.get_node2(4, i_row))
var dev = $scrollout/tbl_out.get_node_user_data(4, i_row)[0]
state_pic.set_frame(dev.state)
func on_command_done(unit_ems):
active_board.on_command_done(unit_ems)