Рефактор

This commit is contained in:
sasha80
2025-09-18 23:24:42 +03:00
parent b2633d8063
commit 3203f9cd20
3 changed files with 61 additions and 46 deletions

View File

@@ -176,7 +176,7 @@ func map_threat_to_bip(th: threats.Threat, bip: Control):
if freq_range[0] <= freq and freq <= freq_range[1]:
sector_key = key
break
if sector_key!= null:
if sector_key != null:
radius_internal = fs_band[sector_key][0]
radius_outter = fs_band[sector_key][1]
freq_low = prd.FS_FREQ[sector_key][0]

View File

@@ -17,7 +17,7 @@ class CapsRpb extends unit.Unit:
var source_addr: Array ## Адрес отправителя данных
func _to_string() -> String: return String('CapsRpb(\"%s\")' % self.name)
func _init(nm): self.name = nm
func _init(unit_name): self.name = unit_name
func parse(data: PackedByteArray, now_tick: int):
tick = now_tick

View File

@@ -207,15 +207,15 @@ func on_nav_data_received(coords: Dictionary, unit_caps):
## Проверяет состояние отправки пакета и если не доставлен, повторяет отправку.
func on_timer_check_state(unit, ecms, resend_timeout) -> void:
func on_timer_check_state(unit_instance, ecms, resend_timeout) -> void:
var tick = Time.get_ticks_msec()
for ecm in ecms.values():
if (tick - ecm.tick_tx) >= resend_timeout:
send_ecm(ecm, unit)
send_ecm(ecm, unit_instance)
ecm.tick_tx = tick
func on_th_aoa_update(threats: Dictionary, ecms: Dictionary, unit) -> void:
func on_th_aoa_update(threats: Dictionary, ecms: Dictionary, unit_instance) -> void:
for thr in threats.values():
var th_id = thr.id
for ecm_i in thrs.keys():
@@ -223,7 +223,7 @@ func on_th_aoa_update(threats: Dictionary, ecms: Dictionary, unit) -> void:
var ecm = ecms[ecm_i]
ecm.params['freq'] = thr.freq
ecm.kni = thr.aoa
send_ecm(ecm, unit)
send_ecm(ecm, unit_instance)
signaller.emit_signal('fs_update_color', ecms)
prd.update_fs_state(ecms)
@@ -238,16 +238,23 @@ func on_th_aoa_update(threats: Dictionary, ecms: Dictionary, unit) -> void:
## Производит приём состояния помех. [param unit] -> [param ecms].
func on_data_capsrpb_received(unit0: capsrpb.CapsRpb, ecms: Dictionary) -> void:
if not unit0.json_dic.has('ts'): return
if not (unit0.json_dic['ts'] is float): return
if unit0.json_dic['ts'] != 5: return
if not unit0.json_dic.has('msvk'): return
if not (unit0.json_dic['msvk'] is Array): return
var msvk = unit0.json_dic['msvk']
func on_data_capsrpb_received(unit_instance: capsrpb.CapsRpb, ecms: Dictionary) -> void:
if not unit_instance.json_dic.has('ts'): return
if not (unit_instance.json_dic['ts'] is float): return
if unit_instance.json_dic['ts'] != 5: return
map_msvk_to_ecms(unit_instance, ecms)
map_mpchf_to_view(unit_instance)
## Извлекает массив состояний выполнения команды
func map_msvk_to_ecms(unit_instance: unit.Unit, ecms: Dictionary):
var json_dic = unit_instance.json_dic
if not json_dic.has('msvk'): return
var msvk = unit_instance.json_dic['msvk']
if msvk is not Array: return
for dic_msvk in msvk:
if not (dic_msvk is Dictionary): continue
if dic_msvk.has('ispp'):
if not dic_msvk.has('ispp'): continue
var ispp = int(dic_msvk['ispp'])
var errmsg = dic_msvk.get('errmsg', '')
if errmsg:
@@ -260,7 +267,15 @@ func on_data_capsrpb_received(unit0: capsrpb.CapsRpb, ecms: Dictionary) -> void:
var ecm = Interfer.new()
ecm.set_from_dic(dic_msvk)
ecm.krp = INTERFER_OFF
send_ecm(ecm, unit0)
send_ecm(ecm, unit_instance)
## Извлекает массив пространственно-частотных фильтров
func map_mpchf_to_view(unit_instance: unit.Unit):
var json_dic = unit_instance.json_dic
if not json_dic.has('mpchf'): return
var mpchf = json_dic['mpchf']
if mpchf is not Array: return
## Вызыватся, когда пользователь выбрал помеху и выбраны цели.