Skip to content
Snippets Groups Projects
Commit 59b6845e authored by Cristian Galperti's avatar Cristian Galperti
Browse files

tunable gated integrator, harness duplicated correctly

parent e14ceb69
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
function TP = algo_template_loadtp() function TP = algo_template_loadtp()
% Setup tunable control params % Setup tunable control params default values
TP.enable = true; TP.enable = true;
TP.gain = single(2); TP.gain = single(2);
TP.refmodel.gain = single(4); % another gain used in referenced model TP.refmodel.gain = single(4); % another gain used in referenced model
TP.rowvect = int32([1 2 3]); TP.rowvect = int32([1 2 3]);
TP.colvect = int16([1 2 3]'); TP.colvect = single([1 2 3]');
TP.matrix = int8([1 2; 3 4]); TP.matrix = int8([1 2; 3 4]);
end end
...@@ -26,6 +26,18 @@ elems(2).Max = []; ...@@ -26,6 +26,18 @@ elems(2).Max = [];
elems(2).DocUnits = ''; elems(2).DocUnits = '';
elems(2).Description = ''; elems(2).Description = '';
elems(3) = Simulink.BusElement;
elems(3).Name = 'signal3';
elems(3).Dimensions = 1;
elems(3).DimensionsMode = 'Fixed';
elems(3).DataType = 'single';
elems(3).SampleTime = -1;
elems(3).Complexity = 'real';
elems(3).Min = [];
elems(3).Max = [];
elems(3).DocUnits = '';
elems(3).Description = '';
algo_template_outBus = Simulink.Bus; algo_template_outBus = Simulink.Bus;
algo_template_outBus.HeaderFile = ''; algo_template_outBus.HeaderFile = '';
algo_template_outBus.Description = ''; algo_template_outBus.Description = '';
......
...@@ -46,11 +46,17 @@ Buses{end+1} = outBus; ...@@ -46,11 +46,17 @@ Buses{end+1} = outBus;
% init bus % init bus
elems(1)=Simulink.BusElement; elems(1)=Simulink.BusElement;
elems(1).Name='init1'; elems(1).Name='clipgain1';
elems(1).DataType='single'; elems(1).DataType='single';
elems(2)=Simulink.BusElement; elems(2)=Simulink.BusElement;
elems(2).Name='init2'; elems(2).Name='tstart1';
elems(2).DataType='int32'; elems(2).DataType='single';
elems(3)=Simulink.BusElement;
elems(3).Name='tstop1';
elems(3).DataType='single';
elems(4)=Simulink.BusElement;
elems(4).Name='enable1';
elems(4).DataType='boolean';
initBus = Simulink.Bus; initBus = Simulink.Bus;
initBus.HeaderFile = ''; initBus.HeaderFile = '';
......
...@@ -20,6 +20,7 @@ filelist={... ...@@ -20,6 +20,7 @@ filelist={...
'algo_template_outBus_def.m',... 'algo_template_outBus_def.m',...
'algo_template_inBus_def.m',... 'algo_template_inBus_def.m',...
'algoobj_template.m',... 'algoobj_template.m',...
'algo_template_create_tree.tcl',...
}; };
for i=1:numel(filelist) for i=1:numel(filelist)
cpcmd=sprintf('cp -vf %s/%s %s/%s',fcnpath,filelist{i},algopath,strrep(filelist{i},'template',name)); cpcmd=sprintf('cp -vf %s/%s %s/%s',fcnpath,filelist{i},algopath,strrep(filelist{i},'template',name));
...@@ -53,17 +54,26 @@ end ...@@ -53,17 +54,26 @@ end
% keeping a list like this % keeping a list like this
% updated (manually ...) with the template content: % updated (manually ...) with the template content:
fprintf('Changing block diagrams properties ...\n'); fprintf('Changing block diagrams properties ...\n');
list={{'algo_template/realtime' ,'SampleTime',}, ... list={{'algo_template/realtime' ,'SampleTime',},...
{'algo_template/signal_in' ,'OutDataTypeStr',}, ... {'algo_template/signal_in' ,'OutDataTypeStr',},...
{'algo_template/signal_out' ,'OutDataTypeStr',}, ... {'algo_template/signal_out' ,'OutDataTypeStr',},...
{'algo_template/Gain' ,'Gain'}, ... {'algo_template/Gain' ,'Gain'},...
{'algo_template/Constant' ,'OutDataTypeStr'}, ... {'algo_template/Constant' ,'OutDataTypeStr'},...
{'algo_template/Model' ,'ModelNameDialog'}, ... {'algo_template/Model' ,'ModelNameDialog'},...
{'algo_template/InitFcn/Constant1','Value'},... {'algo_template/InitFcn/Constant1' ,'Value'},...
{'algo_template/InitFcn/Constant2','Value'},... {'algo_template/InitFcn/Constant2' ,'Value'},...
{'algo_template/InitFcn/InitOut','OutDataTypeStr',}, ... {'algo_template/InitFcn/Constant3' ,'Value'},...
{'algo_template/InitFcn/Constant4' ,'Value'},...
{'algo_template/InitFcn/InitOut' ,'OutDataTypeStr',},...
{'algo_template_harness/Model' ,'ModelNameDialog'},...
{'algo_template_harness/clock' ,'SampleTime'},...
{'algo_template_harness/test_inputs' ,'VariableName'},...
{'algo_template_harness/test_inputs' ,'SampleTime'},...
{'algo_template_harness/test_inputs' ,'OutDataTypeStr'},...
}; };
load_system(['algo_' name]); load_system(['algo_' name]);
load_system(['algo_' name '_harness']);
for i=1:numel(list) for i=1:numel(list)
parobj=strrep(list{i}{1},'template',name); parobj=strrep(list{i}{1},'template',name);
oldvalue = get_param(parobj,list{i}{2}); oldvalue = get_param(parobj,list{i}{2});
...@@ -72,7 +82,7 @@ for i=1:numel(list) ...@@ -72,7 +82,7 @@ for i=1:numel(list)
set_param(parobj,list{i}{2},newvalue); set_param(parobj,list{i}{2},newvalue);
end end
fprintf('Changing referenced subsystem instance parameter ...\n'); fprintf('Changing referenced subsystems instance parameter ...\n');
list={{'algo_template/Model', 'InstanceParameters'}}; list={{'algo_template/Model', 'InstanceParameters'}};
for i=1:numel(list) for i=1:numel(list)
parobj=strrep(list{i}{1},'template',name); parobj=strrep(list{i}{1},'template',name);
...@@ -84,10 +94,13 @@ for i=1:numel(list) ...@@ -84,10 +94,13 @@ for i=1:numel(list)
end end
save_system(['algo_' name]); save_system(['algo_' name]);
load_system(['algo_' name '_harness']);
fprintf('Renaming ''template'' to ''%s'' inside .m files ...\n',name); fprintf('Renaming ''template'' to ''%s'' inside script files ...\n',name);
rncmd=sprintf('cd %s; sed -i ''s/template/%s/g'' *.m', algopath, name); rncmd=sprintf('cd %s; sed -i ''s/template/%s/g'' *.m', algopath, name);
system(rncmd); system(rncmd);
rncmd=sprintf('cd %s; sed -i ''s/template/%s/g'' *.tcl', algopath, name);
system(rncmd);
eval(sprintf('cd %s',startpath)); eval(sprintf('cd %s',startpath));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment