TL;DR: Test Sequences are actually an undocumented type under the hood that you have to access in a very convoluted way to actually change the right Sample Time property programmatically.
Doing some web searching and testing, I was trying to find documentation about the properties that are listed in the Property Inspector when you click on a Test Sequence. What I realized when looking at "Create data to monitor the active step" is that the Property Inspector properties are displaying Stateflow Chart properties. This was the first clue I needed to find out how to access the second Sample Time property.
When trying to access Stateflow objects from MATLAB, you have to use the "find" command with "sfroot" as the "location" argument:
chartObjects = find(sfroot,'-isa','[Stateflow Type]');
The valid types that can be placed in [Stateflow Type] are actually found in the "location" part of the "find" documentation:
- Stateflow.Box
- Stateflow.Chart
- Stateflow.EMChart
- Stateflow.EMFunction
- Stateflow.Function
- Stateflow.Machine
- Stateflow.State
- Stateflow.SLFunction
- Stateflow.StateTransitionTableChart
- Stateflow.TruthTable
- Stateflow.TruthTableChart
So, with the MATLAB current folder set to the location of my externally-saved Test Harness, I called "find" using every type. And guess what? The Test Sequence object does not appear for any of them...but the individual steps INSIDE the Test Sequence DO appear for the Stateflow.State type. And one of the properties of the Stateflow.State object is .Chart, which tells you what the parent chart containing the state is. And lo and behold, it is our Test Sequence.
>> chart = find(sfroot, '-isa', 'Stateflow.State')
chart =
Stateflow.State: 386-by-1
>> chart(1)
ans =
Path: 'MyTestHarness/TestSequence'
Id: 24
Machine: [1×1 Stateflow.Machine]
SSIdNumber: 55
Name: 'MyTestSequenceState'
Description: ''
LabelString: 'MyTestSequenceState'
FontSize: 12
ArrowSize: 8
TestPoint: 0
Chart: [1×1 Stateflow.ReactiveTestingTableChart]
BadIntersection: 0
Subviewer: [1×1 Stateflow.ReactiveTestingTableChart]
Document: ''
Tag: []
RequirementInfo: ''
ExecutionOrder: 0
ContentPreviewEnabled: 0
Position: [871 456 150 90]
Decomposition: 'EXCLUSIVE_OR'
Type: 'OR'
IsSubchart: 1
IsGrouped: 0
Debug: [1×1 Stateflow.StateDebug]
InlineOption: 'Auto'
LoggingInfo: [1×1 Stateflow.SigLoggingInfo]
HasOutputData: 0
OutputData: []
OutputMonitoringMode: 'ChildActivity'
IsExplicitlyCommented: 0
IsImplicitlyCommented: 0
CommentText: ''
AppData: [1×1 struct]
Huh...the Chart property for our State is showing a Stateflow type that wasn't listed before. "ReactiveTestingTableChart". In fact, go ahead and search Mathworks' website for this, and you won't find a single Mathworks piece of documentation on this object. If you want to see the only Mathworks documentation for this object, go back to the MATLAB command window and type
charts = find(sfroot, '-isa', 'Stateflow.ReactiveTestingTableChart')
When this object is opened as a collection in MATLAB, the type is at the top of the "Variables" page with a blue hyperlink.
Clicking that hyperlink brings up the Help window with the following comprehensive documentation:
So, there you have it. As much as Simulink would have you believe this is a Subsystem you're dealing with, you are actually dealing with a special, undocumented type of Stateflow chart. Now that we have wasted several hours tracking down what should be listed for easy reading on Mathworks' website, modifying the Sample Time is trivial:
chart = find(sfroot, '-isa', 'Stateflow.ReactiveTestingTableChart');
for i = 1:length(chart)
if(strcmp(chart(i).Name,"[Test Sequence Block Name]"))
chart(i).SampleTime = '0.001'; % Or whatever value you want; has to be a char vector
end
end
Now if you, too, have an EFM that needs to be tested when called at different rates, perhaps because it controls an external device that has different configurations based on communication rate, you can modify your Test Sequence call rate from within the Test Manager's Callbacks sections, too!