Skip to content

Commit 035869f

Browse files
committed
Update HEV folder structure and add tests for Direct Input
1 parent d23a4e3 commit 035869f

File tree

142 files changed

+1862
-680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+1862
-680
lines changed
304 Bytes
Binary file not shown.

Components/Engine/utils/Engine_InputSignalBuilder.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function plotSignals(inpObj, nvpairs)
8181

8282
if not(inpObj.VisiblePlot_tf)
8383
% Invisible figure.
84-
inpObj.ParentFigure = figure(Visible = 'off');
84+
inpObj.ParentFigure = figure('Visible', 'off');
8585
elseif isfield(nvpairs, 'ParentFigure')
8686
% This function's ParentFigure option is specified.
8787
assert(isa(nvpairs.ParentFigure, 'matlab.ui.Figure'))
-313 KB
Binary file not shown.

HEV/PowerSplitHEV_DirectInput/PowerSplitHEV_DirectInput_inputs.m

Lines changed: 0 additions & 114 deletions
This file was deleted.
Binary file not shown.

HEV/PowerSplitHEV_DirectInput/PowerSplitHEV_DirectInput_setup.m

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
classdef PowerSplitHEV_DirectInput_UnitTest < matlab.unittest.TestCase
2+
% Class implementation of unit test
3+
4+
% Copyright 2021-2022 The MathWorks, Inc.
5+
6+
properties (Constant)
7+
modelName = "PowerSplitHEV_system_model";
8+
end
9+
10+
methods (Test)
11+
12+
function defaultReferencedSubsystems_1(testCase)
13+
%% Test for Default Referenced Subsystems
14+
% This ensures that all the subsystem reference blocks in the model file have
15+
% intended referenced subsystems.
16+
close all
17+
bdclose all
18+
19+
mdl = testCase.modelName;
20+
load_system(mdl)
21+
22+
refSubName = get_param(mdl+"/Controller & Environment", "ReferencedSubsystem");
23+
verifyEqual(testCase, refSubName, 'PowerSplitHEV_DirectInput_refsub');
24+
25+
refSubName = get_param(mdl+"/High Voltage Battery", "ReferencedSubsystem");
26+
verifyEqual(testCase, refSubName, 'BatteryHVElec_refsub');
27+
28+
refSubName = get_param(mdl+"/DC-DC Converter", "ReferencedSubsystem");
29+
verifyEqual(testCase, refSubName, 'DcDcConverterElec_refsub');
30+
31+
refSubName = get_param(mdl+"/Power Split Drive Unit", "ReferencedSubsystem");
32+
verifyEqual(testCase, refSubName, 'PowerSplitDriveUnitBasic_refsub');
33+
34+
refSubName = get_param(mdl+"/Longitudinal Vehicle", "ReferencedSubsystem");
35+
verifyEqual(testCase, refSubName, 'Vehicle1DCustom_refsub');
36+
37+
close all
38+
bdclose all
39+
end
40+
41+
function openAndRun_1(testCase)
42+
%% Most basic check - open model and run simulation.
43+
% Check that the model runs without any warnings or errors.
44+
45+
close all
46+
bdclose all
47+
48+
mdl = testCase.modelName;
49+
50+
t_end = 10; % Simulation stop time in seconds
51+
52+
load_system(mdl)
53+
54+
simIn = Simulink.SimulationInput(mdl);
55+
simIn = setModelParameter(simIn, "StopTime",num2str(t_end));
56+
sim(simIn);
57+
58+
close all
59+
bdclose all
60+
end % function
61+
62+
function openAndRun_2_1(testCase)
63+
%% Check that the model runs without any warnings or errors.
64+
% Specify the referenced subsystems.
65+
66+
close all
67+
bdclose all
68+
69+
mdl = testCase.modelName;
70+
71+
t_end = 10; % Simulation stop time in seconds
72+
73+
load_system(mdl)
74+
75+
set_param(mdl+"/High Voltage Battery", ...
76+
"ReferencedSubsystem", "BatteryHVBasic_refsub")
77+
78+
set_param(mdl+"/DC-DC Converter", ...
79+
"ReferencedSubsystem", "DcDcConverterBasic_refsub")
80+
81+
set_param(mdl+"/Power Split Drive Unit/Engine", ...
82+
"ReferencedSubsystem", "EngineBasic_refsub")
83+
84+
simIn = Simulink.SimulationInput(mdl);
85+
simIn = setModelParameter(simIn, "StopTime",num2str(t_end));
86+
sim(simIn);
87+
88+
close all
89+
bdclose all
90+
end % function
91+
92+
function openAndRun_2_2(testCase)
93+
%% Check that the model runs without any warnings or errors.
94+
% Specify the referenced subsystem.
95+
96+
close all
97+
bdclose all
98+
99+
mdl = testCase.modelName;
100+
101+
t_end = 10; % Simulation stop time in seconds
102+
103+
load_system(mdl)
104+
105+
set_param(mdl+"/High Voltage Battery", ...
106+
"ReferencedSubsystem", "BatteryHVElec_refsub")
107+
108+
set_param(mdl+"/DC-DC Converter", ...
109+
"ReferencedSubsystem", "DcDcConverterElec_refsub")
110+
111+
set_param(mdl+"/Power Split Drive Unit/Engine", ...
112+
"ReferencedSubsystem", "EngineCustom_refsub")
113+
114+
simIn = Simulink.SimulationInput(mdl);
115+
simIn = setModelParameter(simIn, "StopTime",num2str(t_end));
116+
sim(simIn);
117+
118+
close all
119+
bdclose all
120+
end % function
121+
122+
%% Test for Scripts
123+
% Check that scripts run without any warnings or errors.
124+
125+
function runLiveScript_DirectInput_Constant(~)
126+
close all
127+
bdclose all
128+
129+
% The "Constant" simulation is the most basic simulation
130+
% where nothing interesting happens,
131+
% but this ensures that everything in the script works fine.
132+
PowerSplitHEV_DI_testcase_Constant
133+
134+
close all
135+
bdclose all
136+
end
137+
138+
function runLiveScript_DirectInput_Accel(~)
139+
close all
140+
bdclose all
141+
PowerSplitHEV_DI_testcase_Accel
142+
close all
143+
bdclose all
144+
end
145+
146+
function runLiveScript_DirectInput_Downhill(~)
147+
close all
148+
bdclose all
149+
PowerSplitHEV_DI_testcase_Downhill
150+
close all
151+
bdclose all
152+
end
153+
154+
function runLiveScript_DirectInput_Downhill_2(~)
155+
close all
156+
bdclose all
157+
PowerSplitHEV_DI_testcase_Downhill_2
158+
close all
159+
bdclose all
160+
end
161+
162+
function runLiveScript_DirectInput_MG1Drive(~)
163+
close all
164+
bdclose all
165+
PowerSplitHEV_DI_testcase_MG1Drive
166+
close all
167+
bdclose all
168+
end
169+
170+
function runLiveScript_DirectInput_MG2Drive(~)
171+
close all
172+
bdclose all
173+
PowerSplitHEV_DI_testcase_MG2Drive
174+
close all
175+
bdclose all
176+
end
177+
178+
function runLiveScript_DirectInput_MG2Drive_2(~)
179+
close all
180+
bdclose all
181+
PowerSplitHEV_DI_testcase_MG2Drive_2
182+
close all
183+
bdclose all
184+
end
185+
186+
function runLiveScript_DirectInput_PowerSplitDrive(~)
187+
close all
188+
bdclose all
189+
PowerSplitHEV_DI_testcase_PowerSplitDrive
190+
close all
191+
bdclose all
192+
end
193+
194+
%{
195+
function runLiveScript_main_script(~)
196+
close all
197+
bdclose all
198+
PowerSplitHEV_DirectInput_main_script
199+
close all
200+
bdclose all
201+
end
202+
%}
203+
204+
end % methods (Test)
205+
end % classdef

0 commit comments

Comments
 (0)