diff --git a/McuLib/m/mcuPath.m b/McuLib/m/mcuPath.m index 94ba3e9..f9d33cc 100644 --- a/McuLib/m/mcuPath.m +++ b/McuLib/m/mcuPath.m @@ -1,14 +1,14 @@ classdef mcuPath methods(Static) - - + %% GET PATH FROM PARAM function path = get(paramName) blockPath = gcb; path = get_param(blockPath, paramName); end - + %% ADD PATH TO TABLE + function addSourceFileTable(targetParamName, message) % Открываем проводник для выбора файлов [files, pathstr] = uigetfile({ ... @@ -61,6 +61,7 @@ classdef mcuPath customtable.collect(targetParamName, oldTable); end + %% ADD PATH TO EDIT function addPath(targetParamName, message) block = gcb; @@ -91,6 +92,8 @@ classdef mcuPath param.Value = rel; end + %% GET PATH STRING + function absPath = getAbsolutePath(relPath) % relativeToAbsolutePath — преобразует относительный путь в абсолютный. % @@ -115,8 +118,6 @@ classdef mcuPath end end - - function rel = absoluteToRelativePath(pathstr) % absoluteToRelativePath — преобразует абсолютный путь в относительный от текущей директории. % @@ -163,6 +164,5 @@ classdef mcuPath end end - end end \ No newline at end of file diff --git a/McuLib/m/periphConfig.m b/McuLib/m/periphConfig.m index 47decb0..2dfbbe0 100644 --- a/McuLib/m/periphConfig.m +++ b/McuLib/m/periphConfig.m @@ -23,7 +23,6 @@ classdef periphConfig end if ~isempty(config) - if isfield(config, 'Code') res = periphConfig.addCodeConfig(config.Code, periphPath); if res == 0 @@ -52,6 +51,7 @@ classdef periphConfig continue; end + defines = config.(periph).Defines; defNames = fieldnames(defines); @@ -64,7 +64,7 @@ classdef periphConfig def = defines.(defPrompt); % Вызов функции добавления одного параметра - periphConfig.addDefineConfig(mask, containerName, periph, defPrompt, def); + periphConfig.addConfig(mask, containerName, periph, defPrompt, def); end end end @@ -166,7 +166,46 @@ classdef periphConfig fclose(fid); end + function update_callback() + blockPath = gcb; + mask = Simulink.Mask.get(blockPath); + containerName = 'configTabAll'; + container = mask.getDialogControl(containerName); + paramsAll = mcuMask.collect_all_parameters(container); + % Цикл по параметрам + for i = 1:length(paramsAll) + name = paramsAll{i}; + + % Ищем параметры вида Tab__Enable + expr = '^Tab_(\w+)_Enable$'; + tokens = regexp(name, expr, 'tokens'); + if ~isempty(tokens) + periph = tokens{1}{1}; % Извлекаем имя вкладки + paramObj = mask.getParameter(name); + val = paramObj.Value; + + if strcmpi(val, 'off') + % Найдём вкладку по имени + try + tab = container.getDialogControl(periph); + tab.Enabled = 'off'; + catch + warning('Вкладка с именем "%s" не найдена.', periph); + end + else + % Найдём вкладку по имени + try + tab = container.getDialogControl(periph); + tab.Enabled = 'on'; + catch + warning('Вкладка с именем "%s" не найдена.', periph); + end + end + + end + end + end end @@ -250,10 +289,7 @@ classdef periphConfig end end - - - - function addDefineConfig(mask, containerName, periphName, defPrompt, def) + function addConfig(mask, containerName, periphName, defPrompt, def) % mask — объект маски Simulink.Mask.get(blockPath) % containerName — имя контейнера, в который добавляем параметр (например, 'configTabAll') % periphName — имя вкладки / контейнера для текущего периферийного блока (например, 'ADC') @@ -336,10 +372,14 @@ classdef periphConfig param.DialogControl.Row = 'current'; end - if strcmp(paramType, 'popup') - param.TypeOptions = def.Def; + if isfield(def, 'Def') + if strcmp(paramType, 'popup') + param.TypeOptions = def.Def; + else + param.Alias = def.Def; + end else - param.Alias = def.Def; + param.Callback = 'periphConfig.update_callback();'; end end