Доработка подключения и флага чтения записи

This commit is contained in:
2024-10-14 15:49:17 +03:00
parent be169cb949
commit 0a4dc05551
2 changed files with 29 additions and 19 deletions

36
Main.gd
View File

@@ -69,6 +69,8 @@ func _ready():
edit_interval.placeholder_text = 'Ввод значения'
edit_interval.connect('text_submitted', Callable(self, '_on_written_interval'))
var node_select2 = $scroll2/table2
# Привязка для принятия широковещательного канала
soc_brodcast = Socket.new()
var rc = soc_brodcast.bind(Constants.BROADCAST_PORT, '*')
@@ -92,7 +94,6 @@ func draw_tabl(tbl, row: Array, count_row: int):
func poll_receive(sock: Socket) -> bool: ## Приёмник
if timeout - last_update_time > 0:
while sock.get_available_packet_count() > 0:
var rx_data = sock.get_packet()
@@ -109,11 +110,6 @@ func poll_receive(sock: Socket) -> bool: ## Приёмник
if (address == addr_receive) and (port == port_receive) and flag_online:
unit.parse(rx_data)
var line_board_control = node_select.get_node2(0, 1)
line_board_control.modulate = Constants.GREEN
else:
var line_board_control = node_select.get_node2(0, 1)
line_board_control.modulate = Constants.RED
else:
if sock.get_available_packet_count():
last_update_time = 0.0
@@ -186,26 +182,30 @@ func on_command_done(_unit) -> void:
func state_machine() -> void:
var fl_done = (unit.cmd_state == unit.CmdState.DONE) or (unit.cmd_state == unit.CmdState.FAIL)
if state == Constants.STATE.WAIT and fl_done:
$write_ISA.disabled = false
$read_ISA.disabled = false
node_select.set_node_text(3, 1, ' ПРОЧИТАНО ИЗ %x' % port_select)
node_select.set_node_text(1, 1, ' ЗАПИСАТЬ В %x' % port_select)
var nubre_from_port = '%x' % unit.isa_ports[port_select] if unit.isa_ports.has(port_select) else 'ffff'
var line_board_control = node_select.get_node2(0, 1)
var nubre_from_port = 'ffff'
if unit.isa_ports.has(port_select):
nubre_from_port = '%x' % unit.isa_ports[port_select]
line_board_control.modulate = Constants.RED if nubre_from_port == 'ffff' else Constants.GREEN
node_select.set_node_text(4, 1, nubre_from_port)
$read_ISA.disabled = false
$write_ISA.disabled = false
if flag_read_isa:
state = Constants.STATE.READ
elif flag_write_isa:
if flag_write_isa:
flag_write_isa = false
state = Constants.STATE.WRITE
elif flag_read_isa:
flag_read_isa = false
state = Constants.STATE.READ
else:
state = Constants.STATE.WAIT
elif state == Constants.STATE.READ and fl_done: ## Чтение из ИСА
unit.send_isa(unit.CmdCode.READ_ISA, [port_select])
flag_read_isa = false
state = Constants.STATE.WRITE if flag_write_isa else Constants.STATE.WAIT
state = Constants.STATE.WAIT
elif state == Constants.STATE.WRITE and fl_done: ## Запись в ИСА
unit.send_isa(unit.CmdCode.WRITE_ISA, [port_select, ports_wr[port_select]])
flag_write_isa = false
state = Constants.STATE.READ
state = Constants.STATE.WAIT
## Выставить адресс для записи
@@ -252,13 +252,13 @@ func _on_button_pressed(turn_on) -> void:
func _on_button_read() -> void:
port_select = node_select.get_node2(0, 2).text.hex_to_int()
state = Constants.STATE.READ
flag_read_isa = true
func _on_button_write() -> void:
port_select = node_select.get_node2(0, 2).text.hex_to_int()
_on_written_text_submitted(node_select.get_node2(2, 1).text)
state = Constants.STATE.WRITE
flag_write_isa = true
func save_settings():

View File

@@ -30,6 +30,16 @@ layout_mode = 2
script = ExtResource("2_ri1qb")
metadata/_edit_lock_ = true
[node name="scroll2" type="ScrollContainer" parent="."]
offset_left = 34.0
offset_top = 169.0
offset_right = 1127.0
offset_bottom = 232.0
[node name="table2" type="GridContainer" parent="scroll2"]
layout_mode = 2
script = ExtResource("2_ri1qb")
[node name="Turn_on" type="Button" parent="."]
offset_left = 963.0
offset_top = 72.0