module fs 4
This commit is contained in:
@@ -2,8 +2,8 @@ extends Node
|
||||
|
||||
# ЯУ-07 Блок
|
||||
var unit = Yau07.YaU07.new('ЯУ-07Б')
|
||||
#var unit_fs_1 = Fs.FGOS.new()
|
||||
var unit_fs_2 = Fs.FGOS.new()
|
||||
var unit_fs_1 = Fs.FGOS.new()
|
||||
#var unit_fs_2 = Fs.FGOS.new()
|
||||
var soc_unicast: Socket
|
||||
var soc_brodcast: Socket
|
||||
var ip_address_yau: String = Constants.ADDRESSES[0][1]
|
||||
@@ -21,6 +21,7 @@ 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 counter_fs_1: int = 0
|
||||
|
||||
## 2 ФС
|
||||
var client_fs_2: StreamPeer
|
||||
@@ -28,6 +29,7 @@ var ip_fs_2: String = Constants.ADDRESSES[0][5]
|
||||
var peerstream_fs_2: PacketPeer
|
||||
var state_fs_2 = Constants.STATE.IDLE
|
||||
var command_stack_2: Array
|
||||
var counter_fs_2: int = 0
|
||||
|
||||
# Яу-07б
|
||||
signal yau_status_line(_status) ## Вызывается когда меняется состояние связи с ячейкой
|
||||
@@ -82,11 +84,16 @@ func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: Strin
|
||||
if peer.get_available_bytes() > 0:
|
||||
var rx_data: PackedByteArray
|
||||
rx_data.append_array(peer.get_data(peer.get_available_bytes())[1])
|
||||
emit_signal("data_from_fs_1", rx_data)
|
||||
#emit_signal("data_from_fs_2", rx_data)
|
||||
emit_signal("port_fs_opened_1", ip_fs)
|
||||
if state_fs == Constants.STATE.SEND:
|
||||
state_fs = Constants.STATE.DONE
|
||||
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
|
||||
elif client == client_fs_2:
|
||||
emit_signal("data_from_fs_2", rx_data)
|
||||
emit_signal("port_fs_opened_2", ip_fs)
|
||||
if state_fs_2 == Constants.STATE.SEND:
|
||||
state_fs_2 = Constants.STATE.DONE
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -103,7 +110,7 @@ func _ready() -> void:
|
||||
|
||||
unit.connect('line_changed', Callable(self, 'on_line_changed'))
|
||||
unit.connect('command_fail', Callable(self, 'on_command_fail'))
|
||||
#connect_fs_1()
|
||||
connect_fs_1()
|
||||
connect_fs_2()
|
||||
read_port_isa([0x106, 0x108])
|
||||
|
||||
@@ -115,16 +122,16 @@ func _process(delta: float) -> void:
|
||||
|
||||
if client_fs_1:
|
||||
poll_receive_fs(client_fs_1, peerstream_fs_1, ip_fs_1)
|
||||
state_machine_fs()
|
||||
if client_fs_2:
|
||||
poll_receive_fs_2(client_fs_2, peerstream_fs_2, ip_fs_2)
|
||||
poll_receive_fs(client_fs_2, peerstream_fs_2, ip_fs_2)
|
||||
state_machine_fs_2()
|
||||
|
||||
poll_receive_yau07(soc_brodcast)
|
||||
poll_receive_yau07(soc_unicast)
|
||||
|
||||
state_machine_yau07()
|
||||
#state_machine_fs()
|
||||
state_machine_fs_2()
|
||||
|
||||
|
||||
match unit.process(delta):
|
||||
Error.OK: soc_unicast.send_to(ip_address_yau, ip_port_yau, unit.tx_data.slice(0, unit.tx_len))
|
||||
Error.FAILED: print_debug('Ошибка отправки данных')
|
||||
@@ -182,18 +189,24 @@ func on_command_change_device(meta_device):
|
||||
ip_fs_1 = meta_device[3]
|
||||
ip_fs_2 = meta_device[4]
|
||||
#ip_fs_3 = meta_device[5]
|
||||
#connect_fs_1()
|
||||
connect_fs_2()
|
||||
connect_fs_1()
|
||||
#connect_fs_2()
|
||||
|
||||
|
||||
func state_machine_fs():
|
||||
## State fs machine
|
||||
if client_fs_1:
|
||||
## State fs machine
|
||||
if (state_fs == Constants.STATE.IDLE) or (state_fs == Constants.STATE.DONE):
|
||||
if command_stack:
|
||||
var pack: Array = command_stack.pop_front()
|
||||
send_fs_data_1(pack)
|
||||
unit_fs_1.send_fs_data(pack, client_fs_1, peerstream_fs_1)
|
||||
state_fs = Constants.STATE.SEND
|
||||
if 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_1.send_fs_data(pack, client_fs_2, peerstream_fs_2)
|
||||
state_fs_2 = Constants.STATE.SEND
|
||||
|
||||
|
||||
# Подключится к модулю ФС
|
||||
@@ -210,43 +223,52 @@ func connect_fs_1():
|
||||
peerstream_fs_1.set_stream_peer(client_fs_1)
|
||||
|
||||
|
||||
# Отправить команду для ФС
|
||||
func send_fs_data_1(data_to_sand: PackedByteArray):
|
||||
if client_fs_1.get_status() == 2:
|
||||
var peer = peerstream_fs_1.get_stream_peer()
|
||||
if peer:
|
||||
peer.put_data(data_to_sand)
|
||||
emit_signal("data_send")
|
||||
|
||||
|
||||
# Разорвать соединение с ФС
|
||||
func disconnect_fs(client_for_leave):
|
||||
client_for_leave.disconnect_from_host()
|
||||
state_fs = Constants.STATE.IDLE
|
||||
command_stack = []
|
||||
|
||||
#
|
||||
#func start_work_fs():
|
||||
#unit_fs_1.start_session()
|
||||
#unit_fs_1.base_get_current_temp()
|
||||
#
|
||||
#
|
||||
#func get_fs_gen_status(state_gen):
|
||||
#unit_fs_1.set_gen_state(state_gen)
|
||||
#unit_fs_1.get_gen_state()
|
||||
#unit_fs_1.base_get_current_temp()
|
||||
#
|
||||
#
|
||||
#func set_fs_ferq_carrier(freq: int):
|
||||
#unit_fs_1.set_carrier(freq)
|
||||
#unit_fs_1.base_get_current_temp()
|
||||
#unit_fs_1.get_carrier()
|
||||
#
|
||||
#
|
||||
#func set_fs_attenuation(attenuation: float):
|
||||
#unit_fs_1.set_att_batch(attenuation)
|
||||
#unit_fs_1.get_att_batch()
|
||||
#unit_fs_1.base_get_current_temp()
|
||||
|
||||
func start_work_fs():
|
||||
counter_fs_1 = 0
|
||||
unit_fs_1.start_session(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_gen_state(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_att_batch(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_carrier(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
func get_fs_gen_status(state_gen):
|
||||
unit_fs_1.set_gen_state(state_gen, counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_gen_state(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
func set_fs_ferq_carrier(freq: int):
|
||||
unit_fs_1.set_carrier(freq, counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_carrier(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
func set_fs_attenuation(attenuation: float):
|
||||
unit_fs_1.set_att_batch(attenuation, counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_att_batch(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
## 2 ФС коннект
|
||||
@@ -289,45 +311,25 @@ func state_machine_fs_2():
|
||||
state_fs_2 = Constants.STATE.SEND
|
||||
|
||||
|
||||
func poll_receive_fs_2(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: String):
|
||||
client.poll()
|
||||
var peer = peerstream.get_stream_peer()
|
||||
# Проверяем, существует ли соединение
|
||||
if not peer:
|
||||
emit_signal("port_error", ip_fs)
|
||||
return
|
||||
# Проверяем состояние подключения
|
||||
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
emit_signal("port_closed", 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])
|
||||
emit_signal("data_from_fs_2", rx_data)
|
||||
emit_signal("port_fs_opened_2", ip_fs)
|
||||
if state_fs_2 == Constants.STATE.SEND:
|
||||
state_fs_2 = Constants.STATE.DONE
|
||||
|
||||
|
||||
func start_work_fs_2():
|
||||
unit_fs_2.start_session()
|
||||
unit_fs_2.base_get_current_temp()
|
||||
|
||||
|
||||
func get_fs_gen_status_2(state_gen):
|
||||
unit_fs_2.set_gen_state(state_gen)
|
||||
unit_fs_2.get_gen_state()
|
||||
unit_fs_2.base_get_current_temp()
|
||||
|
||||
|
||||
func set_fs_ferq_carrier_2(freq: int):
|
||||
unit_fs_2.set_carrier(freq)
|
||||
unit_fs_2.base_get_current_temp()
|
||||
unit_fs_2.get_carrier()
|
||||
|
||||
|
||||
func set_fs_attenuation_2(attenuation: float):
|
||||
unit_fs_2.set_att_batch(attenuation)
|
||||
unit_fs_2.get_att_batch()
|
||||
unit_fs_2.base_get_current_temp()
|
||||
#
|
||||
#func start_work_fs_2():
|
||||
#unit_fs_2.start_session()
|
||||
#unit_fs_2.base_get_current_temp()
|
||||
#
|
||||
#
|
||||
#func get_fs_gen_status_2(state_gen):
|
||||
#unit_fs_2.set_gen_state(state_gen)
|
||||
#unit_fs_2.get_gen_state()
|
||||
#unit_fs_2.base_get_current_temp()
|
||||
#
|
||||
#
|
||||
#func set_fs_ferq_carrier_2(freq: int):
|
||||
#unit_fs_2.set_carrier(freq)
|
||||
#unit_fs_2.base_get_current_temp()
|
||||
#unit_fs_2.get_carrier()
|
||||
#
|
||||
#
|
||||
#func set_fs_attenuation_2(attenuation: float):
|
||||
#unit_fs_2.set_att_batch(attenuation)
|
||||
#unit_fs_2.get_att_batch()
|
||||
#unit_fs_2.base_get_current_temp()
|
||||
|
||||
Reference in New Issue
Block a user