function [A,B,C,D] = pfcblock_utilGetDiscreteModelForMPCHasSpacingCtrl(Ts,Vx,Ag,Bg,Cg,lag,hasLag)
%#codegen
%
% Get discrete state-space model for Adaptive MPC. Called by the "Path
% Following Control System" Block. This function is called when "Spacing
% control" is enabled.

% Inputs:
%   Ts:                mask variable for sample time
%   Vx:                mask inport for longitudinal velocity
%   Ag,Bg,Cg:          continuous or discrete vehicle model with sample time Ts    
%   lag:               lumped lag in the model
%   hasLag:            indicating if lag>0 (true or false)

% Outputs:
%   A,B,C,D:           discrete time model for MPC

%   Author: Meng Xia, Rong Chen
%   Copyright 2017-2018 The MathWorks, Inc.

% Discrete MPC model
if hasLag
    [A,B,C,D] = pfcblock_utilGetDTModelHasLagForMPCHasSpacingCtrl(Ts,Vx,Ag,Bg,Cg,lag);
else
    [A,B,C,D] = pfcblock_utilGetDTModelNoLagForMPCHasSpacingCtrl(Ts,Vx,Ag,Bg,Cg);
end






