classdef (Hidden = true) SubsystemSfunction < rtw.pil.ModelBlockSfunction
%SubsystemSfunction creates an s-function for Subsystem SIL/PIL
%
% This is an undocumented class. Its methods and properties are likely to
% change without warning from one release to the next.

% Copyright 2019-2020 The MathWorks, Inc.

methods
% constructor
function this = SubsystemSfunction(silPILWrapperUtils, ...
sfunSourcePath, ...
sfunOutDir)
narginchk(3, 3);

% call super class constructor
this@rtw.pil.ModelBlockSfunction(silPILWrapperUtils, ...
sfunSourcePath, ...
sfunOutDir);
end
end

methods(Access = protected)
function doProcess = needToProcessEnableDisableFcn(~)
% always process Enable/Disable functions
doProcess = true;
end

function validateNumIOPortsAgainstSourceComponent(this)
% check the number of inports and outports in code descriptor
% matches up with the number of inports and outports in the
% subsystem graphical interface
errorId = 'PIL:pil_subsystem:NumIOPortMismatch';
this.validateNumIOPortsImplementation(errorId);
end

function disallowSampleTimeInheritance = checkSTInheritanceRule(~, disallowSampleTimeInheritance, ~)
% For RLS the error is not thrown because the harness
% locks down the sample time and prevents the subsystem to have
% different sample time between normal (unconstrained) and SIL
% (as specified in code descriptor at 0.2)
end

function [origModel, currModel] = getGlobalDSMRegistrationModels(this, dsmSID)
% A global DSM should be registered to the hidden model
assert(isempty(dsmSID), 'Global DSM for Subsystem should be empty.');
currModel = this.SILPILWrapperUtils.getLoadableRootComponent();
origModel = currModel;
end
end
end