classdef bypass < handle
%

%   Copyright 2019-2021 The MathWorks, Inc.

    methods (Static = true)
        
        function dlTag = getDAQListTag
            port = get_param(gcb,'PortConnectivity');
            fcnCall = port.DstBlock;
            % @todo update the usage of edit-time filter filterOutInactiveVariantSubsystemChoices()
            % instead use the post-compile filter activeVariants() - g2603543
            daqBlk = find_system(fcnCall,'MatchFilter',@Simulink.match.internal.filterOutInactiveVariantSubsystemChoices, 'FollowLinks', 'on', 'IncludeCommented', 'off', 'LookUnderMasks', 'on', 'MaskType', 'XCP UDP Data Acquisition' ); % look only inside active choice of VSS
            %dlTag is just the blk path with spaces instead of newline
            dlTag = regexprep(getfullname(daqBlk),'[\n\r]+',' ');
        end
        
        function validateModel
            port = get_param(gcb,'PortConnectivity');
            fcnCall = port.DstBlock;
            if isempty(fcnCall)
                return;
            end
            if strcmp(get_param(fcnCall,'Commented'), 'on')
                return
            end
                
            % @todo update the usage of edit-time filter filterOutInactiveVariantSubsystemChoices()
            % instead use the post-compile filter activeVariants() - g2603543
            daqBlk = find_system(fcnCall,'MatchFilter',@Simulink.match.internal.filterOutInactiveVariantSubsystemChoices, 'FollowLinks', 'on', 'IncludeCommented', 'off', 'LookUnderMasks', 'on', 'MaskType', 'XCP UDP Data Acquisition' ); % look only inside active choice of VSS
            %Error if function-call subsystem doesn't contain a DAQ block
            %or more than one daq block
            if isempty(daqBlk) || length(daqBlk)>1
                error(message('xcp:xcpblks:connBypassToDAQFcnCall'));
            end

        end
    end


end
