модуляция по таймеру

This commit is contained in:
2025-03-04 19:15:16 +03:00
parent 24b122c852
commit 1c7aba948a

View File

@@ -3,6 +3,8 @@ extends Node2D
signal read_ems_g_start()
signal read_ems_g_finish()
var timer_modul_um: Timer = Timer.new()
var node_select1: Node
var node_select2: Node
var node_select3: Node
@@ -132,7 +134,10 @@ func _ready() -> void:
node_select_yau_07b.get_node2(1, 2).add_item(key)
node_select_yau_07b_2.get_node2(1, 2).add_item(key)
node_select_yau_07b_3.get_node2(1, 2).add_item(key)
node_select_yau_07b.get_node2(1, 2).set_meta('meta_um', Constants.META.MODUL_UM_2)
node_select_yau_07b_2.get_node2(1, 2).set_meta('meta_um', Constants.META.MODUL_UM_3)
node_select_yau_07b_3.get_node2(1, 2).set_meta('meta_um', Constants.META.MODUL_UM_1)
## Заполненение списка направления луча
for key in Constants.RAY_DICT:
@@ -154,16 +159,20 @@ func _ready() -> void:
## Yau-07b 1
node_select_yau_07b.get_node2(1, 1).get_child(1, false).connect('toggled', Callable(self, '_on_zapret_2'))
node_select_yau_07b.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um_2'))
node_select_yau_07b.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um').bind(node_select_yau_07b.get_node2(1, 2)))
node_select_yau_07b.get_node2(1, 3).connect('item_selected', Callable(self, '_on_btn_ray_1'))
node_select_yau_07b.get_node2(1, 4).connect('item_selected', Callable(self, '_on_attenuator_1'))
node_select_yau_07b.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_fgos_1'))
## Yau-07b 2
node_select_yau_07b_2.get_node2(1, 1).get_child(1, false).connect('toggled', Callable(self, '_on_zapret_3'))
node_select_yau_07b_2.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um_3'))
node_select_yau_07b_2.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um').bind(node_select_yau_07b_2.get_node2(1, 2)))
node_select_yau_07b_2.get_node2(1, 3).connect('item_selected', Callable(self, '_on_btn_ray_2'))
node_select_yau_07b_2.get_node2(1, 4).connect('item_selected', Callable(self, '_on_attenuator_2'))
node_select_yau_07b_2.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_fgos_2'))
## Yau-07b 3
node_select_yau_07b_3.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um').bind(node_select_yau_07b_3.get_node2(1, 2)))
node_select_yau_07b_3.get_node2(1, 4).connect('item_selected', Callable(self, '_on_attenuator_3'))
## FS 1
node_select_fs_1.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_1'))
node_select_fs_1.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_1'))
@@ -188,6 +197,10 @@ func _ready() -> void:
Network.connect('port_fs_closed_2', _on_port_changed_fs_2.bind(Color.CRIMSON))
Network.connect('data_from_fs_1', _on_data_fs_1)
Network.connect('data_from_fs_2', _on_data_fs_2)
self.add_child(timer_modul_um)
timer_modul_um.connect('timeout', Callable(self, '_on_timer_modul_um'))
func add_signs_scene():
@@ -599,58 +612,61 @@ func _on_zapret_3(toggled_on: bool) -> void:
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, zapret_mode)
func _on_modul_um_1(item_from_ray_1: int):
var meta = Constants.META.MODUL_UM_1
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
var modul_um_values = {
1: 0x2000,
2: 0x4000,
3: 0x8000
}
var current_meta: Array = [0, 0, 0]
var modul_um: Array = [0, 0, 0]
var modul_um = modul_um_values.get(item_from_ray_1, 0)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
func _on_modul_um_2(item_from_ray_1: int):
var meta = Constants.META.MODUL_UM_2
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
var modul_um_values = {
1: 0x2000,
2: 0x4000,
3: 0x8000
}
var modul_um = modul_um_values.get(item_from_ray_1, 0)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
func _on_modul_um_3(item_from_ray_1: int):
var meta = Constants.META.MODUL_UM_3
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
func _on_modul_um(item_from_ray_1: int, node: Node):
var modul_um_values = {
1: 0x2000,
2: 0x4000,
3: 0x8000,
}
var modul_um = modul_um_values.get(item_from_ray_1, 0)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
var meta_mapping = {
Constants.META.MODUL_UM_1: 0,
Constants.META.MODUL_UM_2: 1,
Constants.META.MODUL_UM_3: 2,
}
var meta_key = node.get_meta('meta_um')
var index = meta_mapping.get(meta_key, -1)
if index != -1:
current_meta[index] = meta_key
modul_um[index] = modul_um_values.get(item_from_ray_1, 0)
Network.write_port_isa(Constants.BASE_PORTS.EMS_G + 2, current_meta[index])
Network.write_port_isa(Constants.BASE_PORTS.EMS_G + 8, modul_um[index])
else:
return
if modul_um.has(0x8000):
timer_modul_um.wait_time = 2.3
timer_modul_um.start()
else:
timer_modul_um.stop()
## Таймер для модуляции УМ
func _on_timer_modul_um():
for i in range(3):
if modul_um[i] == 0x8000:
Network.write_port_isa(Constants.BASE_PORTS.EMS_G + 2, current_meta[i])
Network.write_port_isa(Constants.BASE_PORTS.EMS_G + 8, modul_um[i])
## Включение/отключение сигнала ФГОЗ
func _on_fgos_1(toggled_on: bool):
var meta = Constants.META.FGOZ_4
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
var modul_um = 0x8000 if toggled_on else 0x0
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
var fgos_um = 0x8000 if toggled_on else 0x0
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, fgos_um)
## Включение/отключение сигнала ФГОЗ
func _on_fgos_2(toggled_on: bool):
var meta = Constants.META.FGOZ_3
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+2, meta)
var modul_um = 0x8000 if toggled_on else 0x0
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, modul_um)
var fgos_um = 0x8000 if toggled_on else 0x0
Network.write_port_isa(Constants.BASE_PORTS.EMS_G+8, fgos_um)
## Регулировка положением луча 1
@@ -693,6 +709,17 @@ func _on_attenuator_2(item_from_att_1: int) -> void:
print_debug('В ISA отсутствует данные в \"%x\" порту' % (Constants.BASE_PORTS.UG+0x8))
## Регулировка аттенюатора луча 3
func _on_attenuator_3(item_from_att_1: int) -> void:
print('test')
if isa_from_yau07b.has(Constants.BASE_PORTS.UG+8):
var mask = 0x38
Network.write_port_isa(Constants.BASE_PORTS.UG+8, set_bits(isa_from_yau07b[Constants.BASE_PORTS.UG+8], item_from_att_1 << 3, mask))
Network.read_port_isa([Constants.BASE_PORTS.UG+8])
else:
print_debug('В ISA отсутствует данные в \"%x\" порту' % (Constants.BASE_PORTS.UG+0x8))
func _on_read_isa_pressed() -> void:
Network.read_port_isa([Constants.BASE_PORTS.EMS_G+2, Constants.BASE_PORTS.EMS_G+4, Constants.BASE_PORTS.EMS_G+8])