diff --git a/Main.gd b/Main.gd index 1902d42..71a9a16 100644 --- a/Main.gd +++ b/Main.gd @@ -15,8 +15,11 @@ var flag_online: bool = false # Флаг для подключения var flag_interval: bool = false # Флаг для включения непрерывной передачи с интервалом var flag_write_isa: bool = false # Флаг для записи в ИСА var flag_read_isa: bool = true # Флаг для чтения из ИСА +var flag_two_ports: bool = false # Флаг наличия работы с двумя портами var ports_wr: Dictionary # Словарь с портами для записи +var ports_wr_2: Dictionary var port_select: int = Constants.BASE_ADDR # Выбранный порд для чтения/записи +var port_select_2: int = Constants.BASE_ADDR # Выбранный порд для чтения/записи var port: int var address: String var dt: float # Дельта @@ -37,9 +40,10 @@ func _ready(): node_select.set_node_text(2, 0, Constants.DEFAULT_ADDRESS) node_select.set_node_text(3, 0, ' IP-ПОРТ') node_select.set_node_text(4, 0, Constants.DEFAULT_PORT) - node_select.set_node_text(0, 1, ' ПОРТ ЯЧЕЙКИ (hex)') + node_select.set_node_text(0, 1, ' 1 ПОРТ ЯЧЕЙКИ (hex)') node_select.set_node_text(1, 2, ' ИНТЕРВАЛ') - + node_select.set_node_text(0, 3, ' 2 ПОРТ ЯЧЕЙКИ (hex)') + # Поле для ввода (запись IP-адреса) var edit_ip = node_select.get_node2(2, 0) edit_ip.editable = true @@ -52,10 +56,19 @@ func _ready(): var edit_node = node_select.get_node2(2, 1) edit_node.editable = true edit_node.placeholder_text = 'Ввод значения' - edit_node.connect('text_submitted', Callable(self, '_on_written_text_submitted')) + edit_node.connect('text_submitted', Callable(self, '_on_written_port')) + + # Поле для ввода (запись в порт_2) + var edit_node_2 = node_select.get_node2(2, 3) + edit_node_2.editable = true + edit_node_2.placeholder_text = 'Ввод значения' + edit_node_2.connect('text_submitted', Callable(self, '_on_written_port_2')) + $read_ISA.disabled = true $write_ISA.disabled = true + $read_ISA2.disabled = true + $write_ISA2.disabled = true # Поле для ввода (базовый порт) var edit_addr = node_select.get_node2(0, 2) @@ -63,6 +76,14 @@ func _ready(): edit_addr.text = '%x' % port_select edit_addr.connect('text_submitted', Callable(self, '_on_written_addres')) + + # Поле для ввода 2 (базовый порт №2) + var edit_addr_2 = node_select.get_node2(0, 4) + edit_addr_2.editable = true + edit_addr_2.placeholder_text = 'Ввод -> Enter' + edit_addr_2.connect('text_submitted', Callable(self, '_on_written_addres_2')) + + # Поле для ввода (интервал непрерывной записи) var edit_interval = node_select.get_node2(2, 2) edit_interval.editable = true @@ -70,6 +91,11 @@ func _ready(): edit_interval.connect('text_submitted', Callable(self, '_on_written_interval')) var node_select2 = $scroll2/table2 + draw_tabl(node_select2, Constants.ROWS_BLOCK_DATA, Constants.ROWS_BLOCK_DATA.size()) + node_select2.set_columns_min_size([250, 160, 150, 190, 150]) + node_select2.set_node_text(0, 0, ' ЧТЕНИЕ ИСА БЛОКА') + node_select2.set_node_text(1, 0, ' ПОРТ БЛОКА') + node_select2.set_node_text(3, 0, ' ДЛИНА СЛОВ') # Привязка для принятия широковещательного канала soc_brodcast = Socket.new() @@ -128,6 +154,22 @@ func _process(delta) -> void: if flag_online and not flag_interval: state_machine() + var port_txt = node_select.get_node2(0, 1) + if port_select != node_select.get_node2(0, 2).get_text().hex_to_int(): + port_txt.text = ' 1 ПОРТ ЯЧЕЙКИ (hex)*' + port_txt.modulate = Color.GREEN + else: + port_txt.text = ' 1 ПОРТ ЯЧЕЙКИ (hex)' + port_txt.modulate = Color.WHITE + if flag_two_ports: + var port_txt_2 = node_select.get_node2(0, 3) + if port_select_2 != node_select.get_node2(0, 4).get_text().hex_to_int(): + port_txt_2.text = ' 2 ПОРТ ЯЧЕЙКИ (hex)*' + port_txt_2.modulate = Color.GREEN + else: + port_txt_2.text = ' 2 ПОРТ ЯЧЕЙКИ (hex)' + port_txt_2.modulate = Color.WHITE + match unit.process(delta): Error.OK: soc_unicast.send_to(address, port, unit.tx_data.slice(0, unit.tx_len)) Error.FAILED: print('Ошибка отправки данных') @@ -164,6 +206,7 @@ func on_line_changed(_unit) -> void: ## Ессли отсутствует подключение к ячейке ЯУ-07 func on_command_fail(_unit) -> void: $Turn_on.button_pressed = false + unit.cmd_state = unit.CmdState.UNCK ## Индикация чтения портов @@ -180,8 +223,21 @@ func on_command_done(_unit) -> void: func state_machine() -> void: - var fl_done = (unit.cmd_state == unit.CmdState.DONE) or (unit.cmd_state == unit.CmdState.FAIL) + var fl_done = (unit.cmd_state == unit.CmdState.DONE) if state == Constants.STATE.WAIT and fl_done: + + if flag_two_ports: + $write_ISA2.disabled = false + $read_ISA2.disabled = false + node_select.set_node_text(3, 3, ' ПРОЧИТАНО ИЗ %x' % port_select_2) + node_select.set_node_text(1, 3, ' ЗАПИСАТЬ В %x' % port_select_2) + var line_board_control_2 = node_select.get_node2(0, 3) + var nubre_from_port_2 = 'ffff' + if unit.isa_ports.has(port_select_2): + nubre_from_port_2 = '%x' % unit.isa_ports[port_select_2] + line_board_control_2.modulate = Constants.RED if nubre_from_port_2 == 'ffff' else Constants.GREEN + node_select.set_node_text(4, 3, nubre_from_port_2) + $write_ISA.disabled = false $read_ISA.disabled = false node_select.set_node_text(3, 1, ' ПРОЧИТАНО ИЗ %x' % port_select) @@ -201,10 +257,16 @@ func state_machine() -> void: else: state = Constants.STATE.WAIT elif state == Constants.STATE.READ and fl_done: ## Чтение из ИСА - unit.send_isa(unit.CmdCode.READ_ISA, [port_select]) + if flag_two_ports: + unit.send_isa(unit.CmdCode.READ_ISA, [port_select, port_select_2]) + else: + unit.send_isa(unit.CmdCode.READ_ISA, [port_select]) state = Constants.STATE.WAIT elif state == Constants.STATE.WRITE and fl_done: ## Запись в ИСА - unit.send_isa(unit.CmdCode.WRITE_ISA, [port_select, ports_wr[port_select]]) + if flag_two_ports: + unit.send_isa(unit.CmdCode.WRITE_ISA, [port_select, ports_wr[port_select], port_select_2, ports_wr_2[port_select_2]]) + else: + unit.send_isa(unit.CmdCode.WRITE_ISA, [port_select, ports_wr[port_select]]) state = Constants.STATE.WAIT @@ -216,8 +278,17 @@ func _on_written_addres(write_addres) -> void: node_select.set_node_text(0, 2, '%x' % port_select) +## Выставить адресс для записи №2 +func _on_written_addres_2(write_addres_2) -> void: + flag_two_ports = true + port_select_2 = write_addres_2.hex_to_int() + if ports_wr_2.has(port_select_2) != true: + ports_wr_2[port_select_2] = 0 + node_select.set_node_text(0, 4, '%x' % port_select_2) + + ## Запись числа порт -func _on_written_text_submitted(write_addres_data) -> void: +func _on_written_port(write_addres_data) -> void: var is_hex = true for chr in write_addres_data: if chr.to_upper() < '0' or chr.to_upper() > 'F': @@ -228,6 +299,18 @@ func _on_written_text_submitted(write_addres_data) -> void: flag_write_isa = true # Запись +## Запись числа порт №2 +func _on_written_port_2(write_addres_data_2): + var is_hex = true + for chr in write_addres_data_2: + if chr.to_upper() < '0' or chr.to_upper() > 'F': + is_hex = false + break + ports_wr_2[port_select_2] = write_addres_data_2.hex_to_int() if is_hex else 0xffff + flag_read_isa = true + flag_write_isa = true # Запись + + func _on_written_interval(write_interval) -> void: timer.start(float(write_interval)) flag_interval = true @@ -255,9 +338,20 @@ func _on_button_read() -> void: flag_read_isa = true +func _on_button_read_2() -> void: + port_select_2 = node_select.get_node2(0, 4).text.hex_to_int() + flag_read_isa = true + + func _on_button_write() -> void: port_select = node_select.get_node2(0, 2).text.hex_to_int() - _on_written_text_submitted(node_select.get_node2(2, 1).text) + _on_written_port(node_select.get_node2(2, 1).text) + flag_write_isa = true + + +func _on_button_write_2() -> void: + port_select_2 = node_select.get_node2(0, 4).text.hex_to_int() + _on_written_port_2(node_select.get_node2(2, 3).text) flag_write_isa = true diff --git a/Pla56EE.tmp b/Pla56EE.tmp new file mode 100644 index 0000000..b430bea --- /dev/null +++ b/Pla56EE.tmp @@ -0,0 +1,92 @@ +[gd_scene load_steps=5 format=3 uid="uid://ccp4ypftnrbwq"] + +[ext_resource type="Script" path="res://Main.gd" id="1_8v2wa"] +[ext_resource type="Script" path="res://table/table.gd" id="2_ri1qb"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jbuuq"] +bg_color = Color(0.0901961, 0.52549, 0.0588235, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_so1no"] +bg_color = Color(0, 0, 0, 1) + +[node name="Node2D" type="Node2D"] +script = ExtResource("1_8v2wa") + +[node name="Background" type="ColorRect" parent="."] +offset_right = 2916.0 +offset_bottom = 1542.0 +color = Color(0.313726, 0.227451, 0.290196, 1) +metadata/_edit_lock_ = true + +[node name="scroll1" type="ScrollContainer" parent="."] +offset_left = 42.0 +offset_top = 72.0 +offset_right = 1135.0 +offset_bottom = 265.0 +metadata/_edit_lock_ = true + +[node name="table1" type="GridContainer" parent="scroll1"] +layout_mode = 2 +script = ExtResource("2_ri1qb") +metadata/_edit_lock_ = true + +[node name="scroll2" type="ScrollContainer" parent="."] +offset_left = 40.0 +offset_top = 169.0 +offset_right = 1133.0 +offset_bottom = 261.0 +metadata/_edit_lock_ = true + +[node name="table2" type="GridContainer" parent="scroll2"] +layout_mode = 2 +script = ExtResource("2_ri1qb") + +[node name="Turn_on" type="Button" parent="."] +offset_left = 963.0 +offset_top = 72.0 +offset_right = 1098.0 +offset_bottom = 96.0 +theme_override_font_sizes/font_size = 17 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +toggle_mode = true +text = "ПОДКЛЮЧИТЬ" +metadata/_edit_lock_ = true + +[node name="read_ISA" type="Button" parent="."] +offset_left = 963.0 +offset_top = 100.0 +offset_right = 1098.0 +offset_bottom = 124.0 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +text = "ПРОЧИТАТЬ" +metadata/_edit_lock_ = true + +[node name="write_ISA" type="Button" parent="."] +offset_left = 963.0 +offset_top = 129.0 +offset_right = 1098.0 +offset_bottom = 153.0 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +text = "ЗАПИСАТЬ" +metadata/_edit_lock_ = true + +[node name="BROADCAST" type="Label" parent="."] +offset_left = 45.0 +offset_top = 274.0 +offset_right = 998.0 +offset_bottom = 297.0 +metadata/_edit_lock_ = true + +[node name="ISA" type="Label" parent="."] +offset_left = 45.0 +offset_top = 243.0 +offset_right = 998.0 +offset_bottom = 266.0 +metadata/_edit_lock_ = true + +[connection signal="toggled" from="Turn_on" to="." method="_on_button_pressed"] +[connection signal="pressed" from="read_ISA" to="." method="_on_button_read"] +[connection signal="pressed" from="write_ISA" to="." method="_on_button_write"] diff --git a/Pla63AD.tmp b/Pla63AD.tmp new file mode 100644 index 0000000..b430bea --- /dev/null +++ b/Pla63AD.tmp @@ -0,0 +1,92 @@ +[gd_scene load_steps=5 format=3 uid="uid://ccp4ypftnrbwq"] + +[ext_resource type="Script" path="res://Main.gd" id="1_8v2wa"] +[ext_resource type="Script" path="res://table/table.gd" id="2_ri1qb"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jbuuq"] +bg_color = Color(0.0901961, 0.52549, 0.0588235, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_so1no"] +bg_color = Color(0, 0, 0, 1) + +[node name="Node2D" type="Node2D"] +script = ExtResource("1_8v2wa") + +[node name="Background" type="ColorRect" parent="."] +offset_right = 2916.0 +offset_bottom = 1542.0 +color = Color(0.313726, 0.227451, 0.290196, 1) +metadata/_edit_lock_ = true + +[node name="scroll1" type="ScrollContainer" parent="."] +offset_left = 42.0 +offset_top = 72.0 +offset_right = 1135.0 +offset_bottom = 265.0 +metadata/_edit_lock_ = true + +[node name="table1" type="GridContainer" parent="scroll1"] +layout_mode = 2 +script = ExtResource("2_ri1qb") +metadata/_edit_lock_ = true + +[node name="scroll2" type="ScrollContainer" parent="."] +offset_left = 40.0 +offset_top = 169.0 +offset_right = 1133.0 +offset_bottom = 261.0 +metadata/_edit_lock_ = true + +[node name="table2" type="GridContainer" parent="scroll2"] +layout_mode = 2 +script = ExtResource("2_ri1qb") + +[node name="Turn_on" type="Button" parent="."] +offset_left = 963.0 +offset_top = 72.0 +offset_right = 1098.0 +offset_bottom = 96.0 +theme_override_font_sizes/font_size = 17 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +toggle_mode = true +text = "ПОДКЛЮЧИТЬ" +metadata/_edit_lock_ = true + +[node name="read_ISA" type="Button" parent="."] +offset_left = 963.0 +offset_top = 100.0 +offset_right = 1098.0 +offset_bottom = 124.0 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +text = "ПРОЧИТАТЬ" +metadata/_edit_lock_ = true + +[node name="write_ISA" type="Button" parent="."] +offset_left = 963.0 +offset_top = 129.0 +offset_right = 1098.0 +offset_bottom = 153.0 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +text = "ЗАПИСАТЬ" +metadata/_edit_lock_ = true + +[node name="BROADCAST" type="Label" parent="."] +offset_left = 45.0 +offset_top = 274.0 +offset_right = 998.0 +offset_bottom = 297.0 +metadata/_edit_lock_ = true + +[node name="ISA" type="Label" parent="."] +offset_left = 45.0 +offset_top = 243.0 +offset_right = 998.0 +offset_bottom = 266.0 +metadata/_edit_lock_ = true + +[connection signal="toggled" from="Turn_on" to="." method="_on_button_pressed"] +[connection signal="pressed" from="read_ISA" to="." method="_on_button_read"] +[connection signal="pressed" from="write_ISA" to="." method="_on_button_write"] diff --git a/Plata-check.tscn b/Plata-check.tscn index 8ceec7f..0a8f179 100644 --- a/Plata-check.tscn +++ b/Plata-check.tscn @@ -3,12 +3,12 @@ [ext_resource type="Script" path="res://Main.gd" id="1_8v2wa"] [ext_resource type="Script" path="res://table/table.gd" id="2_ri1qb"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_so1no"] -bg_color = Color(0, 0, 0, 1) - [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jbuuq"] bg_color = Color(0.0901961, 0.52549, 0.0588235, 1) +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_so1no"] +bg_color = Color(0, 0, 0, 1) + [node name="Node2D" type="Node2D"] script = ExtResource("1_8v2wa") @@ -31,10 +31,11 @@ script = ExtResource("2_ri1qb") metadata/_edit_lock_ = true [node name="scroll2" type="ScrollContainer" parent="."] -offset_left = 34.0 -offset_top = 169.0 -offset_right = 1127.0 -offset_bottom = 232.0 +offset_left = 40.0 +offset_top = 225.0 +offset_right = 1133.0 +offset_bottom = 317.0 +metadata/_edit_lock_ = true [node name="table2" type="GridContainer" parent="scroll2"] layout_mode = 2 @@ -46,46 +47,69 @@ offset_top = 72.0 offset_right = 1098.0 offset_bottom = 96.0 theme_override_font_sizes/font_size = 17 -theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") toggle_mode = true text = "ПОДКЛЮЧИТЬ" metadata/_edit_lock_ = true [node name="read_ISA" type="Button" parent="."] offset_left = 963.0 -offset_top = 100.0 +offset_top = 99.0 offset_right = 1098.0 -offset_bottom = 124.0 -theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +offset_bottom = 123.0 theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") text = "ПРОЧИТАТЬ" metadata/_edit_lock_ = true [node name="write_ISA" type="Button" parent="."] offset_left = 963.0 -offset_top = 129.0 +offset_top = 128.0 offset_right = 1098.0 -offset_bottom = 153.0 -theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +offset_bottom = 152.0 theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") text = "ЗАПИСАТЬ" metadata/_edit_lock_ = true +[node name="read_ISA2" type="Button" parent="."] +offset_left = 963.0 +offset_top = 155.0 +offset_right = 1098.0 +offset_bottom = 179.0 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +text = "ПРОЧИТАТЬ 2" +metadata/_edit_lock_ = true + +[node name="write_ISA2" type="Button" parent="."] +offset_left = 963.0 +offset_top = 184.0 +offset_right = 1098.0 +offset_bottom = 208.0 +theme_override_styles/pressed = SubResource("StyleBoxFlat_jbuuq") +theme_override_styles/normal = SubResource("StyleBoxFlat_so1no") +text = "ЗАПИСАТЬ 2" +metadata/_edit_lock_ = true + [node name="BROADCAST" type="Label" parent="."] offset_left = 45.0 -offset_top = 218.0 +offset_top = 290.0 offset_right = 998.0 -offset_bottom = 241.0 +offset_bottom = 313.0 +autowrap_mode = 2 metadata/_edit_lock_ = true [node name="ISA" type="Label" parent="."] offset_left = 45.0 -offset_top = 187.0 +offset_top = 259.0 offset_right = 998.0 -offset_bottom = 210.0 +offset_bottom = 282.0 metadata/_edit_lock_ = true [connection signal="toggled" from="Turn_on" to="." method="_on_button_pressed"] [connection signal="pressed" from="read_ISA" to="." method="_on_button_read"] [connection signal="pressed" from="write_ISA" to="." method="_on_button_write"] +[connection signal="pressed" from="read_ISA2" to="." method="_on_button_read_2"] +[connection signal="pressed" from="write_ISA2" to="." method="_on_button_write_2"] diff --git a/constants.gd b/constants.gd index 3bc8dd9..bed1e5f 100644 --- a/constants.gd +++ b/constants.gd @@ -12,6 +12,10 @@ var BASE_ADDR: int = int(file.get_line()) if file else 0x100 const ROWS_REGS_DATA: Array = [ [TableNode, TableNode, TableNode, TableNode, TableNode], [TableNode, TableNode, TableNode, TableNode, TableNode], + [TableNode, TableNode, TableNode, TableNode, TableNode], + [TableNode, TableNode, TableNode, TableNode, TableNode], + [TableNode, TableNode, TableNode, TableNode, TableNode]] +const ROWS_BLOCK_DATA: Array = [ [TableNode, TableNode, TableNode, TableNode, TableNode]] enum STATE { WAIT, # Режим ожидания команды diff --git a/project.godot b/project.godot index 8a09ea5..151b7e7 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="Plata-check.exe" run/main_scene="res://Plata-check.tscn" -config/features=PackedStringArray("4.2", "GL Compatibility") +config/features=PackedStringArray("4.3", "GL Compatibility") config/icon="res://icon.svg" [autoload]