function inputMap = slexCustomMappingMyCustomMap(modelName,signalNames, signals)
%

% Copyright 2012-2017 The MathWorks, Inc.

%Convert string to char
if isStringScalar( modelName )
    
    modelName = char( modelName );
    
end

%Convert string to cellstr
if isstring( signalNames ) && ~isscalar( signalNames )
    
    signalNames = signalNames.cellstr;
    
end

%IF is a data set
if isa( signals{1}, 'Simulink.SimulationData.Dataset')
    signalNames = signals{1}.getElementNames';
end

inputMap = getRootInportMap('empty');
%IF model is loaded
if bdIsLoaded(modelName)
    %get the inportNames
    inportNames = slexCustomMappingGetPortNames(modelName,'Inport');
    %get the enableNames
    enableName = slexCustomMappingGetPortNames(modelName,'EnablePort');
    %get the triggerNames
    triggerName = slexCustomMappingGetPortNames(modelName,'TriggerPort');
    portNumber = cell(1,length(inportNames) + ...
        length(enableName) + length(triggerName));
    %FOR EACH INPORT GET PORT NUMBERS
    for kInport =1:length(inportNames)
        portNumber{kInport} = ...
            slexCustomMappingGetPortNumber(modelName,inportNames{kInport});
    end
    %IF ENABLE IS NOT EMPTY
    if ~isempty(enableName)
        portNumber{length(inportNames)+1} = num2str(length(inportNames) + ...
            length(enableName));
    end
    %IF TRIGGER IS NOT EMPTY
    if ~isempty(triggerName)
        portNumber{length(portNumber) + length(enableName) +1} = num2str(length(inportNames) + ...
            length(enableName) + length(triggerName));
    end
    portNumber(cellfun(@isempty,portNumber)) = [];
    portNames = [inportNames' enableName triggerName];
    portNames(cellfun(@isempty,portNames)) = [];
    if ~isempty(portNumber)
        %GET THE NUMBER FROM THE SIGNAL
        numericValue = slexCustomMappingGetNumericValue(signalNames);
        %IS THERE A MATCH
        [bool , loc] = ismember(numericValue,portNumber);
        %IF YES MAKE MAP
        inputMap = getRootInportMap(...
            'model',modelName,...
            'signalName',signalNames(loc(bool)),...
            'blockName',portNames(loc(bool)));
    end
end