필터 지우기
필터 지우기

Detecting Bus Selector missing input signal

조회 수: 5 (최근 30일)
Rajesh
Rajesh 2015년 9월 29일
댓글: goerk 2015년 9월 30일
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.

답변 (1개)

goerk
goerk 2015년 9월 29일
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
Rajesh
Rajesh 2015년 9월 30일
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 2015년 9월 30일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by