добавелно включение вкладок по конфигу
This commit is contained in:
parent
edb22966ff
commit
058d3a00cf
@ -1,14 +1,14 @@
|
|||||||
classdef mcuPath
|
classdef mcuPath
|
||||||
methods(Static)
|
methods(Static)
|
||||||
|
|
||||||
|
%% GET PATH FROM PARAM
|
||||||
|
|
||||||
function path = get(paramName)
|
function path = get(paramName)
|
||||||
blockPath = gcb;
|
blockPath = gcb;
|
||||||
path = get_param(blockPath, paramName);
|
path = get_param(blockPath, paramName);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%% ADD PATH TO TABLE
|
||||||
|
|
||||||
function addSourceFileTable(targetParamName, message)
|
function addSourceFileTable(targetParamName, message)
|
||||||
% Открываем проводник для выбора файлов
|
% Открываем проводник для выбора файлов
|
||||||
[files, pathstr] = uigetfile({ ...
|
[files, pathstr] = uigetfile({ ...
|
||||||
@ -61,6 +61,7 @@ classdef mcuPath
|
|||||||
customtable.collect(targetParamName, oldTable);
|
customtable.collect(targetParamName, oldTable);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%% ADD PATH TO EDIT
|
||||||
|
|
||||||
function addPath(targetParamName, message)
|
function addPath(targetParamName, message)
|
||||||
block = gcb;
|
block = gcb;
|
||||||
@ -91,6 +92,8 @@ classdef mcuPath
|
|||||||
param.Value = rel;
|
param.Value = rel;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%% GET PATH STRING
|
||||||
|
|
||||||
function absPath = getAbsolutePath(relPath)
|
function absPath = getAbsolutePath(relPath)
|
||||||
% relativeToAbsolutePath — преобразует относительный путь в абсолютный.
|
% relativeToAbsolutePath — преобразует относительный путь в абсолютный.
|
||||||
%
|
%
|
||||||
@ -115,8 +118,6 @@ classdef mcuPath
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function rel = absoluteToRelativePath(pathstr)
|
function rel = absoluteToRelativePath(pathstr)
|
||||||
% absoluteToRelativePath — преобразует абсолютный путь в относительный от текущей директории.
|
% absoluteToRelativePath — преобразует абсолютный путь в относительный от текущей директории.
|
||||||
%
|
%
|
||||||
@ -163,6 +164,5 @@ classdef mcuPath
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -23,7 +23,6 @@ classdef periphConfig
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ~isempty(config)
|
if ~isempty(config)
|
||||||
|
|
||||||
if isfield(config, 'Code')
|
if isfield(config, 'Code')
|
||||||
res = periphConfig.addCodeConfig(config.Code, periphPath);
|
res = periphConfig.addCodeConfig(config.Code, periphPath);
|
||||||
if res == 0
|
if res == 0
|
||||||
@ -52,6 +51,7 @@ classdef periphConfig
|
|||||||
continue;
|
continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
defines = config.(periph).Defines;
|
defines = config.(periph).Defines;
|
||||||
defNames = fieldnames(defines);
|
defNames = fieldnames(defines);
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ classdef periphConfig
|
|||||||
def = defines.(defPrompt);
|
def = defines.(defPrompt);
|
||||||
|
|
||||||
% Вызов функции добавления одного параметра
|
% Вызов функции добавления одного параметра
|
||||||
periphConfig.addDefineConfig(mask, containerName, periph, defPrompt, def);
|
periphConfig.addConfig(mask, containerName, periph, defPrompt, def);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -166,7 +166,46 @@ classdef periphConfig
|
|||||||
fclose(fid);
|
fclose(fid);
|
||||||
end
|
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_<Periph>_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
|
end
|
||||||
|
|
||||||
@ -250,10 +289,7 @@ classdef periphConfig
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function addConfig(mask, containerName, periphName, defPrompt, def)
|
||||||
|
|
||||||
|
|
||||||
function addDefineConfig(mask, containerName, periphName, defPrompt, def)
|
|
||||||
% mask — объект маски Simulink.Mask.get(blockPath)
|
% mask — объект маски Simulink.Mask.get(blockPath)
|
||||||
% containerName — имя контейнера, в который добавляем параметр (например, 'configTabAll')
|
% containerName — имя контейнера, в который добавляем параметр (например, 'configTabAll')
|
||||||
% periphName — имя вкладки / контейнера для текущего периферийного блока (например, 'ADC')
|
% periphName — имя вкладки / контейнера для текущего периферийного блока (например, 'ADC')
|
||||||
@ -336,10 +372,14 @@ classdef periphConfig
|
|||||||
param.DialogControl.Row = 'current';
|
param.DialogControl.Row = 'current';
|
||||||
end
|
end
|
||||||
|
|
||||||
if strcmp(paramType, 'popup')
|
if isfield(def, 'Def')
|
||||||
param.TypeOptions = def.Def;
|
if strcmp(paramType, 'popup')
|
||||||
|
param.TypeOptions = def.Def;
|
||||||
|
else
|
||||||
|
param.Alias = def.Def;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
param.Alias = def.Def;
|
param.Callback = 'periphConfig.update_callback();';
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user