1 litera is almost ready

This commit is contained in:
2025-03-07 00:20:35 +03:00
parent 1c7aba948a
commit a7a4ffaa9e
9 changed files with 854 additions and 283 deletions

View File

@@ -18,8 +18,8 @@ var send_array: Array = []
var client_fs_1: StreamPeer
var ip_fs_1: String = Constants.ADDRESSES[0][4]
var peerstream_fs_1: PacketPeer
var state_fs = Constants.STATE.IDLE
var command_stack: Array
var state_fs_1 = Constants.STATE.IDLE
var command_stack_1: Array
var counter_fs_1: int = 0
## 2 ФС
@@ -30,6 +30,14 @@ var state_fs_2 = Constants.STATE.IDLE
var command_stack_2: Array
var counter_fs_2: int = 0
## 3 ФС
var client_fs_3: StreamPeer
var ip_fs_3: String = Constants.ADDRESSES[0][5]
var peerstream_fs_3: PacketPeer
var state_fs_3 = Constants.STATE.IDLE
var command_stack_3: Array
var counter_fs_3: int = 0
# Яу-07б
signal yau_status_line(_status) ## Вызывается когда меняется состояние связи с ячейкой
signal yau_receive(_data_from_yau)
@@ -38,10 +46,9 @@ signal yau_read_isa(_unit_isa_ports)
# ФС модуль
signal data_from_fs_1(data:PackedByteArray)
signal data_from_fs_2(data:PackedByteArray)
signal port_fs_opened_1(port_name: String)
signal port_fs_opened_2(port_name: String)
signal port_fs_closed_1(port_name: String)
signal port_fs_closed_2(port_name: String)
signal data_from_fs_3(data:PackedByteArray)
signal port_fs_opened(port_name: String)
signal port_fs_closed(port_name: String)
signal port_error(error_str: String)
@@ -79,27 +86,37 @@ func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: Strin
if not peer:
emit_signal("port_error", ip_fs)
return
# Проверяем состояние подключения
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
if client == client_fs_1:
emit_signal("port_fs_closed_1", ip_fs)
elif client == client_fs_2:
emit_signal("port_fs_closed_2", ip_fs)
emit_signal("port_fs_closed", ip_fs)
return
if peer.get_available_bytes() > 0:
# Проверяем состояние подключения
#if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
#if client == client_fs_1:
#emit_signal("port_fs_closed", ip_fs)
#elif client == client_fs_2:
#emit_signal("port_fs_closed", ip_fs)
#elif client == client_fs_3:
#emit_signal("port_fs_closed", ip_fs)
#return
while peer.get_available_bytes() > 0:
var rx_data: PackedByteArray
rx_data.append_array(peer.get_data(peer.get_available_bytes())[1])
if client == client_fs_1:
emit_signal("data_from_fs_1", rx_data)
emit_signal("port_fs_opened_1", ip_fs)
if state_fs == Constants.STATE.SEND:
state_fs = Constants.STATE.DONE
emit_signal("port_fs_opened", ip_fs)
if state_fs_1 == Constants.STATE.SEND:
state_fs_1 = Constants.STATE.DONE
elif client == client_fs_2:
emit_signal("data_from_fs_2", rx_data)
emit_signal("port_fs_opened_2", ip_fs)
emit_signal("port_fs_opened", ip_fs)
if state_fs_2 == Constants.STATE.SEND:
state_fs_2 = Constants.STATE.DONE
elif client == client_fs_3:
emit_signal("data_from_fs_3", rx_data)
emit_signal("port_fs_opened", ip_fs)
if state_fs_3 == Constants.STATE.SEND:
state_fs_3 = Constants.STATE.DONE
func _ready() -> void:
@@ -116,7 +133,11 @@ func _ready() -> void:
unit.connect('line_changed', Callable(self, 'on_line_changed'))
unit.connect('command_fail', Callable(self, 'on_command_fail'))
set_config()
func set_config():
write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.CI_2_B_UF)
read_port_isa([Constants.BASE_PORTS.EMS_G+8])
write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.CI_3_B_UF)
@@ -128,9 +149,11 @@ func _ready() -> void:
write_port_isa(Constants.BASE_PORTS.EMS_G+2, Constants.META.FGOZ_3)
read_port_isa([Constants.BASE_PORTS.EMS_G+8, Constants.BASE_PORTS.UG+6, Constants.BASE_PORTS.UG+8])
connect_fs_1()
start_work_fs()
connect_fs_2()
connect_fs_3()
start_work_fs()
start_work_fs_2()
start_work_fs_3()
func _process(delta: float) -> void:
@@ -144,6 +167,9 @@ func _process(delta: float) -> void:
if client_fs_2:
poll_receive_fs(client_fs_2, peerstream_fs_2, ip_fs_2)
state_machine_fs(client_fs_2)
if client_fs_3:
poll_receive_fs(client_fs_3, peerstream_fs_3, ip_fs_3)
state_machine_fs(client_fs_3)
poll_receive_yau07(soc_brodcast)
poll_receive_yau07(soc_unicast)
@@ -207,33 +233,41 @@ func on_command_change_device(meta_device):
ip_port_yau = meta_device[1]
ip_fs_1 = meta_device[3]
ip_fs_2 = meta_device[4]
#ip_fs_3 = meta_device[5]
ip_fs_3 = meta_device[5]
connect_fs_1()
connect_fs_2()
if Constants.CURRENT_MODE == Constants.MODE.PRD_K:
connect_fs_3()
func state_machine_fs(client_fs):
## State fs machine
if client_fs == client_fs_1:
if (state_fs == Constants.STATE.IDLE) or (state_fs == Constants.STATE.DONE):
if command_stack:
var pack: Array = command_stack.pop_front()
if (state_fs_1 == Constants.STATE.IDLE) or (state_fs_1 == Constants.STATE.DONE):
if command_stack_1:
var pack: Array = command_stack_1.pop_front()
unit_fs.send_fs_data(pack, client_fs_1, peerstream_fs_1)
state_fs = Constants.STATE.SEND
state_fs_1 = Constants.STATE.SEND
if client_fs == client_fs_2:
if (state_fs_2 == Constants.STATE.IDLE) or (state_fs_2 == Constants.STATE.DONE):
if command_stack_2:
var pack: Array = command_stack_2.pop_front()
unit_fs.send_fs_data(pack, client_fs_2, peerstream_fs_2)
state_fs_2 = Constants.STATE.SEND
if client_fs == client_fs_3:
if (state_fs_3 == Constants.STATE.IDLE) or (state_fs_3 == Constants.STATE.DONE):
if command_stack_3:
var pack: Array = command_stack_3.pop_front()
unit_fs.send_fs_data(pack, client_fs_3, peerstream_fs_3)
state_fs_3 = Constants.STATE.SEND
# Подключится к модулю ФС
func connect_fs_1():
if client_fs_1:
unit_fs.disconnect_fs(client_fs_1)
state_fs = Constants.STATE.IDLE
command_stack = []
state_fs_1 = Constants.STATE.IDLE
command_stack_1 = []
client_fs_1 = StreamPeerTCP.new()
peerstream_fs_1 = PacketPeerStream.new()
@@ -254,6 +288,15 @@ func start_work_fs():
counter_fs_1 += 1
unit_fs.get_gen_state(counter_fs_1, client_fs_1)
counter_fs_1 += 1
var set_freq = Constants.FS_FREQ.f2 if Constants.CURRENT_MODE == Constants.MODE.PRD_H else Constants.FS_FREQ.f4 if Constants.CURRENT_MODE == Constants.MODE.PRD_B else Constants.FS_FREQ.f6
unit_fs.set_carrier(set_freq * 1_000_000, counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.set_att_batch(Constants.FS_ATT.att_1_prd_H1, counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.set_base_can_macro(set_freq, counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.get_att_batch(counter_fs_1, client_fs_1)
counter_fs_1 += 1
unit_fs.get_carrier(counter_fs_1, client_fs_1)
@@ -272,8 +315,8 @@ func set_fs_gen_status(state_gen):
func get_gen_state_1():
unit_fs.get_gen_state(counter_fs_1, client_fs_1)
counter_fs_1 += 1
#unit_fs.get_base_current_temp(counter_fs_1, client_fs_1)
#counter_fs_1 += 1
unit_fs.get_base_current_temp(counter_fs_1, client_fs_1)
counter_fs_1 += 1
func set_fs_ferq_carrier(freq: int):
@@ -348,6 +391,15 @@ func start_work_fs_2():
counter_fs_2 += 1
unit_fs.get_gen_state(counter_fs_2, client_fs_2)
counter_fs_2 += 1
var set_freq = Constants.FS_FREQ.f3 if Constants.CURRENT_MODE == Constants.MODE.PRD_H else Constants.FS_FREQ.f5 if Constants.CURRENT_MODE == Constants.MODE.PRD_B else Constants.FS_FREQ.f7
unit_fs.set_carrier(set_freq * 1_000_000, counter_fs_2, client_fs_2)
counter_fs_2 += 1
unit_fs.set_att_batch(Constants.FS_ATT.att_2_prd_H1, counter_fs_2, client_fs_2)
counter_fs_2 += 1
unit_fs.set_base_can_macro(set_freq, counter_fs_2, client_fs_2)
counter_fs_2 += 1
unit_fs.get_att_batch(counter_fs_2, client_fs_2)
counter_fs_2 += 1
unit_fs.get_carrier(counter_fs_2, client_fs_2)
@@ -366,8 +418,8 @@ func set_fs_gen_status_2(state_gen: bool):
func get_gen_state_2():
unit_fs.get_gen_state(counter_fs_2, client_fs_2)
counter_fs_2 += 1
#unit_fs.get_base_current_temp(counter_fs_2, client_fs_2)
#counter_fs_2 += 1
unit_fs.get_base_current_temp(counter_fs_2, client_fs_2)
counter_fs_2 += 1
func set_fs_ferq_carrier_2(freq: int):
@@ -416,3 +468,108 @@ func set_configure_gen_msk_2():
func set_configure_gen_const_2():
unit_fs.set_configure_state_msk_const_1(counter_fs_2, client_fs_2)
counter_fs_2 += 1
## 3 ФС коннект
func connect_fs_3():
if client_fs_3:
unit_fs.disconnect_fs(client_fs_3)
state_fs_3 = Constants.STATE.IDLE
command_stack_3 = []
client_fs_3 = StreamPeerTCP.new()
peerstream_fs_3 = PacketPeerStream.new()
var rc = client_fs_3.connect_to_host(ip_fs_3, Constants.PORT_FS)
if rc!= Error.OK:
emit_signal("port_error", ip_fs_3)
else:
peerstream_fs_3.set_stream_peer(client_fs_3)
func start_work_fs_3():
counter_fs_3 = 0
unit_fs.start_session(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.set_gen_state(false, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.set_gen_state(true, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_gen_state(counter_fs_3, client_fs_3)
counter_fs_3 += 1
var set_freq = Constants.FS_FREQ.f1
unit_fs.set_carrier(set_freq * 1_000_000, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.set_att_batch(Constants.FS_ATT.att_3_prd_K1, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.set_base_can_macro(set_freq, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_att_batch(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_carrier(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_base_current_temp(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_base_can_macro(counter_fs_3, client_fs_3)
counter_fs_3 += 1
func set_fs_gen_status_3(state_gen: bool):
unit_fs.set_gen_state(state_gen, counter_fs_3, client_fs_3)
counter_fs_3 += 1
func get_gen_state_3():
unit_fs.get_gen_state(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_base_current_temp(counter_fs_3, client_fs_3)
counter_fs_3 += 1
func set_fs_ferq_carrier_3(freq: int):
unit_fs.set_carrier(freq, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_base_current_temp(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_carrier(counter_fs_3, client_fs_3)
counter_fs_3 += 1
func set_fs_attenuation_3(attenuation: float):
unit_fs.set_att_batch(attenuation, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_att_batch(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_base_current_temp(counter_fs_3, client_fs_3)
counter_fs_3 += 1
## Установка CAN частоты для подстройки фильтра ФС
func set_can_macro_3(can_frequency: int):
unit_fs.set_base_can_macro(can_frequency, counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_base_current_temp(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.get_base_can_macro(counter_fs_3, client_fs_3)
counter_fs_3 += 1
## Установка CAN статуса(вкл/откл) для подстройки фильтра ФС
func status_can_macro_3(state_can: bool):
unit_fs.status_can_macro_exec(state_can, counter_fs_3, client_fs_3)
counter_fs_3 += 1
## Установка модуляции msk на генератор ФС
func set_configure_gen_msk_3():
unit_fs.set_configure_state_msk_modul_3(counter_fs_3, client_fs_3)
counter_fs_3 += 1
unit_fs.set_configure_state_msk_modul_3(counter_fs_3, client_fs_3)
counter_fs_3 += 1
## Установка модуляции const на генератор ФС
func set_configure_gen_const_3():
unit_fs.set_configure_state_msk_const_1(counter_fs_3, client_fs_3)
counter_fs_3 += 1