Исправление записи в ISA порт

This commit is contained in:
QAMuser
2024-08-23 09:09:30 +03:00
parent 110791a97c
commit dc30bcc1e1
2 changed files with 22 additions and 15 deletions

34
Main.gd
View File

@@ -36,14 +36,14 @@ func _ready():
# Таблица 1
node_select = $scroll1/table1
draw_tabl(node_select, ROWS_REGS_DATA, ROWS_REGS_DATA.size())
node_select.set_columns_min_size([250, 150, 150, 200, 150])
node_select.set_node_text(0, 0, 'НЕТ СВЯЗИ С ЯУ-07')
node_select.set_columns_min_size([250, 160, 150, 190, 150])
node_select.set_node_text(0, 0, ' НЕТ СВЯЗИ С ЯУ-07')
node_select.set_node_text(1, 0, ' IP-АДРЕС')
node_select.set_node_text(2, 0, '10.1.1.70')
node_select.set_node_text(3, 0, ' IP-ПОРТ')
node_select.set_node_text(4, 0, '50070')
node_select.set_node_text(0, 1, 'ПОРТ ЯЧЕЙКИ (hex)')
node_select.set_node_text(1, 2, 'ИНТЕРВАЛ')
node_select.set_node_text(0, 1, ' ПОРТ ЯЧЕЙКИ (hex)')
node_select.set_node_text(1, 2, ' ИНТЕРВАЛ')
# Поле для ввода (запись IP-адреса)
var edit_ip = node_select.get_node2(2, 0)
@@ -65,7 +65,7 @@ func _ready():
# Поле для ввода (базовый порт)
var edit_addr = node_select.get_node2(0, 2)
edit_addr.editable = true
edit_addr.placeholder_text = '%x' % port_select
edit_addr.placeholder_text = ' 0x%x' % port_select
edit_addr.connect('text_submitted', Callable(self, '_on_written_addres'))
# Поле для ввода (интервал непрерывной записи)
@@ -108,17 +108,17 @@ func _process(delta):
var fl_done = unit.cmd_state == unit.CmdState.DONE
if state == 1 and fl_done: ## Чтение из ИСА
unit.send_isa(unit.CmdCode.READ_ISA, [port_select])
node_select.set_node_text(3, 1, 'ПРОЧИТАНО ИЗ %x' % port_select)
node_select.set_node_text(3, 1, ' ПРОЧИТАНО ИЗ %x' % port_select)
state = 2
elif state == 2 and fl_done: ## Запись в ИСА
unit.send_isa(unit.CmdCode.WRITE_ISA, [port_select, ports_wr[port_select]])
if unit.isa_ports.has(port_select):
node_select.set_node_text(4, 1, '%x' % unit.isa_ports[port_select])
var isa: Array
node_select.set_node_text(4, 1, ' %x' % unit.isa_ports[port_select])
var isa: Array = []
for i in unit.isa_ports:
isa.append('%x: %x' % [i, unit.isa_ports[i]])
node_select.set_node_text(1, 1, 'ЗАПИСАТЬ В %x' % port_select)
node_select.set_node_text(1, 1, ' ЗАПИСАТЬ В %x' % port_select)
$ISA.text = 'ISA: ' + str(isa)
state = 1
@@ -134,14 +134,21 @@ func on_timer():
poll_receive(soc_brodcast, unit, address, port)
var fl_done = unit.cmd_state == unit.CmdState.DONE
if state == 1 and fl_done: ## Чтение из ИСА
unit.send_isa(unit.CmdCode.READ_ISA, [port_select, ports_wr[port_select]])
unit.send_isa(unit.CmdCode.READ_ISA, [port_select])
node_select.set_node_text(3, 1, ' ПРОЧИТАНО ИЗ %x' % port_select)
state = 2
elif state == 2 and fl_done: ## Запись в ИСА
unit.send_isa(unit.CmdCode.WRITE_ISA, [port_select, ports_wr[port_select]])
if unit.isa_ports.has(port_select):
node_select.set_node_text(4, 1, '%x' % unit.isa_ports[port_select])
var isa: Array = []
for i in unit.isa_ports:
isa.append('%x: %x' % [i, unit.isa_ports[i]])
node_select.set_node_text(1, 1, ' ЗАПИСАТЬ В %x' % port_select)
$ISA.text = 'ISA: ' + str(isa)
state = 1
var rc = unit.process(dt)
if rc == Error.OK:
soc_unicast.send_to(address, port, unit.tx_data.slice(0, unit.tx_len))
@@ -154,7 +161,7 @@ func on_line_changed(_unit):
## Ессли отсутствует подключение к ячейке ЯУ-07
func on_command_fail(_unit):
var line_yau07_control = node_select.get_node2(0, 0)
line_yau07_control.text = 'НЕТ СВЯЗИ С ЯУ-07'
line_yau07_control.text = ' НЕТ СВЯЗИ С ЯУ-07'
line_yau07_control.modulate = Color(1, 0, 0, 1)
flag_online = false
soc_unicast = Socket.new()
@@ -164,9 +171,10 @@ func on_command_fail(_unit):
func on_command_done(_unit):
if flag_online:
var line_yau07_control = node_select.get_node2(0, 0)
line_yau07_control.text = 'ЯУ-07 НА СВЯЗИ'
line_yau07_control.text = ' ЯУ-07 НА СВЯЗИ'
line_yau07_control.modulate = Color(0, 1, 0, 1)
## Выставить адресс для записи
func _on_written_addres(write_addres):
port_select = write_addres.hex_to_int()
@@ -207,7 +215,7 @@ func _on_button_pressed(turn_on):
flag_online = true
else:
var line_yau07_control = node_select.get_node2(0, 0)
line_yau07_control.text = 'НЕТ СВЯЗИ С ЯУ-07'
line_yau07_control.text = ' НЕТ СВЯЗИ С ЯУ-07'
line_yau07_control.modulate = Color(1, 0, 0, 1)
var light_interval = node_select.get_node2(1, 2)
light_interval.modulate = Color(0.5, 0.5, 0.5, 1)

View File

@@ -24,7 +24,6 @@ theme_override_colors/font_uneditable_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 17
theme_override_styles/normal = SubResource("StyleBoxFlat_hrhif")
theme_override_styles/read_only = SubResource("StyleBoxFlat_q1ixs")
alignment = 1
editable = false
caret_blink = true
caret_blink_interval = 0.5