Clear Filters
Clear Filters

Detecting Bus Selector missing input signal

16 views (last 30 days)
Rajesh
Rajesh on 29 Sep 2015
Commented: goerk on 30 Sep 2015
Dear All, I have a bus selector,in which some of the input signals to the bus selector are selected as bus selector output signals already.But at a later point of time,I delete one signal from the bus creator which fed to the bus selector.
So at the bus selector output,the deleted signal will be shown as "???xxx" (consider xxx is the already selected signal).
If I read the output signals of the bus selector by get_param function,still I get signal xxx.
I want to know how to detect this missing input signal "???xxx" from command window.
Any help will be highly appreciated.

Answers (1)

goerk
goerk on 29 Sep 2015
a fast hack is shown in this code snippet:
busselectors = find_system(gcs, 'FindAll', 'on', 'BlockType', 'BusSelector')
for i=1:length(busselectors)
%detection
outputSignals_str = get_param(busselectors(i),'OutputSignals');
outputSignals = strsplit(outputSignals_str,',');
inputSignals = get_param(busselectors(i),'InputSignals');
isValidSignal = false(size(outputSignals));
for j=1:length(outputSignals)
isValidSignal(j) = sum(strcmp(inputSignals,outputSignals(j)))>0;
end
%eg. remove the not valid signals
validOutputSignals = outputSignals(isValidSignal);
validOutputSignals_str = strjoin(validOutputSignals,',');
set_param(busselectors(i),'OutputSignals', validOutputSignals_str);
end
  2 Comments
Rajesh
Rajesh on 30 Sep 2015
Hi Goerk, Thanks for your answer. Your code will work perfectly when the bus selector inputs are not part of some other bus creator(I meant to say nested bus creators).
Take an example of a output signals of a bus selector."Food.Fruit.Mango.Yellow".Yellow is a signal that was a part of Bus Creator Mango and in turn Bus Mango was connected to Bus creator Fruit and bus Fruit was connected to Bus creator Food.
This is the case I am encountering. Considering I have already selected the signal "Food.Fruit.Mango.Yellow" as output of a bus selector.But at a later point If I have deleted the signal Yellow from Bus Creator Mango then at the bus selector how to find this signal is not available. I am struggling to find a solution for this problem.
goerk
goerk on 30 Sep 2015
Hi Rajesh,
for nested busses the idea is the same, but as inputSignals you get a cell array instead of a string. With a bit of work it should be possible to generate the strings out of it (eg. nestedBus.sig01). With this strings the rest can be performed with the code from above.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!