modul fs 1

This commit is contained in:
2025-02-06 22:27:26 +03:00
parent da73feed4b
commit a2467c3d8b
4 changed files with 99 additions and 57 deletions

View File

@@ -18,9 +18,9 @@ config/icon="res://icon.svg"
[autoload] [autoload]
Constants="*res://scripts/constants.gd" Constants="*res://scripts/constants.gd"
Fs="*res://scripts/FS.gd"
Yau07="*res://scripts/yau07.gd" Yau07="*res://scripts/yau07.gd"
Network="*res://scripts/network.gd" Network="*res://scripts/network.gd"
Fs="*res://scripts/FS.gd"
[debug] [debug]

View File

@@ -2,7 +2,7 @@ extends Node2D
signal read_ems_g_start() signal read_ems_g_start()
signal read_ems_g_finish() signal read_ems_g_finish()
var unit_fs_1 = Fs.FGOS.new()
var flag_mode = Constants.ADDRESSES[0][3] var flag_mode = Constants.ADDRESSES[0][3]
var broadcast_packet: PackedByteArray var broadcast_packet: PackedByteArray
var node_select1: Node var node_select1: Node
@@ -90,10 +90,11 @@ func _ready() -> void:
node_select_fs_2.set_node_text(1, 0, 'Литера 3') node_select_fs_2.set_node_text(1, 0, 'Литера 3')
node_select_fs_2.set_node_text(0, 1, 'Состояние') node_select_fs_2.set_node_text(0, 1, 'Состояние')
node_select_fs_2.set_node_text(0, 2, 'Частота') node_select_fs_2.set_node_text(0, 2, 'Частота')
#node_select_fs_2.get_node2(1, 2).placeholder_text = '500' node_select_fs_2.get_node2(1, 2).placeholder_text = 'в МГц'
node_select_fs_2.get_node2(1, 2).editable = true
node_select_fs_2.set_node_text(0, 3, 'Аттенюатор') node_select_fs_2.set_node_text(0, 3, 'Аттенюатор')
#node_select_fs_2.get_node2(1, 3).placeholder_text = '38.7' node_select_fs_2.get_node2(1, 3).placeholder_text = 'в dB'
#node_select_fs_2.get_node2(1, 3).d = true node_select_fs_2.get_node2(1, 3).editable = true
node_select_fs_2.set_node_text(0, 4, 'Генератор') node_select_fs_2.set_node_text(0, 4, 'Генератор')
node_select_fs_2.set_node_text(0, 5, 'fpga') node_select_fs_2.set_node_text(0, 5, 'fpga')
node_select_fs_2.set_node_text(0, 6, 'СИ 3 от ФС') node_select_fs_2.set_node_text(0, 6, 'СИ 3 от ФС')
@@ -136,7 +137,8 @@ func _ready() -> void:
Network.connect('yau_status_line', Callable(self, '_on_yau_status')) Network.connect('yau_status_line', Callable(self, '_on_yau_status'))
Network.connect('yau_receive', Callable(self, '_on_data_received')) Network.connect('yau_receive', Callable(self, '_on_data_received'))
Network.connect('yau_read_isa', Callable(self, '_on_read_isa')) Network.connect('yau_read_isa', Callable(self, '_on_read_isa'))
Network.connect('data_from_fs_1', Callable(self, '_on_data_fs_1')) Network.connect('data_from_fs_1', _on_data_fs_1)
Network.connect('data_from_fs_2', _on_data_fs_2)
node_select_yau_07b.get_node2(1, 1).get_child(1, false).connect('toggled', Callable(self, '_on_zapret1')) node_select_yau_07b.get_node2(1, 1).get_child(1, false).connect('toggled', Callable(self, '_on_zapret1'))
node_select_yau_07b.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um_1')) node_select_yau_07b.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um_1'))
@@ -150,9 +152,13 @@ func _ready() -> void:
node_select_yau_07b_2.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_fgos_2')) node_select_yau_07b_2.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_fgos_2'))
node_select_fs_1.get_node2(1, 4).get_child(1, false).connect('toggled', Callable(self, '_on_get_status_1')) node_select_fs_1.get_node2(1, 4).get_child(1, false).connect('toggled', Callable(self, '_on_get_status_1'))
node_select_fs_1.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att')) node_select_fs_1.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_1'))
node_select_fs_1.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq')) node_select_fs_1.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_1'))
node_select_fs_2.get_node2(1, 4).get_child(1, false).connect('toggled', Callable(self, '_on_get_status_2'))
node_select_fs_2.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_2'))
node_select_fs_2.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_2'))
func draw_control_panel_prd(mode) -> void: func draw_control_panel_prd(mode) -> void:
for node_path in Constants.NODE_MAP: for node_path in Constants.NODE_MAP:
@@ -223,7 +229,6 @@ func _on_data_fs_1(fs_1_data):
Constants.CMD.BASE_GET_CURRENT_TEMP: Constants.CMD.BASE_GET_CURRENT_TEMP:
if GRP == Constants.GROUP.BASE: if GRP == Constants.GROUP.BASE:
node_select_fs_1.set_node_text(1, 5, '%.2f' % fs_1_data.decode_float(0xC) + ' °C') node_select_fs_1.set_node_text(1, 5, '%.2f' % fs_1_data.decode_float(0xC) + ' °C')
#$read.text = str(fs_1_data.hex_encode())
func _on_data_fs_2(fs_2_data): func _on_data_fs_2(fs_2_data):
@@ -514,26 +519,37 @@ func _on_read_isa_pressed() -> void:
func set_bits(v, a, m): func set_bits(v, a, m):
return (~m) & v | a & m return (~m) & v | a & m
## 1 ФС
func _on_start_fs_1(): func _on_start_fs_1():
unit_fs_1.start_session() Network.start_work_fs()
unit_fs_1.base_get_current_temp()
func _on_get_status_1(toggled_btn): func _on_get_status_1(toggled_btn):
var inverted_state = not toggled_btn var inverted_state = not toggled_btn
unit_fs_1.set_gen_state(inverted_state) Network.get_fs_gen_status(inverted_state)
unit_fs_1.get_gen_state()
func _on_set_ferq(freq): func _on_set_ferq_1(freq: String):
unit_fs_1.set_carrier(int(freq) * 1_000_000) Network.set_fs_ferq_carrier(int(freq) * 1_000_000)
unit_fs_1.base_get_current_temp()
unit_fs_1.get_carrier()
func _on_set_att(att): func _on_set_att_1(att: String):
unit_fs_1.set_att_batch(float(att)) Network.set_fs_attenuation(float(att))
unit_fs_1.base_get_current_temp()
unit_fs_1.base_get_current_temp()
unit_fs_1.get_att_batch() ## 2 ФС
func _on_start_fs_2():
Network.start_work_fs()
func _on_get_status_2(toggled_btn):
var inverted_state = not toggled_btn
Network.get_fs_gen_status(inverted_state)
func _on_set_ferq_2(freq: String):
Network.set_fs_ferq_carrier(int(freq) * 1_000_000)
func _on_set_att_2(att: String):
Network.set_fs_attenuation(float(att))

View File

@@ -15,45 +15,45 @@ func _process(_delta: float) -> void:
func _enter_tree() -> void: func _enter_tree() -> void:
# Подключаем сигналы к методам # Подключаем сигналы к методам
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('data_from_fs_1', _on_data_received)
Network.connect('port_opened', _on_port_changed.bind(Color.GREEN)) #Network.connect('port_opened', _on_port_changed.bind(Color.GREEN))
Network.connect('port_closed', _on_port_changed.bind(Color.GRAY)) #Network.connect('port_closed', _on_port_changed.bind(Color.GRAY))
Network.connect('port_error', _on_port_changed.bind(Color.RED)) #Network.connect('port_error', _on_port_changed.bind(Color.RED))
func _on_port_changed(port_name: String, color: Color) -> void: #func _on_port_changed(port_name: String, color: Color) -> void:
$manage_panel/con/ip_connect.text = port_name #$manage_panel/con/ip_connect.text = port_name
$fs_connect.self_modulate = color #$fs_connect.self_modulate = color
func _on_data_send(): func _on_data_send():
pass pass
#
func _on_data_received(data: PackedByteArray): #func _on_data_received(data: PackedByteArray):
var GRP = data.decode_u8(0x0) #var GRP = data.decode_u8(0x0)
var CMD = data.decode_u8(0x1) #var CMD = data.decode_u8(0x1)
match CMD: #match CMD:
Constants.CMD.READ_CARRIER: #Constants.CMD.READ_CARRIER:
if GRP == Constants.GROUP.BASE: #if GRP == Constants.GROUP.BASE:
$manage_panel/get_freq/freq_ind.text = str(data.decode_u64(0xC)) + ' Гц' #$manage_panel/get_freq/freq_ind.text = str(data.decode_u64(0xC)) + ' Гц'
Constants.CMD.READ_ATT: #Constants.CMD.READ_ATT:
if GRP == Constants.GROUP.RF: #if GRP == Constants.GROUP.RF:
$manage_panel/get_att/att_ind.text = '-' + str(data.decode_float(0x18)) + ' dB' #$manage_panel/get_att/att_ind.text = '-' + str(data.decode_float(0x18)) + ' dB'
Constants.CMD.READ_GEN_STATUS: #Constants.CMD.READ_GEN_STATUS:
if GRP == Constants.GROUP.GENERATOR: #if GRP == Constants.GROUP.GENERATOR:
if data.decode_u32(0xC) == 0: #if data.decode_u32(0xC) == 0:
$manage_panel/get_gen_status/status_ind.text = 'Включен' #$manage_panel/get_gen_status/status_ind.text = 'Включен'
$manage_panel/get_gen_status/status_ind.modulate = Color.GREEN #$manage_panel/get_gen_status/status_ind.modulate = Color.GREEN
else: #else:
$manage_panel/get_gen_status/status_ind.text = 'Выключен' #$manage_panel/get_gen_status/status_ind.text = 'Выключен'
$manage_panel/get_gen_status/status_ind.modulate = Color.RED #$manage_panel/get_gen_status/status_ind.modulate = Color.RED
Constants.CMD.BASE_GET_CURRENT_TEMP: #Constants.CMD.BASE_GET_CURRENT_TEMP:
if GRP == Constants.GROUP.BASE: #if GRP == Constants.GROUP.BASE:
$temp_1.text = '%.2f' % data.decode_float(0xC) + ' °C' #$temp_1.text = '%.2f' % data.decode_float(0xC) + ' °C'
$temp_2.text = str(data.decode_float(0x10)) + ' °C' #$temp_2.text = str(data.decode_float(0x10)) + ' °C'
$temp_3.text = str(data.decode_float(0x14)) + ' °C' #$temp_3.text = str(data.decode_float(0x14)) + ' °C'
$read.text = str(data.hex_encode()) #$read.text = str(data.hex_encode())
func _on_send_pressed() -> void: func _on_send_pressed() -> void:

View File

@@ -2,6 +2,7 @@ extends Node
# ЯУ-07 Блок # ЯУ-07 Блок
var unit = Yau07.YaU07.new('ЯУ-07Б') var unit = Yau07.YaU07.new('ЯУ-07Б')
var unit_fs_1 = Fs.FGOS.new()
var soc_unicast: Socket var soc_unicast: Socket
var soc_brodcast: Socket var soc_brodcast: Socket
var ip_address_yau: String = Constants.ADDRESSES[0][1] var ip_address_yau: String = Constants.ADDRESSES[0][1]
@@ -27,6 +28,7 @@ signal yau_read_isa(_unit_isa_ports)
signal data_send() signal data_send()
signal data_from_fs_1(data:PackedByteArray) signal data_from_fs_1(data:PackedByteArray)
signal data_from_fs_2(data:PackedByteArray)
signal port_opened(port_name: String) signal port_opened(port_name: String)
signal port_closed(port_name: String) signal port_closed(port_name: String)
signal port_error(error_str: String) signal port_error(error_str: String)
@@ -73,7 +75,8 @@ func poll_receive_fs(client: StreamPeerTCP):
if peer.get_available_bytes() > 0: if peer.get_available_bytes() > 0:
var rx_data: PackedByteArray var rx_data: PackedByteArray
rx_data.append_array(peer.get_data(peer.get_available_bytes())[1]) 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_1", rx_data)
emit_signal("data_from_fs_2", rx_data)
emit_signal("port_opened", ip_fs_1) emit_signal("port_opened", ip_fs_1)
if state_fs == Constants.STATE.SEND: if state_fs == Constants.STATE.SEND:
state_fs = Constants.STATE.DONE state_fs = Constants.STATE.DONE
@@ -209,3 +212,26 @@ func disconnect_fs(client_for_leave):
client_for_leave.disconnect_from_host() client_for_leave.disconnect_from_host()
state_fs = Constants.STATE.IDLE state_fs = Constants.STATE.IDLE
command_stack = [] 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()