%%helperCreateBusLaneInfo creates a bus object used by
% HighwayLaneFollowingWithIntelligentVehiclesTestBench.slx
%
%   This is a helper script for example purposes and may be removed or
%   modified in the future.

% Copyright 2020 The MathWorks, Inc.

function helperCreateBusLaneInfo(laneInfo)
%helperCreateBusLaneInfo the helper function updates the dimension
%"LaneCenters" of BusLaneInfo based on the number of points in LaneCenters.
    % Create bus for BusLaneInfo
    BusLaneInfo = Simulink.Bus;
    BusLaneInfo.Description = '';
    BusLaneInfo.DataScope = 'Auto';
    BusLaneInfo.HeaderFile = '';
    BusLaneInfo.Alignment = -1;
    saveVarsTmp{1} = Simulink.BusElement;
    saveVarsTmp{1}.Name = 'LaneWidth';
    saveVarsTmp{1}.Complexity = 'real';
    saveVarsTmp{1}.Dimensions = [1 1];
    saveVarsTmp{1}.DataType = 'double';
    saveVarsTmp{1}.Min = [];
    saveVarsTmp{1}.Max = [];
    saveVarsTmp{1}.DimensionsMode = 'Fixed';
    saveVarsTmp{1}.SamplingMode = 'Sample based';
    saveVarsTmp{1}.SampleTime = -1;
    saveVarsTmp{1}.DocUnits = '';
    saveVarsTmp{1}.Description = '';
    saveVarsTmp{1}(2, 1) = Simulink.BusElement;
    saveVarsTmp{1}(2, 1).Name = 'LaneDirection';
    saveVarsTmp{1}(2, 1).Complexity = 'real';
    saveVarsTmp{1}(2, 1).Dimensions = [1 1];
    saveVarsTmp{1}(2, 1).DataType = 'double';
    saveVarsTmp{1}(2, 1).Min = [];
    saveVarsTmp{1}(2, 1).Max = [];
    saveVarsTmp{1}(2, 1).DimensionsMode = 'Fixed';
    saveVarsTmp{1}(2, 1).SamplingMode = 'Sample based';
    saveVarsTmp{1}(2, 1).SampleTime = -1;
    saveVarsTmp{1}(2, 1).DocUnits = '';
    saveVarsTmp{1}(2, 1).Description = '';
    saveVarsTmp{1}(3, 1) = Simulink.BusElement;
    saveVarsTmp{1}(3, 1).Name = 'LaneCenters';
    saveVarsTmp{1}(3, 1).Complexity = 'real';
    saveVarsTmp{1}(3, 1).Dimensions = size(laneInfo(1).LaneCenters);
    saveVarsTmp{1}(3, 1).DataType = 'double';
    saveVarsTmp{1}(3, 1).Min = [];
    saveVarsTmp{1}(3, 1).Max = [];
    saveVarsTmp{1}(3, 1).DimensionsMode = 'Fixed';
    saveVarsTmp{1}(3, 1).SamplingMode = 'Sample based';
    saveVarsTmp{1}(3, 1).SampleTime = -1;
    saveVarsTmp{1}(3, 1).DocUnits = '';
    saveVarsTmp{1}(3, 1).Description = '';
    BusLaneInfo.Elements = saveVarsTmp{1};
    clear saveVarsTmp;
    
    assignin('base', 'BusLaneInfo', BusLaneInfo);
end