modul fs 2
This commit is contained in:
@@ -252,9 +252,10 @@ color = Color(0.669446, 0.567301, 0.66881, 1)
|
||||
[node name="ISA" type="Label" parent="."]
|
||||
offset_left = 225.0
|
||||
offset_top = 11.0
|
||||
offset_right = 1853.0
|
||||
offset_right = 409.0
|
||||
offset_bottom = 48.0
|
||||
autowrap_mode = 3
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="read_isa" type="Button" parent="."]
|
||||
offset_left = 85.0
|
||||
@@ -262,6 +263,7 @@ offset_top = 7.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 38.0
|
||||
text = "Прочитать ISA"
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="."]
|
||||
offset_left = 216.0
|
||||
@@ -281,6 +283,7 @@ theme_override_styles/tab_unselected = SubResource("StyleBoxTexture_17le6")
|
||||
tab_alignment = 2
|
||||
current_tab = 0
|
||||
tab_focus_mode = 0
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PRD" type="Panel" parent="TabContainer"]
|
||||
layout_mode = 2
|
||||
@@ -329,13 +332,14 @@ script = ExtResource("2_vmbyo")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK" type="Sprite2D" parent="TabContainer/PRD/body_grid/litera_2_4_6"]
|
||||
modulate = Color(1, 1, 0.941176, 0.588235)
|
||||
modulate = Color(1, 1, 0.941176, 0.733333)
|
||||
material = ExtResource("3_3syd3")
|
||||
position = Vector2(914, 5)
|
||||
scale = Vector2(0.247968, 0.234167)
|
||||
position = Vector2(955, 5)
|
||||
scale = Vector2(0.23, 0.217)
|
||||
texture = SubResource("PlaceholderTexture2D_723du")
|
||||
offset = Vector2(800, 600)
|
||||
script = SubResource("GDScript_0sobq")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK grad" type="TextureRect" parent="TabContainer/PRD/body_grid/litera_2_4_6/PSK"]
|
||||
modulate = Color(1, 1, 0.941176, 0.784314)
|
||||
@@ -387,13 +391,14 @@ script = ExtResource("2_vmbyo")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK2" type="Sprite2D" parent="TabContainer/PRD/body_grid/litera_3_5_7"]
|
||||
modulate = Color(1, 1, 0.941176, 0.588235)
|
||||
modulate = Color(1, 1, 0.941176, 0.733333)
|
||||
material = ExtResource("3_3syd3")
|
||||
position = Vector2(914, -6)
|
||||
scale = Vector2(0.247968, 0.234167)
|
||||
position = Vector2(955, -6)
|
||||
scale = Vector2(0.23, 0.217)
|
||||
texture = SubResource("PlaceholderTexture2D_723du")
|
||||
offset = Vector2(800, 600)
|
||||
script = SubResource("GDScript_0sobq")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK grad" type="TextureRect" parent="TabContainer/PRD/body_grid/litera_3_5_7/PSK2"]
|
||||
modulate = Color(1, 1, 0.941176, 0.784314)
|
||||
|
||||
BIN
Web.png
BIN
Web.png
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 18 KiB |
@@ -108,7 +108,8 @@ class FGOS:
|
||||
var crc = crc32(packet)
|
||||
packet.resize(packet.size() + 4)
|
||||
packet.encode_u32(packet.size() - 4, crc)
|
||||
Network.command_stack.append(packet)
|
||||
#Network.command_stack.append(packet)
|
||||
Network.command_stack_2.append(packet)
|
||||
|
||||
|
||||
func _parse(rx_data: PackedByteArray):
|
||||
|
||||
@@ -137,6 +137,8 @@ func _ready() -> void:
|
||||
Network.connect('yau_status_line', Callable(self, '_on_yau_status'))
|
||||
Network.connect('yau_receive', Callable(self, '_on_data_received'))
|
||||
Network.connect('yau_read_isa', Callable(self, '_on_read_isa'))
|
||||
Network.connect('port_fs_opened_1', _on_port_changed_fs_1.bind(Color.GREEN))
|
||||
Network.connect('port_fs_opened_2', _on_port_changed_fs_2.bind(Color.GREEN))
|
||||
Network.connect('data_from_fs_1', _on_data_fs_1)
|
||||
Network.connect('data_from_fs_2', _on_data_fs_2)
|
||||
|
||||
@@ -418,7 +420,8 @@ func on_btn_select(intem_from_sector: int) -> void:
|
||||
Network.on_command_change_device(meta)
|
||||
flag_mode = meta[2]
|
||||
draw_control_panel_prd(flag_mode)
|
||||
_on_start_fs_1()
|
||||
#_on_start_fs_1()
|
||||
_on_start_fs_2()
|
||||
|
||||
|
||||
func _on_zapret1(toggled_on: bool) -> void:
|
||||
@@ -519,7 +522,12 @@ func _on_read_isa_pressed() -> void:
|
||||
func set_bits(v, a, m):
|
||||
return (~m) & v | a & m
|
||||
|
||||
|
||||
## 1 ФС
|
||||
func _on_port_changed_fs_1(port_name: String, _color: Color) -> void:
|
||||
$TabContainer/PRD/body_grid/litera_2_4_6/fs_control.set_node_text(1, 1, port_name)
|
||||
|
||||
|
||||
func _on_start_fs_1():
|
||||
Network.start_work_fs()
|
||||
|
||||
@@ -538,18 +546,21 @@ func _on_set_att_1(att: String):
|
||||
|
||||
|
||||
## 2 ФС
|
||||
func _on_port_changed_fs_2(port_name: String, _color: Color) -> void:
|
||||
$TabContainer/PRD/body_grid/litera_3_5_7/fs_control.set_node_text(1, 1, port_name)
|
||||
|
||||
func _on_start_fs_2():
|
||||
Network.start_work_fs()
|
||||
Network.start_work_fs_2()
|
||||
|
||||
|
||||
func _on_get_status_2(toggled_btn):
|
||||
var inverted_state = not toggled_btn
|
||||
Network.get_fs_gen_status(inverted_state)
|
||||
Network.get_fs_gen_status_2(inverted_state)
|
||||
|
||||
|
||||
func _on_set_ferq_2(freq: String):
|
||||
Network.set_fs_ferq_carrier(int(freq) * 1_000_000)
|
||||
Network.set_fs_ferq_carrier_2(int(freq) * 1_000_000)
|
||||
|
||||
|
||||
func _on_set_att_2(att: String):
|
||||
Network.set_fs_attenuation(float(att))
|
||||
Network.set_fs_attenuation_2(float(att))
|
||||
|
||||
@@ -13,8 +13,9 @@ func _process(_delta: float) -> void:
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
pass
|
||||
# Подключаем сигналы к методам
|
||||
Network.connect('data_send', _on_data_send)
|
||||
#Network.connect('data_send', _on_data_send)
|
||||
#Network.connect('data_from_fs_1', _on_data_received)
|
||||
#Network.connect('port_opened', _on_port_changed.bind(Color.GREEN))
|
||||
#Network.connect('port_closed', _on_port_changed.bind(Color.GRAY))
|
||||
|
||||
@@ -2,7 +2,8 @@ extends Node
|
||||
|
||||
# ЯУ-07 Блок
|
||||
var unit = Yau07.YaU07.new('ЯУ-07Б')
|
||||
var unit_fs_1 = 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]
|
||||
@@ -15,21 +16,30 @@ var state = Constants.STATE.WAIT
|
||||
var send_array: Array = []
|
||||
|
||||
# ФС Блок
|
||||
var ip_fs_1: String = Constants.ADDRESSES[0][4]
|
||||
var command_stack: Array
|
||||
var state_fs = Constants.STATE.IDLE
|
||||
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
|
||||
|
||||
## 2 ФС
|
||||
var client_fs_2: StreamPeer
|
||||
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
|
||||
|
||||
|
||||
signal yau_status_line(_status) ## Вызывается когда меняется состояние связи с ячейкой
|
||||
signal yau_receive(_data_from_yau)
|
||||
signal yau_read_isa(_unit_isa_ports)
|
||||
|
||||
signal data_send()
|
||||
#signal data_send()
|
||||
#signal data_send_2()
|
||||
signal data_from_fs_1(data:PackedByteArray)
|
||||
signal data_from_fs_2(data:PackedByteArray)
|
||||
signal port_opened(port_name: String)
|
||||
signal port_fs_opened_1(port_name: String)
|
||||
signal port_fs_opened_2(port_name: String)
|
||||
signal port_closed(port_name: String)
|
||||
signal port_error(error_str: String)
|
||||
|
||||
@@ -60,24 +70,24 @@ func poll_receive_yau07(sock: Socket) -> bool: ## Приёмник
|
||||
return false
|
||||
|
||||
|
||||
func poll_receive_fs(client: StreamPeerTCP):
|
||||
func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: String):
|
||||
client.poll()
|
||||
var peer = peerstream_fs_1.get_stream_peer()
|
||||
var peer = peerstream.get_stream_peer()
|
||||
# Проверяем, существует ли соединение
|
||||
if not peer:
|
||||
emit_signal("port_error", ip_fs_1)
|
||||
emit_signal("port_error", ip_fs)
|
||||
return
|
||||
# Проверяем состояние подключения
|
||||
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
emit_signal("port_closed", ip_fs_1)
|
||||
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_1", rx_data)
|
||||
emit_signal("data_from_fs_2", rx_data)
|
||||
emit_signal("port_opened", ip_fs_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
|
||||
|
||||
@@ -96,7 +106,8 @@ func _ready() -> void:
|
||||
|
||||
unit.connect('line_changed', Callable(self, 'on_line_changed'))
|
||||
unit.connect('command_fail', Callable(self, 'on_command_fail'))
|
||||
connect_fs()
|
||||
#connect_fs_1()
|
||||
connect_fs_2()
|
||||
read_port_isa([0x106, 0x108])
|
||||
|
||||
|
||||
@@ -106,13 +117,16 @@ func _process(delta: float) -> void:
|
||||
last_update_time_fs += delta
|
||||
|
||||
if client_fs_1:
|
||||
poll_receive_fs(client_fs_1)
|
||||
poll_receive_fs(client_fs_1, peerstream_fs_1, ip_fs_1)
|
||||
if client_fs_2:
|
||||
poll_receive_fs_2(client_fs_2, peerstream_fs_2, ip_fs_2)
|
||||
|
||||
poll_receive_yau07(soc_brodcast)
|
||||
poll_receive_yau07(soc_unicast)
|
||||
|
||||
state_machine_yau07()
|
||||
state_machine_fs()
|
||||
#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))
|
||||
@@ -169,9 +183,10 @@ func on_command_change_device(meta_device):
|
||||
ip_address_yau = meta_device[0]
|
||||
ip_port_yau = meta_device[1]
|
||||
ip_fs_1 = meta_device[3]
|
||||
#ip_fs_2 = meta_device[4]
|
||||
ip_fs_2 = meta_device[4]
|
||||
#ip_fs_3 = meta_device[5]
|
||||
connect_fs()
|
||||
#connect_fs_1()
|
||||
connect_fs_2()
|
||||
|
||||
|
||||
func state_machine_fs():
|
||||
@@ -180,12 +195,12 @@ func state_machine_fs():
|
||||
if (state_fs == Constants.STATE.IDLE) or (state_fs == Constants.STATE.DONE):
|
||||
if command_stack:
|
||||
var pack: Array = command_stack.pop_front()
|
||||
send_data(pack)
|
||||
send_fs_data_1(pack)
|
||||
state_fs = Constants.STATE.SEND
|
||||
|
||||
|
||||
# Подключится к модулю ФС
|
||||
func connect_fs():
|
||||
func connect_fs_1():
|
||||
if client_fs_1:
|
||||
disconnect_fs(client_fs_1)
|
||||
|
||||
@@ -199,7 +214,7 @@ func connect_fs():
|
||||
|
||||
|
||||
# Отправить команду для ФС
|
||||
func send_data(data_to_sand: PackedByteArray):
|
||||
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:
|
||||
@@ -213,25 +228,110 @@ func disconnect_fs(client_for_leave):
|
||||
state_fs = Constants.STATE.IDLE
|
||||
command_stack = []
|
||||
|
||||
|
||||
func start_work_fs():
|
||||
unit_fs_1.start_session()
|
||||
unit_fs_1.base_get_current_temp()
|
||||
#
|
||||
#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 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()
|
||||
## 2 ФС коннект
|
||||
func connect_fs_2():
|
||||
if client_fs_2:
|
||||
disconnect_fs_2(client_fs_2)
|
||||
|
||||
client_fs_2 = StreamPeerTCP.new()
|
||||
peerstream_fs_2 = PacketPeerStream.new()
|
||||
var rc = client_fs_2.connect_to_host(ip_fs_2, Constants.PORT_FS)
|
||||
if rc!= Error.OK:
|
||||
print_debug('Port error %s' % ip_fs_2)
|
||||
#emit_signal("port_error", ip_fs_2)
|
||||
else:
|
||||
peerstream_fs_2.set_stream_peer(client_fs_2)
|
||||
|
||||
|
||||
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 disconnect_fs_2(client_for_leave):
|
||||
client_for_leave.disconnect_from_host()
|
||||
state_fs_2 = Constants.STATE.IDLE
|
||||
command_stack_2 = []
|
||||
|
||||
|
||||
# Отправить команду для ФС
|
||||
func send_fs_data_2(data_to_sand: PackedByteArray):
|
||||
if client_fs_2.get_status() == 2:
|
||||
var peer = peerstream_fs_2.get_stream_peer()
|
||||
if peer:
|
||||
peer.put_data(data_to_sand)
|
||||
emit_signal("data_send_2")
|
||||
|
||||
|
||||
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 state_machine_fs_2():
|
||||
if client_fs_2:
|
||||
## State fs_2 machine
|
||||
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()
|
||||
send_fs_data_2(pack)
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user