Main Content

addDataStoreSignal

Class: sltest.testmanager.LoggedSignalSet
Package: sltest.testmanager

Add a data store or Simulink.Signal object to a set

Syntax

obj = addDataStoreSignal(lgset,BlockPath)

Description

obj = addDataStoreSignal(lgset,BlockPath) creates and adds an sltest.testmanager.LoggedSignal object to a set when the LoggedSignal object derives from a data store or Simulink.Signal object. You must open or load the model to add a LoggedSignal from the model.

Input Arguments

expand all

Logged signal set object contained in a test case.

Simulink.BlockPath object that uniquely identifies a Data Store Write block and the associated data store memory or associated Simulink.Signal object.

Examples

expand all

Open a model and create a signal set.

% Open model for this example
openExample('sldemo_mdlref_dsm')

% Create test case
tf = sltest.testmanager.TestFile(strcat(pwd,'\mytf.mldatx'));
ts = sltest.testmanager.TestSuite(tf,'myts');
tc = sltest.testmanager.TestCase(ts,'baseline','mytc');

% Create signal set
mylgset = tc.addLoggedSignalSet;

Identify the global data store paths for these model components. To programmatically determine the path, select each component individually and in the MATLAB Command Window, enter gcb:

  • Select Model block sldemo_mdlref_dsm_bot2

  • In sldemo_mdlref_dsm_bot2, select the Data Store Write block.

Use the returned paths to create a Simulink.BlockPath object for the global data store.

% Add signal to set
bPath = Simulink.BlockPath({'sldemo_mdlref_dsm/A1',...
                            'sldemo_mdlref_dsm_bot2/DSW'});
sig1 = mylgset.addDataStoreSignal(bPath);

% Check signal was added successfully
sigs = mylgset.getLoggedSignals

Begin with the model and signal set created in the previous example.

Identify the global data store paths for these model components. To programmatically determine the path, select each component individually and in the MATLAB Command Window, enter gcb:

  • Select Model block sldemo_mdlref_dsm_bot

  • In sldemo_mdlref_dsm_bot, select subsystem PositiveSS subsystem

  • In subsystem PositiveSS, select the Data Store Write block

Use the returned paths to create a Simulink.BlockPath object for the local data store.

% Add signal to set
bPath = Simulink.BlockPath({'sldemo_mdlref_dsm/A',...
    'sldemo_mdlref_dsm_bot/PositiveSS',...
    'sldemo_mdlref_dsm_bot/PositiveSS/DSW'});
sig2 = mylgset.addDataStoreSignal(bPath);

% Check that signal was added successfully
sigs = mylgset.getLoggedSignals;

Version History

Introduced in R2019a