dev: добавил user friendly названия параметров настроек

This commit is contained in:
Andrew 2024-12-24 17:24:54 +03:00
parent fdec6e8f6e
commit bd3ca92171
2 changed files with 50 additions and 3 deletions

View File

@ -10,7 +10,7 @@ from utils.json_tools import read_json, write_json
from utils import qt_settings as qts from utils import qt_settings as qts
class settingsWindow(QWidget): class settingsWindow(QWidget):
def __init__(self, path: str, name: str, upd_func: Callable[[], None]): def __init__(self, path: str, name: str, upd_func: Callable[[], None], names: dict):
""" """
Окно настроек для редактирования параметров. Окно настроек для редактирования параметров.
:param path: Путь к файлу настроек (JSON). :param path: Путь к файлу настроек (JSON).
@ -25,6 +25,7 @@ class settingsWindow(QWidget):
self._num_points: Optional[QLineEdit] = None self._num_points: Optional[QLineEdit] = None
self._param_table: Optional[QTableWidget] = None self._param_table: Optional[QTableWidget] = None
self._assosiated_names = names
self.load_settings() self.load_settings()
self._init_ui() self._init_ui()
@ -92,7 +93,8 @@ class settingsWindow(QWidget):
column_count = len(self._data[first_key]) column_count = len(self._data[first_key])
self._param_table.setRowCount(len(self._data)) self._param_table.setRowCount(len(self._data))
self._param_table.setColumnCount(column_count) self._param_table.setColumnCount(column_count)
self._param_table.setVerticalHeaderLabels(self._data.keys()) headers = [self._assosiated_names[key] for key in self._data.keys()]
self._param_table.setVerticalHeaderLabels(headers)
int_delegate = ValidatorDelegate(data_type='int', parent=self._param_table) int_delegate = ValidatorDelegate(data_type='int', parent=self._param_table)
float_delegate = ValidatorDelegate(data_type='float', parent=self._param_table) float_delegate = ValidatorDelegate(data_type='float', parent=self._param_table)
@ -180,13 +182,58 @@ class settingsWindow(QWidget):
class SystemSettings(settingsWindow): class SystemSettings(settingsWindow):
def __init__(self, path, name, upd_func): def __init__(self, path, name, upd_func):
super().__init__(path, name, upd_func) assosiated_names = {
"trace_storage_path": "trace path",
"monitor_update_period": "Monitoring period",
"a_max_1": "Max lin accel FE, m/s^2",
"v_max_1": "Max lin speed FE, m/s",
"a_max_2":"Max lin accel ME, m/s^2",
"v_max_2": "Max lin speed FE, m/s",
"mass_1": "Mass FE, kg",
"mass_2": "Mass ME, kg",
"k_hardness_1": "Hardness coef FE, N/m",
"k_hardness_2": "Hardness coef ME, N/m",
"torque_max_1": "Max torque FE, N*m",
"torque_max_2": "Max torque ME, N*m",
"transmission_ratio_1": "Transmission ratio FE",
"transmission_ratio_2": "Transmission ratio ME",
"contact_distance_1": "Contact distance FE, m",
"contact_distance_2": "Contact distance ME, m",
"k_prop": "Proportionality factor",
"time_capture": "Calculated points per sec",
"UML_time_scaler": "UML_time_scaler",
"Range ME, mm": "Range ME, mm"
}
super().__init__(path, name, upd_func, assosiated_names)
self._num_points.setVisible(False) self._num_points.setVisible(False)
def _expand(self): def _expand(self):
pass pass
class OperatorSettings(settingsWindow): class OperatorSettings(settingsWindow):
def __init__(self, path, name, upd_func):
assosiated_names = {
"distance_h_start_1": "Closing start dist FE, m" ,
"distance_h_start_2": "Closing start dist ME, m",
"distance_s_1": "Rob movement start dist FE, m",
"distance_s_2": "Rob movement start dist ME, m",
"distance_l_1": "Max oncoming dist FE, m",
"distance_l_2": "Max oncoming dist ME, m",
"distance_h_end1": "Oncoming end dist FE, m",
"distance_h_end2": "Oncoming end dist FE, m",
"time_wielding": "Time of welding, sec",
"time_command": "Communication time compensator, sec",
"time_robot_movement": "Rob movement time, sec",
"object_thickness": "Workpiece thickness, m",
"force_target": "Target force, N",
"force_capture": "Capture force, N",
"Tesla closing": "Client closing time, sec",
"Tesla squeeze": "Client squeeze time, sec",
"Tesla welding": "Client welding time, sec",
"Tesla oncomming_relief": "Client moving to next point time, sec",
"Tesla summary time": "Client summary time, sec"
}
super().__init__(path, name, upd_func, assosiated_names)
pass pass