メインコンテンツ

reloadData

Reload data signal of root inports of model on target computer

Description

reloadData(target_stimulation_object, inport, loadSource) reloads the data signal to the specified root inport of the model running on the Speedgoat® target computer. The data source can be a timeseries object or a Parquet file name.

example

reloadData(target_stimulation_object, playback, loadSource) reloads the data signal for the specified Playback block. The data source can be a timeseries object, a Simulink.SimulationData.Dataset object, pairs of port numbers and timeseries objects, or pairs of port numbers and Parquet file names.

example

reloadData(target_stimulation_object, blockPath, {parameter_name, loadSource}) reloads the data to the specified tunable parameter. The data source can be a timeseries object or a Parquet file name.

Parquet file usage has some limitations:

  • Only Parquet file format is supported for file-based loading. Other formats (MAT, CSV, XLSX) are not accepted.

  • File-based loading is supported only through the reloadData function at runtime. Parquet files cannot be specified at build time.

  • Each inport, Playback block port, or parameter maps to a single Parquet file.

These tips can help with Parquet file usage:

  • If the filename does not include a path, MATLAB® searches the current folder and the MATLAB path.

  • The Parquet file is transferred from the development computer to the target computer during the reloadData call. Ensure the development computer has sufficient access to the file.

example

Examples

collapse all

To load data to an inport, create a time series object.

  1. sampleTime = 0.1; %sample time of the model
    endTime = 10; %end time of the model
    numberOfSamples = endTime * 1/sampleTime + 1;
    timeVector = (0:numberOfSamples) * sampleTime;
    u = timeseries(timeVector*10,timeVector);
  2. Load the object to the inport named first.

    reloadData(tg.Stimulation,'first',u);
  3. To load the same object to multiple inports named first and third.

    reloadData(tg.Stimulation,'first',u,'third',u);

Load data directly from a Parquet file to an inport:

  1. Load Parquet file to inport named first.

    reloadData(tg.Stimulation, 'first', 'testData.parquet');
  2. Load using inport number.

    reloadData(tg.Stimulation, 1, 'testData');

Load Parquet files to specific ports of a Playback block:

Load files to ports 1 and 2 of Playback block named Playback1.

reloadData(tg.Stimulation, 'Playback1', {{1, 'channel1.parquet'}, {2, 'channel2.parquet'}});
  1. Create time series variables.

    ts1 = timeseries(data1, timeVector);
    ts2 = timeseries(data2, timeVector);
  2. Load timeseries to ports of Playback block.

    reloadData(tg.Stimulation, 'Playback1', {{1, ts1}, {2, ts2}});

Load a Parquet file to a tunable parameter.

Load file to the 'Frequency' parameter of Signal Generator block.

reloadData(tg.Stimulation, 'slrt_ex_osc/Signal Generator', {'Frequency', 'freqData.parquet'});
  1. Create time series variable.

    freqTs = timeseries(freqValues, timeVector);
    
  2. Load time series data.

    reloadData(tg.Stimulation, 'slrt_ex_osc/Signal Generator', {'Frequency', freqTs});

Input Arguments

collapse all

Object that represents the stimulation of root inports or Playback blocks of the model running on the Speedgoat target computer. A Target.Stimulation object is created when you create a Target object by using the slrealtime command.

Example: tg.Stimulation

Specifies the name of the inport or inport number or block path of the inport present on the model running on the target computer. Specify as:

  • An inport name (for example, 'first')

  • An inport number (for example, 1)

  • A block path of the inport (for example, 'myModel/In1')

Example: {'signal_1'}, [2], {'model_name/in4'}

Specifies the name of the Playback block or block path of the Playback block present in the model running on the target computer. Specify as:

  • A block name (for example, 'Playback')

  • A block path (for example, 'myModel/Playback')

Example: {'signal_1'}, [2], {'model_name/in4'}

The block_path values for tunable parameters in stimulation operations can be:

  • Empty character vector ('') or empty string scalar ("") for base or model workspace variables

  • Character vector or string scalar string for block path to parameters in the top model

  • Cell array of character vectors or string scalars for model block arguments

Example: '', 'Gain1', {'top/model','sub/model'}

The parameter can designate either a block parameter or a global parameter that provides the value for a block parameter. The block parameter or MATLAB variable must be observable to be accessible through the parameter name.

Note

Simulink® Real-Time™ does not support parameters of multiword data types.

Example: 'Gain', 'oscp.G1', 'oscp', 'G2'

Specifies the data to load. Accepted types depend on the choice of inport, playback, or blockPath source.

Source

Accepted loadSource Types

Inport

timeseries object, or Parquet file name

Playback block

timeseries object, Simulink.SimulationData.Dataset object, cell array of {port, timeseries} pairs, or cell array of {port, filename} pairs

Parameter

timeseries object, or Parquet file name (provided inside the cell array as {parameterName, loadSource})

When specifying a Parquet file as loadSource, provide the file name as a character vector or string scalar. If the file name does not include an extension, .parquet is assumed. Each inport, Playback block port, or parameter requires its own Parquet file.

FormLocationExample
File name onlyCurrent folder or folder on the MATLAB path'myFile.parquet'
Relative pathFile in a subfolder'dataDir/myFile.parquet'
Absolute pathFull path to file'C:\myFolder\myFile.parquet'

The Parquet file must satisfy the these constraints:

RequirementDetails
Timestamp column typeTime64[us] (microsecond resolution)
Timestamp orderingStrictly monotonically increasing (no equal or decreasing values)
Null valuesNo null values in the timestamp column
Data column typesMust match the data types expected by the target application
Row groupsAll row groups must be non-empty; ordering must hold across row group boundaries

Example: {{1,playbackData1},{2,playbackData2}}

Version History

Introduced in R2021a

expand all