Merge remote-tracking branch 'origin/dev_maxim' into dev_danil
# Conflicts: # scripts/PRD.gd # scripts/network.gd
This commit is contained in:
1003
PRD57EF.tmp
Normal file
1003
PRD57EF.tmp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -251,9 +251,10 @@ color = Color(0.669446, 0.567301, 0.66881, 1)
|
||||
[node name="ISA" type="Label" parent="."]
|
||||
offset_left = 225.0
|
||||
offset_top = 11.0
|
||||
offset_right = 1853.0
|
||||
offset_right = 409.0
|
||||
offset_bottom = 48.0
|
||||
autowrap_mode = 3
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="read_isa" type="Button" parent="."]
|
||||
offset_left = 85.0
|
||||
@@ -261,6 +262,7 @@ offset_top = 7.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 38.0
|
||||
text = "Прочитать ISA"
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="."]
|
||||
offset_left = 216.0
|
||||
@@ -280,6 +282,7 @@ theme_override_styles/tab_unselected = SubResource("StyleBoxTexture_17le6")
|
||||
tab_alignment = 2
|
||||
current_tab = 1
|
||||
tab_focus_mode = 0
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PRD" type="Panel" parent="TabContainer"]
|
||||
visible = false
|
||||
@@ -329,13 +332,14 @@ script = ExtResource("2_vmbyo")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK" type="Sprite2D" parent="TabContainer/PRD/body_grid/litera_2_4_6"]
|
||||
modulate = Color(1, 1, 0.941176, 0.588235)
|
||||
modulate = Color(1, 1, 0.941176, 0.733333)
|
||||
material = ExtResource("3_3syd3")
|
||||
position = Vector2(914, 5)
|
||||
scale = Vector2(0.247968, 0.234167)
|
||||
position = Vector2(955, 5)
|
||||
scale = Vector2(0.23, 0.217)
|
||||
texture = SubResource("PlaceholderTexture2D_723du")
|
||||
offset = Vector2(800, 600)
|
||||
script = SubResource("GDScript_0sobq")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK grad" type="TextureRect" parent="TabContainer/PRD/body_grid/litera_2_4_6/PSK"]
|
||||
modulate = Color(1, 1, 0.941176, 0.784314)
|
||||
@@ -387,13 +391,14 @@ script = ExtResource("2_vmbyo")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK2" type="Sprite2D" parent="TabContainer/PRD/body_grid/litera_3_5_7"]
|
||||
modulate = Color(1, 1, 0.941176, 0.588235)
|
||||
modulate = Color(1, 1, 0.941176, 0.733333)
|
||||
material = ExtResource("3_3syd3")
|
||||
position = Vector2(914, -6)
|
||||
scale = Vector2(0.247968, 0.234167)
|
||||
position = Vector2(955, -6)
|
||||
scale = Vector2(0.23, 0.217)
|
||||
texture = SubResource("PlaceholderTexture2D_723du")
|
||||
offset = Vector2(800, 600)
|
||||
script = SubResource("GDScript_0sobq")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="PSK grad" type="TextureRect" parent="TabContainer/PRD/body_grid/litera_3_5_7/PSK2"]
|
||||
modulate = Color(1, 1, 0.941176, 0.784314)
|
||||
@@ -742,25 +747,26 @@ script = ExtResource("2_vmbyo")
|
||||
|
||||
[node name="load_boadr" type="ColorRect" parent="TabContainer/EMS_G"]
|
||||
layout_mode = 0
|
||||
offset_left = 27.0
|
||||
offset_top = 148.0
|
||||
offset_right = 1596.0
|
||||
offset_bottom = 717.0
|
||||
offset_left = 35.0
|
||||
offset_top = 58.0
|
||||
offset_right = 1604.0
|
||||
offset_bottom = 782.0
|
||||
color = Color(0, 0, 0, 0.596078)
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="load" type="Sprite2D" parent="TabContainer/EMS_G/load_boadr"]
|
||||
material = SubResource("ShaderMaterial_slcfo")
|
||||
position = Vector2(786, 284.5)
|
||||
scale = Vector2(24.4688, 8.89063)
|
||||
position = Vector2(785.001, 361.5)
|
||||
scale = Vector2(24.5313, 11.2656)
|
||||
texture = SubResource("GradientTexture2D_0pk2o")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="Load_text" type="Label" parent="TabContainer/EMS_G/load_boadr"]
|
||||
layout_mode = 0
|
||||
offset_left = 693.0
|
||||
offset_top = 277.0
|
||||
offset_top = 341.0
|
||||
offset_right = 849.0
|
||||
offset_bottom = 316.0
|
||||
offset_bottom = 380.0
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_shadow_color = Color(0.427493, 0.427493, 0.427493, 1)
|
||||
theme_override_font_sizes/font_size = 28
|
||||
|
||||
BIN
Web.png
BIN
Web.png
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 18 KiB |
@@ -18,9 +18,9 @@ config/icon="res://icon.svg"
|
||||
[autoload]
|
||||
|
||||
Constants="*res://scripts/constants.gd"
|
||||
Fs="*res://scripts/FS.gd"
|
||||
Yau07="*res://scripts/yau07.gd"
|
||||
Network="*res://scripts/network.gd"
|
||||
Fs="*res://scripts/FS.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
|
||||
120
scripts/FS.gd
120
scripts/FS.gd
@@ -66,32 +66,33 @@ class FGOS:
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D]
|
||||
|
||||
const INDEX_SIZE: int = 0xC
|
||||
const GROUP_OFFSET: int = 0x0
|
||||
const CMD_OFFSET: int = 0x1
|
||||
const COUNTER_OFFSET: int = 0x4
|
||||
const PAYLOAD_OFFSET: int = 0x8
|
||||
|
||||
const INIT: int = 0xFFFFFFFF
|
||||
const FINAL_XOR_VALUE: int = 0x00000000
|
||||
|
||||
signal line_changed(unit: FGOS) ## Вызывается когда меняется состояние связи с ячейкой
|
||||
|
||||
var counter: int = 0
|
||||
var online: bool = false ## Состояние связи с ячейкой
|
||||
var status: = PackedByteArray() ## Поле "состояние прибора"
|
||||
#var fgos_data = {} ## Результат выполнения команды "читать порт"
|
||||
|
||||
|
||||
func crc32(data: PackedByteArray) -> int:
|
||||
var crc = Constants.INIT
|
||||
var crc = INIT
|
||||
for byte in data:
|
||||
var index = (crc ^ byte) & 0xFF
|
||||
crc = (Constants.CRC32_TABLE[index] ^ (crc >> 8)) & 0xFFFFFFFF
|
||||
crc = (CRC32_TABLE[index] ^ (crc >> 8)) & 0xFFFFFFFF
|
||||
# Возвращаем только последние 4 байта в обратном порядке
|
||||
var final_crc = crc ^ Constants.FINAL_XOR_VALUE
|
||||
var final_crc = crc ^ FINAL_XOR_VALUE
|
||||
return final_crc
|
||||
|
||||
|
||||
func _form_packet(group: int, cmd: int, index_size: int, data = null):
|
||||
func _form_packet(group: int, cmd: int, index_size: int, counter: int, data = null):
|
||||
var packet = PackedByteArray()
|
||||
packet.resize(index_size)
|
||||
packet.encode_u8(GROUP_OFFSET, group)
|
||||
@@ -103,82 +104,87 @@ class FGOS:
|
||||
return packet
|
||||
|
||||
|
||||
func _send_packet(packet: PackedByteArray):
|
||||
func send_packet_to(packet: PackedByteArray, client: StreamPeer):
|
||||
var crc = crc32(packet)
|
||||
packet.resize(packet.size() + 4)
|
||||
packet.encode_u32(packet.size() - 4, crc)
|
||||
Network.command_stack.append(packet)
|
||||
|
||||
|
||||
func _parse(rx_data: PackedByteArray):
|
||||
|
||||
if not online:
|
||||
online = true
|
||||
emit_signal('line_changed', self)
|
||||
|
||||
|
||||
var status_len = rx_data.decode_u16(6) # Длина массива байтового "состояние прибора"
|
||||
|
||||
var i: = 0
|
||||
var len_rx_data: = rx_data.size()
|
||||
status.resize(status_len)
|
||||
while i < status_len:
|
||||
var byte_i = i + 8
|
||||
if byte_i < len_rx_data:
|
||||
status[i] = rx_data[byte_i] # Массив байтовый "состояние прибора"
|
||||
i += 1
|
||||
emit_signal('data_received', self)
|
||||
if client == Network.client_fs_1:
|
||||
Network.command_stack.append(packet)
|
||||
else:
|
||||
Network.command_stack_2.append(packet)
|
||||
|
||||
|
||||
func send_fs_data(data_to_sand: PackedByteArray, client_fs: StreamPeer, peerstream_fs: PacketPeer):
|
||||
if client_fs.get_status() == 2:
|
||||
var peer = peerstream_fs.get_stream_peer()
|
||||
if peer:
|
||||
peer.put_data(data_to_sand)
|
||||
else:
|
||||
print_debug('client_fs.get_status != 2 !!!')
|
||||
|
||||
|
||||
#func _parse(rx_data: PackedByteArray):
|
||||
#if not online:
|
||||
#online = true
|
||||
#emit_signal('line_changed', self)
|
||||
#
|
||||
#var status_len = rx_data.decode_u16(6) # Длина массива байтового "состояние прибора"
|
||||
#
|
||||
#var i: = 0
|
||||
#var len_rx_data: = rx_data.size()
|
||||
#status.resize(status_len)
|
||||
#while i < status_len:
|
||||
#var byte_i = i + 8
|
||||
#if byte_i < len_rx_data:
|
||||
#status[i] = rx_data[byte_i] # Массив байтовый "состояние прибора"
|
||||
#i += 1
|
||||
#emit_signal('data_received', self)
|
||||
|
||||
|
||||
func start_session():
|
||||
counter = 0
|
||||
var packet = _form_packet(Constants.GROUP.BASE, Constants.CMD.START_SESSION, 0xC)
|
||||
_send_packet(packet)
|
||||
get_gen_state()
|
||||
get_att_batch()
|
||||
get_carrier()
|
||||
func start_session(counter: int, client: StreamPeer):
|
||||
var packet = _form_packet(GROUP.BASE, CmdCode.START_SESSION, INDEX_SIZE, counter)
|
||||
send_packet_to(packet, client)
|
||||
|
||||
|
||||
func set_gen_state(button_state: bool):
|
||||
func set_gen_state(button_state: bool, counter: int, client: StreamPeer):
|
||||
var index_size = 0x1C
|
||||
var packet = _form_packet(Constants.GROUP.GENERATOR, Constants.CMD.SET_GEN_STATUS, index_size)
|
||||
var packet = _form_packet(GROUP.GENERATOR, CmdCode.SET_GEN_STATUS, index_size, counter)
|
||||
packet.encode_u16(0x8, 0x0010)
|
||||
packet.encode_u32(0xC, button_state) ## MODE GEN STATUS
|
||||
_send_packet(packet)
|
||||
get_gen_state()
|
||||
send_packet_to(packet, client)
|
||||
|
||||
|
||||
func set_carrier(installation_frequency: int):
|
||||
func set_carrier(installation_frequency: int, counter: int, client: StreamPeer):
|
||||
var index_size = 0x1C
|
||||
var packet = _form_packet(Constants.GROUP.BASE, Constants.CMD.SET_CARRIER, index_size)
|
||||
var packet = _form_packet(GROUP.BASE, CmdCode.SET_CARRIER, index_size, counter)
|
||||
packet.encode_u16(0x8, 0x10)
|
||||
packet.encode_u64(0xC, installation_frequency) ## uint64_t freq low dword/high dword
|
||||
_send_packet(packet)
|
||||
send_packet_to(packet, client)
|
||||
|
||||
|
||||
func set_att_batch(attenuation: float):
|
||||
func set_att_batch(attenuation: float, counter: int, client: StreamPeer):
|
||||
var index_size = 0x1C
|
||||
var packet = _form_packet(Constants.GROUP.RF, Constants.CMD.SET_ATT, index_size)
|
||||
var packet = _form_packet(GROUP.RF, CmdCode.SET_ATT, index_size, counter)
|
||||
packet.encode_u16(0x8, 0x10)
|
||||
packet.encode_float(0x18, attenuation)
|
||||
_send_packet(packet)
|
||||
send_packet_to(packet, client)
|
||||
|
||||
|
||||
func get_carrier():
|
||||
var packet = _form_packet(Constants.GROUP.BASE, Constants.CMD.READ_CARRIER, INDEX_SIZE)
|
||||
_send_packet(packet)
|
||||
func get_carrier(counter: int, client: StreamPeer):
|
||||
var packet = _form_packet(GROUP.BASE, CmdCode.READ_CARRIER, INDEX_SIZE, counter)
|
||||
send_packet_to(packet, client)
|
||||
|
||||
|
||||
func get_att_batch():
|
||||
var packet = _form_packet(Constants.GROUP.RF, Constants.CMD.READ_ATT, INDEX_SIZE)
|
||||
_send_packet(packet)
|
||||
func get_att_batch(counter: int, client: StreamPeer):
|
||||
var packet = _form_packet(GROUP.RF, CmdCode.READ_ATT, INDEX_SIZE, counter)
|
||||
send_packet_to(packet, client)
|
||||
|
||||
|
||||
func get_gen_state():
|
||||
var packet = _form_packet(Constants.GROUP.GENERATOR, Constants.CMD.READ_GEN_STATUS, INDEX_SIZE)
|
||||
_send_packet(packet)
|
||||
func get_gen_state(counter: int, client: StreamPeer):
|
||||
var packet = _form_packet(GROUP.GENERATOR, CmdCode.READ_GEN_STATUS, INDEX_SIZE, counter)
|
||||
send_packet_to(packet, client)
|
||||
|
||||
|
||||
func base_get_current_temp():
|
||||
var packet = _form_packet(Constants.GROUP.BASE, Constants.CMD.BASE_GET_CURRENT_TEMP, INDEX_SIZE)
|
||||
_send_packet(packet)
|
||||
func base_get_current_temp(counter: int, client: StreamPeer):
|
||||
var packet = _form_packet(GROUP.BASE, CmdCode.BASE_GET_CURRENT_TEMP, INDEX_SIZE, counter)
|
||||
send_packet_to(packet, client)
|
||||
|
||||
115
scripts/PRD.gd
115
scripts/PRD.gd
@@ -2,7 +2,7 @@ extends Node2D
|
||||
|
||||
signal read_ems_g_start()
|
||||
signal read_ems_g_finish()
|
||||
var unit_fs_1 = Fs.FGOS.new()
|
||||
|
||||
var flag_mode = Constants.ADDRESSES[0][3]
|
||||
var broadcast_packet: PackedByteArray
|
||||
var node_select1: Node
|
||||
@@ -34,14 +34,14 @@ func _ready() -> void:
|
||||
node_select1.set_columns_min_size([120, 120])
|
||||
node_select1.set_node_text(0, 0, 'Мощность')
|
||||
node_select1.set_node_text(1, 0, 'Температура')
|
||||
|
||||
|
||||
# Таблица УКП_2
|
||||
node_select2 = $TabContainer/PRD/body_grid/litera_3_5_7/table_ukp_2
|
||||
draw_tabl(node_select2, Constants.ROWS_REGS_DATA, Constants.ROWS_REGS_DATA.size())
|
||||
node_select2.set_columns_min_size([120, 120])
|
||||
node_select2.set_node_text(0, 0, 'Мощность')
|
||||
node_select2.set_node_text(1, 0, 'Температура')
|
||||
|
||||
|
||||
# Таблица ЯУ-07б
|
||||
var node_select_yau_07b = $TabContainer/PRD/body_grid/litera_2_4_6/yau07b_control
|
||||
draw_tabl(node_select_yau_07b, Constants.ROWS_YAU_07B_1, Constants.ROWS_YAU_07B_1.size())
|
||||
@@ -53,7 +53,7 @@ func _ready() -> void:
|
||||
node_select_yau_07b.set_node_text(0, 3, 'Положение луча')
|
||||
node_select_yau_07b.set_node_text(0, 4, 'Аттенюатор')
|
||||
node_select_yau_07b.set_node_text(0, 6, 'СИ 2 в УФ')
|
||||
|
||||
|
||||
var node_select_yau_07b_2 = $TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control
|
||||
draw_tabl(node_select_yau_07b_2, Constants.ROWS_YAU_07B_2, Constants.ROWS_YAU_07B_2.size())
|
||||
node_select_yau_07b_2.set_columns_min_size([160, 120])
|
||||
@@ -65,7 +65,7 @@ func _ready() -> void:
|
||||
node_select_yau_07b_2.set_node_text(0, 4, 'Аттенюатор')
|
||||
node_select_yau_07b_2.set_node_text(0, 5, 'ФГОЗ 3')
|
||||
node_select_yau_07b_2.set_node_text(0, 6, 'СИ 3 в УФ')
|
||||
|
||||
|
||||
#Таблица ФС
|
||||
var node_select_fs_1 = $TabContainer/PRD/body_grid/litera_2_4_6/fs_control
|
||||
draw_tabl(node_select_fs_1, Constants.ROWS_FS, Constants.ROWS_FS.size())
|
||||
@@ -82,7 +82,7 @@ func _ready() -> void:
|
||||
node_select_fs_1.set_node_text(0, 4, 'Генератор')
|
||||
node_select_fs_1.set_node_text(0, 5, 'fpga')
|
||||
node_select_fs_1.set_node_text(0, 6, 'СИ 2 от ФС')
|
||||
|
||||
|
||||
var node_select_fs_2 = $TabContainer/PRD/body_grid/litera_3_5_7/fs_control
|
||||
draw_tabl(node_select_fs_2, Constants.ROWS_FS, Constants.ROWS_FS.size())
|
||||
node_select_fs_2.set_columns_min_size([120, 120, 150])
|
||||
@@ -90,19 +90,20 @@ func _ready() -> void:
|
||||
node_select_fs_2.set_node_text(1, 0, 'Литера 3')
|
||||
node_select_fs_2.set_node_text(0, 1, 'Состояние')
|
||||
node_select_fs_2.set_node_text(0, 2, 'Частота')
|
||||
#node_select_fs_2.get_node2(1, 2).placeholder_text = '500'
|
||||
node_select_fs_2.get_node2(1, 2).placeholder_text = 'в МГц'
|
||||
node_select_fs_2.get_node2(1, 2).editable = true
|
||||
node_select_fs_2.set_node_text(0, 3, 'Аттенюатор')
|
||||
#node_select_fs_2.get_node2(1, 3).placeholder_text = '38.7'
|
||||
#node_select_fs_2.get_node2(1, 3).d = true
|
||||
node_select_fs_2.get_node2(1, 3).placeholder_text = 'в dB'
|
||||
node_select_fs_2.get_node2(1, 3).editable = true
|
||||
node_select_fs_2.set_node_text(0, 4, 'Генератор')
|
||||
node_select_fs_2.set_node_text(0, 5, 'fpga')
|
||||
node_select_fs_2.set_node_text(0, 6, 'СИ 3 от ФС')
|
||||
|
||||
|
||||
# Выбор прибора для подключения
|
||||
var node_select_device = $TabContainer/PRD/select_dev
|
||||
draw_tabl(node_select_device, Constants.SELECT_DEVICE, Constants.SELECT_DEVICE.size())
|
||||
var get_select_device = node_select_device.get_node2(1, 0)
|
||||
|
||||
|
||||
# Заполнение адресов
|
||||
for i_addr in Constants.ADDRESSES.size():
|
||||
get_select_device.add_item(Constants.ADDRESSES[i_addr][0])
|
||||
@@ -110,7 +111,7 @@ func _ready() -> void:
|
||||
get_select_device.connect('item_selected', Callable(self, 'on_btn_select'))
|
||||
node_select_device.get_node2(0,0).text = 'ПРИБОР'
|
||||
node_select_device.set_columns_min_size([100, 100])
|
||||
|
||||
|
||||
# Получаем имя выбранного прибора
|
||||
if Constants.ADDRESSES.size() > 0:
|
||||
get_select_device.select(0)
|
||||
@@ -136,8 +137,11 @@ func _ready() -> void:
|
||||
Network.connect('yau_status_line', Callable(self, '_on_yau_status'))
|
||||
Network.connect('yau_receive', Callable(self, '_on_data_received'))
|
||||
Network.connect('yau_read_isa', Callable(self, '_on_read_isa'))
|
||||
Network.connect('data_from_fs_1', Callable(self, '_on_data_fs_1'))
|
||||
|
||||
Network.connect('port_fs_opened_1', _on_port_changed_fs_1.bind(Color.GREEN))
|
||||
Network.connect('port_fs_opened_2', _on_port_changed_fs_2.bind(Color.GREEN))
|
||||
Network.connect('data_from_fs_1', _on_data_fs_1)
|
||||
Network.connect('data_from_fs_2', _on_data_fs_2)
|
||||
|
||||
node_select_yau_07b.get_node2(1, 1).get_child(1, false).connect('toggled', Callable(self, '_on_zapret1'))
|
||||
node_select_yau_07b.get_node2(1, 2).connect('item_selected', Callable(self, '_on_modul_um_1'))
|
||||
node_select_yau_07b.get_node2(1, 3).connect('item_selected', Callable(self, '_on_btn_ray_1'))
|
||||
@@ -150,6 +154,12 @@ func _ready() -> void:
|
||||
node_select_yau_07b_2.get_node2(1, 5).get_child(1, false).connect('toggled', Callable(self, '_on_fgos_2'))
|
||||
|
||||
node_select_fs_1.get_node2(1, 4).get_child(1, false).connect('toggled', Callable(self, '_on_get_status_1'))
|
||||
node_select_fs_1.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_1'))
|
||||
node_select_fs_1.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_1'))
|
||||
|
||||
node_select_fs_2.get_node2(1, 4).get_child(1, false).connect('toggled', Callable(self, '_on_get_status_2'))
|
||||
node_select_fs_2.get_node2(1, 3).connect('text_submitted', Callable(self, '_on_set_att_2'))
|
||||
node_select_fs_2.get_node2(1, 2).connect('text_submitted', Callable(self, '_on_set_ferq_2'))
|
||||
|
||||
|
||||
func draw_control_panel_prd(pribor) -> void:
|
||||
@@ -273,9 +283,13 @@ func _on_read_isa(unit_isa_ports: Dictionary) -> void:
|
||||
$ISA.text = 'ISA: ' + str(len(Constants.EMS_G_PORT_DATA_HOLDER))
|
||||
|
||||
if isa_data.has(Constants.BASE_PORTS.UG+6):
|
||||
$TabContainer/PRD/body_grid/litera_2_4_6/yau07b_control.get_node2(1, 3).select(isa_data[0x106] & 0x7)
|
||||
$TabContainer/PRD/body_grid/litera_2_4_6/yau07b_control.get_node2(1, 4).select((isa_data[0x106] & 0x38)>> 3)
|
||||
$TabContainer/PRD/body_grid/litera_2_4_6/PSK/ray_1.material.set('shader_parameter/turn', 0.735 + 0.025 * (isa_data[0x106] & 0x7))
|
||||
$TabContainer/PRD/body_grid/litera_2_4_6/PSK/ray_1.material.set('shader_parameter/inner_radius', 0.8 - 0.01 * (isa_data[0x106] & 0x38))
|
||||
if isa_data.has(Constants.BASE_PORTS.UG+8):
|
||||
$TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control.get_node2(1, 3).select(isa_data[0x108] & 0x7)
|
||||
$TabContainer/PRD/body_grid/litera_3_5_7/yau07b_control.get_node2(1, 4).select((isa_data[0x108] & 0x38)>>3)
|
||||
$TabContainer/PRD/body_grid/litera_3_5_7/PSK2/ray_2.material.set('shader_parameter/turn', 0.735 + 0.025 * (isa_data[0x108] & 0x7))
|
||||
$TabContainer/PRD/body_grid/litera_3_5_7/PSK2/ray_2.material.set('shader_parameter/inner_radius', 0.8 - 0.01 * (isa_data[0x108] & 0x38))
|
||||
|
||||
@@ -302,7 +316,6 @@ func _on_data_fs_1(fs_1_data):
|
||||
Constants.CMD.BASE_GET_CURRENT_TEMP:
|
||||
if GRP == Constants.GROUP.BASE:
|
||||
node_select_fs_1.set_node_text(1, 5, '%.2f' % fs_1_data.decode_float(0xC) + ' °C')
|
||||
#$read.text = str(fs_1_data.hex_encode())
|
||||
|
||||
|
||||
func _on_data_fs_2(fs_2_data):
|
||||
@@ -348,23 +361,23 @@ func _on_data_received(data_from_yau_07):
|
||||
var _DKM: int = data_from_yau_07.decode_u16(Constants.DataIndices.DKM) # ДКМ от УГ
|
||||
#node_select1.set_node_text(2, 0, '%d' % dry_contact)
|
||||
#node_select1.set_node_text(3, 0, '%d' % DKM)
|
||||
|
||||
|
||||
|
||||
|
||||
## УКП
|
||||
for i in range(6): ## Мощность от УКП_1
|
||||
var power_ukp_1 = data_from_yau_07.decode_u16(Constants.DataIndices.POWER_UKP_1 + 2 * i)
|
||||
node_select1.set_node_text(0, i+1, '%d' % power_ukp_1)
|
||||
|
||||
|
||||
for i in range(6): ## Температура от УКП_1
|
||||
var temperature_ukp_1 = data_from_yau_07.decode_u16(Constants.DataIndices.TEMPERATURE_UKP_1 + 2 * i)
|
||||
var TMP = Constants.CONST_MIN_TEMP + (Constants.MAXIMUM_CODE_ADC - temperature_ukp_1) * Constants.TEMP
|
||||
node_select1.set_node_text(1, i+1, '%d °С' % TMP)
|
||||
|
||||
|
||||
for i_pow in range(6): ## Мощность от УКП_2
|
||||
if len(data_from_yau_07) > Constants.DataIndices.POWER_UKP_2 + 2 * i_pow:
|
||||
var power_ukp_2 = data_from_yau_07.decode_u16(Constants.DataIndices.POWER_UKP_2 + 2 * i_pow)
|
||||
node_select2.set_node_text(0, i_pow+1, '%d' % power_ukp_2)
|
||||
|
||||
|
||||
for row in range(6): ## Температура от УКП_2
|
||||
if len(data_from_yau_07) > Constants.DataIndices.TEMPERATURE_UKP_2 + 2 * row:
|
||||
var temperature_ukp_2 = data_from_yau_07.decode_u16(Constants.DataIndices.TEMPERATURE_UKP_2 + 2 * row)
|
||||
@@ -479,7 +492,7 @@ func _on_load_config():
|
||||
func set_tab_and_buttons(tab_index: int, button_name: String) -> void:
|
||||
$TabContainer.current_tab = tab_index
|
||||
var side_panel = $Background/side_panel
|
||||
|
||||
|
||||
for button in side_panel.get_children():
|
||||
if button is Button:
|
||||
button.button_pressed = (button.name == button_name)
|
||||
@@ -490,18 +503,10 @@ func on_btn_select(intem_from_sector: int) -> void:
|
||||
var get_select_device = node_select_device.get_node2(1, 0)
|
||||
var meta = get_select_device.get_item_metadata(intem_from_sector)
|
||||
Network.on_command_change_device(meta)
|
||||
flag_mode = meta[2]
|
||||
draw_control_panel_prd(flag_mode)
|
||||
_on_start_fs_1()
|
||||
Constants.CURRENT_MODE = meta[2]
|
||||
draw_control_panel_prd(Constants.CURRENT_MODE)
|
||||
|
||||
|
||||
func fill_item(node: Node, i_column: int, i_row: int, arr: Dictionary, select: int = 0) -> void:
|
||||
var optionbutton = node.get_node2(i_column, i_row) as OptionButton
|
||||
for key in arr.keys():
|
||||
var item_text = key + " - " + str(arr[key])
|
||||
optionbutton.add_item(item_text)
|
||||
if select < arr.size():
|
||||
optionbutton.select(select)
|
||||
_on_start_fs_2()
|
||||
|
||||
|
||||
func _on_zapret1(toggled_on: bool) -> void:
|
||||
@@ -559,8 +564,8 @@ func _on_btn_ray_1(item_from_ray_1: int) -> void:
|
||||
Network.read_port_isa([Constants.BASE_PORTS.UG+6])
|
||||
else:
|
||||
print_debug('В ISA отсутствует данные в \"%x\" порту' % (Constants.BASE_PORTS.UG+0x6))
|
||||
|
||||
|
||||
|
||||
|
||||
## Регулировка положением луча 2
|
||||
func _on_btn_ray_2(item_from_ray_2: int) -> void:
|
||||
if isa_from_yau07b.has(Constants.BASE_PORTS.UG+8):
|
||||
@@ -603,22 +608,44 @@ func set_bits(v, a, m):
|
||||
return (~m) & v | a & m
|
||||
|
||||
|
||||
## 1 ФС
|
||||
func _on_port_changed_fs_1(port_name: String, _color: Color) -> void:
|
||||
$TabContainer/PRD/body_grid/litera_2_4_6/fs_control.set_node_text(1, 1, port_name)
|
||||
|
||||
|
||||
func _on_start_fs_1():
|
||||
unit_fs_1.start_session()
|
||||
unit_fs_1.base_get_current_temp()
|
||||
Network.start_work_fs()
|
||||
|
||||
|
||||
func _on_get_status_1(toggled_btn):
|
||||
var inverted_state = not toggled_btn
|
||||
unit_fs_1.set_gen_state(inverted_state)
|
||||
unit_fs_1.get_gen_state()
|
||||
Network.get_fs_gen_status(inverted_state)
|
||||
|
||||
|
||||
func _on_set_ferq():
|
||||
var freq = int($set_space/write_to_set_freq.get_text()) * 1_000_000
|
||||
unit_fs_1.set_carrier(freq)
|
||||
func _on_set_ferq_1(freq: String):
|
||||
Network.set_fs_ferq_carrier(int(freq) * 1_000_000)
|
||||
|
||||
|
||||
func _on_set_att():
|
||||
var att = float($set_space/write_to_set_att.get_text())
|
||||
unit_fs_1.set_att_batch(att)
|
||||
func _on_set_att_1(att: String):
|
||||
Network.set_fs_attenuation(float(att))
|
||||
|
||||
|
||||
## 2 ФС
|
||||
func _on_port_changed_fs_2(port_name: String, _color: Color) -> void:
|
||||
$TabContainer/PRD/body_grid/litera_3_5_7/fs_control.set_node_text(1, 1, port_name)
|
||||
|
||||
func _on_start_fs_2():
|
||||
Network.start_work_fs_2()
|
||||
|
||||
|
||||
func _on_get_status_2(toggled_btn):
|
||||
var inverted_state = not toggled_btn
|
||||
Network.get_fs_gen_status_2(inverted_state)
|
||||
|
||||
|
||||
func _on_set_ferq_2(freq: String):
|
||||
Network.set_fs_ferq_carrier_2(int(freq) * 1_000_000)
|
||||
|
||||
|
||||
func _on_set_att_2(att: String):
|
||||
Network.set_fs_attenuation_2(float(att))
|
||||
|
||||
@@ -169,50 +169,14 @@ enum STATE_VAL {
|
||||
|
||||
var EMS_G_PORT_DATA_HOLDER: Array = []
|
||||
|
||||
# Таблица CRC-32 для модуля ФС
|
||||
const CRC32_TABLE: Array = [
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D]
|
||||
|
||||
const PORT_FS = 1201
|
||||
const INIT: int = 0xFFFFFFFF
|
||||
const FINAL_XOR_VALUE: int = 0x00000000
|
||||
|
||||
enum GROUP {
|
||||
BASE = 0x00,
|
||||
GENERATOR = 0x03,
|
||||
RF = 0x06,
|
||||
}
|
||||
|
||||
enum CMD {
|
||||
START_SESSION = 0x0,
|
||||
READ_CARRIER = 0x1F,
|
||||
@@ -222,4 +186,4 @@ enum CMD {
|
||||
READ_GEN_STATUS = 0x05,
|
||||
SET_GEN_STATUS = 0x06,
|
||||
BASE_GET_CURRENT_TEMP = 0x36,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +115,12 @@ func process_sockets_horizon(blank: int, imp: int, count: int, col: int, parent_
|
||||
|
||||
if i == 1:
|
||||
set_frame(get_specific_node(parent_node2, 5), frame_type)
|
||||
var CI_2_UF = parent_node2.get_child(3).get_child(0).get_child(0).get_child(0).get_child(2).get_node2(1, 6).get_child(1)
|
||||
set_frame(CI_2_UF, frame_type)
|
||||
if i == 2:
|
||||
set_frame(get_specific_node(parent_node2, 6), frame_type)
|
||||
var CI_3_UF = parent_node2.get_child(3).get_child(0).get_child(0).get_child(1).get_child(2).get_node2(1, 6).get_child(1)
|
||||
set_frame(CI_3_UF, frame_type)
|
||||
if i == 4:
|
||||
set_frame(get_specific_node(parent_node2, 7), frame_type)
|
||||
if i == 5:
|
||||
@@ -139,18 +143,16 @@ func process_sockets_vert(blank: int, imp: int, count: int, col: int, parent_nod
|
||||
|
||||
if i == 1:
|
||||
set_frame(get_specific_node(parent_node2, 1), frame_type)
|
||||
var CI_2_UF = parent_node2.get_child(3).get_child(0).get_child(0).get_child(0).get_child(2).get_node2(1, 6).get_child(1)
|
||||
set_frame(CI_2_UF, frame_type)
|
||||
if i == 2:
|
||||
set_frame(get_specific_node(parent_node2, 2), frame_type)
|
||||
var CI_3_UF = parent_node2.get_child(3).get_child(0).get_child(0).get_child(1).get_child(2).get_node2(1, 6).get_child(1)
|
||||
set_frame(CI_3_UF, frame_type)
|
||||
if i == 9:
|
||||
set_frame(get_specific_node(parent_node2, 3), frame_type)
|
||||
var CI_2_FS = parent_node2.get_child(3).get_child(0).get_child(0).get_child(0).get_child(0).get_node2(1, 6).get_child(1)
|
||||
set_frame(CI_2_FS, frame_type)
|
||||
if i == 10:
|
||||
set_frame(get_specific_node(parent_node2, 4), frame_type)
|
||||
var CI_3_FS = parent_node2.get_child(3).get_child(0).get_child(0).get_child(1).get_child(0).get_node2(1, 6).get_child(1)
|
||||
set_frame(CI_3_FS, frame_type)
|
||||
|
||||
|
||||
func get_specific_node(parent_node2: Node, child_index: int)-> Node:
|
||||
|
||||
@@ -13,73 +13,74 @@ func _process(_delta: float) -> void:
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
pass
|
||||
# Подключаем сигналы к методам
|
||||
Network.connect('data_send', _on_data_send)
|
||||
Network.connect('data_from_fs_1', _on_data_received)
|
||||
Network.connect('port_opened', _on_port_changed.bind(Color.GREEN))
|
||||
Network.connect('port_closed', _on_port_changed.bind(Color.GRAY))
|
||||
Network.connect('port_error', _on_port_changed.bind(Color.RED))
|
||||
#Network.connect('data_send', _on_data_send)
|
||||
#Network.connect('data_from_fs_1', _on_data_received)
|
||||
#Network.connect('port_opened', _on_port_changed.bind(Color.GREEN))
|
||||
#Network.connect('port_closed', _on_port_changed.bind(Color.GRAY))
|
||||
#Network.connect('port_error', _on_port_changed.bind(Color.RED))
|
||||
|
||||
|
||||
func _on_port_changed(port_name: String, color: Color) -> void:
|
||||
$manage_panel/con/ip_connect.text = port_name
|
||||
$fs_connect.self_modulate = color
|
||||
#func _on_port_changed(port_name: String, color: Color) -> void:
|
||||
#$manage_panel/con/ip_connect.text = port_name
|
||||
#$fs_connect.self_modulate = color
|
||||
|
||||
|
||||
func _on_data_send():
|
||||
pass
|
||||
|
||||
|
||||
func _on_data_received(data: PackedByteArray):
|
||||
var GRP = data.decode_u8(0x0)
|
||||
var CMD = data.decode_u8(0x1)
|
||||
match CMD:
|
||||
Constants.CMD.READ_CARRIER:
|
||||
if GRP == Constants.GROUP.BASE:
|
||||
$manage_panel/get_freq/freq_ind.text = str(data.decode_u64(0xC)) + ' Гц'
|
||||
Constants.CMD.READ_ATT:
|
||||
if GRP == Constants.GROUP.RF:
|
||||
$manage_panel/get_att/att_ind.text = '-' + str(data.decode_float(0x18)) + ' dB'
|
||||
Constants.CMD.READ_GEN_STATUS:
|
||||
if GRP == Constants.GROUP.GENERATOR:
|
||||
if data.decode_u32(0xC) == 0:
|
||||
$manage_panel/get_gen_status/status_ind.text = 'Включен'
|
||||
$manage_panel/get_gen_status/status_ind.modulate = Color.GREEN
|
||||
else:
|
||||
$manage_panel/get_gen_status/status_ind.text = 'Выключен'
|
||||
$manage_panel/get_gen_status/status_ind.modulate = Color.RED
|
||||
Constants.CMD.BASE_GET_CURRENT_TEMP:
|
||||
if GRP == Constants.GROUP.BASE:
|
||||
$temp_1.text = '%.2f' % data.decode_float(0xC) + ' °C'
|
||||
$temp_2.text = str(data.decode_float(0x10)) + ' °C'
|
||||
$temp_3.text = str(data.decode_float(0x14)) + ' °C'
|
||||
$read.text = str(data.hex_encode())
|
||||
#
|
||||
#func _on_data_received(data: PackedByteArray):
|
||||
#var GRP = data.decode_u8(0x0)
|
||||
#var CMD = data.decode_u8(0x1)
|
||||
#match CMD:
|
||||
#Constants.CMD.READ_CARRIER:
|
||||
#if GRP == Constants.GROUP.BASE:
|
||||
#$manage_panel/get_freq/freq_ind.text = str(data.decode_u64(0xC)) + ' Гц'
|
||||
#Constants.CMD.READ_ATT:
|
||||
#if GRP == Constants.GROUP.RF:
|
||||
#$manage_panel/get_att/att_ind.text = '-' + str(data.decode_float(0x18)) + ' dB'
|
||||
#Constants.CMD.READ_GEN_STATUS:
|
||||
#if GRP == Constants.GROUP.GENERATOR:
|
||||
#if data.decode_u32(0xC) == 0:
|
||||
#$manage_panel/get_gen_status/status_ind.text = 'Включен'
|
||||
#$manage_panel/get_gen_status/status_ind.modulate = Color.GREEN
|
||||
#else:
|
||||
#$manage_panel/get_gen_status/status_ind.text = 'Выключен'
|
||||
#$manage_panel/get_gen_status/status_ind.modulate = Color.RED
|
||||
#Constants.CMD.BASE_GET_CURRENT_TEMP:
|
||||
#if GRP == Constants.GROUP.BASE:
|
||||
#$temp_1.text = '%.2f' % data.decode_float(0xC) + ' °C'
|
||||
#$temp_2.text = str(data.decode_float(0x10)) + ' °C'
|
||||
#$temp_3.text = str(data.decode_float(0x14)) + ' °C'
|
||||
#$read.text = str(data.hex_encode())
|
||||
|
||||
|
||||
func _on_send_pressed() -> void:
|
||||
unit_fs.get_carrier()
|
||||
unit_fs.get_carrier(counter, Network.client_fs_1)
|
||||
|
||||
|
||||
func _on_get_att() -> void:
|
||||
unit_fs.get_att_batch()
|
||||
unit_fs.get_att_batch(counter, Network.client_fs_1)
|
||||
|
||||
|
||||
func _on_start():
|
||||
unit_fs.start_session()
|
||||
unit_fs.base_get_current_temp()
|
||||
unit_fs.start_session(counter, Network.client_fs_1)
|
||||
unit_fs.base_get_current_temp(counter, Network.client_fs_1)
|
||||
|
||||
|
||||
func _on_get_status(toggled_btn):
|
||||
var inverted_state = not toggled_btn
|
||||
unit_fs.set_gen_state(inverted_state)
|
||||
unit_fs.get_gen_state()
|
||||
unit_fs.set_gen_state(inverted_state, counter, Network.client_fs_1)
|
||||
unit_fs.get_gen_state(counter, Network.client_fs_1)
|
||||
|
||||
|
||||
func _on_set_ferq():
|
||||
var freq = int($set_space/write_to_set_freq.get_text()) * 1_000_000
|
||||
unit_fs.set_carrier(freq)
|
||||
unit_fs.set_carrier(freq, counter, Network.client_fs_1)
|
||||
|
||||
|
||||
func _on_set_att():
|
||||
var att = float($set_space/write_to_set_att.get_text())
|
||||
unit_fs.set_att_batch(att)
|
||||
unit_fs.set_att_batch(att, counter, Network.client_fs_1)
|
||||
|
||||
@@ -2,6 +2,8 @@ extends Node
|
||||
|
||||
# ЯУ-07 Блок
|
||||
var unit = Yau07.YaU07.new('ЯУ-07Б')
|
||||
var unit_fs_1 = Fs.FGOS.new()
|
||||
#var unit_fs_2 = Fs.FGOS.new()
|
||||
var soc_unicast: Socket
|
||||
var soc_brodcast: Socket
|
||||
var ip_address_yau: String = Constants.ADDRESSES[0][1]
|
||||
@@ -14,25 +16,34 @@ var state = Constants.STATE.WAIT
|
||||
var send_array: Array = []
|
||||
|
||||
# ФС Блок
|
||||
var ip_fs_1: String = Constants.ADDRESSES[0][4]
|
||||
var command_stack: Array
|
||||
var state_fs = Constants.STATE.IDLE
|
||||
var client_fs_1: StreamPeer
|
||||
var ip_fs_1: String = Constants.ADDRESSES[0][4]
|
||||
var peerstream_fs_1: PacketPeer
|
||||
var state_fs = Constants.STATE.IDLE
|
||||
var command_stack: Array
|
||||
var counter_fs_1: int = 0
|
||||
|
||||
## 2 ФС
|
||||
var client_fs_2: StreamPeer
|
||||
var ip_fs_2: String = Constants.ADDRESSES[0][5]
|
||||
var peerstream_fs_2: PacketPeer
|
||||
var state_fs_2 = Constants.STATE.IDLE
|
||||
var command_stack_2: Array
|
||||
var counter_fs_2: int = 0
|
||||
|
||||
# Яу-07б
|
||||
signal yau_status_line(_status) ## Вызывается когда меняется состояние связи с ячейкой
|
||||
signal yau_receive(_data_from_yau)
|
||||
signal yau_read_isa(_unit_isa_ports)
|
||||
|
||||
signal data_send()
|
||||
# ФС модуль
|
||||
signal data_from_fs_1(data:PackedByteArray)
|
||||
signal port_opened(port_name: String)
|
||||
signal data_from_fs_2(data:PackedByteArray)
|
||||
signal port_fs_opened_1(port_name: String)
|
||||
signal port_fs_opened_2(port_name: String)
|
||||
signal port_closed(port_name: String)
|
||||
signal port_error(error_str: String)
|
||||
|
||||
|
||||
|
||||
## Класс для отправки данных в сокет
|
||||
class Socket extends PacketPeerUDP:
|
||||
func send_to(addr: String, port: int, data: PackedByteArray):
|
||||
@@ -46,7 +57,7 @@ func poll_receive_yau07(sock: Socket) -> bool: ## Приёмник
|
||||
broadcast_packet = sock.get_packet()
|
||||
var addr_receive = sock.get_packet_ip()
|
||||
var port_receive = sock.get_packet_port()
|
||||
|
||||
|
||||
if (ip_address_yau == addr_receive) and (ip_port_yau == port_receive):
|
||||
last_update_time_yau07 = 0.0
|
||||
unit.parse(broadcast_packet)
|
||||
@@ -58,25 +69,31 @@ func poll_receive_yau07(sock: Socket) -> bool: ## Приёмник
|
||||
return false
|
||||
|
||||
|
||||
func poll_receive_fs(client: StreamPeerTCP):
|
||||
func poll_receive_fs(client: StreamPeerTCP, peerstream: PacketPeer, ip_fs: String):
|
||||
client.poll()
|
||||
var peer = peerstream_fs_1.get_stream_peer()
|
||||
var peer = peerstream.get_stream_peer()
|
||||
# Проверяем, существует ли соединение
|
||||
if not peer:
|
||||
emit_signal("port_error", ip_fs_1)
|
||||
emit_signal("port_error", ip_fs)
|
||||
return
|
||||
# Проверяем состояние подключения
|
||||
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
emit_signal("port_closed", ip_fs_1)
|
||||
emit_signal("port_closed", ip_fs)
|
||||
return
|
||||
|
||||
|
||||
if peer.get_available_bytes() > 0:
|
||||
var rx_data: PackedByteArray
|
||||
rx_data.append_array(peer.get_data(peer.get_available_bytes())[1])
|
||||
emit_signal("data_from_fs_1", rx_data)
|
||||
emit_signal("port_opened", ip_fs_1)
|
||||
if state_fs == Constants.STATE.SEND:
|
||||
state_fs = Constants.STATE.DONE
|
||||
if client == client_fs_1:
|
||||
emit_signal("data_from_fs_1", rx_data)
|
||||
emit_signal("port_fs_opened_1", ip_fs)
|
||||
if state_fs == Constants.STATE.SEND:
|
||||
state_fs = Constants.STATE.DONE
|
||||
elif client == client_fs_2:
|
||||
emit_signal("data_from_fs_2", rx_data)
|
||||
emit_signal("port_fs_opened_2", ip_fs)
|
||||
if state_fs_2 == Constants.STATE.SEND:
|
||||
state_fs_2 = Constants.STATE.DONE
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -85,15 +102,16 @@ func _ready() -> void:
|
||||
var rc = soc_brodcast.bind(Constants.BROADCAST_PORT, '*')
|
||||
if rc != OK:
|
||||
print_debug('Ошибка: Неудачная привязка широковещательного адреса')
|
||||
|
||||
|
||||
soc_unicast = Socket.new()
|
||||
rc = soc_unicast.bind(Constants.UNICAST_PORT, Constants.UNICAST_ADDRESS)
|
||||
if rc != OK:
|
||||
print_debug('Ошибка: неудачная привязка адреса: ', ip_address_yau)
|
||||
print_debug('Ошибка: неудачная привязка адреса: ', ip_address_yau)
|
||||
|
||||
unit.connect('line_changed', Callable(self, 'on_line_changed'))
|
||||
unit.connect('command_fail', Callable(self, 'on_command_fail'))
|
||||
connect_fs()
|
||||
connect_fs_1()
|
||||
connect_fs_2()
|
||||
read_port_isa([0x106, 0x108])
|
||||
|
||||
|
||||
@@ -101,15 +119,18 @@ func _process(delta: float) -> void:
|
||||
|
||||
last_update_time_yau07 += delta
|
||||
last_update_time_fs += delta
|
||||
|
||||
|
||||
if client_fs_1:
|
||||
poll_receive_fs(client_fs_1)
|
||||
|
||||
poll_receive_fs(client_fs_1, peerstream_fs_1, ip_fs_1)
|
||||
state_machine_fs(client_fs_1)
|
||||
if client_fs_2:
|
||||
poll_receive_fs(client_fs_2, peerstream_fs_2, ip_fs_2)
|
||||
state_machine_fs(client_fs_2)
|
||||
|
||||
poll_receive_yau07(soc_brodcast)
|
||||
poll_receive_yau07(soc_unicast)
|
||||
|
||||
|
||||
state_machine_yau07()
|
||||
state_machine_fs()
|
||||
|
||||
match unit.process(delta):
|
||||
Error.OK: soc_unicast.send_to(ip_address_yau, ip_port_yau, unit.tx_data.slice(0, unit.tx_len))
|
||||
@@ -142,12 +163,12 @@ func state_machine_yau07():
|
||||
state = Constants.STATE.WAIT
|
||||
|
||||
|
||||
# Записать команду в ИСА
|
||||
# Записать команду в ИСА
|
||||
func read_port_isa(read_ports: Array) -> void:
|
||||
send_array.append(['rd', read_ports])
|
||||
|
||||
|
||||
# Прочитать данные из порта от ИСА
|
||||
# Прочитать данные из порта от ИСА
|
||||
func write_port_isa(port_isa: int, data_isa: int) -> void:
|
||||
var write_data: Dictionary = {port_isa: data_isa}
|
||||
send_array.append(['wr', write_data])
|
||||
@@ -166,26 +187,33 @@ func on_command_change_device(meta_device):
|
||||
ip_address_yau = meta_device[0]
|
||||
ip_port_yau = meta_device[1]
|
||||
ip_fs_1 = meta_device[3]
|
||||
#ip_fs_2 = meta_device[4]
|
||||
ip_fs_2 = meta_device[4]
|
||||
#ip_fs_3 = meta_device[5]
|
||||
connect_fs()
|
||||
connect_fs_1()
|
||||
connect_fs_2()
|
||||
|
||||
|
||||
func state_machine_fs():
|
||||
if client_fs_1:
|
||||
## State fs machine
|
||||
func state_machine_fs(client_fs):
|
||||
## State fs machine
|
||||
if client_fs == client_fs_1:
|
||||
if (state_fs == Constants.STATE.IDLE) or (state_fs == Constants.STATE.DONE):
|
||||
if command_stack:
|
||||
var pack: Array = command_stack.pop_front()
|
||||
send_data(pack)
|
||||
unit_fs_1.send_fs_data(pack, client_fs_1, peerstream_fs_1)
|
||||
state_fs = Constants.STATE.SEND
|
||||
if client_fs == client_fs_2:
|
||||
if (state_fs_2 == Constants.STATE.IDLE) or (state_fs_2 == Constants.STATE.DONE):
|
||||
if command_stack_2:
|
||||
var pack: Array = command_stack_2.pop_front()
|
||||
unit_fs_1.send_fs_data(pack, client_fs_2, peerstream_fs_2)
|
||||
state_fs_2 = Constants.STATE.SEND
|
||||
|
||||
|
||||
# Подключится к модулю ФС
|
||||
func connect_fs():
|
||||
func connect_fs_1():
|
||||
if client_fs_1:
|
||||
disconnect_fs(client_fs_1)
|
||||
|
||||
|
||||
client_fs_1 = StreamPeerTCP.new()
|
||||
peerstream_fs_1 = PacketPeerStream.new()
|
||||
var rc = client_fs_1.connect_to_host(ip_fs_1, Constants.PORT_FS)
|
||||
@@ -195,17 +223,111 @@ func connect_fs():
|
||||
peerstream_fs_1.set_stream_peer(client_fs_1)
|
||||
|
||||
|
||||
# Отправить команду для ФС
|
||||
func send_data(data_to_sand: PackedByteArray):
|
||||
if client_fs_1.get_status() == 2:
|
||||
var peer = peerstream_fs_1.get_stream_peer()
|
||||
if peer:
|
||||
peer.put_data(data_to_sand)
|
||||
emit_signal("data_send")
|
||||
|
||||
|
||||
# Разорвать соединение с ФС
|
||||
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_1.start_session(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_gen_state(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_att_batch(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_carrier(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
func get_fs_gen_status(state_gen):
|
||||
unit_fs_1.set_gen_state(state_gen, counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_gen_state(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
func set_fs_ferq_carrier(freq: int):
|
||||
unit_fs_1.set_carrier(freq, counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_carrier(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
func set_fs_attenuation(attenuation: float):
|
||||
unit_fs_1.set_att_batch(attenuation, counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.get_att_batch(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_1, client_fs_1)
|
||||
counter_fs_1 += 1
|
||||
|
||||
|
||||
## 2 ФС коннект
|
||||
func connect_fs_2():
|
||||
if client_fs_2:
|
||||
disconnect_fs_2(client_fs_2)
|
||||
|
||||
client_fs_2 = StreamPeerTCP.new()
|
||||
peerstream_fs_2 = PacketPeerStream.new()
|
||||
var rc = client_fs_2.connect_to_host(ip_fs_2, Constants.PORT_FS)
|
||||
if rc!= Error.OK:
|
||||
print_debug('Port error %s' % ip_fs_2)
|
||||
#emit_signal("port_error", ip_fs_2)
|
||||
else:
|
||||
peerstream_fs_2.set_stream_peer(client_fs_2)
|
||||
|
||||
|
||||
# Разорвать соединение с ФС
|
||||
func disconnect_fs_2(client_for_leave):
|
||||
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_1.start_session(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.get_gen_state(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.get_att_batch(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.get_carrier(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
#
|
||||
func get_fs_gen_status_2(state_gen):
|
||||
unit_fs_1.set_gen_state(state_gen, counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.get_gen_state(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
|
||||
|
||||
func set_fs_ferq_carrier_2(freq: int):
|
||||
unit_fs_1.set_carrier(freq, counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.get_carrier(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
|
||||
|
||||
func set_fs_attenuation_2(attenuation: float):
|
||||
unit_fs_1.set_att_batch(attenuation, counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.get_att_batch(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
unit_fs_1.base_get_current_temp(counter_fs_2, client_fs_2)
|
||||
counter_fs_2 += 1
|
||||
|
||||
@@ -31,6 +31,7 @@ caret_blink = true
|
||||
caret_blink_interval = 0.5
|
||||
|
||||
[node name="Color_Ems_g" type="ColorRect" parent="."]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_right = 1933.0
|
||||
offset_bottom = 1088.0
|
||||
|
||||
Reference in New Issue
Block a user