Dynamic mask dialogues - change parameters of more than one subsystem

1 view (last 30 days)
Hello everybody,
I'm currently using callbacks in parameter masks to switch block choice for configurable Subsystems. So I have a system tree like
parent
- Isolierung (configurable subsystem)
- Bypass (Option 1)
- Schichtteil (Option 2)
- Isolierung1 (configurable subsystem)
- Bypass (Option 1)
- Schichtteil (Option 2)
etc.
When I use a parameter 'iso', it Looks (and works) like this for one subsystem:
switch (get_param(gcb,'iso'))
case 'mit Isolierung'
set_param([gcb '/Isolierung'], 'BlockChoice', 'Schichtteil')
case 'ohne Isolierung'
set_param([gcb '/Isolierung'], 'BlockChoice', 'Bypass')
end
'iso' is Dropdown...
When I try to change more than one system, I get errors:
switch (get_param(gcb,'iso'))
case 'mit Isolierung'
set_param([gcb '/Isolierung'], 'BlockChoice', 'Schichtteil')
set_param([gcb '/Isolierung1'], 'BlockChoice', 'Schichtteil')
case 'ohne Isolierung'
set_param([gcb '/Isolierung'], 'BlockChoice', 'Bypass')
set_param([gcb '/Isolierung1'], 'BlockChoice', 'Bypass')
end
Error:Error invoking object method --> Error in Rohr_mit_Wand/Rohr NTU5: Initialization commands cannot be evaluated. -->Invalid Simulink object name: Rohr_mit_Wand/Rohr NTU5/Isolierung/Schichtteil/Isolierung1
Update: I investigated further:
>> gcb
ans =
comp_smscp/Rohre_Ventile/Rohr NTU5
>> get_param([gcb '/Isolierung3'], 'BlockChoice')
ans =
Bypass
>> gcb
ans =
comp_smscp/Rohre_Ventile/Rohr NTU5
>> set_param([gcb '/Isolierung3'], 'BlockChoice', 'Schichtteil')
>> gcb
ans =
comp_smscp/Rohre_Ventile/Rohr NTU5/Isolierung3/Schichtteil
So with every set_param, gcb changes its path. How can I step back to the previous path or set multiple subsystem parameters at once?

Accepted Answer

Andreas
Andreas on 29 Oct 2013
Ok, found the answer and the trick is quite simple: thinking ;)
What about using a variable to save the first correct block path given by "gcb"? Nevertheless I wonder why
set_param([gcb '/xxx'], 'yyy')
changes the path to "current block/xxx".
My solution looks like the following now:
path = gcb
switch (get_param(gcb,'iso'))
case 'mit Isolierung'
set_param([path '/Isolierung'], 'BlockChoice', 'Schichtteil')
set_param([path '/Isolierung1'], 'BlockChoice', 'Schichtteil')
set_param([path '/Isolierung2'], 'BlockChoice', 'Schichtteil')
set_param([path '/Isolierung3'], 'BlockChoice', 'Schichtteil')
set_param([path '/Isolierung4'], 'BlockChoice', 'Schichtteil')
case 'ohne Isolierung'
set_param([path '/Isolierung'], 'BlockChoice', 'Bypass')
set_param([path '/Isolierung1'], 'BlockChoice', 'Bypass')
set_param([path '/Isolierung2'], 'BlockChoice', 'Bypass')
set_param([path '/Isolierung3'], 'BlockChoice', 'Bypass')
set_param([path '/Isolierung4'], 'BlockChoice', 'Bypass')
end

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!