Variant Subsystem (Dynamic Couplings)

Motivation

This example is a straightforward extension of the example A01 "Variant Subsystem (simple)". It extends the previous one by more variability, which results in a higher number of variants. It uses dynamic coupling relations and shows how they can be specified with SES Functions. Subsequently, we only describe the extensions, which are highlighted in the SES tree.

Basic enlargement and resulting system variants:
Basic SES:

Description

The example extends the previous one by a varying number of signal generators, that means:

Overall, the SES describes now 6 different model variants (2 x 3).

Dynamic Configuration of a MultiAspect (Modifications regarding to node SignalMAsp)

The first thing that has to be changed in the SES compared to the example A01, is the Number Of Replications property at the MultiAspect node. Previously it was set to the constant value of 3. Now you define an SES Variable NumSignals to control the number of sine wave generators. This variable may have the value 1, 2 or 3, which has to be defined as Semantic Condition wit ismember(NumSignals,[1,2,3]).

Moreover, we have to define 3 different coupling specifications, one for each possible case of replication. Therefor, we can define 3 coupling tables, such as in the example SES, or we can define an SES Function, such as following, named c_sg:

function cplg = c_sg(children,parent,num)
%create empty data structure for couplings
cplg = cell(num,4);
%set variable couplings btw children & parent
for i = 1:num
    cplg(i,1:4) = {children{i}, num2str(1),parent, num2str(i)};
end
end
and activate the "Choose Function to set Coupling" field in the editor with the following SES Function call:

  c_sg('Children','Parent',NumSignals)

Dynamic Couplings at Aspects Using SES Functions

Because of the problem enlargement by a varying number of input generators, the number of ports and the couplings are different for the various variants. This problem is solved by using SES Functions for specifying the coupling relations at the Aspect nodes (see nodes ModelDec, LCDec and NLCDec) in the SES, similiar to the above described SES Function for the MultiAspect node and the SES Functions used in example B07. For details regarding to the call and definition of SES Functions open this SES model example in the SES editor and have a look to the tab "Functions". Examplary, we show subsequently the definition of the SES Function CtrCoupl,

function cellArray = CtrCoupl(Children,Parent,NumSignals)
switch NumSignals
    case 1
        cellArray = {Parent,'1',     Children{1},'1';
                     Children{1},'1',Children{2},'1';
                     Children{2},'1',Parent,     '1'}; 
    case 2
        cellArray = {Parent,     '1',Children{2},'1';
                     Parent,     '2',Children{1},'1';
                     Children{1},'1',Children{2},'2';
                     Children{2},'1',Parent,     '1'};  
    case 3
        cellArray = {Parent,     '1',Children{2},'1';
                     Parent,     '2',Children{1},'1';
                     Children{1},'1',Children{2},'2';
                     Parent,     '3',Children{2},'3';
                     Children{2},'1',Parent,     '1'};
    otherwise
        cellArray = cell(1,4);
end
end
which is used in the same manner for specifying the variable coupling relations at node LCDec and NLCDec with the SES Function call

  CtrlCoupl('Children','Parent',NumSignals)

Variable Configuration of Entities and Referenced Dynamic Models

Moreover, the varying internal structure of the controllers, caused by the variable number of sensor inputs, requires a variable configuration for the leaf entity Add, which references a dynamic model in the MB by its attribute mb='add'. That's why, its attribute Inputs is specified using an SES Function call, addFun(NumSignals), to calculate this attribute dynamically depending on the specific number of choosen sensor inputs (signal generators). Subsequently, you see the definition of the SES Function.

function Inputs = addFun(NumRep)
switch NumRep
    case 1
        Inputs = '|+';
    case 2
        Inputs = '|++';
    otherwise
        Inputs = '|+++';        
end
end

MB and Model Generation

Analogous to the example A01, this SES defines references to dynamic models in an MB, namely the Simulink library. For controlling the entire model generation process use the MATLAB function ./startFcn... located in the example's directory. All other functions involved with the model generation process are located in the example's subdirectory private.