Main Content

sltest.observer.configureObserverPort

Configure Observer Port block

Since R2024b

    Description

    sltest.observer.configureObserverPort(obsport,"Signal",path,port) configures the Observer Port block, obsport, to observe the signal at port, port, of the block located at path.

    example

    sltest.observer.configureObserverPort(obsport,"SFData",path,dataobj) configures the Observer Port block, obsport, to observe the Stateflow® data object, dataobj, in the chart located at path.

    example

    sltest.observer.configureObserverPort(obsport,"SFStateActivity",path,stateobj,activity) configures the Observer Port block, obsport, to observe the specified activity of the Stateflow state, stateobj, in the Stateflow chart located at path. You can observe state activity only if the state is at the top level of the Stateflow chart.

    example

    sltest.observer.configureObserverPort(obsport,"FMUInternalVariable",path,fmuvar) configures the Observer Port block, obsport, to observe the Functional Mockup Unit (FMU) internal variable, fmuvar, in the block located at path.

    example

    Examples

    collapse all

    import sltest.observer.*
    openExample("sf_car")
    
    mdlHandle = get_param(gcs,"Handle");
    obsrefHandle = addObserverReference(mdlHandle);
    obsmodelHandle = get_param(gcs,"Handle");
    
    obsportHandle = addObserverPort(obsmodelHandle);
    configureObserverPort(obsportHandle,"Signal",...
       Simulink.BlockPath("sf_car/transmission"),2);
    import sltest.observer.*
    openExample("sf_car")
    
    mdlHandle = get_param(gcs,"Handle");
    obsrefHandle = addObserverReference(mdlHandle);
    obsmodelHandle = get_param(gcs,"Handle");
    
    obsportHandle = addObserverPort(obsmodelHandle);
    sf_dataobj = find(sfroot,"-isa","Stateflow.Data",...
       "-depth",4,Name = "up_th");
    configureObserverPort(obsportHandle,"SFData",...
       Simulink.BlockPath("sf_car/shift_logic"),sf_dataobj);

    Configure an Observer Port to observe the OFF state in the Stateflow chart of the observe_sfstate_activity model.

    import sltest.observer.*
    open_system("observe_sfstate_activity") 
    
    mdlHandle = get_param(gcs,"Handle");
    obsref1 = addObserverReference(mdlHandle);
    obsmodelHandle = get_param(gcs,"Handle");
    obsportHandle = addObserverPort(obsmodelHandle);
    
    chartObj = find(sfroot,"-isa","Stateflow.Chart");
    stateObj = find(chartObj,"-isa","Stateflow.State",...
       Name="OFF");
    activityType = 'Self';
    
    blockPath = Simulink.BlockPath...
       ({'observe_sfstate_activity/Chart'});
    configureObserverPort(obsportHandle,...
       "SFStateActivity",blockPath,stateObj,activityType);
    import sltest.observer.*
    openExample("fmuPIDwithInternalVar");
    
    mdlHandle = get_param(gcs,"Handle");
    mdlName = get_param(gcs,"Name"); 
    
    obsref = Simulink.findBlocksOfType(...
       'fmuPIDwithInternalVar','ObserverReference');
    obsrefName =get_param(obsref,"Name");
    
    open_system(strcat(mdlName,"/",obsrefName))
    obsmodel = gcs;
    obsmodelHandle = get_param(gcs,"Handle");
    
    obsportHandle = addObserverPort(obsmodelHandle);
    
    fmuvar = 'trackingError';
    blockPath = Simulink.BlockPath('fmuPIDwithInternalVar/FMU');
    configureObserverPort(obsportHandle,...
       "FMUInternalVariable",blockPath,fmuvar);

    Input Arguments

    collapse all

    Observer Port block, specified as a double data type block handle.

    Path to the element to observe in the system model, specified as a Simulink.BlockPath object. The paths specific to each element type are:

    • 'Signal' — The block from which the signal originates

    • 'SFData' — The top level of the Stateflow chart that contains the data

    • 'SFStateActivity' — The top level of the Stateflow chart that contains the state activity

    • 'FMUInternalVariable' — The Functional Model Unit

    Port index that identifies the port of the signal, specified as an integer.

    Stateflow data object to observe, specified as a Stateflow.Data (Stateflow) object.

    Stateflow state object to observe, specified as a Stateflow.State (Stateflow) object.

    Stateflow activity type, specified as 'Self'. For information about Stateflow activity types, see Monitor State Activity Through Active State Data (Stateflow).

    FMU internal variable to observe, specified as a string or character vector.

    Version History

    Introduced in R2024b