закончен контроль

This commit is contained in:
danil_tim
2025-02-11 13:53:09 +03:00
parent 16833dcba3
commit 6e5f973405
5 changed files with 219 additions and 163 deletions

View File

@@ -58,7 +58,7 @@ func poll_receive_yau07(sock: Socket) -> bool: ## Приёмник
broadcast_packet = sock.get_packet()
var addr_receive = sock.get_packet_ip()
var port_receive = sock.get_packet_port()
if (ip_address_yau == addr_receive) and (ip_port_yau == port_receive):
last_update_time_yau07 = 0.0
unit.parse(broadcast_packet)
@@ -84,7 +84,7 @@ func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: Strin
elif client == client_fs_2:
emit_signal("port_fs_closed_2", ip_fs)
return
if peer.get_available_bytes() > 0:
var rx_data: PackedByteArray
rx_data.append_array(peer.get_data(peer.get_available_bytes())[1])
@@ -106,11 +106,11 @@ func _ready() -> void:
var rc = soc_brodcast.bind(Constants.BROADCAST_PORT, '*')
if rc != OK:
print_debug('Ошибка: Неудачная привязка широковещательного адреса')
soc_unicast = Socket.new()
rc = soc_unicast.bind(Constants.UNICAST_PORT, Constants.UNICAST_ADDRESS)
if rc != OK:
print_debug('Ошибка: неудачная привязка адреса: ', ip_address_yau)
print_debug('Ошибка: неудачная привязка адреса: ', ip_address_yau)
unit.connect('line_changed', Callable(self, 'on_line_changed'))
unit.connect('command_fail', Callable(self, 'on_command_fail'))
@@ -123,17 +123,17 @@ func _process(delta: float) -> void:
last_update_time_yau07 += delta
last_update_time_fs += delta
if client_fs_1:
poll_receive_fs(client_fs_1, peerstream_fs_1, ip_fs_1)
state_machine_fs(client_fs_1)
if client_fs_2:
poll_receive_fs(client_fs_2, peerstream_fs_2, ip_fs_2)
state_machine_fs(client_fs_2)
poll_receive_yau07(soc_brodcast)
poll_receive_yau07(soc_unicast)
state_machine_yau07()
match unit.process(delta):
@@ -167,12 +167,12 @@ func state_machine_yau07():
state = Constants.STATE.WAIT
# Записать команду в ИСА
# Записать команду в ИСА
func read_port_isa(read_ports: Array) -> void:
send_array.append(['rd', read_ports])
# Прочитать данные из порта от ИСА
# Прочитать данные из порта от ИСА
func write_port_isa(port_isa: int, data_isa: int) -> void:
var write_data: Dictionary = {port_isa: data_isa}
send_array.append(['wr', write_data])
@@ -217,7 +217,7 @@ func state_machine_fs(client_fs):
func connect_fs_1():
if client_fs_1:
disconnect_fs(client_fs_1)
client_fs_1 = StreamPeerTCP.new()
peerstream_fs_1 = PacketPeerStream.new()
var rc = client_fs_1.connect_to_host(ip_fs_1, Constants.PORT_FS)