function commblkbernoullisrc2_setprm(block, P, seed, frameBased, ...
                                     orient, outDataType)
%COMMBLKBERNOULLISRC2_SETPRM Mask function for Bernoulli Binary Generator 
%   block.
%
%   Sets subsystem block parameters after validation.

%   Copyright 2008-2015 The MathWorks, Inc.

% Set up underlying blocks/params based on whether sample/frame-based.
if frameBased % Frame-based case
    set_param([block, '/Frame Status Conversion'],'OutFrame','Frame-based');
    set_param([block, '/Reshape'],'OutputDimensionality','Customize');
    
    set_param([block, '/Constant'],'VectorParams1D','off',...
        'SamplingMode', 'Frame based');
else  % Sample-based case
    % Note: P below is possibly the expanded P (expanded by seed size)
    vLen = [length(P) length(seed)];
    vSize = {size(P) size(seed)};
    dimcomp = find(vLen~=1, 1); % Index of the first vector parameter
                                % used for comparison with other parameters
    
    set_param([block, '/Frame Status Conversion'],'OutFrame','Sample-based');
    
    % Interpret as 1-D; OR scalar output
    if (orient) || ~any(vLen-1)
        set_param([block, '/Reshape'],'OutputDimensionality','1-D array');
        set_param([block, '/Constant'],'VectorParams1D','on',...
                'SamplingMode','Sample based');
    else % 2-D vector output
        set_param([block, '/Constant'],'VectorParams1D','off',...
                'SamplingMode','Sample based');
        
        vec = vSize{dimcomp};
        if vec(1) > vec(2) % Column vector
            set_param([block, '/Reshape'],'OutputDimensionality', ...
                    'Column vector');
        else  % Row vector
            set_param([block, '/Reshape'],'OutputDimensionality','Row vector');
        end
    end
end

% Set the output datatype based on user selection
switch (outDataType)
    % Set the Relational Operator block's output type
    case 1 % 'boolean'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'boolean');
    case 2 %'int8'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'sint(8)');
    case 3 %'uint8'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'uint(8)');
    case 4 %'int16'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'sint(16)');
    case 5 %'uint16'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'uint(16)');
    case 6 %'int32'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'sint(32)');
    case 7 %'uint32'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'uint(32)');
    case 8 %'single'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'float(''single'')');
    case 9 %'double'
        set_param([block, '/Relational Operator'],'OutDataTypeStr', 'float(''double'')');
end

% For single outputs, also set the SP Random source type. The outputs are
% different as compared to double.
if isequal(outDataType, 8) % single
    set_param([block, '/Random Source'],'DataType','Single');
    set_param([block, '/Constant'],'OutDataTypeStr','single');
else
    set_param([block, '/Random Source'],'DataType','Double');
    set_param([block, '/Constant'],'OutDataTypeStr','double');
end
    
% [EOF]
