function [propertyName,propertyField] = computeLoad(elem,objcomputeBatterySizing)

%% Overview
% computeLoad : used by iterator to iterate through each component of the
% model. computeLoad collates the stereotype values and sets the values of
% the corresponding memeber varaibles of computeBatterySizing class.
%%

% initialize property values
propertyName = [];
propertyField =  [];

% fetch prototype info
protoTypes = elem.getStereotypes ;  %#ok<*NASGU>

% since the prototypes are added to the component's arch, extract details
% from arch. If the Parent is empty, then it is a model.
if isa(elem,'systemcomposer.arch.BaseComponent') && (~isempty(elem.Parent))
    
    archName =  elem.Architecture.Name;
    protoTypes = elem.Architecture.getStereotypes; 
    
else
    
    archName = '';
    protoTypes = '';
    
end


%%
% Collate info from each ach component based on Properties values

if ~isempty(protoTypes)
    
    for profileIndex = 1:length(protoTypes)
        
        if(~strcmp(protoTypes{profileIndex}, 'systemcomposer'))
            
            protoQualName = protoTypes{profileIndex} ;
            posIdentifier = strfind(protoQualName,'.') ;
            profileName = protoQualName(posIdentifier+1:end);
            
            % Battery specific properties
            if strcmp(profileName,'Battery')
                
                objcomputeBatterySizing.batteryCCA = str2double(elem.Battery.ColdCrankingAmps);
                objcomputeBatterySizing.batteryCapacity = str2double(elem.Battery.Capacity);
                
            end
            
            % Crancking In-rush current sum from all components active
            % during cranking
            if strcmp(profileName,'Inductive_Load') & (elem.(profileName).isActiveDuringCranking) %#ok<*AND2>
                
                objcomputeBatterySizing.totalCrankingInrushCurrent = objcomputeBatterySizing.totalCrankingInrushCurrent + str2double(elem.(profileName).InrushCurrent);
                objcomputeBatterySizing.totalCrankingCurrent = objcomputeBatterySizing.totalCrankingCurrent + (str2double(elem.(profileName).Power)/str2double(elem.(profileName).Voltage));
                
            end
            
            if strcmp(profileName,'Resistive_Load') & (elem.(profileName).isActiveDuringCranking) %#ok<*AND2>
                
                objcomputeBatterySizing.totalCrankingCurrent = objcomputeBatterySizing.totalCrankingCurrent + (str2double(elem.(profileName).Power)/str2double(elem.(profileName).Voltage));
                
            end
                        
            % Total Acc load
            if (strcmp(profileName,'Inductive_Load') | strcmp(profileName,'Resistive_Load'))  %#ok<*OR2>
                
                if (elem.(profileName).isAcc)
                    
                    objcomputeBatterySizing.totalAccesoriesCurrent = objcomputeBatterySizing.totalAccesoriesCurrent + (str2double(elem.(profileName).Power)/str2double(elem.(profileName).Voltage));
                    
                end
            end
            
            % Total Key Off load - resistive
            if(strcmp(profileName,'Resistive_Load'))
                
                objcomputeBatterySizing.totalKeyOffLoad = objcomputeBatterySizing.totalKeyOffLoad + str2double(elem.(profileName).KeyOffLoad);
                
            end
            
            % Total Key off load - inductive
            if(strcmp(profileName,'Inductive_Load'))
                
                objcomputeBatterySizing.totalKeyOffLoad = objcomputeBatterySizing.totalKeyOffLoad + str2double(elem.(profileName).KeyOffload);
                
            end
            
            
        end
        
    end
    
    
end


