Main Content

addDataStoreSignal

Class: sltest.testmanager.LoggedSignalSet
Namespace: 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 the models for this example.

sldemo_mdlref_dsm
sldemo_mdlref_dsm_bot2

Create the test file, test suite and test case structure.

tf = sltest.testmanager.TestFile('mytf');
ts = sltest.testmanager.TestSuite(tf,'myts');
tc = sltest.testmanager.TestCase(ts,'baseline','mytc');

Create a signal set.

mylgset = addLoggedSignalSet(tc);

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.

bPath = Simulink.BlockPath({'sldemo_mdlref_dsm/A1',...
          'sldemo_mdlref_dsm_bot2/DSW'});
sig1 = mylgset.addDataStoreSignal(bPath);
sigs = mylgset.getLoggedSignals
sigs = 
  LoggedSignal with properties:

           Name: 'ErrorCond'
         Source: 'base workspace'
      PortIndex: 0
         Active: 1
    PlotIndices: []

Open the model for this example.

sldemo_mdlref_dsm
sldemo_mdlref_dsm_bot

Create the test file, test suite and test case structure.

tf = sltest.testmanager.TestFile('myTestfile');
ts = sltest.testmanager.TestSuite(tf,'myts');
tc = sltest.testmanager.TestCase(ts,'baseline','mytc');

Create a signal set.

mylgset = addLoggedSignalSet(tc);

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 in sldemo_mdlref_dsm_bot

  • In sldemo_mdlref_dsm_bot, select the 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.

bPath = Simulink.BlockPath({'sldemo_mdlref_dsm/A',...
    'sldemo_mdlref_dsm_bot/PositiveSS',...
    'sldemo_mdlref_dsm_bot/PositiveSS/DSW'});
sig2 = mylgset.addDataStoreSignal(bPath);
sigs = mylgset.getLoggedSignals
sigs = 
  LoggedSignal with properties:

           Name: 'RefSignalVal'
         Source: 'sldemo_mdlref_dsm/A/PositiveSS/DSM'
      PortIndex: 0
         Active: 1
    PlotIndices: []

Version History

Introduced in R2019a