diff --git a/scripts/FS.gd b/scripts/FS.gd index 19b5269..9e5ea9e 100644 --- a/scripts/FS.gd +++ b/scripts/FS.gd @@ -116,6 +116,7 @@ class FGOS: Network.command_stack.append(packet) else: Network.command_stack_2.append(packet) + online = true func send_fs_data(data_to_sand: PackedByteArray, client_fs: StreamPeer, peerstream_fs: PacketPeer): @@ -223,3 +224,9 @@ class FGOS: func get_base_can_macro(counter: int, client: StreamPeer): var packet = _form_packet(GROUP.BASE, CmdCode.BASE_CAN_MACRO_READ, INDEX_SIZE, counter) send_packet_to(packet, client) + + + # Разорвать соединение с ФС + func disconnect_fs(client_for_leave: StreamPeer): + client_for_leave.disconnect_from_host() + online = false diff --git a/scripts/control_panel.gd b/scripts/control_panel.gd index 7225afd..2e72b9c 100644 --- a/scripts/control_panel.gd +++ b/scripts/control_panel.gd @@ -40,10 +40,11 @@ class Logger extends Node: func _ready() -> void: Network.connect('port_fs_opened_1', _on_fs_status_1.bind(Constants.STATE_VAL.GOOD)) - Network.connect('port_fs_closed_1', _on_fs_status_1.bind(Constants.STATE_VAL.NONE)) + Network.connect('port_fs_closed_1', _on_fs_status_1.bind(Constants.STATE_VAL.ERROR)) + Network.connect('data_from_fs_1', _on_data_fs_1) Network.connect('port_fs_opened_2', _on_fs_status_2.bind(Constants.STATE_VAL.GOOD)) - Network.connect('port_fs_closed_2', _on_fs_status_2.bind(Constants.STATE_VAL.NONE)) + Network.connect('port_fs_closed_2', _on_fs_status_2.bind(Constants.STATE_VAL.ERROR)) self.add_child(timer) timer.connect('timeout', Callable(self, '_on_timer')) @@ -122,8 +123,6 @@ func _status_cell(status): else: for i in range(5, 13): node_cell_ind[i].state = Constants.STATE_VAL.NONE - - func _status_prd(): @@ -254,12 +253,52 @@ func _draw_control_panel_prd(pribor): $soc_DKM/DKM_2.fname = 'ДКМ7' -func _on_fs_status_1(_name_port, status_fs_1): +func _on_fs_status_1(name_port, status_fs_1: int): $Kasseta_FS/ref_A1.state = status_fs_1 + #if logger: + #var message: String = "Модуль ФС-1: %s" % name_port + #logger.info(message) - -func _on_fs_status_2(_name_port, status_fs_2): +func _on_fs_status_2(name_port, status_fs_2): $Kasseta_FS/ref_A2.state = status_fs_2 + #if logger: + #var message: String = "Модуль ФС-2: %s" % name_port + #logger.info(message) + + +func fs_setup(freq_1): + Network.status_can_macro_1(false) + Network.set_fs_ferq_carrier(freq_1 * 1_000_000) + Network.set_fs_attenuation(float(19)) + Network.set_can_macro(freq_1) + Network.status_can_macro_1(true) + Network.get_fs_gen_status(false) + + +func _on_data_fs_1(fs_1_data): + if logger: + var GRP = fs_1_data.decode_u8(0x0) + var CMD = fs_1_data.decode_u8(0x1) + match CMD: + Constants.CMD.READ_CARRIER: + if GRP == Constants.GROUP.BASE: + logger.info('В модуль ФС-1 установлена частота: %s МГц ✅' % (fs_1_data.decode_u64(0xC) / 1_000_000)) + Constants.CMD.READ_ATT: + if GRP == Constants.GROUP.RF: + logger.info('В модуль ФС-1 установлена аттенюация: %s dB ✅' % (fs_1_data.decode_float(0x18))) + Constants.CMD.READ_GEN_STATUS: + if GRP == Constants.GROUP.GENERATOR: + if fs_1_data.decode_u32(0xC) == 0: + logger.info('Состояние генератора ФС-1: Включен ✅') + else: + logger.info('Состояние генератора ФС-1: Отключен ❌') + Constants.CMD.BASE_CAN_MACRO_READ: + if GRP == Constants.GROUP.BASE: + logger.info('В модуль ФС-1 установлена частота CAN: %s МГц ✅' % (fs_1_data.decode_u16(0x20))) + + +func yau_07b_setup(): + Network.write_port_isa(Constants.BASE_PORTS.UG, 9) func _on_start_super_control(): @@ -270,15 +309,19 @@ func _on_start_super_control(): _draw_control_panel_prd(Constants.CURRENT_MODE) if (Network.unit.online): $soc_y5/yau_07b.state = Constants.STATE_VAL.GOOD - logger.info("Яу-07б: Есть связь ✅") + logger.info("ЯУ-07Б: Есть связь ✅") + yau_07b_setup() _status_cell(Network.unit.status) else: for i in range(1, count_cell): node_cell_ind[i].state = Constants.STATE_VAL.NONE $soc_y5/yau_07b.state = Constants.STATE_VAL.ERROR - logger.error("Яу-07б: Нет связи ❌") - + logger.error("ЯУ-07Б: Нет связи ❌") + + if Network.unit_fs.online: + logger.info('Настройка модуля ФС (932 Гц)') + fs_setup(932) # Гц _status_prd() past_pribor = Constants.CURRENT_MODE @@ -287,7 +330,7 @@ func _on_start_super_control(): func _on_timer(): if (Network.unit.online): logger = Logger.new(get_node('log_array')) - logger.info("Яу-07б: Есть связь ✅") + logger.info("ЯУ-07Б: Есть связь ✅") $soc_y5/yau_07b.state = Constants.STATE_VAL.GOOD _status_cell(Network.unit.status) else: @@ -295,4 +338,4 @@ func _on_timer(): node_cell_ind[i].state = Constants.STATE_VAL.NONE $soc_y5/yau_07b.state = Constants.STATE_VAL.ERROR - logger.error("Яу-07б: Нет связи ❌") + logger.error("ЯУ-07Б: Нет связи ❌") diff --git a/scripts/network.gd b/scripts/network.gd index 793e72a..8ce9d8c 100644 --- a/scripts/network.gd +++ b/scripts/network.gd @@ -227,7 +227,9 @@ func state_machine_fs(client_fs): # Подключится к модулю ФС func connect_fs_1(): if client_fs_1: - disconnect_fs(client_fs_1) + unit_fs.disconnect_fs(client_fs_1) + state_fs = Constants.STATE.IDLE + command_stack = [] client_fs_1 = StreamPeerTCP.new() peerstream_fs_1 = PacketPeerStream.new() @@ -238,19 +240,10 @@ func connect_fs_1(): peerstream_fs_1.set_stream_peer(client_fs_1) -# Разорвать соединение с ФС -func disconnect_fs(client_for_leave): - client_for_leave.disconnect_from_host() - state_fs = Constants.STATE.IDLE - command_stack = [] - - func start_work_fs(): counter_fs_1 = 0 unit_fs.start_session(counter_fs_1, client_fs_1) counter_fs_1 += 1 - unit_fs.set_att_batch(19.0, counter_fs_1, client_fs_1) - counter_fs_1 += 1 unit_fs.get_gen_state(counter_fs_1, client_fs_1) counter_fs_1 += 1 unit_fs.get_att_batch(counter_fs_1, client_fs_1) @@ -266,10 +259,10 @@ func start_work_fs(): func get_fs_gen_status(state_gen): unit_fs.set_gen_state(state_gen, counter_fs_1, client_fs_1) counter_fs_1 += 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_gen_state(counter_fs_1, client_fs_1) + counter_fs_1 += 1 func set_fs_ferq_carrier(freq: int): @@ -302,8 +295,6 @@ func set_can_macro(can_frequency: int): func status_can_macro_1(state_can: bool): unit_fs.status_can_macro_exec(state_can, counter_fs_1, client_fs_1) counter_fs_1 += 1 - unit_fs.get_base_can_macro(counter_fs_1, client_fs_1) - counter_fs_1 += 1 func set_configure_gen_msk_1(): @@ -321,7 +312,9 @@ func set_configure_gen_const_1(): ## 2 ФС коннект func connect_fs_2(): if client_fs_2: - disconnect_fs_2(client_fs_2) + unit_fs.disconnect_fs(client_fs_2) + state_fs_2 = Constants.STATE.IDLE + command_stack_2 = [] client_fs_2 = StreamPeerTCP.new() peerstream_fs_2 = PacketPeerStream.new() @@ -332,13 +325,6 @@ func connect_fs_2(): peerstream_fs_2.set_stream_peer(client_fs_2) -# Разорвать соединение с ФС -func disconnect_fs_2(client_for_leave: StreamPeer): - client_for_leave.disconnect_from_host() - state_fs_2 = Constants.STATE.IDLE - command_stack_2 = [] - - func start_work_fs_2(): counter_fs_2 = 0 unit_fs.start_session(counter_fs_2, client_fs_2) @@ -384,6 +370,7 @@ func set_fs_attenuation_2(attenuation: float): counter_fs_2 += 1 +## Установка CAN частоты для подстройки фильтра ФС func set_can_macro_2(can_frequency: int): unit_fs.set_base_can_macro(can_frequency, counter_fs_2, client_fs_2) counter_fs_2 += 1 @@ -393,12 +380,13 @@ func set_can_macro_2(can_frequency: int): counter_fs_2 += 1 +## Установка CAN статуса(вкл/откл) для подстройки фильтра ФС func status_can_macro_2(state_can: bool): unit_fs.status_can_macro_exec(state_can, counter_fs_2, client_fs_2) counter_fs_2 += 1 - unit_fs.get_base_can_macro(counter_fs_2, client_fs_2) - counter_fs_2 += 1 + +## Установка модуляции msk на генератор ФС func set_configure_gen_msk_2(): unit_fs.set_configure_state_msk_modul_1(counter_fs_2, client_fs_2) counter_fs_2 += 1 @@ -406,6 +394,7 @@ func set_configure_gen_msk_2(): counter_fs_2 += 1 +## Установка модуляции const на генератор ФС func set_configure_gen_const_2(): unit_fs.set_configure_state_msk_const_1(counter_fs_2, client_fs_2) counter_fs_2 += 1 diff --git a/scripts/switch.gd b/scripts/switch.gd index 4c4d69f..c37816a 100644 --- a/scripts/switch.gd +++ b/scripts/switch.gd @@ -7,5 +7,5 @@ func _ready() -> void: set('theme_override_styles/panel', style) -func _process(_delta: float) -> void: - pass +#func _process(_delta: float) -> void: + #pass diff --git a/table/node.tscn b/table/node.tscn index e2b91cf..b18a1ab 100644 --- a/table/node.tscn +++ b/table/node.tscn @@ -27,6 +27,7 @@ theme_override_font_sizes/font_size = 17 theme_override_styles/read_only = SubResource("StyleBoxFlat_q1ixs") theme_override_styles/normal = SubResource("StyleBoxFlat_q1ixs") alignment = 1 +editable = false caret_blink = true caret_blink_interval = 0.5