function validateMappedEventSources(modelName)
% VALIDATEMAPPEDEVENTSOURCES Validate mapped event sources

%   Copyright 2023 The MathWorks, Inc.

hCS = getActiveConfigSet(modelName);
data = get_param(hCS, 'CoderTargetData');
isValid = 1;

if isfield(data, 'TaskMap')
    if isfield(data.TaskMap, 'Tasks')
        allTasks = fieldnames(data.TaskMap.Tasks);
        for i=1:numel(allTasks)
            mappedSource = data.TaskMap.Tasks.(allTasks{i}).MappedSource;
            if contains(mappedSource, 'unspecified', 'IgnoreCase',true)
                isValid = 0;
                break
            end
        end
    end
end
if ~isValid
    error(message('TIC2000:codegen:MappedSourceInvalid'));
end
end