%% set_block_display
%    update a block based on an inputed boolean value representing
%    the typecheck state.
% inputs:
%   block_handle:handle - handle block to update
%   checked:boolean - 0 if not typechecked, 1 if typechecked
% outputs:
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function [] = set_block_display(block_handle,checked)
%if object.pvs_checked == 1
mask_string = [];
code_block = sprintf('%s/code',getfullname(block_handle));
in_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Inport');
for i = 1:size(in_handles,1)
    mask_string = [mask_string 'port_label(''input'',' int2str(i) ',''' get_param(in_handles(i),'Name') ''');' ];
end

out_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Outport');
for i = 1:size(out_handles,1)
    mask_string = [mask_string 'port_label(''output'',' int2str(i) ',''' get_param(out_handles(i),'Name') ''');' ];
end

mask_string = [mask_string 'text(0.5, 0.9, ''Tabular Expression'', ''horizontalAlignment'', ''center'');'];
if checked == 0
    mask_string = [mask_string 'color(''red'');text(0.5, 0.1, ''Not Checked'', ''horizontalAlignment'', ''center'')'];
else
    mask_string = [mask_string 'color(''green'');text(0.5, 0.1, ''Checked'', ''horizontalAlignment'', ''center'')'];
    
end
set_param(getfullname(block_handle),'MaskDisplay',mask_string);
end

