all test harness signals are initialized to the wrong values (ZEROS)

1 次查看(过去 30 天)
Issue: When i create a test harness for a specific subsystem, all the subsystem input ports signals shows up initialized to ZEROS in the test sequence - wrong initialization. I know i can change these initialization statements manually, but the system under test has more than a 100 signals which makes it tedious.
In the model, these signals are each associated with Simulink.Signal object where each initialized to a specific InitialValue. Note that the test sequence was able to the pull the datatype information for each signal from the workspace definition that is enforced by the non-virtual bus definition. refer to below as an example:
% SIGNALS OBJECTS
<SignalName> = Simulink.Signal;
<SignalName>.CoderInfo.StorageClass = 'ExportedGlobal';
<SignalName>.CoderInfo.Alias = '';
<SignalName>.CoderInfo.Alignment = -1;
<SignalName>.Description = '';
<SignalName>.DataType = 'auto';
<SignalName>.Min = [];
<SignalName>.Max = [];
<SignalName>.DocUnits = '';
<SignalName>.Dimensions = -1;
<SignalName>.DimensionsMode = 'auto';
<SignalName>.Complexity = 'real';
<SignalName>.SampleTime = -1;
<SignalName>.InitialValue = '1';
% BUS OBJECTS
elems(3) = Simulink.BusElement;
elems(3).Name = 'SignalName';
elems(3).Dimensions = 1;
elems(3).DimensionsMode = 'Fixed';
elems(3).DataType = 'boolean';
elems(3).SampleTime = -1;
elems(3).Complexity = 'real';
elems(3).Min = [];
elems(3).Max = [];
elems(3).DocUnits = '';
elems(3).Description = '';
how do I make test harness to pull/adopt the intial value information for each signal defined in the workspace upon its creation and set them in the initialization step of the test sequence.
Any help is appreciated; thank you in advance!

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2020-7-1
Find the source of the signal in the model (the output of a Gain block or could be a root level Inport block, where the signal is originated), right click the signal line, select properties, the signal label should be the same as the signal name, check the "signal name must resolve to Simulink data object". That is how the signal properties (including data type and initial value) are linked to the Simulink.Signal object.
  4 个评论
Yamen
Yamen 2020-7-4
编辑:Yamen 2020-7-4
Attached is an example that explains the context of "subsystem", "test harness", "test sequence", and decribe what my issue is.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Inputs 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by