+ блокировка добавления структур и юнионов в переменные
+ запись return iq type в debug_vars.c + переход на русский в gui
This commit is contained in:
parent
07e42c774a
commit
c44216a450
BIN
DebugVarEdit.exe
BIN
DebugVarEdit.exe
Binary file not shown.
@ -26,6 +26,16 @@ from PySide2.QtGui import QTextCursor, QKeyEvent, QIcon
|
|||||||
from PySide2.QtCore import Qt, QProcess, QObject, Signal, QSettings
|
from PySide2.QtCore import Qt, QProcess, QObject, Signal, QSettings
|
||||||
|
|
||||||
|
|
||||||
|
var_edit_title = "Редактор переменных для отладки"
|
||||||
|
xml_path_title = "Путь к XML:"
|
||||||
|
proj_path_title = "Путь к проекту:"
|
||||||
|
makefile_path_title = "Пусть к makefile (относительно проекта)"
|
||||||
|
output_path_title = "Папка для debug_vars.c:"
|
||||||
|
scan_title = "Обновить переменные"
|
||||||
|
build_title = "Обновить файл"
|
||||||
|
add_vars_title = "Добавить переменные"
|
||||||
|
open_output_title = "Открыть файл"
|
||||||
|
|
||||||
# 3. UI: таблица с переменными
|
# 3. UI: таблица с переменными
|
||||||
class VarEditor(QWidget):
|
class VarEditor(QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -44,7 +54,7 @@ class VarEditor(QWidget):
|
|||||||
self.initUI()
|
self.initUI()
|
||||||
|
|
||||||
def initUI(self):
|
def initUI(self):
|
||||||
self.setWindowTitle("Variable Editor")
|
self.setWindowTitle(var_edit_title)
|
||||||
|
|
||||||
base_path = scanVars.get_base_path()
|
base_path = scanVars.get_base_path()
|
||||||
icon_path = os.path.join(base_path, "icon.ico")
|
icon_path = os.path.join(base_path, "icon.ico")
|
||||||
@ -56,7 +66,7 @@ class VarEditor(QWidget):
|
|||||||
|
|
||||||
# XML Output
|
# XML Output
|
||||||
xml_layout = QHBoxLayout()
|
xml_layout = QHBoxLayout()
|
||||||
xml_layout.addWidget(QLabel("XML Output:"))
|
xml_layout.addWidget(QLabel(xml_path_title))
|
||||||
self.xml_output_edit = QLineEdit()
|
self.xml_output_edit = QLineEdit()
|
||||||
self.xml_output_edit.returnPressed.connect(self.update)
|
self.xml_output_edit.returnPressed.connect(self.update)
|
||||||
self.xml_output_edit.textChanged.connect(self.__on_xml_path_changed)
|
self.xml_output_edit.textChanged.connect(self.__on_xml_path_changed)
|
||||||
@ -68,7 +78,7 @@ class VarEditor(QWidget):
|
|||||||
|
|
||||||
# Project Path
|
# Project Path
|
||||||
proj_layout = QHBoxLayout()
|
proj_layout = QHBoxLayout()
|
||||||
proj_layout.addWidget(QLabel("Project Path:"))
|
proj_layout.addWidget(QLabel(proj_path_title))
|
||||||
self.proj_path_edit = QLineEdit()
|
self.proj_path_edit = QLineEdit()
|
||||||
self.proj_path_edit.returnPressed.connect(self.update)
|
self.proj_path_edit.returnPressed.connect(self.update)
|
||||||
self.proj_path_edit.textChanged.connect(self.__on_proj_path_changed)
|
self.proj_path_edit.textChanged.connect(self.__on_proj_path_changed)
|
||||||
@ -80,7 +90,7 @@ class VarEditor(QWidget):
|
|||||||
|
|
||||||
# Makefile Path
|
# Makefile Path
|
||||||
makefile_layout = QHBoxLayout()
|
makefile_layout = QHBoxLayout()
|
||||||
makefile_layout.addWidget(QLabel("Makefile Path (relative path):"))
|
makefile_layout.addWidget(QLabel(makefile_path_title))
|
||||||
self.makefile_edit = QLineEdit()
|
self.makefile_edit = QLineEdit()
|
||||||
self.makefile_edit.returnPressed.connect(self.update)
|
self.makefile_edit.returnPressed.connect(self.update)
|
||||||
self.makefile_edit.textChanged.connect(self.__on_makefile_path_changed)
|
self.makefile_edit.textChanged.connect(self.__on_makefile_path_changed)
|
||||||
@ -94,7 +104,7 @@ class VarEditor(QWidget):
|
|||||||
|
|
||||||
# Source Output File/Directory
|
# Source Output File/Directory
|
||||||
source_output_layout = QHBoxLayout()
|
source_output_layout = QHBoxLayout()
|
||||||
source_output_layout.addWidget(QLabel("Source Output File:"))
|
source_output_layout.addWidget(QLabel(output_path_title))
|
||||||
self.source_output_edit = QLineEdit()
|
self.source_output_edit = QLineEdit()
|
||||||
source_output_layout.addWidget(self.source_output_edit)
|
source_output_layout.addWidget(self.source_output_edit)
|
||||||
btn_source_output_browse = QPushButton("...")
|
btn_source_output_browse = QPushButton("...")
|
||||||
@ -103,19 +113,19 @@ class VarEditor(QWidget):
|
|||||||
btn_source_output_browse.clicked.connect(self.__browse_source_output)
|
btn_source_output_browse.clicked.connect(self.__browse_source_output)
|
||||||
|
|
||||||
|
|
||||||
self.btn_update_vars = QPushButton("Обновить данные о переменных")
|
self.btn_update_vars = QPushButton(scan_title)
|
||||||
self.btn_update_vars.clicked.connect(self.update_vars_data)
|
self.btn_update_vars.clicked.connect(self.update_vars_data)
|
||||||
|
|
||||||
# Кнопка сохранения
|
# Кнопка сохранения
|
||||||
btn_save = QPushButton("Build")
|
btn_save = QPushButton(build_title)
|
||||||
btn_save.clicked.connect(self.save_build)
|
btn_save.clicked.connect(self.save_build)
|
||||||
|
|
||||||
# Кнопка добавления переменных
|
# Кнопка добавления переменных
|
||||||
self.btn_add_vars = QPushButton("Add Variables")
|
self.btn_add_vars = QPushButton(add_vars_title)
|
||||||
self.btn_add_vars.clicked.connect(self.__open_variable_selector)
|
self.btn_add_vars.clicked.connect(self.__open_variable_selector)
|
||||||
|
|
||||||
# Кнопка открыть output-файл с выбором программы
|
# Кнопка открыть output-файл с выбором программы
|
||||||
btn_open_output = QPushButton("Открыть Output File...")
|
btn_open_output = QPushButton(open_output_title)
|
||||||
btn_open_output.clicked.connect(self.__open_output_file_with_program)
|
btn_open_output.clicked.connect(self.__open_output_file_with_program)
|
||||||
# Таблица
|
# Таблица
|
||||||
self.table = VariableTableWidget()
|
self.table = VariableTableWidget()
|
||||||
|
@ -329,6 +329,7 @@ class VariableSelectorDialog(QDialog):
|
|||||||
for i in range(node.childCount()):
|
for i in range(node.childCount()):
|
||||||
stack.append(node.child(i))
|
stack.append(node.child(i))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def insert_completion(self, text):
|
def insert_completion(self, text):
|
||||||
|
|
||||||
node = self.find_node_by_fullname(text)
|
node = self.find_node_by_fullname(text)
|
||||||
@ -371,7 +372,6 @@ class VariableSelectorDialog(QDialog):
|
|||||||
self.filter_tree()
|
self.filter_tree()
|
||||||
|
|
||||||
def on_add_clicked(self):
|
def on_add_clicked(self):
|
||||||
print("on_add_clicked triggered")
|
|
||||||
self.selected_names = []
|
self.selected_names = []
|
||||||
self.tree.setFocus()
|
self.tree.setFocus()
|
||||||
|
|
||||||
@ -414,12 +414,10 @@ class VariableSelectorDialog(QDialog):
|
|||||||
self.all_vars.append(new_var)
|
self.all_vars.append(new_var)
|
||||||
self.var_map[name] = new_var # Чтобы в будущем не добавлялось повторно
|
self.var_map[name] = new_var # Чтобы в будущем не добавлялось повторно
|
||||||
|
|
||||||
print("accept")
|
|
||||||
self.done(QDialog.Accepted)
|
self.done(QDialog.Accepted)
|
||||||
|
|
||||||
|
|
||||||
def on_delete_clicked(self):
|
def on_delete_clicked(self):
|
||||||
print("on_delete_clicked triggered")
|
|
||||||
selected_names = self._get_selected_var_names()
|
selected_names = self._get_selected_var_names()
|
||||||
if not selected_names:
|
if not selected_names:
|
||||||
print("nothing selected")
|
print("nothing selected")
|
||||||
@ -468,7 +466,6 @@ class VariableSelectorDialog(QDialog):
|
|||||||
ET.ElementTree(root).write(self.xml_path, encoding="utf-8", xml_declaration=True)
|
ET.ElementTree(root).write(self.xml_path, encoding="utf-8", xml_declaration=True)
|
||||||
|
|
||||||
self.populate_tree()
|
self.populate_tree()
|
||||||
print("accept")
|
|
||||||
self.done(QDialog.Accepted)
|
self.done(QDialog.Accepted)
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,11 +67,22 @@ class VariableTableWidget(QTableWidget):
|
|||||||
self.type_options = list(dict.fromkeys(type_map.values()))
|
self.type_options = list(dict.fromkeys(type_map.values()))
|
||||||
self.display_type_options = [t.replace('pt_', '') for t in self.type_options]
|
self.display_type_options = [t.replace('pt_', '') for t in self.type_options]
|
||||||
iq_types = ['iq_none', 'iq'] + [f'iq{i}' for i in range(1, 31)]
|
iq_types = ['iq_none', 'iq'] + [f'iq{i}' for i in range(1, 31)]
|
||||||
|
|
||||||
|
# --- ДО: удаляем отображение структур и union-переменных
|
||||||
|
for var in vars_list:
|
||||||
|
pt_type = var.get('pt_type', '')
|
||||||
|
if 'struct' in pt_type or 'union' in pt_type:
|
||||||
|
var['show_var'] = 'false'
|
||||||
|
var['enable'] = 'false'
|
||||||
|
|
||||||
|
|
||||||
filtered_vars = [v for v in vars_list if v.get('show_var', 'false') == 'true']
|
filtered_vars = [v for v in vars_list if v.get('show_var', 'false') == 'true']
|
||||||
self.setRowCount(len(filtered_vars))
|
self.setRowCount(len(filtered_vars))
|
||||||
self.verticalHeader().setVisible(False)
|
self.verticalHeader().setVisible(False)
|
||||||
style_with_padding = "padding-left: 5px; padding-right: 5px; font-size: 14pt;" # регулируй отступы по горизонтали
|
style_with_padding = "padding-left: 5px; padding-right: 5px; font-size: 14pt;" # регулируй отступы по горизонтали
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for row, var in enumerate(filtered_vars):
|
for row, var in enumerate(filtered_vars):
|
||||||
# №
|
# №
|
||||||
no_item = QTableWidgetItem(str(row))
|
no_item = QTableWidgetItem(str(row))
|
||||||
@ -190,8 +201,8 @@ class VariableTableWidget(QTableWidget):
|
|||||||
'enable': cb.isChecked(),
|
'enable': cb.isChecked(),
|
||||||
'name': name,
|
'name': name,
|
||||||
'pt_type': f'pt_{pt}',
|
'pt_type': f'pt_{pt}',
|
||||||
'iq_type': iq,
|
'iq_type': f't_{iq}',
|
||||||
'return_type': ret,
|
'return_type': f't_{ret}',
|
||||||
'shortname': shortname,
|
'shortname': shortname,
|
||||||
'type': origin_type,
|
'type': origin_type,
|
||||||
})
|
})
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -331,17 +331,25 @@ def generate_vars_file(proj_path, xml_path, output_dir):
|
|||||||
if not pt_type:
|
if not pt_type:
|
||||||
pt_type = map_type_to_pt(vtype, vname)
|
pt_type = map_type_to_pt(vtype, vname)
|
||||||
|
|
||||||
|
|
||||||
|
ret_type = info.get('pt_type')
|
||||||
|
if not ret_type:
|
||||||
|
pt_type = 't_iq_none'
|
||||||
|
|
||||||
# Дополнительные поля, например комментарий
|
# Дополнительные поля, например комментарий
|
||||||
comment = info.get("comment", "")
|
comment = info.get("comment", "")
|
||||||
short_name = info.get("shortname", f'"{vname}"')
|
short_name = info.get("shortname", f'"{vname}"')
|
||||||
short_trimmed = short_name[:10] # ограничиваем длину до 10
|
short_trimmed = short_name[:10] # ограничиваем длину до 10
|
||||||
short_str = f'"{short_trimmed}"' # оборачиваем в кавычки
|
|
||||||
|
|
||||||
if pt_type not in ('pt_struct', 'pt_union'):
|
if pt_type not in ('pt_struct', 'pt_union'):
|
||||||
formated_name = f'"{vname}"'
|
f_name = f'{vname},'
|
||||||
|
f_type = f'{pt_type},'
|
||||||
|
f_iq = f'{iq_type},'
|
||||||
|
f_ret_iq = f'{ret_type},'
|
||||||
|
f_short_name = f'"{short_trimmed}"' # оборачиваем в кавычки
|
||||||
# Добавим комментарий после записи, если он есть
|
# Добавим комментарий после записи, если он есть
|
||||||
comment_str = f' // {comment}' if comment else ''
|
comment_str = f' // {comment}' if comment else ''
|
||||||
line = f'{{(char *)&{vname:<41} , {pt_type:<21} , {iq_type:<21} , {short_str:<20}}}, \\{comment_str}'
|
line = f'{{(char *)&{f_name:<45} {f_type:<15} {f_iq:<15} {f_ret_iq:<15} {f_short_name:<21}}}, \\{comment_str}'
|
||||||
new_debug_vars[vname] = line
|
new_debug_vars[vname] = line
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -216,7 +216,7 @@ def analyze_variables_across_files(c_files, h_files, include_dirs):
|
|||||||
return vars_in_file
|
return vars_in_file
|
||||||
|
|
||||||
optional_printf(PRINT_STATUS, "Parsing header files (.h)...")
|
optional_printf(PRINT_STATUS, "Parsing header files (.h)...")
|
||||||
optional_printf(PRINT_STATUS, 'Progress: "Parsing variables from headers"')
|
optional_printf(PRINT_STATUS, 'Progress: "Parsing variables from headers..."')
|
||||||
total_h = len(h_files)
|
total_h = len(h_files)
|
||||||
for i, h in enumerate(h_files, 1):
|
for i, h in enumerate(h_files, 1):
|
||||||
vars_in_h = parse_file(h)
|
vars_in_h = parse_file(h)
|
||||||
@ -232,7 +232,7 @@ def analyze_variables_across_files(c_files, h_files, include_dirs):
|
|||||||
optional_printf(PRINT_STATUS, f"Progress: {i}/{total_h}")
|
optional_printf(PRINT_STATUS, f"Progress: {i}/{total_h}")
|
||||||
|
|
||||||
optional_printf(PRINT_STATUS, "Parsing source files (.c)...")
|
optional_printf(PRINT_STATUS, "Parsing source files (.c)...")
|
||||||
optional_printf(PRINT_STATUS, 'Progress: "Parsing variables from sources files"')
|
optional_printf(PRINT_STATUS, 'Progress: "Parsing variables from sources files..."')
|
||||||
total_c = len(c_files)
|
total_c = len(c_files)
|
||||||
for i, c in enumerate(c_files, 1):
|
for i, c in enumerate(c_files, 1):
|
||||||
vars_in_c = parse_file(c)
|
vars_in_c = parse_file(c)
|
||||||
@ -255,7 +255,7 @@ def analyze_variables_across_files(c_files, h_files, include_dirs):
|
|||||||
optional_printf(PRINT_STATUS, f"Progress: {i}/{total_c}")
|
optional_printf(PRINT_STATUS, f"Progress: {i}/{total_c}")
|
||||||
|
|
||||||
optional_printf(PRINT_STATUS, "Checking which variables need explicit extern declaration...")
|
optional_printf(PRINT_STATUS, "Checking which variables need explicit extern declaration...")
|
||||||
optional_printf(PRINT_STATUS, 'Progress: "Checking extern declarations"')
|
optional_printf(PRINT_STATUS, 'Progress: "Checking extern declarations..."')
|
||||||
total_vars = len(unique_vars)
|
total_vars = len(unique_vars)
|
||||||
for i, (name, info) in enumerate(unique_vars.items(), 1):
|
for i, (name, info) in enumerate(unique_vars.items(), 1):
|
||||||
if not info["extern"] and not info["static"] and info["file"].endswith('.c'):
|
if not info["extern"] and not info["static"] and info["file"].endswith('.c'):
|
||||||
@ -377,7 +377,7 @@ def analyze_typedefs_and_struct(typedefs, structs):
|
|||||||
substituted_structs[resolved_sname] = substituted_fields """
|
substituted_structs[resolved_sname] = substituted_fields """
|
||||||
|
|
||||||
# Раскрываем typedef'ы
|
# Раскрываем typedef'ы
|
||||||
optional_printf(PRINT_STATUS, 'Progress: "Resolving typedefs"')
|
optional_printf(PRINT_STATUS, 'Progress: "Resolving typedefs..."')
|
||||||
total_typedefs = len(typedefs)
|
total_typedefs = len(typedefs)
|
||||||
resolved_typedefs = {}
|
resolved_typedefs = {}
|
||||||
for i, tname in enumerate(typedefs, 1):
|
for i, tname in enumerate(typedefs, 1):
|
||||||
@ -387,7 +387,7 @@ def analyze_typedefs_and_struct(typedefs, structs):
|
|||||||
optional_printf(PRINT_STATUS, f"Progress: {i}/{total_typedefs}")
|
optional_printf(PRINT_STATUS, f"Progress: {i}/{total_typedefs}")
|
||||||
|
|
||||||
# Теперь раскрываем вложенные структуры
|
# Теперь раскрываем вложенные структуры
|
||||||
optional_printf(PRINT_STATUS, 'Progress: "Resolving structs"')
|
optional_printf(PRINT_STATUS, 'Progress: "Resolving structs..."')
|
||||||
total_structs = len(structs)
|
total_structs = len(structs)
|
||||||
resolved_structs = {}
|
resolved_structs = {}
|
||||||
for i, (sname, fields) in enumerate(structs.items(), 1):
|
for i, (sname, fields) in enumerate(structs.items(), 1):
|
||||||
@ -507,7 +507,7 @@ def analyze_typedefs_and_structs_across_files(c_files, include_dirs):
|
|||||||
visit(tu.cursor)
|
visit(tu.cursor)
|
||||||
return typedefs, structs
|
return typedefs, structs
|
||||||
|
|
||||||
optional_printf(PRINT_STATUS, 'Progress: "Resolving structs and typedefs"')
|
optional_printf(PRINT_STATUS, 'Progress: "Resolving structs and typedefs..."')
|
||||||
total_files = len(c_files)
|
total_files = len(c_files)
|
||||||
for i, c_file in enumerate(c_files, 1):
|
for i, c_file in enumerate(c_files, 1):
|
||||||
typedefs_in_file, structs_in_file = parse_file(c_file)
|
typedefs_in_file, structs_in_file = parse_file(c_file)
|
||||||
|
33
debug_vars.c
33
debug_vars.c
@ -4,32 +4,32 @@
|
|||||||
|
|
||||||
// Èíêëþäû äëÿ äîñòóïà ê ïåðåìåííûì
|
// Èíêëþäû äëÿ äîñòóïà ê ïåðåìåííûì
|
||||||
#include "RS_Functions_modbus.h"
|
#include "RS_Functions_modbus.h"
|
||||||
#include "xp_project.h"
|
#include "dq_to_alphabeta_cos.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "v_pwm24.h"
|
#include "v_pwm24.h"
|
||||||
#include "rotation_speed.h"
|
|
||||||
#include "log_can.h"
|
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
#include "adc_tools.h"
|
#include "xp_project.h"
|
||||||
#include "f281xpwm.h"
|
|
||||||
#include "pwm_vector_regul.h"
|
|
||||||
#include "dq_to_alphabeta_cos.h"
|
|
||||||
#include "xp_write_xpwm_time.h"
|
#include "xp_write_xpwm_time.h"
|
||||||
|
#include "pwm_vector_regul.h"
|
||||||
|
#include "log_can.h"
|
||||||
|
#include "f281xpwm.h"
|
||||||
|
#include "adc_tools.h"
|
||||||
|
#include "rotation_speed.h"
|
||||||
#include "teta_calc.h"
|
#include "teta_calc.h"
|
||||||
#include "RS_Functions.h"
|
#include "RS_Functions.h"
|
||||||
#include "x_parallel_bus.h"
|
#include "detect_phase_break2.h"
|
||||||
|
#include "svgen_dq.h"
|
||||||
#include "xp_rotation_sensor.h"
|
#include "xp_rotation_sensor.h"
|
||||||
#include "Spartan2E_Functions.h"
|
#include "Spartan2E_Functions.h"
|
||||||
#include "xPeriphSP6_loader.h"
|
#include "xPeriphSP6_loader.h"
|
||||||
#include "x_serial_bus.h"
|
|
||||||
#include "xp_controller.h"
|
#include "xp_controller.h"
|
||||||
#include "detect_phase_break2.h"
|
#include "x_serial_bus.h"
|
||||||
#include "svgen_dq.h"
|
#include "x_parallel_bus.h"
|
||||||
|
#include "log_params.h"
|
||||||
|
#include "log_to_memory.h"
|
||||||
|
#include "global_time.h"
|
||||||
#include "CRC_Functions.h"
|
#include "CRC_Functions.h"
|
||||||
#include "CAN_Setup.h"
|
#include "CAN_Setup.h"
|
||||||
#include "log_params.h"
|
|
||||||
#include "global_time.h"
|
|
||||||
#include "log_to_memory.h"
|
|
||||||
#include "pid_reg3.h"
|
#include "pid_reg3.h"
|
||||||
#include "IQmathLib.h"
|
#include "IQmathLib.h"
|
||||||
#include "doors_control.h"
|
#include "doors_control.h"
|
||||||
@ -314,8 +314,9 @@ extern int zero_ADC[20];
|
|||||||
|
|
||||||
|
|
||||||
// Îïðåäåëåíèå ìàññèâà ñ óêàçàòåëÿìè íà ïåðåìåííûå äëÿ îòëàäêè
|
// Îïðåäåëåíèå ìàññèâà ñ óêàçàòåëÿìè íà ïåðåìåííûå äëÿ îòëàäêè
|
||||||
int DebugVar_Qnt = 1;
|
int DebugVar_Qnt = 2;
|
||||||
#pragma DATA_SECTION(dbg_vars,".dbgvar_info")
|
#pragma DATA_SECTION(dbg_vars,".dbgvar_info")
|
||||||
DebugVar_t dbg_vars[] = {\
|
DebugVar_t dbg_vars[] = {\
|
||||||
{(char *)&ADC0finishAddr , pt_uint8 , iq12 , Addr }, \
|
{(char *)&ADC0finishAddr, pt_uint8, iq7, pt_uint8, "asdasjjjjj" }, \
|
||||||
|
{(char *)&ADC1finishAddr, pt_int16, iq_none, pt_int16, "ADC1finish" }, \
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user