function helperEDRModulationTestVerdict(phyMode,...
    edrTestParams,estimatedInitFreqOff,symRMSDEVM,...
    blockRMSDEVM,blockFreqDrifts)
%helperEDRModulationTestVerdict Displays the 
%test verdict for transmitter test corresponding to EDR modulation accuracy
%and carrier frequency stability.
%   helperEDRModulationTestVerdict...
%   (PHYMODE,EDRTESTPARAMS,ESTIMATEDINITFREQOFF,SYMRMSDEVM,...
%   SYMPEAKDEVM,BLOCKRMSDEVM,BLOCKFREQDRIFTS) plots DEVM measurements and
%   displays the test verdict.
%
%   PHYMODE specifies the physical layer transmission mode, specified as 
%   'EDR2M' or 'EDR3M'.
%   
%   EDRTESTPARAMS structure containing the EDR modulation accuracy and carrier 
%   frequency stability test parameters.
%
%   ESTIMATEDINITFREQOFF specifies the estimated initial frequency offset.
%   
%   SYMRMSDEVM is a vector specifying all the RMS DEVM measurements of each
%   symbol.
%
%   BLOCKRMSDEVM is a vector specifying all the RMS DEVM measurements of
%   each block.
%
%   BLOCKFREQDRIFTS is a vector specifying all the estimated frequency
%   drift values of each block.

%   Copyright 2020 The MathWorks, Inc.

% Display simulation results
% Display RMS DEVM results
disp('Modulation Accuracy Test Results: ');
% Plot RMS DEVM at symbol level
figure,
plot(symRMSDEVM(1:edrTestParams.requiredBlocks*edrTestParams.blockLength));
grid on
title('Payload Symbol DEVM');
xlabel('Symbol Index');
ylabel('DEVM');
if strcmp(phyMode,'EDR2M')
    disp('       Expected peak DEVM for all pi/4-DQPSK symbols is less than or equal to 0.35');
    if (max(symRMSDEVM(1:edrTestParams.requiredBlocks)))<0.35
        disp('       Result: Pass');
    else
        disp('       Result: Fail');
    end
else
    disp('       Expected peak DEVM for all 8-DPSK symbols is less than or equal to 0.13');
    if (max(symRMSDEVM(1:edrTestParams.requiredBlocks)))<0.13
        disp('       Result: Pass');
    else
        disp('       Result: Fail');
    end
end
if strcmp(phyMode,'EDR2M')
    estimatedPercentage = ((sum(blockRMSDEVM(1:edrTestParams.requiredBlocks) < 0.3))/edrTestParams.requiredBlocks)*100;
    disp(['       Percentage of pi/4-DQPSK symbols with DEVM less than or equal to 0.3 is ',...
    num2str(estimatedPercentage)]);        
    disp('       Expected percentage of pi/4-DQPSK symbols with DEVM less than or equal to 0.3 is 99 % ');
    if estimatedPercentage>=99
        disp('       Result: Pass');
    else
        disp('       Result: Fail');
    end
else
    estimatedPercentage = ((sum(blockRMSDEVM(1:edrTestParams.requiredBlocks) < 0.2))/edrTestParams.requiredBlocks)*100;
    disp(['       Percentage of 8-DPSK symbols with DEVM less than or equal to 0.25 is ',...
    num2str(estimatedPercentage)]);        
    disp('       Expected percentage of pi/4-DQPSK symbols with DEVM less than or equal to 0.25 is 99 % ');
    if estimatedPercentage>=99
        disp('       Result: Pass');
    else
        disp('       Result: Fail');
    end
end

% RMS DEVM at block level
figure,plot(blockRMSDEVM(1:edrTestParams.requiredBlocks) )
grid on
title('Block RMS DEVM')
xlabel('Block Index')
ylabel('RMS DEVM')
if strcmp(phyMode,'EDR2M')
    disp('       Expected RMS DEVM for all pi/4-DQPSK blocks is less than or equal to 0.2');
    if (max(blockRMSDEVM(1:edrTestParams.requiredBlocks)))<0.2
        disp('       Result: Pass');
    else
        disp('       Result: Fail');
    end
else
    disp('       Expected peak DEVM for all 8-DPSK symbols is less than or equal to 0.13');
    if (max(blockRMSDEVM(1:edrTestParams.requiredBlocks)))<0.13
        disp('       Result: Pass');
    else
        disp('       Result: Fail');
    end
end
% Display Carrier Frequency Stability Test
% Display estimated initial frequency offset
disp('Carrier Frequency Stability Test Results: ');
disp ('       Expected initial frequency offset range: [-75 kHz, 75 kHz]');
disp ('       Do estimated initial frequency offsets for all the packets fall under expected values?');
if (all((estimatedInitFreqOff/1e3 >= -75)) && all((estimatedInitFreqOff/1e3 <= 75)))
    disp('       Result: Yes');
else
    disp('       Result: No');
end
% Display estimated sampling frequency
disp ('       Expected sampling frequencies range: [-10 kHz, 10 kHz]');
disp ('       Do estimated sampling frequencies for all the blocks fall under expected values?');

if (all(blockFreqDrifts/1e3 >= -10) && all(blockFreqDrifts/1e3 <= 10))
    disp('       Result: Yes');
else
    disp('       Result: No');
end
end