Рефактор

This commit is contained in:
sasha80
2025-04-29 14:21:27 +03:00
parent fb5144653a
commit c92278eeec
2 changed files with 6 additions and 15 deletions

View File

@@ -147,17 +147,12 @@ func _ready() -> void:
units[unit_key] = new_unit
units_udprx[unit_key] = new_unit
dst_ports[unit_key] = st[2][0]
if logger_page:
new_unit.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key))
if proto in UDP_PROTO:
var new_unit = UDP_PROTO[proto].new(unit_name)
var unit_key = settings.get_unit_key(unit_name)
units[unit_key] = new_unit
units_udp[unit_key] = new_unit
if logger_page:
new_unit.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key))
new_unit.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key))
if len(st[2]) > 1:
dst_ports[unit_key] = st[2][1]
else:
@@ -168,25 +163,16 @@ func _ready() -> void:
var unit_key = settings.get_unit_key(unit_name)
units_tcp[unit_key] = unit_tcp
units[unit_key] = unit_tcp
if logger_page:
unit_tcp.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key))
unit_tcp.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key))
if proto in MODBUS_PROTO:
var unit_modbus = MODBUS_PROTO[proto].new(unit_name)
var unit_key = settings.get_unit_key(unit_name)
if logger_page:
unit_modbus.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key))
unit_modbus.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key))
units_modbus[unit_key] = unit_modbus
units[unit_key] = unit_modbus
if proto in SERIAL_PROTO:
var unit_serial = SERIAL_PROTO[proto].new(unit_name)
var unit_key = settings.get_unit_key(unit_name)
if logger_page:
unit_serial.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(unit_key))
unit_serial.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(unit_key))
var serial = create_serial(unit_name)
units_serial[unit_key] = unit_serial
units[unit_key] = unit_serial
@@ -200,6 +186,11 @@ func _ready() -> void:
tcp_sockets.append([create_tcpsocket('уарэп-5п28'), units_tcp[settings.get_unit_key('уарэп-5п28')]])
for key in dst_ports:
unit_keys[dst_ports[key]] = key
if logger_page:
for key in units:
var u = units[key]
u.connect('line_changed', Callable(logger_page, 'on_line_changed').bind(key))
u.connect('command_fail', Callable(logger_page, 'on_command_fail').bind(key))
func poll_receive_udp(sock: Socket) -> bool: