diff --git a/algos/template/algo_template.slx b/algos/template/algo_template.slx index 2759c85d3e689413b87a5c682b8a256cc4371ef1..709053d40f90f16f277cdd429543730a0bab7175 100644 Binary files a/algos/template/algo_template.slx and b/algos/template/algo_template.slx differ diff --git a/algos/template/referenced_model_example.slx b/algos/template/algo_template_referenced.slx similarity index 100% rename from algos/template/referenced_model_example.slx rename to algos/template/algo_template_referenced.slx diff --git a/algos/template/duplicate_template.m b/algos/template/duplicate_template.m index f0f995db816d3e244589b919f9ba3599d8d640dc..c31e5f4cf9def564fba14d41eb6593a676b0a375 100644 --- a/algos/template/duplicate_template.m +++ b/algos/template/duplicate_template.m @@ -11,6 +11,7 @@ fprintf('Copying files ...\n'); filelist={... 'algo_template.slx',... 'algo_template_harness.slx',... + 'algo_template_referenced.slx',... 'algo_template_harness_run.m',... 'algo_template_test.m',... 'algo_template_loadtp.m',... @@ -44,19 +45,20 @@ end % The way I found to get block diagrams % programmatically (of opened system) is via: % proplist = find_system -% paramstruct get_param(proplist{1},'DialogParameters') +% paramstruct = get_param(proplist{1},'DialogParameters') % and then -% get_param(proplist{1},<paramstruct field> +% get_param(proplist{1},<paramstruct field>) % -% hence I do not see other option than -% keeping a list lije this -% updated with the template content: +% hence I do not see other options than +% keeping a list like this +% updated (manually ...) with the template content: fprintf('Changing block diagrams properties ...\n'); -list={{'algo_template/realtime' ,'SampleTime'}, ... - {'algo_template/signal_in' ,'OutDataTypeStr'}, ... - {'algo_template/signal_out' ,'OutDataTypeStr'}, ... +list={{'algo_template/realtime' ,'SampleTime',}, ... + {'algo_template/signal_in' ,'OutDataTypeStr',}, ... + {'algo_template/signal_out' ,'OutDataTypeStr',}, ... {'algo_template/Gain' ,'Gain'}, ... - {'algo_template/Constant' ,'OutDataTypeStr'}, ... + {'algo_template/Constant' ,'OutDataTypeStr'}, ... + {'algo_template/Model' ,'ModelNameDialog'}, ... }; load_system(['algo_' name]); for i=1:numel(list) @@ -66,6 +68,18 @@ for i=1:numel(list) fprintf('changing %s,%s %s->%s\n', parobj,list{i}{2},oldvalue,newvalue); set_param(parobj,list{i}{2},newvalue); end + +fprintf('Changing referenced subsystem instance parameter ...\n'); +list={{'algo_template/Model', 'InstanceParameters'}}; +for i=1:numel(list) + parobj=strrep(list{i}{1},'template',name); + oldvalue = get_param(parobj,list{i}{2}); + newvalue = oldvalue; + newvalue.Value = sprintf('algo_%s_tp.refmodel',name); + fprintf('changing %s,%s %s->%s\n', parobj,list{i}{2},oldvalue.Value,newvalue.Value); + set_param(parobj,list{i}{2},newvalue); +end + save_system(['algo_' name]); fprintf('Renaming ''template'' to ''%s'' inside .m files ...\n',name);