Перенос помехи с целью (на текущий сектор)

This commit is contained in:
lepshiy
2024-10-14 09:43:38 +03:00
parent 13b21a37f3
commit 443df3a04d
4 changed files with 61 additions and 9 deletions

View File

@@ -159,6 +159,7 @@ func _ready():
signaller.connect('interfer_off_all', Callable(self, 'on_interfer_off_all'))
signaller.connect('fs_selected', Callable(self, 'on_fs_selected'))
interfer.connect('interfer_update', Callable(self, 'on_interfer_new'))
signaller.connect('fs_update_color', Callable(self, 'on_fs_update_color'))
func get_all_nodes(root):
@@ -186,15 +187,15 @@ func on_threat_update(th):
var bip = get_node('%d' % th.id)
bip.update()
map_threat_to_bip(th, bip)
## Обработчик выбора помехи для цели.
func on_interfer_new(ecm):
if interfer.thrs.has(ecm.ispp):
if interfer.thrs.has(ecm.ispp):
var th_id = interfer.thrs[ecm.ispp]
var bip = get_node('%d' % th_id)
if ecm.krp != interfer.INTERFER_OFF:
var th_id = interfer.thrs[ecm.ispp]
var bip = get_node('%d' % th_id)
if bip!= null:
if ecm.krp!= interfer.INTERFER_OFF:
bip.set_track_visible(true)
if ecm.svk == 1:
bip.set_ecm_visible(true)
@@ -202,6 +203,10 @@ func on_interfer_new(ecm):
else:
bip.set_ecm_visible(false)
bip.set_track_visible(false)
else:
interfer.thrs.erase(ecm.ispp)
set_fs_color(ecm)
update_fs_colors()
set_fs_color(ecm)
@@ -213,6 +218,13 @@ func on_interfer_off_all():
bip.set_track_visible(false)
fs_active.clear()
update_fs_colors()
func on_interfer_off(ecm_id):
fs_active.erase(ecm_id)
fs_selected.erase(ecm_id)
fs_active.clear()
update_fs_colors()
## Обработчик сигнала обнаружения цели.
@@ -229,7 +241,6 @@ func on_threat_lost(th) -> void:
remove_child(bip)
bip.free()
## обработчик нажатия на цель на экране.
func on_bip_pressed(th_id, _ecm_btns):
if btn_select == BtnSel.THREAT:
@@ -419,7 +430,6 @@ func update_fs_colors():
fs_colors[key] = color_select
$canvas.set_band_colors(fs_colors)
func unsel_fs_all(need_btns_off: bool):
fs_selected.clear()
update_fs_colors()
@@ -474,3 +484,9 @@ func set_btns_disabled(value: bool, btn):
btn.set_disabled(true)
else:
btn.set_disabled(value)
func on_fs_update_color(ecms):
fs_active.clear()
for ecm in ecms.values():
set_fs_color(ecm)
update_fs_colors()

View File

@@ -112,7 +112,10 @@ func _ready():
signaller.connect('interfer_rcv', Callable(self, 'on_interfer_rcv').bind(unit_5p28, ecms))
signaller.connect('interfer_new', Callable(self, 'send_ecm').bind(unit))
signaller.connect('interfer_off_all', Callable(self, 'on_interfer_off_all').bind(unit, ecms))
signaller.connect('th_aoa_update', Callable(self, 'on_th_aoa_update').bind(ecms, unit))
signaller.connect('interfer_off', Callable(self, 'on_interfer_off'))
threats.connect('threat_lost', Callable(self, 'on_threats_lost').bind(ecms, unit))
## Проверяет состояние отправки пакета и если не доставлен, повторяет отправку.
func on_timer_check_state(unit, ecms, resend_timeout):
@@ -124,6 +127,18 @@ func on_timer_check_state(unit, ecms, resend_timeout):
ecm.tick_tx = tick
func on_th_aoa_update(threats: Dictionary, ecms: Dictionary, unit):
for thr in threats.values():
var th_id = thr.id
for ecm_i in thrs.keys():
if thrs[ecm_i] == th_id:
var ecm = ecms[ecm_i]
ecm.params['freq'] = thr.freq
ecm.kni = thr.aoa
send_ecm(ecm, unit)
signaller.emit_signal('fs_update_color', ecms)
## Производит приём состояния помех. [param unit] -> [param ecms].
func on_data_capsrpb_received(unit: capsrpb.CapsRpb, ecms: Dictionary):
if not unit.json_dic.has('ts'): return
@@ -247,6 +262,16 @@ func on_interfer_off_all(unit, ecms):
push_id(ecm.ispp)
send_ecm(ecm, unit)
signaller.emit_signal('interfer_off',ecm, ecms, thrs)
func on_threats_lost(th, ecms, unit):
for key in interfer.thrs:
if interfer.thrs[key] == th.id:
var ecm_id = key
var ecm = ecms[ecm_id]
ecm.krp = INTERFER_OFF
push_id(ecm.ispp)
send_ecm(ecm, unit)
signaller.emit_signal('interfer_off',ecm, ecms, thrs)
func pop_id():

View File

@@ -127,3 +127,8 @@ signal map_coords_changed(lan: float, lat: float)
## Вызывается при изменении размера изображения для отображения карты.[br]
## [param mode] - Вновь установленный режим.
signal map_mode_changed(mode: int)
## Вызывается при обновлении позиции(угла) цели.[br]
signal th_aoa_update(threats: Dictionary)
signal fs_update_color(ecms:Dictionary)

View File

@@ -51,11 +51,15 @@ func _ready() -> void:
var unit_5p28_key = repsettings.get_unit_key('уарэп-5п28')
var unit_5p28 = repnetwork.units_tcp[unit_5p28_key]
var timer_check_lost: = Timer.new()
var timer_aoa_update: = Timer.new()
add_child(timer_check_lost)
add_child(timer_aoa_update)
unit.connect('data_received', Callable(self, 'on_data_capsrpb_received').bind(threats))
unit_5p28.connect('get_threats', Callable(self, 'on_get_threats').bind(unit_5p28, threats))
timer_check_lost.connect('timeout', Callable(self, 'on_timer_check_lost').bind(repsettings.ThreatParams.time_lost, threats))
timer_check_lost.start(repsettings.ThreatParams.time_lost / 1000.0)
timer_aoa_update.connect('timeout', Callable(self, 'on_timer_aoa_update').bind(threats))
timer_aoa_update.start(0.25)
signaller.connect('rto_threat_sel', Callable(self, 'on_rto_threat_sel').bind(threats))
signaller.connect('rto_threat_unsel', Callable(self, 'on_rto_threat_unsel').bind(threats))
signaller.connect('rto_threat_unsel_all', Callable(self, 'on_rto_threat_unsel_all').bind(threats))
@@ -72,12 +76,14 @@ func on_timer_check_lost(time_lost: int, threats: Dictionary):
call_deferred('emit_signal', 'threat_lost', th)
if sz != threats.size():
call_deferred('emit_signal', 'threats_resized', threats)
func on_timer_aoa_update(threats:Dictionary):
signaller.emit_signal('th_aoa_update', threats)
## отправляет словарь целей в юнит, для запаковки и отправки в 5П28.
func on_get_threats(unit, threats): unit.pack_threats(threats)
## Снимает выделение с цели, если нажать по отметке цели.
func on_rto_threat_unsel(th_id, threats): threats[th_id].selected = false