После отладки, добавление индикации состояний эмс ячеек

This commit is contained in:
TotMaxim
2025-11-12 20:47:35 +03:00
parent 2980aa9f15
commit 87e360e1a9
10 changed files with 323 additions and 90 deletions

View File

@@ -266,7 +266,7 @@ func on_th_aoa_update(threats: Dictionary, ecms: Dictionary, unit_instance) -> v
thr.nmfs = nmfs
if (thr.proto in gos_protocols) and thr.fflags.proto and (not gos_flag):
gos_nmfs.append(nmfs)
thr.emit_state = 0
for ecm in ecms.values():
if thr.nmfs == ecm.nmfs:
@@ -278,7 +278,7 @@ func on_th_aoa_update(threats: Dictionary, ecms: Dictionary, unit_instance) -> v
ecm_active = false
if ecm_active and (prd.fs_caps_id[ecm.nmfs] in fs_closed):
interfer_off(ecm, unit_instance)
var th_id = thr.id
for ecm_i in thrs.keys():
if thrs[ecm_i] == th_id:
@@ -675,4 +675,3 @@ func set_th_emit(th: threats.Threat, ecm: Interfer):
return
else:
th.emit_state = 1

View File

@@ -182,7 +182,7 @@ class TestPRD extends Node:
'ip5_25': [7, false],
}
####
const RAY_m5:= 'RAY_m5'
const RAY_5:= 'RAY_5'
const RAY_15:= 'RAY_15'
@@ -263,17 +263,16 @@ class TestPRD extends Node:
var flag_si_fs_input: bool = false
var flag_si_fs_output: bool = false
var unit_prd: Object
var power_amplify: Array
var power_result: Dictionary
#var control_label: Label
var control_timer: Timer = Timer.new()
var ems_6666_timer: Timer = Timer.new()
var machine_timer: Timer = Timer.new()
var cc: int = 0
var cmd_array: Array
signal control_is_over()
signal update_progress(progress_value: float)
signal update_max_value_progress(max_progress_value: int)
var cc: int = 0
var cmd_array: Array
var progress_value: float:
set(v):
@@ -302,14 +301,14 @@ class TestPRD extends Node:
## Пакеты от ЯУ-07
func on_data_received(unit_pribor: Object) -> void:
var status: PackedByteArray = unit_pribor.status
socket_status_ems_g(status)
if machine_timer.is_stopped():
return
var status: PackedByteArray = unit_pribor.status
block_kasseta_y5_config = check_block_kasseta_y5(status, block_kasseta_y5_config)
block_ip_config = check_block_ip(status, block_ip_config)
control_results.temperature = check_temperature_um(status, power_amplify)
socket_status_ems_g(status)
_process_dkm_status(status)
if current_litera != 0:
var tek_litera: Dictionary = power_for_litera[current_litera]
@@ -318,8 +317,29 @@ class TestPRD extends Node:
tek_litera[_get_ray_key(state)] = power_um_ukp(status, current_litera, tek_litera[_get_ray_key(state)])
power_for_litera[current_litera] = tek_litera
var ems_input_1: int
var ems_input_2: int
var ems_input_lit_1: int
var ems_output_1: int
var ems_output_2: int
var ems_output_lit_1: int
func socket_status_ems_g(packet_form_yau_07: PackedByteArray) -> void:
if self_name in ['', '', '', '']:
ems_input_1 = (packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) & (1 << 9)) != 0
ems_input_2 = (packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) & (1 << 10)) != 0
if self_name in ['', '', '', '']:
ems_input_1 = (packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) & (1 << 11)) != 0
ems_input_1 = (packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) & (1 << 12)) != 0
if self_name in ['', '', '', '']:
ems_input_1 = (packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) & (1 << 13)) != 0
ems_input_1 = (packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) & (1 << 14)) != 0
ems_input_lit_1 = (packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD) & (1 << 8)) != 0
ems_output_1 = (packet_form_yau_07.decode_u16(DataIndices.OUT_BLANK_PRD) & (1 << 4)) != 0
ems_output_2 = (packet_form_yau_07.decode_u16(DataIndices.OUT_BLANK_PRD) & (1 << 5)) != 0
ems_output_lit_1 = (packet_form_yau_07.decode_u16(DataIndices.OUT_BLANK_PRD) & (1 << 3)) != 0
var number_socket_input: int
if current_litera >= 1 and current_litera <= 7:
number_socket_input = current_litera + 7
@@ -327,6 +347,8 @@ class TestPRD extends Node:
var in_blank: int = packet_form_yau_07.decode_u16(DataIndices.IN_BLANK_PRD)
flag_si_fs_input = (in_blank & (1 << number_socket_input)) != 0 ## Флаг СИ от ФС входа в ЭМС-Г для текущей литеры
var number_socket_output: int
number_socket_output = 4 if current_litera in [2, 4, 6] else 3 if current_litera == 1 else 5
@@ -344,7 +366,7 @@ class TestPRD extends Node:
fs_result = on_fs_state(packet_type_7, fs_mapping, fs_result)
control_results[fs_key] = fs_result[fs_key]
flag_fs_status_ok = control_results[fs_key] == 1
##
func state_control_machine() -> void:
match state:
@@ -354,11 +376,14 @@ class TestPRD extends Node:
_handle_fs_turn_on_state()
state = STATE_MACHINE.FS_WORK
STATE_MACHINE.FS_WORK:
for key in ecms.keys():
pass
#print([fs_parameters, current_litera])
#print('ecms: %s %s' % [ecms[key].kni, ecms[key].params.freq])
if ecms.size() and flag_fs_status_ok:
var flag_ecm: bool = false
for key in ecms:
var params = ecms[key].params.freq
if fs_parameters[current_litera].freq == params:
var kni = ecms[key].kni
if pribor_config[self_name].angle == kni:
flag_ecm = true
if flag_ecm and flag_fs_status_ok:
ems_6666_timer.start()
_handle_fs_work_state()
STATE_MACHINE.CHEK_KASSETA_Y5:
@@ -490,13 +515,13 @@ class TestPRD extends Node:
## Таймер отправки команды в ЭМС-Г для модуляции
func _on_ems_6666_timer() -> void:
cmd_array.append([unit_prd.CmdCode.WRITE_ISA, [constants.BASE_ADDR_EMS_G, 6666]])
## Таймер вызова машины состояний
func on_state_mashine():
state_control_machine()
func progressbar_status() -> void:
match state:
STATE_MACHINE.INIT:
@@ -546,8 +571,8 @@ class TestPRD extends Node:
func on_interfer_resized(ecms_dic: Dictionary) -> void:
ecms = ecms_dic
func _on_start_contol_device()-> void:
_determine_self_name()
machine_timer.wait_time = constants.STATE_MASHINE_TIMER
@@ -601,13 +626,13 @@ class TestPRD extends Node:
add_child(ems_6666_timer)
ems_6666_timer.timeout.connect(_on_ems_6666_timer)
ems_6666_timer.wait_time = 1.0
add_child(machine_timer)
machine_timer.connect('timeout', Callable(self, 'on_state_mashine'))
func on_mode_changed(in_tree: bool) -> void:
if not in_tree:
if not in_tree: ## TODO: Дополнительная проверка если контроль идет, если нет, то смысла вызывать нет
progress_value = 0
machine_timer.stop()
state = STATE_MACHINE.INIT
@@ -615,7 +640,7 @@ class TestPRD extends Node:
#prd_v_module.cmd_array.append([unit_prd_v.CmdCode.WRITE_ISA, [constants_v.ADDR_UG_LITERA_1, ug_work_1, constants_v.ADDR_UG_LITERA_2, ug_work_2]])
else:
pass
func _process_dkm_status(status: PackedByteArray) -> void:
if not control_results.has(_get_current_fs_key()):
@@ -722,7 +747,7 @@ class TestPRD extends Node:
params.width,
sectors[litera - 1] if litera == 1 else sectors[litera - 5] if litera > 5 else sectors[litera - 4] if litera > 3 else sectors[litera - 2]
])
signaller.emit_signal('emit_changed', mode)
#signaller.emit_signal('emit_changed', mode)
signaller.emit_signal('interfer_init', interfer_name, fs_arr, power_um)
@@ -749,52 +774,6 @@ class TestPRD extends Node:
return y5_config
## Проверка температур УМ от УКП
static func check_temperature_um(status_prd: PackedByteArray, power_amplifier: Array) -> bool:
const Constants: Dictionary = {
'CONST_MIN_TEMP': -25,
'MAXIMUM_CODE_ADC': 3796,
'MINIMUM_CODE_AD': 2660,
'TEMPERATURE_UKP_1': 47,
'TEMPERATURE_UKP_2': 79,
}
const TEMP: float = 115.0 / (Constants.MAXIMUM_CODE_ADC - Constants.MINIMUM_CODE_AD)
var ukp1_online: int = (status_prd[0] >> 2) & 1
var ukp2_online = (status_prd[0] >> 3) & 1
var all_temp_is_ok: bool = true
if ukp1_online:
var tmp_1: int
var temperature_ukp_1: int
for i_temp in 6:
temperature_ukp_1 = status_prd.decode_u16(Constants.TEMPERATURE_UKP_1 + 2 * i_temp)
tmp_1 = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3)
#power_amplifier[i_temp].value1 = tmp_1
if tmp_1>70:
all_temp_is_ok = false
if power_amplifier.size() > 12: # Темпуратура от УМ литеры 1
temperature_ukp_1 = status_prd.decode_u16(Constants.TEMPERATURE_UKP_1 + 2 * 7)
tmp_1 = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_1) * TEMP + 3)
#power_amplifier[6].value1 = tmp_1
if tmp_1>70:
all_temp_is_ok = false
if ukp2_online:
for i_temp in 6:
var temperature_ukp_2: int = status_prd.decode_u16(Constants.TEMPERATURE_UKP_2 + 2 * i_temp)
var tmp_2: int = round(Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_2) * TEMP + 3)
if power_amplifier.size() > 12:
#power_amplifier[i_temp+7].value1 = tmp_2
if tmp_2>70:
all_temp_is_ok = false
else:
#power_amplifier[i_temp+6].value1 = tmp_2
if tmp_2>70:
all_temp_is_ok = false
return all_temp_is_ok
## Проверка ДКМ
static func check_dkm(status_prd: PackedByteArray, bit_dkm: int) -> bool:
var dkm: int = 28