diff --git a/+TableBlock/delete_recursive.m b/+TableBlock/delete_recursive.m index c73fb428b80f301ad51d4c394a4de77567d8c5a6..18268887ffc8125c28ef527afbde045592796a58 100644 --- a/+TableBlock/delete_recursive.m +++ b/+TableBlock/delete_recursive.m @@ -1,29 +1,20 @@ - %% delete_recursive - % delete any lines that are unconnected and one end or both - % code from - % http://www.mathworks.com/matlabcentral/fileexchange/12352-delete-unconnected-lines - % Copyright (c) 2009, Per-Anders Ekström - function delete_recursive( line ) - %DELETE_RECURSIVE( LINE ) Delete line if: - % 1) do not have any source-block - % 2) do not have any line-children AND no destination-block - % otherwise go recursively through all eventual line-children +%% delete_recursive +function delete_recursive( line_handle ) + +if get( line_handle, 'SrcPortHandle' ) < 0 + delete_line( line_handle ) ; + return +end +LineChild = get( line_handle, 'LineChildren' ) ; +if ~isempty( LineChild ) + for i=1:length( LineChild ) + obj.delete_recursive( LineChild( i ) ) + end +else + if get( line_handle, 'DstPortHandle' ) < 0 + delete_line( line_handle ) ; + end +end +end + - if get( line, 'SrcPortHandle' ) < 0 - delete_line( line ) ; - return - end - LineChildren = get( line, 'LineChildren' ) ; - if isempty( LineChildren ) - if get( line, 'DstPortHandle' ) < 0 - delete_line( line ) ; - end - else - for i=1:length( LineChildren ) - obj.delete_recursive( LineChildren( i ) ) - end - end - end - % end copyright - - diff --git a/+TableBlock/set_block_display.m b/+TableBlock/set_block_display.m index d1ce718689e542997b6091e854f45376b2687279..cb6691e403cc728d55b28a668882944a9b4b2b0c 100644 --- a/+TableBlock/set_block_display.m +++ b/+TableBlock/set_block_display.m @@ -1,32 +1,34 @@ %% 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 - 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'')']; +% 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 - end - set_param(getfullname(block_handle),'MaskDisplay',mask_string); - end - diff --git a/+TableBlock/set_code.m b/+TableBlock/set_code.m index 1398710b2095738018226bdff185065620c69763..231f5361c606aaaea15010d9e761262d7ca18d4c 100644 --- a/+TableBlock/set_code.m +++ b/+TableBlock/set_code.m @@ -1,196 +1,188 @@ - %% set_code - % set the script of an embedded matlab block to an inputed - % string of eml code, create the inputs and outputs for the - % subsystem to connect to the eml block - % inputs: - % block_handle:handle - handle block to update - % code:string - eml code - % function_name:string - name of the function - % outputs: - % eml_handle:handle - handle of eml block, as this function may - % create a new block. - function eml_handle = set_code(block_handle,code,function_name) - % unlink the block from the library, this is necessary if - % we - % want to change the subsystem of the block. - set_param(block_handle,'LinkStatus','none') - - - % determine if the name already exists in the model - - if (~strcmp(get(block_handle,'Name'),function_name)) - try - set_param(block_handle,'Name',function_name); - catch exception - msgbox(exception.message); - end - end - - % embedded matlab code block store code in stateflow states so - % we need to get the root hande - S = sfroot; - - % get the path of the code block - code_block = sprintf('%s/code',getfullname(block_handle)); - % determine if code block already exists - code_blocks = find_system(getfullname(block_handle),'LookUnderMasks','all','BlockType','SubSystem','Name','code'); - - % if the code block does not already exists we need to create a - % new one - if (isempty(code_blocks)) - code_blocks = add_block('simulink/User-Defined Functions/Embedded MATLAB Function',code_block); - end - - eml_handle = code_blocks - % find the state of the code block and update it to the new - % code - myState = S.find('-isa','Stateflow.EMChart', '-and', 'Path', code_block); % find which one we want to edit - - if (~isempty(myState)) - myState.Script = sprintf('%s',code); - end - - % delete any lines that are unconnected and one end or both - % code from - % http://www.mathworks.com/matlabcentral/fileexchange/12352-delete-unconnected-lines - % Copyright (c) 2009, Per-Anders Ekström - % delete all the lines - lines = find_system( getfullname(block_handle), ... - 'LookUnderMasks', 'all', ... - 'FindAll', 'on', ... - 'Type', 'line' ) ; - - - % for each line, call delete_recursive if handle still exist - for i=1:length( lines ) - if ishandle( lines( i ) ) - TableBlock.delete_recursive( lines( i ) ) - end - end - % end copyright - - % we need to determine which of the inports and outports we - % need to create and delete. Whenever we delete a port anything - % connected with this port is unconnected, other blocks, scopes - % etc. We would like to avoid this if possible because it can - % be quite annoying. - - % First loop through all the inport blocks, if there does not - % exists an inport in the code block of the same name then - % delete the inport block - inports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'FindAll','On','BlockType','Inport'); - for i=1:size(inports,1) - found = 0; - in_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Inport'); - - for j=1:size(in_handles,1) - if strcmp(get_param(inports(i),'Name'),get_param(in_handles(j),'Name')) - found = 1; - end - end - - if (~found) - % old inport no longer exists - delete_block(inports(i)); - end - end - - % now we loop through all the inports in the code block if - % there is an inport block of the same name then connect them, - % else create a new inport block and connect them - in_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Inport'); - for j = 1:size(in_handles,1) - found = 0; - inports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'BlockType','Inport'); - for i = 1:size(inports,1) - if strcmp(get_param(inports(i),'Name'),get_param(in_handles(j),'Name')) - found = 1; - - % draw the line - new_port_num = sprintf('%s/1',get_param(in_handles(j),'Name')); - dest_port = sprintf('%s/%d','code',j); - try - add_line(getfullname(block_handle),new_port_num,dest_port); - end - end - end - if (~found) - new_port = sprintf('%s/%s',getfullname(block_handle),get_param(in_handles(j),'Name')); - add_block('simulink/Sources/In1',new_port) - new_port_num = sprintf('%s/1',get_param(in_handles(j),'Name')); - dest_port = sprintf('%s/%d','code',j); - % sometimes line will be created automatically - try - add_line(getfullname(block_handle),new_port_num,dest_port); - end - end - - - end - - - % Next we do the same thing with the outputs - outports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'FindAll','On','BlockType','Outport'); - for i=1:size(outports,1) - found = 0; - out_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Outport'); - - for j=1:size(out_handles,1) - if strcmp(get_param(outports(i),'Name'),get_param(out_handles(j),'Name')) - found = 1; - end - end - - if (~found) - % old inport no longer exists - delete_block(outports(i)); - end - end - - out_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Outport'); - for j = 1:size(out_handles,1) - found = 0; - outports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'BlockType','Outport'); - for i = 1:size(outports,1) - if strcmp(get_param(outports(i),'Name'),get_param(out_handles(j),'Name')) - found = 1; - - % draw the line - new_port_num = sprintf('%s/1',get_param(out_handles(j),'Name')); - dest_port = sprintf('%s/%d','code',j); - try - add_line(getfullname(block_handle),dest_port,new_port_num); - end - end - end - if (~found) - new_port = sprintf('%s/%s',getfullname(block_handle),get_param(out_handles(j),'Name')); - add_block('simulink/Sinks/Out1',new_port) - new_port_num = sprintf('%s/1',get_param(out_handles(j),'Name')); - dest_port = sprintf('%s/%d','code',j); - try - add_line(getfullname(block_handle),dest_port,new_port_num); - end - end - end - - % delete any lines that are unconnected and one end or both - % again sometimes extra lines are created - % code from - % http://www.mathworks.com/matlabcentral/fileexchange/12352-delete-unconnected-lines - % Copyright (c) 2009, Per-Anders Ekström - % delete all the lines - lines = find_system( getfullname(block_handle), ... - 'LookUnderMasks', 'all', ... - 'FindAll', 'on', ... - 'Type', 'line' ) ; - - % for each line, call delete_recursive if handle still exist - for i=1:length( lines ) - if ishandle( lines( i ) ) - TableBlock.delete_recursive( lines( i ) ) - end - end - % end copyright - - end \ No newline at end of file +%% set_code +% set the script of an embedded matlab block to an inputed +% string of eml code, create the inputs and outputs for the +% subsystem to connect to the eml block +% inputs: +% block_handle:handle - handle block to update +% code:string - eml code +% function_name:string - name of the function +% outputs: +% eml_handle:handle - handle of eml block, as this function may +% create a new block. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function eml_handle = set_code(block_handle,code,function_name) +% unlink the block from the library, this is necessary if +% we +% want to change the subsystem of the block. +set_param(block_handle,'LinkStatus','none') + + +% determine if the name already exists in the model + +if (~strcmp(get(block_handle,'Name'),function_name)) + try + set_param(block_handle,'Name',function_name); + catch exception + msgbox(exception.message); + end +end + +% embedded matlab code block store code in stateflow states so +% we need to get the root hande +S = sfroot; + +% get the path of the code block +code_block = sprintf('%s/code',getfullname(block_handle)); +% determine if code block already exists +code_blocks = find_system(getfullname(block_handle),'LookUnderMasks','all','BlockType','SubSystem','Name','code'); + +% if the code block does not already exists we need to create a +% new one +if (isempty(code_blocks)) + code_blocks = add_block('simulink/User-Defined Functions/Embedded MATLAB Function',code_block); +end + +eml_handle = code_blocks +% find the state of the code block and update it to the new +% code +myState = S.find('-isa','Stateflow.EMChart', '-and', 'Path', code_block); % find which one we want to edit + +if (~isempty(myState)) + myState.Script = sprintf('%s',code); +end + +% delete any lines that are unconnected and one end or both +% code from +lines = find_system( getfullname(block_handle), ... + 'LookUnderMasks', 'all', ... + 'FindAll', 'on', ... + 'Type', 'line' ) ; + + +for i=1:length( lines ) + if ishandle( lines( i ) ) + TableBlock.delete_recursive( lines( i ) ) + end +end + + +% we need to determine which of the inports and outports we +% need to create and delete. Whenever we delete a port anything +% connected with this port is unconnected, other blocks, scopes +% etc. We would like to avoid this if possible because it can +% be quite annoying. + +% First loop through all the inport blocks, if there does not +% exists an inport in the code block of the same name then +% delete the inport block +inports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'FindAll','On','BlockType','Inport'); +for i=1:size(inports,1) + found = 0; + in_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Inport'); + + for j=1:size(in_handles,1) + if strcmp(get_param(inports(i),'Name'),get_param(in_handles(j),'Name')) + found = 1; + end + end + + if (~found) + % old inport no longer exists + delete_block(inports(i)); + end +end + +% now we loop through all the inports in the code block if +% there is an inport block of the same name then connect them, +% else create a new inport block and connect them +in_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Inport'); +for j = 1:size(in_handles,1) + found = 0; + inports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'BlockType','Inport'); + for i = 1:size(inports,1) + if strcmp(get_param(inports(i),'Name'),get_param(in_handles(j),'Name')) + found = 1; + + % draw the line + new_port_num = sprintf('%s/1',get_param(in_handles(j),'Name')); + dest_port = sprintf('%s/%d','code',j); + try + add_line(getfullname(block_handle),new_port_num,dest_port); + end + end + end + if (~found) + new_port = sprintf('%s/%s',getfullname(block_handle),get_param(in_handles(j),'Name')); + add_block('simulink/Sources/In1',new_port) + new_port_num = sprintf('%s/1',get_param(in_handles(j),'Name')); + dest_port = sprintf('%s/%d','code',j); + % sometimes line will be created automatically + try + add_line(getfullname(block_handle),new_port_num,dest_port); + end + end + + +end + + +% Next we do the same thing with the outputs +outports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'FindAll','On','BlockType','Outport'); +for i=1:size(outports,1) + found = 0; + out_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Outport'); + + for j=1:size(out_handles,1) + if strcmp(get_param(outports(i),'Name'),get_param(out_handles(j),'Name')) + found = 1; + end + end + + if (~found) + % old inport no longer exists + delete_block(outports(i)); + end +end + +out_handles=find_system(code_block, 'SearchDepth',1,'FindAll','On','FollowLinks','On','LookUnderMasks','All','BlockType','Outport'); +for j = 1:size(out_handles,1) + found = 0; + outports = find_system(getfullname(block_handle),'LookUnderMasks','all','SearchDepth',1,'BlockType','Outport'); + for i = 1:size(outports,1) + if strcmp(get_param(outports(i),'Name'),get_param(out_handles(j),'Name')) + found = 1; + + % draw the line + new_port_num = sprintf('%s/1',get_param(out_handles(j),'Name')); + dest_port = sprintf('%s/%d','code',j); + try + add_line(getfullname(block_handle),dest_port,new_port_num); + end + end + end + if (~found) + new_port = sprintf('%s/%s',getfullname(block_handle),get_param(out_handles(j),'Name')); + add_block('simulink/Sinks/Out1',new_port) + new_port_num = sprintf('%s/1',get_param(out_handles(j),'Name')); + dest_port = sprintf('%s/%d','code',j); + try + add_line(getfullname(block_handle),dest_port,new_port_num); + end + end +end + +% delete any lines that are unconnected and one end or both +% again sometimes extra lines are created +lines = find_system( getfullname(block_handle), ... + 'LookUnderMasks', 'all', ... + 'FindAll', 'on', ... + 'Type', 'line' ) ; + +for i=1:length( lines ) + if ishandle( lines( i ) ) + TableBlock.delete_recursive( lines( i ) ) + end +end + +end \ No newline at end of file diff --git a/@Cell/cal_height.m b/@Cell/cal_height.m index fb409ba2776c694612c33c4e86f340f2dfc465e5..329bfcebb8f928011953630d01fd0546de44cef3 100644 --- a/@Cell/cal_height.m +++ b/@Cell/cal_height.m @@ -3,24 +3,25 @@ % if the cell does not have a subgrid the height will be 1, else % it will be the height of the subgrid. % inputs: -% object:Cell - Current Cell Object +% object:Cell - Current Cell Object % edit:boolean - 0 when not in edit mode, 1 in edit mode % outputs; % h:double - height in number of cells +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function h = cal_height(object,edit) - h = 0; - if (isempty(object.subgrid)) - h = 1; - else - for i=1:size(object.subgrid.cells,2) - h = h + cal_height(object.subgrid.cells(i),edit); - end - % edit button is half a cell high, if in edit mode increase - % by 0.5 - if (edit == 1) - h = h + 0.5; - end - +h = 0; +if (isempty(object.subgrid)) + h = 1; +else + for i=1:size(object.subgrid.cells,2) + h = h + cal_height(object.subgrid.cells(i),edit); end + % edit button is half a cell high, if in edit mode increase + % by 0.5 + if (edit == 1) + h = h + 0.5; + end + +end end - \ No newline at end of file diff --git a/@Cell/delete_Cell.m b/@Cell/delete_Cell.m index 26c72d2ada47c516878971c8602b8b36b233a53b..caca6344d6890a9be719d3d115128125369ef4d0 100644 --- a/@Cell/delete_Cell.m +++ b/@Cell/delete_Cell.m @@ -1,28 +1,29 @@ - %% delete_Cell - % deletes the current cell, will recursively delete any subgrids - % if they exist. - % inputs: - % object:Cell - Current Cell Object - % outputs; - % none - function [] = delete_Cell(object) - if(isempty(object.subgrid)) - delete(object.grid_pb); - delete(object.cond); - object.cond = []; - object.grid_pb = []; - %delete(object); - else - % delete the subgrid - object.subgrid.deep_delete - if(ishghandle(object.grid_pb)) - delete(object.grid_pb); - end - delete(object.cond); - object.cond = []; - object.grid_pb = []; - %delete(object); - end - end - - \ No newline at end of file +%% delete_Cell +% deletes the current cell, will recursively delete any subgrids +% if they exist. +% inputs: +% object:Cell - Current Cell Object +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = delete_Cell(object) +if(isempty(object.subgrid)) + delete(object.grid_pb); + delete(object.cond); + object.cond = []; + object.grid_pb = []; + %delete(object); +else + % delete the subgrid + object.subgrid.deep_delete + if(ishghandle(object.grid_pb)) + delete(object.grid_pb); + end + delete(object.cond); + object.cond = []; + object.grid_pb = []; + %delete(object); +end +end + diff --git a/@Cell/flag_cell.m b/@Cell/flag_cell.m index 2d10a581eec79712f423b04745aa51abf06f6125..3168646547d89924c71479497217ddf257a130f7 100644 --- a/@Cell/flag_cell.m +++ b/@Cell/flag_cell.m @@ -1,21 +1,22 @@ - %% flag_cell - % mode - % 0 - normal - % 1 - red (error/false) - % 2 - green (ok/true) - function [] = flag_cell(object,mode) - - if (isempty(object.color)) - object.color = get(object.cond,'BackgroundColor'); - end - - if (mode == 0) - set(object.cond,'BackgroundColor',object.color); - elseif (mode == 1) - set(object.cond,'BackgroundColor',[0.92 0.65 0.65]) - elseif (mode == 2) - set(object.cond,'BackgroundColor',[0.03 1.0 0.32]); - end - - end - \ No newline at end of file +%% flag_cell +% mode +% 0 - normal +% 1 - red (error/false) +% 2 - green (ok/true) +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = flag_cell(object,mode) + +if (isempty(object.color)) + object.color = get(object.cond,'BackgroundColor'); +end + +if (mode == 0) + set(object.cond,'BackgroundColor',object.color); +elseif (mode == 1) + set(object.cond,'BackgroundColor',[0.92 0.65 0.65]) +elseif (mode == 2) + set(object.cond,'BackgroundColor',[0.03 1.0 0.32]); +end + +end diff --git a/@Cell/get_pos.m b/@Cell/get_pos.m index 8b826f7c736a6a8634e3a4a6643d45191299bea7..36d8e57fa1bd78f4b8b6289060bbdf52a9a90564 100644 --- a/@Cell/get_pos.m +++ b/@Cell/get_pos.m @@ -1,14 +1,15 @@ - - %% get_pos - % Returns the position of the edit box for the cell - % inputs: - % object:Cell - Current Cell Object - % outputs; - % pos:[double double double double] - position of the cell - function pos = get_pos(object) - if (~isempty(object.cond)) - pos = get(object.cond,'position'); - end - end - - \ No newline at end of file + +%% get_pos +% Returns the position of the edit box for the cell +% inputs: +% object:Cell - Current Cell Object +% outputs; +% pos:[double double double double] - position of the cell +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function pos = get_pos(object) +if (~isempty(object.cond)) + pos = get(object.cond,'position'); +end +end + diff --git a/@Cell/new_Grid.m b/@Cell/new_Grid.m index ea89b92abbd0e26334e8c43c43803084f706b992..2586ab7afc81057c06ad4f6db3d8b7d898caa797 100644 --- a/@Cell/new_Grid.m +++ b/@Cell/new_Grid.m @@ -1,19 +1,19 @@ - %% new_Grid - % - % inputs: - % object:Cell - Current Cell Object - % outputs; - % - function [] = new_Grid(object) - object.subgrid = Grid(object.cell_index,object); - object.subgrid.new_Cell; - object.subgrid.new_Cell; - object.subgrid.set_rGrid(object.parent_grid.rGrid); - object.pb_flag = 0; - delete(object.grid_pb); - if(~isempty(object.parent_grid.rGrid)) - object.parent_grid.rGrid.delete_g2s(object); - end - end - - \ No newline at end of file +%% new_Grid +% +% inputs: +% object:Cell - Current Cell Object +% outputs; +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = new_Grid(object) +object.subgrid = Grid(object.cell_index,object); +object.subgrid.new_Cell; +object.subgrid.new_Cell; +object.subgrid.set_rGrid(object.parent_grid.rGrid); +object.pb_flag = 0; +delete(object.grid_pb); +if(~isempty(object.parent_grid.rGrid)) + object.parent_grid.rGrid.delete_g2s(object); +end +end + diff --git a/@Cell/pb_call.m b/@Cell/pb_call.m index 78c30e051af000c5403adc03cf4e9ef87cf3a86c..cbbe776ff839ceac5621fedbd851dacca482160e 100644 --- a/@Cell/pb_call.m +++ b/@Cell/pb_call.m @@ -1,36 +1,37 @@ - %% pb_call - % callback function for the new subgrid button - % inputs: - % object:Cell - Current Cell Object - % src:double - Source of the callback - % event:eventdata - Data of the eventcall - % outputs; - % none - function [] = pb_call(object,src,event) - gui = get(src,'userdata'); - - - - - object.new_Grid; - gui.reset_wh(); - %gui.draw_grid2(gui.Grid2); - gui.draw_allgrids(0); - - if isempty(event) || event ~= 1 - - undo_data.action = 4; - undo_data.grid = object.subgrid; - undo_data.cell = object; - undo_data.text = []; - undo_data.subgrid = []; - - gui.undo_man.new_state(undo_data); - end - - gui.update_undoredo - - - end - - \ No newline at end of file +%% pb_call +% callback function for the new subgrid button +% inputs: +% object:Cell - Current Cell Object +% src:double - Source of the callback +% event:eventdata - Data of the eventcall +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = pb_call(object,src,event) +gui = get(src,'userdata'); + + + + +object.new_Grid; +gui.reset_wh(); +%gui.draw_grid2(gui.Grid2); +gui.draw_allgrids(0); + +if isempty(event) || event ~= 1 + + undo_data.action = 4; + undo_data.grid = object.subgrid; + undo_data.cell = object; + undo_data.text = []; + undo_data.subgrid = []; + + gui.undo_man.new_state(undo_data); +end + +gui.update_undoredo + + +end + diff --git a/@Cell/set_pb.m b/@Cell/set_pb.m index 93bbdc6a8e337608255adfeae869b2cfef4fc88a..66ed4e1d2cbad63ddf165c73969e3c006790ee73 100644 --- a/@Cell/set_pb.m +++ b/@Cell/set_pb.m @@ -1,22 +1,23 @@ %% set_pb - % create the new subgrid push button handle - % inputs: - % object:Cell - Current Cell Object - % outputs; - % none - function [] = set_pb(object,fig,pos) - if(object.pb_flag == 1 && (isempty(object.grid_pb) || ~ishghandle(object.grid_pb))) - object.grid_pb = uicontrol('style','push',... - 'units','pix',... - 'string','+',... - 'HorizontalAlign','left',... - 'Parent',fig,... - 'position',pos,... - 'callback',@(src,event)pb_call(object,src,event)); - elseif (object.pb_flag == 1 && ~isempty(object.grid_pb)) - set(object.grid_pb,'Position',pos); - else - end - end - - \ No newline at end of file +% create the new subgrid push button handle +% inputs: +% object:Cell - Current Cell Object +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_pb(object,fig,pos) +if(object.pb_flag == 1 && (isempty(object.grid_pb) || ~ishghandle(object.grid_pb))) + object.grid_pb = uicontrol('style','push',... + 'units','pix',... + 'string','+',... + 'HorizontalAlign','left',... + 'Parent',fig,... + 'position',pos,... + 'callback',@(src,event)pb_call(object,src,event)); +elseif (object.pb_flag == 1 && ~isempty(object.grid_pb)) + set(object.grid_pb,'Position',pos); +else +end +end + diff --git a/@Cell/set_pos.m b/@Cell/set_pos.m index f4f6bef93e954a6ab5b0bac9331498b521ee5600..c66650468ff5f16271c4e8eec566f92b6f3acd96 100644 --- a/@Cell/set_pos.m +++ b/@Cell/set_pos.m @@ -1,15 +1,17 @@ %% set_pos - % allows accessor to set the position of the edit box for the - % cell. - % inputs: - % object:Cell - Current Cell Object - % pos:[double double double double] - the new position of the - % cell - % outputs; - % none - function [] = set_pos(object,pos) - if (~isempty(object.cond)) - set(object.cond,'position',pos); - end - end - +% allows accessor to set the position of the edit box for the +% cell. +% inputs: +% object:Cell - Current Cell Object +% pos:[double double double double] - the new position of the +% cell +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_pos(object,pos) +if (~isempty(object.cond)) + set(object.cond,'position',pos); +end +end + diff --git a/@Data/Data.m b/@Data/Data.m index 8e9991fac95da495522ac95cb6a9847a49c89e38..0bb9f7fd880aed3db7ace9d262ce81900f18c044 100644 --- a/@Data/Data.m +++ b/@Data/Data.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef Data < handle % This class will store the data for each table, ideally to seperate % out the data from the gui and logic. @@ -30,7 +32,7 @@ classdef Data < handle end end - + end diff --git a/@Data/clone.m b/@Data/clone.m index 0c647c96bb2e1b557ecb83c19c2299fa347045ae..e8536b20fe5e3c3c111bc52cd4a7d776b1e3e553 100644 --- a/@Data/clone.m +++ b/@Data/clone.m @@ -1,41 +1,42 @@ - %% clone - % creates copy of a data object, which involves copying - % properties and calling individual clone functions on objects if - % necessary. - % inputs: - % object:Data - current object - % handle:Data - the handle to the block - % outputs: - % copy:Data - copy of the current block, perhaps with a new name - function copy = clone(object,handle) - % assume that dialog is closed - if ~object.valid - copy = []; - return; - end - copy = Data(); - if ~isempty(handle) - copy.function_name = get(handle,'Name'); - else - copy.function_name = ''; - end - copy.function_inputs = object.function_inputs; - copy.checked = object.checked; - copy.settings = object.settings; - copy.multi_mode = object.multi_mode; - - copy.Grid2 = Grid(2,[]); - copy.Grid1 = Grid(1,[]); - copy.Grid0 = RGrid(copy.Grid1,copy.Grid2); - copy.Grid1.set_rGrid(copy.Grid0); - copy.Grid2.set_rGrid(copy.Grid0); - +%% clone +% creates copy of a data object, which involves copying +% properties and calling individual clone functions on objects if +% necessary. +% inputs: +% object:Data - current object +% handle:Data - the handle to the block +% outputs: +% copy:Data - copy of the current block, perhaps with a new name +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function copy = clone(object,handle) +% assume that dialog is closed +if ~object.valid + copy = []; + return; +end +copy = Data(); +if ~isempty(handle) + copy.function_name = get(handle,'Name'); +else + copy.function_name = ''; +end +copy.function_inputs = object.function_inputs; +copy.checked = object.checked; +copy.settings = object.settings; +copy.multi_mode = object.multi_mode; - object.Grid2.clone(copy.Grid2,object.Grid2.grid_index,[]) - object.Grid1.clone(copy.Grid1,object.Grid1.grid_index,[]) - - object.copy_results(copy) +copy.Grid2 = Grid(2,[]); +copy.Grid1 = Grid(1,[]); +copy.Grid0 = RGrid(copy.Grid1,copy.Grid2); +copy.Grid1.set_rGrid(copy.Grid0); +copy.Grid2.set_rGrid(copy.Grid0); + + +object.Grid2.clone(copy.Grid2,object.Grid2.grid_index,[]) +object.Grid1.clone(copy.Grid1,object.Grid1.grid_index,[]) + +object.copy_results(copy) + +end - end - - \ No newline at end of file diff --git a/@Data/copy_results.m b/@Data/copy_results.m index 52c325021796cd25575d9f1f5e38b89637834929..27785ecb6f9f774a627cf49ac6783d7cca10923a 100644 --- a/@Data/copy_results.m +++ b/@Data/copy_results.m @@ -1,20 +1,21 @@ - %% copy_results - % copy the results text of the current grid0 to a destination - % Data's grid0 object. - % inputs: - % object:Data - current object - % dest:Data - destination object to save results text to, results - % grid is assumed to already be set up. - % outputs: - % none - function [] = copy_results(object,dest) - for i=1:size(dest.Grid0.Cells,2) - for j=1:size(object.Grid0.Cells,2) - if (strcmp(object.Grid0.Cells(j).Cell1.cond_text,dest.Grid0.Cells(i).Cell1.cond_text) && strcmp(object.Grid0.Cells(j).Cell2.cond_text,dest.Grid0.Cells(i).Cell2.cond_text)) - dest.Grid0.Cells(i).result_text = object.Grid0.Cells(j).result_text; - end - end - end +%% copy_results +% copy the results text of the current grid0 to a destination +% Data's grid0 object. +% inputs: +% object:Data - current object +% dest:Data - destination object to save results text to, results +% grid is assumed to already be set up. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = copy_results(object,dest) +for i=1:size(dest.Grid0.Cells,2) + for j=1:size(object.Grid0.Cells,2) + if (strcmp(object.Grid0.Cells(j).Cell1.cond_text,dest.Grid0.Cells(i).Cell1.cond_text) && strcmp(object.Grid0.Cells(j).Cell2.cond_text,dest.Grid0.Cells(i).Cell2.cond_text)) + dest.Grid0.Cells(i).result_text = object.Grid0.Cells(j).result_text; end - - \ No newline at end of file + end +end +end + diff --git a/@Data/getData.m b/@Data/getData.m index 6eefdbb5ae2697992a391f435ef27c19596e0027..5bb6f0c545ada5a7605fd9bd32b7d554f9ee06da 100644 --- a/@Data/getData.m +++ b/@Data/getData.m @@ -1,22 +1,23 @@ - %% getData - % resturn individual properties to calling function - % inputs: - % object:Data - current object - % outputs: - % grid0:Grid - Results Grid - % grid1:Grid - Left Grid - % grid2:Grid - Top Grid - % name:string - Function name - % inputs:string - input string - % checked:boolean - typecheck status - function [grid0, grid1, grid2, name, inputs, checked, multi] = getData(object) - grid0 = object.Grid0; - grid1 = object.Grid1; - grid2 = object.Grid2; - name = object.function_name; - inputs = object.function_inputs; - checked = object.checked; - multi = object.multi_mode; - end - - \ No newline at end of file +%% getData +% resturn individual properties to calling function +% inputs: +% object:Data - current object +% outputs: +% grid0:Grid - Results Grid +% grid1:Grid - Left Grid +% grid2:Grid - Top Grid +% name:string - Function name +% inputs:string - input string +% checked:boolean - typecheck status +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [grid0, grid1, grid2, name, inputs, checked, multi] = getData(object) +grid0 = object.Grid0; +grid1 = object.Grid1; +grid2 = object.Grid2; +name = object.function_name; +inputs = object.function_inputs; +checked = object.checked; +multi = object.multi_mode; +end + diff --git a/@Data/init.m b/@Data/init.m index 2c20b6ce4345551d46bfbba5c0e781a85af4ad54..019fc8294a3e40f28663a8e5fe718bacb174403f 100644 --- a/@Data/init.m +++ b/@Data/init.m @@ -1,19 +1,20 @@ - %% init - % initialize the data to some default values and objects - % inputs: - % object:Data - current object - % outputs: - % none - function [] = init(object) - object.Grid2 = Grid(2,[]); - object.Grid1 = Grid(1,[]); - object.Grid0 = RGrid(object.Grid1,object.Grid2); - object.Grid1.set_rGrid(object.Grid0); - object.Grid2.set_rGrid(object.Grid0); - object.Grid2.new_Cell; - object.Grid1.new_Cell; - object.checked = 0; - object.multi_mode = 0; - end - - \ No newline at end of file +%% init +% initialize the data to some default values and objects +% inputs: +% object:Data - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = init(object) +object.Grid2 = Grid(2,[]); +object.Grid1 = Grid(1,[]); +object.Grid0 = RGrid(object.Grid1,object.Grid2); +object.Grid1.set_rGrid(object.Grid0); +object.Grid2.set_rGrid(object.Grid0); +object.Grid2.new_Cell; +object.Grid1.new_Cell; +object.checked = 0; +object.multi_mode = 0; +end + diff --git a/@Data/save.m b/@Data/save.m index b61ac014140510d4e33e02867467f818da741f1b..51ddaa5f737fe98ce8d9270a2419ff7677c81df3 100644 --- a/@Data/save.m +++ b/@Data/save.m @@ -1,10 +1,12 @@ - %% save - % saves the current data object to an external file - % inputs: - % object:Data - current Data object - % outputs: - % none - function [] = save(object) - filename = [ object.function_name '.table']; - save(filename,'object'); - end +%% save +% saves the current data object to an external file +% inputs: +% object:Data - current Data object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = save(object) +filename = [ object.function_name '.table']; +save(filename,'object'); +end diff --git a/@Data/setData.m b/@Data/setData.m index 23628a9f7bee6d206bda2092686bfdf0acbe2f28..1083886b8f9667d7eed68c3aeee564d25b814887 100644 --- a/@Data/setData.m +++ b/@Data/setData.m @@ -1,23 +1,24 @@ - %% setData - % set the object properties, used when copying and other places - % inputs: - % object:Data - current object - % grid0:Grid - Results Grid - % grid1:Grid - Left Grid - % grid2:Grid - Top Grid - % name:string - Function name - % inputs:string - input string - % checked:boolean - typecheck status - % outputs: - % none - function [] = setData(object, grid0, grid1, grid2, name, inputs, checked, multi) - object.Grid0 = grid0; - object.Grid1 = grid1; - object.Grid2 = grid2; - object.function_name = name; - object.function_inputs = inputs; - object.checked = checked; - object.multi_mode = multi; - end - - \ No newline at end of file +%% setData +% set the object properties, used when copying and other places +% inputs: +% object:Data - current object +% grid0:Grid - Results Grid +% grid1:Grid - Left Grid +% grid2:Grid - Top Grid +% name:string - Function name +% inputs:string - input string +% checked:boolean - typecheck status +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = setData(object, grid0, grid1, grid2, name, inputs, checked, multi) +object.Grid0 = grid0; +object.Grid1 = grid1; +object.Grid2 = grid2; +object.function_name = name; +object.function_inputs = inputs; +object.checked = checked; +object.multi_mode = multi; +end + diff --git a/@Data/setvalues.m b/@Data/setvalues.m index 48f7b9eb935907fd4d233328caa75794cc21f90c..1af97742a04d01bcdb39c656af861afb627f3161 100644 --- a/@Data/setvalues.m +++ b/@Data/setvalues.m @@ -1,12 +1,13 @@ %% setvalues - % set the settings property to a settings object - % inputs: - % object:Data - current object - % settings:Settings - settings object to save - % outputs: - % none - function [] = setvalues(object,settings) - object.settings = settings; - end - - \ No newline at end of file +% set the settings property to a settings object +% inputs: +% object:Data - current object +% settings:Settings - settings object to save +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = setvalues(object,settings) +object.settings = settings; +end + diff --git a/@Data/valid.m b/@Data/valid.m index e2d19930fe9de2513d9601575b10da6d29a7cb17..244e401548514f88075bab2c619fa2b0673edccb 100644 --- a/@Data/valid.m +++ b/@Data/valid.m @@ -1,24 +1,25 @@ - %% valid - % determine if a given data object is valid for use or not - % inputs: - % object:Data - current object - % outputs: - % valid:boolean - 0 if not valid, 1 if valid - function valid = valid(object) - if isempty(object.Grid0) - valid = 0; - return - end - if isempty(object.Grid1) - valid = 0; - return - end - if isempty(object.Grid2) - valid = 0; - return - end - valid = 1; - - end - - \ No newline at end of file +%% valid +% determine if a given data object is valid for use or not +% inputs: +% object:Data - current object +% outputs: +% valid:boolean - 0 if not valid, 1 if valid +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function valid = valid(object) +if isempty(object.Grid0) + valid = 0; + return +end +if isempty(object.Grid1) + valid = 0; + return +end +if isempty(object.Grid2) + valid = 0; + return +end +valid = 1; + +end + diff --git a/@EMLGenerator/EMLGenerator.m b/@EMLGenerator/EMLGenerator.m index a51b82dce9b899b8b8dd1c1282e14f4dddccb752..24a4710de036481665ed794c6ed6c06c46b6a3f5 100644 --- a/@EMLGenerator/EMLGenerator.m +++ b/@EMLGenerator/EMLGenerator.m @@ -1,7 +1,9 @@ + classdef EMLGenerator < handle %UNTITLED Summary of this class goes here % Detailed explanation goes here - +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification properties data = []; datatype = []; @@ -9,13 +11,13 @@ classdef EMLGenerator < handle end methods(Static) - revised_input = parse_inputs(input_string) - + revised_input = parse_inputs(input_string) + converted = type_convert(name,type,expression) - - + + end diff --git a/@EMLGenerator/generate_eml_code.m b/@EMLGenerator/generate_eml_code.m index 3ae8eb2b1e3bbe1a0fa893fadc0153a1fcc534a0..4844f3412307e0a32f3ae8c20dde78e609465ef0 100644 --- a/@EMLGenerator/generate_eml_code.m +++ b/@EMLGenerator/generate_eml_code.m @@ -1,17 +1,18 @@ - %% generate_eml_code - % generates the embedded matlab code by calling other methods in - % this class - % inputs: - % object:EMLGenerator - current object - % outputs: - % code:string - string of eml code - function code = generate_eml_code(object) - code = []; - code = [code object.generate_preamble]; - code = [code object.generate_eml_cond(object.data.Grid1,object.data.Grid2,0)]; - - end - - - - \ No newline at end of file +%% generate_eml_code +% generates the embedded matlab code by calling other methods in +% this class +% inputs: +% object:EMLGenerator - current object +% outputs: +% code:string - string of eml code +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function code = generate_eml_code(object) +code = []; +code = [code object.generate_preamble]; +code = [code object.generate_eml_cond(object.data.Grid1,object.data.Grid2,0)]; + +end + + + diff --git a/@EMLGenerator/generate_eml_cond.m b/@EMLGenerator/generate_eml_cond.m index a70b27897a06e55ec0e48bdddfe9c963b9c543ae..11989d4be8b5e7371c37371b5b0c10dbb7ed6923 100644 --- a/@EMLGenerator/generate_eml_cond.m +++ b/@EMLGenerator/generate_eml_cond.m @@ -1,99 +1,101 @@ %% generate_eml_cond - % generate the embedded matlab for a conditon grid, recursive - % function, will call horizontal generator if finds conditions - % in that grid. - % inputs: - % object:EMLGenerator - current object - % g1:Grid - Grid 1 - % g2:Grid - Grid 2 - % depth:int - integer representing recursion dept for formating - % use - % outputs: - % code:string - string of eml code - function code = generate_eml_cond(object,g1,g2,depth) - - - - - space = ''; - for i=1:depth - space = [space sprintf(' ')]; - end - g1cond1 = g1.cells(1).cond_text; - g2cond1 = g2.cells(1).cond_text; - code = []; - %1D horizontal - if(~isempty(g1cond1) && isempty(g2cond1)) - if object.data.multi_mode == 0 - code = [code object.generate_eml_horizontal(g1,g2.cells(1),depth)]; - else - code = [code object.generate_eml_multi(g1,g2.cells(1),depth)]; - end - % something in vertical column - else +% generate the embedded matlab for a conditon grid, recursive +% function, will call horizontal generator if finds conditions +% in that grid. +% inputs: +% object:EMLGenerator - current object +% g1:Grid - Grid 1 +% g2:Grid - Grid 2 +% depth:int - integer representing recursion dept for formating +% use +% outputs: +% code:string - string of eml code +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function code = generate_eml_cond(object,g1,g2,depth) - elsecell = []; - for i=1:size(g2.cells,2) - g2cond = g2.cells(i).cond_text; - % condition string of otherwise corresponds to an else - % statement, we allow this statement to be in any order - % in the cells of the grid, so we need to find where it - % is, if it exists. - if (strcmp(g2cond,'otherwise')) - elsecell = g2.cells(i); - found = 1; - continue - end - if (i == 1) - code = [code sprintf('%sif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))]; - else - code = [code sprintf('%selseif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))]; - end - if(~isempty(g2.cells(i).subgrid)) - code = [code object.generate_eml_cond(g1,g2.cells(i).subgrid,depth+1)]; - else - if (~isempty(g1cond1)) - if object.data.multi_mode == 0 - code = [code object.generate_eml_horizontal(g1,g2.cells(i),depth+1)]; - else - code = [code object.generate_eml_multi(g1,g2.cells(i),depth+1)]; - end - %code = [code object.generate_eml_horizontal(g1,g2.cells(i),depth+1)]; - else - - resultcell = object.data.Grid0.search_return(g1.cells(1),g2.cells(i)); - if(~isempty(resultcell)) - code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; - else - end - end - end - - end - if(~isempty(elsecell)) - %resultcell = object.Grid0.search_return(elsecell,elsecell); - code = [code sprintf('%selse\n',space)]; - if(~isempty(elsecell.subgrid)) - code = [code object.generate_eml_cond(g1,elsecell.subgrid,depth) sprintf('\n')]; +space = ''; +for i=1:depth + space = [space sprintf(' ')]; +end +g1cond1 = g1.cells(1).cond_text; +g2cond1 = g2.cells(1).cond_text; +code = []; +%1D horizontal +if(~isempty(g1cond1) && isempty(g2cond1)) + if object.data.multi_mode == 0 + code = [code object.generate_eml_horizontal(g1,g2.cells(1),depth)]; + else + code = [code object.generate_eml_multi(g1,g2.cells(1),depth)]; + end + % something in vertical column +else + + elsecell = []; + for i=1:size(g2.cells,2) + g2cond = g2.cells(i).cond_text; + % condition string of otherwise corresponds to an else + % statement, we allow this statement to be in any order + % in the cells of the grid, so we need to find where it + % is, if it exists. + if (strcmp(g2cond,'otherwise')) + elsecell = g2.cells(i); + found = 1; + continue + end + if (i == 1) + code = [code sprintf('%sif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))]; + else + code = [code sprintf('%selseif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))]; + end + + if(~isempty(g2.cells(i).subgrid)) + code = [code object.generate_eml_cond(g1,g2.cells(i).subgrid,depth+1)]; + else + if (~isempty(g1cond1)) + if object.data.multi_mode == 0 + code = [code object.generate_eml_horizontal(g1,g2.cells(i),depth+1)]; else - if (~isempty(g1cond1)) - code = [code object.generate_eml_horizontal(g1,elsecell,depth) sprintf('\n')]; - else + code = [code object.generate_eml_multi(g1,g2.cells(i),depth+1)]; + end + %code = [code object.generate_eml_horizontal(g1,g2.cells(i),depth+1)]; + else - resultcell = object.data.Grid0.search_return(g1.cells(1),elsecell); - if(~isempty(resultcell)) - code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; - - end - end + resultcell = object.data.Grid0.search_return(g1.cells(1),g2.cells(i)); + if(~isempty(resultcell)) + code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; + + else end + end + end + + end + if(~isempty(elsecell)) + %resultcell = object.Grid0.search_return(elsecell,elsecell); + code = [code sprintf('%selse\n',space)]; + + if(~isempty(elsecell.subgrid)) + code = [code object.generate_eml_cond(g1,elsecell.subgrid,depth) sprintf('\n')]; + else + if (~isempty(g1cond1)) + code = [code object.generate_eml_horizontal(g1,elsecell,depth) sprintf('\n')]; + else - end - - code = [code sprintf('%send\n',space)]; - - end - end \ No newline at end of file + resultcell = object.data.Grid0.search_return(g1.cells(1),elsecell); + if(~isempty(resultcell)) + code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; + + end + end + end + + end + + code = [code sprintf('%send\n',space)]; + +end +end \ No newline at end of file diff --git a/@EMLGenerator/generate_eml_horizontal.m b/@EMLGenerator/generate_eml_horizontal.m index abc6d94ce42e12193e771bbc27b4b48a8934a3b9..f4d19ba2d4f0a22cb4c5464024525e1e205fc4b9 100644 --- a/@EMLGenerator/generate_eml_horizontal.m +++ b/@EMLGenerator/generate_eml_horizontal.m @@ -1,53 +1,54 @@ %% generate_eml_horizontal - % generate the embedded matlab code for grid1, seperated from - % the code for grid2 since for a 2d table grid1 conditions will - % be sub conditions of grid2 conditions - % inputs: - % object:EMLGenerator - current object - % g1:Grid - Grid 1 - % g2_cell:Cell - Cell for which grid1 is sub conditon of - % depth:int - integer representing recursion dept for formating - % use - % outputs: - % code:string - string of eml code - function code = generate_eml_horizontal(object,g1,g2_cell,depth) - space = ''; - for i=1:depth - space = [space sprintf(' ')]; - end - code = []; +% generate the embedded matlab code for grid1, seperated from +% the code for grid2 since for a 2d table grid1 conditions will +% be sub conditions of grid2 conditions +% inputs: +% object:EMLGenerator - current object +% g1:Grid - Grid 1 +% g2_cell:Cell - Cell for which grid1 is sub conditon of +% depth:int - integer representing recursion dept for formating +% use +% outputs: +% code:string - string of eml code +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function code = generate_eml_horizontal(object,g1,g2_cell,depth) +space = ''; +for i=1:depth + space = [space sprintf(' ')]; +end +code = []; - elsecell = []; - for i=1:size(g1.cells,2) - g1cond = g1.cells(i).cond_text; - % condition string of otherwise corresponds to an else - % statement, we allow this statement to be in any order - % in the cells of the grid, so we need to find where it - % is, if it exists. - if (strcmp(g1cond,'otherwise')) - elsecell = g1.cells(i); - found = 1; - continue - end - if (i == 1) - code = [code sprintf('%sif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))]; - else - code = [code sprintf('%selseif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))]; - end - resultcell = object.data.Grid0.search_return(g1.cells(i),g2_cell); - if(~isempty(resultcell)) - code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; - - else - end - end - if(~isempty(elsecell)) - resultcell = object.data.Grid0.search_return(elsecell,g2_cell); - code = [code sprintf('%selse\n%soutput = %s;\n',space,[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; +elsecell = []; +for i=1:size(g1.cells,2) + g1cond = g1.cells(i).cond_text; + % condition string of otherwise corresponds to an else + % statement, we allow this statement to be in any order + % in the cells of the grid, so we need to find where it + % is, if it exists. + if (strcmp(g1cond,'otherwise')) + elsecell = g1.cells(i); + found = 1; + continue + end + if (i == 1) + code = [code sprintf('%sif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))]; + else + code = [code sprintf('%selseif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))]; + end + resultcell = object.data.Grid0.search_return(g1.cells(i),g2_cell); + if(~isempty(resultcell)) + code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; + + else + end +end +if(~isempty(elsecell)) + resultcell = object.data.Grid0.search_return(elsecell,g2_cell); + code = [code sprintf('%selse\n%soutput = %s;\n',space,[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; + +end +code = [code sprintf('%send\n',space)]; - end - code = [code sprintf('%send\n',space)]; +end - end - - \ No newline at end of file diff --git a/@EMLGenerator/generate_preamble.m b/@EMLGenerator/generate_preamble.m index fe56f3b747fcaa4c4a9f1117844c14a82e01cea8..6d819f0001845840ce58445e1466648ebed29483 100644 --- a/@EMLGenerator/generate_preamble.m +++ b/@EMLGenerator/generate_preamble.m @@ -1,68 +1,69 @@ %% generate_preamble - % generates the preamble for the eml code, the preamble is - % everything before the first if statement, this is seperated - % out to make the code simpler. - % inputs: - % object:EMLGenerator - current object - % outputs: - % code:string - string of eml code - function code = generate_preamble(object) - - code = []; - function_name = EMLGenerator.parse_inputs(object.data.function_name); - %generate input list - parsed_input = EMLGenerator.parse_inputs(object.data.function_inputs); - input = []; - for i= 1:size(parsed_input,2) - input = [input char(parsed_input{i}(1))]; - if i ~= size(parsed_input,2) - input = [input ','] - end - end - - output = []; - if (object.data.multi_mode == 1) - for i=1:size(object.data.Grid1.cells,2) - parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.Grid1.cells(i).cond_text))); +% generates the preamble for the eml code, the preamble is +% everything before the first if statement, this is seperated +% out to make the code simpler. +% inputs: +% object:EMLGenerator - current object +% outputs: +% code:string - string of eml code +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function code = generate_preamble(object) - output = [output char(parsed_output{1}(1))]; - - if i ~= size(object.data.Grid1.cells,2) - output = [output ','] - end - end - else - output = 'output'; - end - - code = sprintf('function [%s] = %s(%s)\n%s\n',output,char(function_name{1}(1)),input,'%%#eml'); - % simulink forces you to have an output for all execution paths - % since it can't compute completness and disjointness we need - % to have a default value, if the user builds the table - % properly the default value will never be used. since - % different types might have a different default value, the - % temporary solution is just to use one of the outputs from our - % table, we will use the first cell because it is - % guaranteed to - % be filled in, regardless of the dimensionality of the table. - - if (object.data.multi_mode == 1) - for i=1:size(object.data.Grid1.cells,2) - parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.Grid1.cells(i).cond_text))); +code = []; +function_name = EMLGenerator.parse_inputs(object.data.function_name); +%generate input list +parsed_input = EMLGenerator.parse_inputs(object.data.function_inputs); +input = []; +for i= 1:size(parsed_input,2) + input = [input char(parsed_input{i}(1))]; + if i ~= size(parsed_input,2) + input = [input ','] + end +end - output_str = char(parsed_output{1}(1)); - - code = [code sprintf('%s=%s;\n',output_str,EMLGenerator.type_convert(output_str,object.datatype,char(object.data.Grid0.Cells(i).result_text)))]; +output = []; +if (object.data.multi_mode == 1) + for i=1:size(object.data.Grid1.cells,2) + parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.Grid1.cells(i).cond_text))); + + output = [output char(parsed_output{1}(1))]; + + if i ~= size(object.data.Grid1.cells,2) + output = [output ','] + end + end +else + output = 'output'; +end - end - - else - test = 'output'; - output_string = EMLGenerator.type_convert(test,object.datatype,char(object.data.Grid0.Cells(1).result_text) ); - code = [code sprintf('output=%s;\n', output_string )]; +code = sprintf('function [%s] = %s(%s)\n%s\n',output,char(function_name{1}(1)),input,'%%#eml'); +% simulink forces you to have an output for all execution paths +% since it can't compute completness and disjointness we need +% to have a default value, if the user builds the table +% properly the default value will never be used. since +% different types might have a different default value, the +% temporary solution is just to use one of the outputs from our +% table, we will use the first cell because it is +% guaranteed to +% be filled in, regardless of the dimensionality of the table. - end +if (object.data.multi_mode == 1) + for i=1:size(object.data.Grid1.cells,2) + parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.Grid1.cells(i).cond_text))); - end + output_str = char(parsed_output{1}(1)); - \ No newline at end of file + code = [code sprintf('%s=%s;\n',output_str,EMLGenerator.type_convert(output_str,object.datatype,char(object.data.Grid0.Cells(i).result_text)))]; + + end + +else + test = 'output'; + output_string = EMLGenerator.type_convert(test,object.datatype,char(object.data.Grid0.Cells(1).result_text) ); + code = [code sprintf('output=%s;\n', output_string )]; + +end + +end + diff --git a/@EMLGenerator/parse_inputs.m b/@EMLGenerator/parse_inputs.m index da89204d669583db519bea9a2eb55026afa86498..94a43adebfae7954a897179e2e83846ca641b89f 100644 --- a/@EMLGenerator/parse_inputs.m +++ b/@EMLGenerator/parse_inputs.m @@ -1,51 +1,53 @@ %% parse_inputs - % parse an input string and return the list of inputs as a - % matrix with accompaning type or indicating an error - % inputs: - % input_string:string - string containing input string, comma - % delimited list of variables, each variable may or may not be - % followed by a colon then a type string. - % outputs: - % revised_input:matrix - matrix containing parsed list, ex. - % [{'x' 'int'};{'y'};{ 'z:{x:real|x>1}' }] - function revised_input = parse_inputs(input_string) - revised_input = []; - input_string2 = reshape(input_string',1,size(input_string,1)*size(input_string,2)); - inputs = regexprep(input_string2,'\n',''); - inputs = regexp(inputs,',','split'); - - % need to be careful here because pvs dependant types can have - % :'s in them - - % find the first :, any thing before this is considered the - % variable any thing following is considered the type - c_locations = regexp(inputs,':','start'); - for i= 1:size(inputs,2) - sub_input = []; - if size(c_locations{i},2) == 0 - sub_input{1} = inputs{i}; - new_inputs{i} = sub_input; - else - sub_input{1} = inputs{i}(1:c_locations{i}(1)-1); - sub_input{2} = inputs{i}(c_locations{i}(1)+1:end); - new_inputs{i} = sub_input; - %new_inputs{i}(1) = inputs{i}(1:c_locations{i}(1)) - %new_inputs{i}(2) = inputs{i}(c_locations{i}(1):end) - end - end - - %inputs = regexp(inputs,':','split') - - for i=1:size(new_inputs,2) - new_inputs{i}(1) = regexprep(new_inputs{i}(1),'\s',''); +% parse an input string and return the list of inputs as a +% matrix with accompaning type or indicating an error +% inputs: +% input_string:string - string containing input string, comma +% delimited list of variables, each variable may or may not be +% followed by a colon then a type string. +% outputs: +% revised_input:matrix - matrix containing parsed list, ex. +% [{'x' 'int'};{'y'};{ 'z:{x:real|x>1}' }] +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function revised_input = parse_inputs(input_string) +revised_input = []; +input_string2 = reshape(input_string',1,size(input_string,1)*size(input_string,2)); +inputs = regexprep(input_string2,'\n',''); +inputs = regexp(inputs,',','split'); - valid = regexp(new_inputs{i}(1),'[a-zA-Z][_a-zA-Z0-9]*','match'); - if isempty(char(new_inputs{i}(1))) || ~strcmp(new_inputs{i}(1),valid{1}) - new_inputs{i}(2) = {'error'}; - %revised_input = cat(2,revised_input,[char(inputs{i}(1)); 'error']) - end - end - if isempty(revised_input) - revised_input = new_inputs; - end - end \ No newline at end of file +% need to be careful here because pvs dependant types can have +% :'s in them + +% find the first :, any thing before this is considered the +% variable any thing following is considered the type +c_locations = regexp(inputs,':','start'); +for i= 1:size(inputs,2) + sub_input = []; + if size(c_locations{i},2) == 0 + sub_input{1} = inputs{i}; + new_inputs{i} = sub_input; + else + sub_input{1} = inputs{i}(1:c_locations{i}(1)-1); + sub_input{2} = inputs{i}(c_locations{i}(1)+1:end); + new_inputs{i} = sub_input; + %new_inputs{i}(1) = inputs{i}(1:c_locations{i}(1)) + %new_inputs{i}(2) = inputs{i}(c_locations{i}(1):end) + end +end + +%inputs = regexp(inputs,':','split') + +for i=1:size(new_inputs,2) + new_inputs{i}(1) = regexprep(new_inputs{i}(1),'\s',''); + + valid = regexp(new_inputs{i}(1),'[a-zA-Z][_a-zA-Z0-9]*','match'); + if isempty(char(new_inputs{i}(1))) || ~strcmp(new_inputs{i}(1),valid{1}) + new_inputs{i}(2) = {'error'}; + %revised_input = cat(2,revised_input,[char(inputs{i}(1)); 'error']) + end +end +if isempty(revised_input) + revised_input = new_inputs; +end +end \ No newline at end of file diff --git a/@EMLGenerator/set_datatype.m b/@EMLGenerator/set_datatype.m index b96a791649266a996da90f2d73e8fe3e22eb4552..50561bcd1e315edbb447b1efe78816214977a4f0 100644 --- a/@EMLGenerator/set_datatype.m +++ b/@EMLGenerator/set_datatype.m @@ -1,12 +1,13 @@ %% set_datatype - % set the datatype property based inputed string based on the simulink settings - % inputs: - % object:EMLGenerator - current object - % type:string - string of datatype conversion - % outputs: - % none - function [] = set_datatype(object,type) - object.datatype = type; - end - - \ No newline at end of file +% set the datatype property based inputed string based on the simulink settings +% inputs: +% object:EMLGenerator - current object +% type:string - string of datatype conversion +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_datatype(object,type) +object.datatype = type; +end + diff --git a/@EMLGenerator/type_convert.m b/@EMLGenerator/type_convert.m index dcd3e157e4fbe452c09b2671197540120126e511..2a14d467a734fdacbcf1cd1cf667215e141d931b 100644 --- a/@EMLGenerator/type_convert.m +++ b/@EMLGenerator/type_convert.m @@ -6,6 +6,8 @@ % expression:string - string of the expression % outputs: % converted:string - type conversion string +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function converted = type_convert(name,type,expression) if ~isempty(type) for i=1:size(type,1) diff --git a/@GUI/GUI.m b/@GUI/GUI.m index 31d072832f3de8c806dd0be91a527d172be64056..1acd5745f06b3a1678d465497cdf460e8583c709 100644 --- a/@GUI/GUI.m +++ b/@GUI/GUI.m @@ -1,5 +1,7 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef GUI < handle - + properties % vertical grid @@ -54,7 +56,7 @@ classdef GUI < handle TableBlk = []; saved = []; validation_report_handle = []; - multi_type = 0; + multi_type = 0; multi_mode = []; multi_grp = []; multi_opt_reg = []; @@ -82,8 +84,8 @@ classdef GUI < handle end methods(Static) - msgbox_scroll(msg) - + msgbox_scroll(msg) + end end diff --git a/@GUI/about_call.m b/@GUI/about_call.m index f14fd25654dc3d033c5db23ba477fca4437f7c1f..91e4ed06957bcef9029833976b56b8e1cf6ffb3c 100644 --- a/@GUI/about_call.m +++ b/@GUI/about_call.m @@ -1,3 +1,11 @@ +%% about_call +% Displays a messagebox with information about the current +% inputs: +% object:PVS_checker - GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = about_call(object,src,event) msgbox(sprintf('Table Toolbox v%s\nCopyright 2010\nColin Eles\nMcMaster Center for Software Certification',object.version),'About Table Tool','modal'); end \ No newline at end of file diff --git a/@GUI/check_call.m b/@GUI/check_call.m index ab6cbbb671f90d4741c0d3ed688d01fe69b404ac..f4f0adca4b94c3e7e0ac8ebe7780d7411a76ea9b 100644 --- a/@GUI/check_call.m +++ b/@GUI/check_call.m @@ -1,32 +1,34 @@ - %% check_call - % callback function for check pushbutton. compiles a message of - % the errors that were detected in each of the grids. outputs the - % message to users via a msgbox. - % inputs: - % object:GUI - current GUI object - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function error = check_call(object,src,event) - error = 0; - - msg = object.check_inputs; - if (isempty(msg)) - set(object.function_inputs_control,'BackgroundColor',[1 1 1]) - msg = object.check_grid_condition(object.Grid2); - if object.multi_mode == 0 - msg = [msg object.check_grid_condition(object.Grid1)]; - end - msg = [msg object.check_grid_result(object.Grid0)]; - else - set(object.function_inputs_control,'BackgroundColor',[0.92 0.65 0.65]) - end - - if ~isempty(msg) - msgbox(msg); - error = 1; - end - - end - +%% check_call +% callback function for check pushbutton. compiles a message of +% the errors that were detected in each of the grids. outputs the +% message to users via a msgbox. +% inputs: +% object:GUI - current GUI object +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function error = check_call(object,src,event) +error = 0; + +msg = object.check_inputs; +if (isempty(msg)) + set(object.function_inputs_control,'BackgroundColor',[1 1 1]) + msg = object.check_grid_condition(object.Grid2); + if object.multi_mode == 0 + msg = [msg object.check_grid_condition(object.Grid1)]; + end + msg = [msg object.check_grid_result(object.Grid0)]; +else + set(object.function_inputs_control,'BackgroundColor',[0.92 0.65 0.65]) +end + +if ~isempty(msg) + msgbox(msg); + error = 1; +end + +end + diff --git a/@GUI/check_grid_condition.m b/@GUI/check_grid_condition.m index 3baa772bcf5f2ba0aae151bccd42e543b23c1f52..4cabe247f10c53ac249dc845caab61962eb68858 100644 --- a/@GUI/check_grid_condition.m +++ b/@GUI/check_grid_condition.m @@ -1,58 +1,60 @@ - %% check_grid - % check_grid will recursively loop through all the cells of a - % grid and call the check_matlab_syntax function for each of the - % strings in the cells. if there is an error the cell will - % change colours to alert the user where the problem is. - % inputs: - % object:GUI - current GUI object - % grid:Grid - Grid object being checked - % outputs: - % none - function msg = check_grid_condition(object,grid) - msg = []; - for i = 1:size(grid.cells,2) - - error = ''; - string = get(grid.cells(i).cond,'String'); - - if ( strcmp(string,'') || isempty(string)) && i == 1 && isempty(grid.parent_grid) && size(grid.cells,2) == 1 - break - end - - % if the string is empty indicating that the table is 1 - % dimensional or the string is "otherwise" skip the syntax - % checking. - if(~isempty(string) && ~strcmp(string,'otherwise')) - error = object.check_matlab_syntax_condition(char(string),0); - end - if isempty(error) - if (strcmp(string,'') || isempty(string)) - error = 'Cell is empty'; - end - end - if ~isempty(error) - % generate the message string - msg = [msg sprintf('\n')]; - - msg = [msg 'Condtion -> ' char(string) sprintf('\n')]; - msg = [msg error sprintf('\n')]; - - % set tooltip string of cell to error msg - set(grid.cells(i).cond,'TooltipString',error) - % change background colour - grid.cells(i).flag_cell(1); - else - % reset tooltip and colour if no error found - set(grid.cells(i).cond,'TooltipString','') - grid.cells(i).flag_cell(0); - - - end - % recurse through subgrid - if(~isempty(grid.cells(i).subgrid)) - msg = [msg object.check_grid_condition(grid.cells(i).subgrid)]; - end - - - end +%% check_grid +% check_grid will recursively loop through all the cells of a +% grid and call the check_matlab_syntax function for each of the +% strings in the cells. if there is an error the cell will +% change colours to alert the user where the problem is. +% inputs: +% object:GUI - current GUI object +% grid:Grid - Grid object being checked +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function msg = check_grid_condition(object,grid) +msg = []; +for i = 1:size(grid.cells,2) + + error = ''; + string = get(grid.cells(i).cond,'String'); + + if ( strcmp(string,'') || isempty(string)) && i == 1 && isempty(grid.parent_grid) && size(grid.cells,2) == 1 + break + end + + % if the string is empty indicating that the table is 1 + % dimensional or the string is "otherwise" skip the syntax + % checking. + if(~isempty(string) && ~strcmp(string,'otherwise')) + error = object.check_matlab_syntax_condition(char(string),0); + end + if isempty(error) + if (strcmp(string,'') || isempty(string)) + error = 'Cell is empty'; end + end + if ~isempty(error) + % generate the message string + msg = [msg sprintf('\n')]; + + msg = [msg 'Condtion -> ' char(string) sprintf('\n')]; + msg = [msg error sprintf('\n')]; + + % set tooltip string of cell to error msg + set(grid.cells(i).cond,'TooltipString',error) + % change background colour + grid.cells(i).flag_cell(1); + else + % reset tooltip and colour if no error found + set(grid.cells(i).cond,'TooltipString','') + grid.cells(i).flag_cell(0); + + + end + % recurse through subgrid + if(~isempty(grid.cells(i).subgrid)) + msg = [msg object.check_grid_condition(grid.cells(i).subgrid)]; + end + + +end +end diff --git a/@GUI/check_grid_result.m b/@GUI/check_grid_result.m index c25622c9861966f38255efc8dfbe29e35a4f0958..9b54bb754f21672289f4c3f497b2ce7370d8d4bc 100644 --- a/@GUI/check_grid_result.m +++ b/@GUI/check_grid_result.m @@ -1,39 +1,41 @@ - %% check_grid_result - % Similar to above function check_grid_result, will loop through - % the cells of the output grid, unline check_grid, does not need to - % recurse. - % inputs: - % object:GUI - current GUI object - % grid:RGrid - RGrid object to be checked - % outputs: - % none - function msg = check_grid_result(object,grid) - msg = []; - for i = 1:size(grid.Cells,2) - error = ''; - string = get(grid.Cells(i).result,'String'); - - - error = object.check_matlab_syntax_condition(char(string),1); - if isempty(error) - if (strcmp(string,'') || isempty(string)) - error = 'Cell is empty'; - end - end - if ~isempty(error) - msg = [msg sprintf('\n')]; - - msg = [msg 'Result -> ' char(string) sprintf('\n')]; - msg = [msg error sprintf('\n')]; - - - set(grid.Cells(i).result,'TooltipString',error) - grid.Cells(i).flag_cell(1) - else - set(grid.Cells(i).result,'TooltipString','') - grid.Cells(i).flag_cell(0) - end - - end +%% check_grid_result +% Similar to above function check_grid_result, will loop through +% the cells of the output grid, unline check_grid, does not need to +% recurse. +% inputs: +% object:GUI - current GUI object +% grid:RGrid - RGrid object to be checked +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function msg = check_grid_result(object,grid) +msg = []; +for i = 1:size(grid.Cells,2) + error = ''; + string = get(grid.Cells(i).result,'String'); + + + error = object.check_matlab_syntax_condition(char(string),1); + if isempty(error) + if (strcmp(string,'') || isempty(string)) + error = 'Cell is empty'; end + end + if ~isempty(error) + msg = [msg sprintf('\n')]; + msg = [msg 'Result -> ' char(string) sprintf('\n')]; + msg = [msg error sprintf('\n')]; + + + set(grid.Cells(i).result,'TooltipString',error) + grid.Cells(i).flag_cell(1) + else + set(grid.Cells(i).result,'TooltipString','') + grid.Cells(i).flag_cell(0) + end + +end +end + diff --git a/@GUI/check_inputs.m b/@GUI/check_inputs.m index 2879c3c9db5b7781a2a4773d010d26347e6a08de..770f1d58e4f2fa6682288ee2148896a107949c55 100644 --- a/@GUI/check_inputs.m +++ b/@GUI/check_inputs.m @@ -1,21 +1,23 @@ - - - %% check_inputs - % ensure that the inputs are proper variable names, and that the - % input string parses properly - % inputs: - % object:GUI - current GUI object - % outputs: - % error:string - error string if variable is not inputed properly - function error = check_inputs(object) - parsed_input = EMLGenerator.parse_inputs(get(object.function_inputs_control,'string')); - error = []; - for i=1:size(parsed_input,2) - if(size(parsed_input{i},2) == 2) - if (strcmp(parsed_input{i}(2),'error')) - error = [error sprintf('%s is not a valid variable name\n',char(parsed_input{i}(1))) ]; - end - end - end + + +%% check_inputs +% ensure that the inputs are proper variable names, and that the +% input string parses properly +% inputs: +% object:GUI - current GUI object +% outputs: +% error:string - error string if variable is not inputed properly +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function error = check_inputs(object) +parsed_input = EMLGenerator.parse_inputs(get(object.function_inputs_control,'string')); +error = []; +for i=1:size(parsed_input,2) + if(size(parsed_input{i},2) == 2) + if (strcmp(parsed_input{i}(2),'error')) + error = [error sprintf('%s is not a valid variable name\n',char(parsed_input{i}(1))) ]; end + end +end +end diff --git a/@GUI/check_matlab_syntax_condition.m b/@GUI/check_matlab_syntax_condition.m index 7e549cc3be1405b08e71687a2090d602c6b42c72..dc602838cf2b9e1c50cd712620092030acbfe4e9 100644 --- a/@GUI/check_matlab_syntax_condition.m +++ b/@GUI/check_matlab_syntax_condition.m @@ -1,61 +1,63 @@ - %% check_matlab_syntax - % this function will check that a string is valid matlab syntax - % for the context that it is in. we need to build up the - % expression which involves initiallizeing the input variables to - % a dummy value and wraping an if statement around conditionals - % inputs: - % object:GUI - current GUI object - % string:string - string to be checked - % result:boolean - false if the string is a conditoin true if - % the string is an output statement - % outputs: - % error:string - string containing the error message, empty if - % there is no error - function error = check_matlab_syntax_condition(object,string,result) - % split the list of inputs to get inputs seperatly - - parsed_input = EMLGenerator.parse_inputs(get(object.function_inputs_control,'string')); - check_string = []; - - % initialize inputs to zero - % functions are assumed to be total, so 0 is just for - % convienence - for i=1:size(parsed_input,2) - % set to zero - check_string = [check_string sprintf('%s=0;\n',char(parsed_input{i}(1)))]; - - - end - if ~result - % the string is a condition we need to evaulate it as it - % will be used in the code, as in order for an if statement - % to be valid the condition must evaulate to a numeric - % value not a structure or something else. we need to have - % the 1 in there as a dummy output, which is necesary for - % an if statement to be valid in matlab. - check_string = [check_string 'if (' string sprintf(')\n1;\nend')]; - else - % the string is an output statement we can just evaulate the - % string on its own. - check_string = [check_string string ';' sprintf('\n')]; - end - % attempt to evaluate the string catch the error. - try - eval(check_string); - error = []; - catch exception - error = exception.message; - % attempt to make one of the common errors slightly less - % cryptic. - if(strcmp(exception.identifier,'MATLAB:m_invalid_lhs_of_assignment')) - error = [error sprintf('\nTo check equality use ==')]; - end - end - end - - - - - - - +%% check_matlab_syntax +% this function will check that a string is valid matlab syntax +% for the context that it is in. we need to build up the +% expression which involves initiallizeing the input variables to +% a dummy value and wraping an if statement around conditionals +% inputs: +% object:GUI - current GUI object +% string:string - string to be checked +% result:boolean - false if the string is a conditoin true if +% the string is an output statement +% outputs: +% error:string - string containing the error message, empty if +% there is no error +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function error = check_matlab_syntax_condition(object,string,result) +% split the list of inputs to get inputs seperatly + +parsed_input = EMLGenerator.parse_inputs(get(object.function_inputs_control,'string')); +check_string = []; + +% initialize inputs to zero +% functions are assumed to be total, so 0 is just for +% convienence +for i=1:size(parsed_input,2) + % set to zero + check_string = [check_string sprintf('%s=0;\n',char(parsed_input{i}(1)))]; + + +end +if ~result + % the string is a condition we need to evaulate it as it + % will be used in the code, as in order for an if statement + % to be valid the condition must evaulate to a numeric + % value not a structure or something else. we need to have + % the 1 in there as a dummy output, which is necesary for + % an if statement to be valid in matlab. + check_string = [check_string 'if (' string sprintf(')\n1;\nend')]; +else + % the string is an output statement we can just evaulate the + % string on its own. + check_string = [check_string string ';' sprintf('\n')]; +end +% attempt to evaluate the string catch the error. +try + eval(check_string); + error = []; +catch exception + error = exception.message; + % attempt to make one of the common errors slightly less + % cryptic. + if(strcmp(exception.identifier,'MATLAB:m_invalid_lhs_of_assignment')) + error = [error sprintf('\nTo check equality use ==')]; + end +end +end + + + + + + + diff --git a/@GUI/check_output_consistent.m b/@GUI/check_output_consistent.m index 232413fd496e0633b547d18ca0ed6c84dee1c404..c67e2f177a09586d417514d62fda0534791aeb3a 100644 --- a/@GUI/check_output_consistent.m +++ b/@GUI/check_output_consistent.m @@ -1,6 +1,6 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function result = check_output_consistent( object ) -%UNTITLED Summary of this function goes here -% Detailed explanation goes here output_block_types = object.output_data_type; output_table = {}; diff --git a/@GUI/close_fig.m b/@GUI/close_fig.m index 1f86ab92e15070371faf95bdb6adb9edfe3b48a6..af3dcd9789cc1f1a34df85ae88825a893495f976 100644 --- a/@GUI/close_fig.m +++ b/@GUI/close_fig.m @@ -1,26 +1,28 @@ - %% close_fig - % callback function that is called whenever the close button is - % pressed. - % inputs: - % object - current GUI object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = close_fig(object,src,event) - if (object.validation_report_handle ~= 0) - delete(object.validation_report_handle) - end - object.save_data; - object.Data.open = 0; - object.Data.fig = []; - delete(object.fig); - % remove reference to the old figure. - object.fig = []; - % in simulink mode - if(object.mode == 1) - parent = get_param(object.block_handle,'Parent'); - open_system(parent); - end - end - +%% close_fig +% callback function that is called whenever the close button is +% pressed. +% inputs: +% object - current GUI object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = close_fig(object,src,event) +if (object.validation_report_handle ~= 0) + delete(object.validation_report_handle) +end +object.save_data; +object.Data.open = 0; +object.Data.fig = []; +delete(object.fig); +% remove reference to the old figure. +object.fig = []; +% in simulink mode +if(object.mode == 1) + parent = get_param(object.block_handle,'Parent'); + open_system(parent); +end +end + diff --git a/@GUI/create_std_text.m b/@GUI/create_std_text.m index e5a4ba36ff2cfc8aeff2e268d931d2ca5a4f9208..d930207220577c1706405e352aaef02236edea72 100644 --- a/@GUI/create_std_text.m +++ b/@GUI/create_std_text.m @@ -1,31 +1,29 @@ +%% create_std_text +% function will create an edit text box used for conditons and +% results. we want these to be consistent so its easier for it to +% be in one function. +% inputs: +% obj:GUI - current GUI object +% Parent:double - handle to parent figure +% position:[double double double double] - position to place edit +% box in. +% outputs: +% control:double - handle pointing to newly created uicontrol +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function control = create_std_text(object, Parent, position) +control = uicontrol('style','edit',... + 'Parent',Parent,... + 'units','pix',... + 'position',position,... + 'min',0,'max',1,... % This is the key to multiline edits. + 'string',{''},... + 'Max',2.0,... + 'Clipping','on',... + 'fontweight','bold',... + 'BackgroundColor',[1 1 1],... + 'horizontalalign','center',... + 'KeyPressFcn',@(src,event)textbox_callback(object,src,event),... + 'fontsize',11); +end - - - %% create_std_text - % function will create an edit text box used for conditons and - % results. we want these to be consistent so its easier for it to - % be in one function. - % inputs: - % obj:GUI - current GUI object - % Parent:double - handle to parent figure - % position:[double double double double] - position to place edit - % box in. - % outputs: - % control:double - handle pointing to newly created uicontrol - function control = create_std_text(object, Parent, position) - control = uicontrol('style','edit',... - 'Parent',Parent,... - 'units','pix',... - 'position',position,... - 'min',0,'max',1,... % This is the key to multiline edits. - 'string',{''},... - 'Max',2.0,... - 'Clipping','on',... - 'fontweight','bold',... - 'BackgroundColor',[1 1 1],... - 'horizontalalign','center',... - 'KeyPressFcn',@(src,event)textbox_callback(object,src,event),... - 'fontsize',11); - end - - \ No newline at end of file diff --git a/@GUI/draw_allgrids.m b/@GUI/draw_allgrids.m index 14e33baa6a5e70100cfc455bbccfe0638e1059b8..9b7d5a3f98da13f16b9f6cd765694b31dd417688 100644 --- a/@GUI/draw_allgrids.m +++ b/@GUI/draw_allgrids.m @@ -1,15 +1,17 @@ - %% draw_allgrids - % function will call the draw methods for each of the 3 grids. - % inputs: - % obj:GUI - current GUI object - % load:boolean - 0 if grid is being refreshed, 1 if grid is being - % loaded for the firs time. - % outputs: - % none - function [] = draw_allgrids(object,load) - object.draw_grid2(object.Grid2,load); - object.draw_grid1(object.Grid1,load); - - object.draw_grid0(object.Grid0,load); - end - +%% draw_allgrids +% function will call the draw methods for each of the 3 grids. +% inputs: +% obj:GUI - current GUI object +% load:boolean - 0 if grid is being refreshed, 1 if grid is being +% loaded for the firs time. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = draw_allgrids(object,load) +object.draw_grid2(object.Grid2,load); +object.draw_grid1(object.Grid1,load); + +object.draw_grid0(object.Grid0,load); +end + diff --git a/@GUI/draw_grid0.m b/@GUI/draw_grid0.m index 9c7f1172062da4666951292e2472eb10618f69ac..a49ed91657692ff75f1c57e198135e375ad7acd3 100644 --- a/@GUI/draw_grid0.m +++ b/@GUI/draw_grid0.m @@ -1,36 +1,38 @@ - %% draw_grid0 - % function will draw the output grid onto the figure - % inputs: - % obj:GUI - current GUI object - % grid:Grid - grid to be drawn, should be grid on left. - % load:boolean - 0 if grid is being refreshed, 1 if grid is being - % loaded for the firs time. - % outputs: - % none - function [] = draw_grid0(object,grid,load) - % ensure that the results grid is up to date. - grid.refresh(); - for i=1:size(grid.Cells,2) - % get the x coordinate from the associated top grid cell, - % get the y coordinate from the associated right grid cell. - pos1 = grid.Cells(i).Cell1.get_pos; - pos2 = grid.Cells(i).Cell2.get_pos; - pos = [0 0 0 0]; - pos(1) = pos1(1); - pos(2) = pos2(2); - pos(3) = pos1(3); - pos(4) = pos2(4); - if isempty(grid.Cells(i).result) || ~ishandle(grid.Cells(i).result)%load == 1 - - grid.Cells(i).result = object.create_std_text(object.fig,pos); - % if we are loading the cell, try to restore the text - % that was saved using save_results. - if load == 1 - set(grid.Cells(i).result,'String',grid.Cells(i).result_text); - end - else - set(grid.Cells(i).result,'position',pos); - end - end - end +%% draw_grid0 +% function will draw the output grid onto the figure +% inputs: +% obj:GUI - current GUI object +% grid:Grid - grid to be drawn, should be grid on left. +% load:boolean - 0 if grid is being refreshed, 1 if grid is being +% loaded for the firs time. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = draw_grid0(object,grid,load) +% ensure that the results grid is up to date. +grid.refresh(); +for i=1:size(grid.Cells,2) + % get the x coordinate from the associated top grid cell, + % get the y coordinate from the associated right grid cell. + pos1 = grid.Cells(i).Cell1.get_pos; + pos2 = grid.Cells(i).Cell2.get_pos; + pos = [0 0 0 0]; + pos(1) = pos1(1); + pos(2) = pos2(2); + pos(3) = pos1(3); + pos(4) = pos2(4); + if isempty(grid.Cells(i).result) || ~ishandle(grid.Cells(i).result)%load == 1 + grid.Cells(i).result = object.create_std_text(object.fig,pos); + % if we are loading the cell, try to restore the text + % that was saved using save_results. + if load == 1 + set(grid.Cells(i).result,'String',grid.Cells(i).result_text); + end + else + set(grid.Cells(i).result,'position',pos); + end +end +end + diff --git a/@GUI/draw_grid1.m b/@GUI/draw_grid1.m index c166b841e5f5984fedb3d5bfe6e5808593e63217..c0fabc6d316869accde3b13122dac9c23f1dc7db 100644 --- a/@GUI/draw_grid1.m +++ b/@GUI/draw_grid1.m @@ -1,86 +1,88 @@ - %% draw_grid1 - % Draws the grid on the top onto the figure. the current - % assumption is that the top grid does not have any subgrids, - % inputs: - % obj:GUI - current GUI object - % grid:Grid - grid to be drawn, should be grid on top. - % load:boolean - 0 if grid is being refreshed, 1 if grid is being - % loaded for the firs time. - % outputs: - % none - function [] = draw_grid1(object,grid,load) - % assumption grid 1 has no subgrids - pos = []; - for i=1:size(grid.cells,2) - % if we are in edit mode we need to shift over the cells to - % accomidate for the new grid buttons in the left grid. - if(object.edit == 1) - pb_space = grid.cells(i).grid_push_width; - else - pb_space = 0; - end - figpos = get(object.fig,'position'); - - % check if grid2 is empty, currently grid 2 will never be - % empty, may change in future though. - if (isempty(object.Grid2)) - pos = [grid.cells(i).condition_text_x grid.cells(i).condition_text_y grid.cells(i).condition_text_width grid.cells(i).condition_text_height]; - else - pos = [grid.cells(i).condition_text_x+grid.cells(i).condition_text_width*object.Grid2.max_width(1) figpos(4)-object.header_height-grid.cells(i).condition_text_y-grid.cells(i).condition_text_height grid.cells(i).condition_text_width grid.cells(i).condition_text_height]; - end - % set the x coordinate of the cell - pos(1) = pos(1) + (i-1)*grid.cells(i).condition_text_width + grid.cells(i).condition_text_offset + pb_space; - % if the edit box does not exist create it, if it does - % adjust it's position. - if (isempty(grid.cells(i).cond) || ~ishandle(grid.cells(i).cond))%load == 1) - grid.cells(i).cond = object.create_std_text(object.fig,pos); - if (load == 1) - set(grid.cells(i).cond,'String',grid.cells(i).cond_text); - end - else - grid.cells(i).set_pos(pos); - end - - if(object.edit == 0) - string = get(grid.cells(i).cond,'String') - if(isempty(string)) - set(grid.cells(i).cond,'Visible','off'); - end - else - set(grid.cells(i).cond,'Visible','on'); - end - end - % if we are in edit mode, draw the new and delete buttons at - % the right of the last cell - if( object.edit == 1) - pos(1) = pos(1) + pos(3); - pos(2) = pos(2) + 20; - pos(4) = 20; - pos(3) = 60; - grid.set_pb(object.fig,pos); - pos(2) = pos(2) - 20; - - grid.set_delete_pb(object.fig,pos); - set(grid.delete_cell_pb,'userdata',object); - set(grid.new_cell_pb,'userdata',object); - else - delete(grid.new_cell_pb) - grid.new_cell_pb = []; - delete(grid.delete_cell_pb) - grid.delete_cell_pb = []; - end - if object.edit ==1 || load == 1 - fig_pos = get(object.fig,'position'); - if(pos(1)+pos(3)>fig_pos(3)) - fig_pos(3) = pos(1)+pos(3); - set(object.fig,'position',fig_pos); - elseif (pos(1) + pos(3)object.fig_width) - fig_pos(3) = pos(1)+pos(3); - set(object.fig,'position',fig_pos); - end - end +%% draw_grid1 +% Draws the grid on the top onto the figure. the current +% assumption is that the top grid does not have any subgrids, +% inputs: +% obj:GUI - current GUI object +% grid:Grid - grid to be drawn, should be grid on top. +% load:boolean - 0 if grid is being refreshed, 1 if grid is being +% loaded for the firs time. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = draw_grid1(object,grid,load) +% assumption grid 1 has no subgrids +pos = []; +for i=1:size(grid.cells,2) + % if we are in edit mode we need to shift over the cells to + % accomidate for the new grid buttons in the left grid. + if(object.edit == 1) + pb_space = grid.cells(i).grid_push_width; + else + pb_space = 0; + end + figpos = get(object.fig,'position'); + + % check if grid2 is empty, currently grid 2 will never be + % empty, may change in future though. + if (isempty(object.Grid2)) + pos = [grid.cells(i).condition_text_x grid.cells(i).condition_text_y grid.cells(i).condition_text_width grid.cells(i).condition_text_height]; + else + pos = [grid.cells(i).condition_text_x+grid.cells(i).condition_text_width*object.Grid2.max_width(1) figpos(4)-object.header_height-grid.cells(i).condition_text_y-grid.cells(i).condition_text_height grid.cells(i).condition_text_width grid.cells(i).condition_text_height]; + end + % set the x coordinate of the cell + pos(1) = pos(1) + (i-1)*grid.cells(i).condition_text_width + grid.cells(i).condition_text_offset + pb_space; + % if the edit box does not exist create it, if it does + % adjust it's position. + if (isempty(grid.cells(i).cond) || ~ishandle(grid.cells(i).cond))%load == 1) + grid.cells(i).cond = object.create_std_text(object.fig,pos); + if (load == 1) + set(grid.cells(i).cond,'String',grid.cells(i).cond_text); + end + else + grid.cells(i).set_pos(pos); + end + + if(object.edit == 0) + string = get(grid.cells(i).cond,'String') + if(isempty(string)) + set(grid.cells(i).cond,'Visible','off'); end - + else + set(grid.cells(i).cond,'Visible','on'); + end +end +% if we are in edit mode, draw the new and delete buttons at +% the right of the last cell +if( object.edit == 1) + pos(1) = pos(1) + pos(3); + pos(2) = pos(2) + 20; + pos(4) = 20; + pos(3) = 60; + grid.set_pb(object.fig,pos); + pos(2) = pos(2) - 20; + + grid.set_delete_pb(object.fig,pos); + set(grid.delete_cell_pb,'userdata',object); + set(grid.new_cell_pb,'userdata',object); +else + delete(grid.new_cell_pb) + grid.new_cell_pb = []; + delete(grid.delete_cell_pb) + grid.delete_cell_pb = []; +end +if object.edit ==1 || load == 1 + fig_pos = get(object.fig,'position'); + if(pos(1)+pos(3)>fig_pos(3)) + fig_pos(3) = pos(1)+pos(3); + set(object.fig,'position',fig_pos); + elseif (pos(1) + pos(3)object.fig_width) + fig_pos(3) = pos(1)+pos(3); + set(object.fig,'position',fig_pos); + end +end +end + diff --git a/@GUI/draw_grid2.m b/@GUI/draw_grid2.m index b8191c1b4544532f1e0a5a4d48ce450ff39e9212..a1f5f57e895bb4255ad63d8b0af26cf485505c00 100644 --- a/@GUI/draw_grid2.m +++ b/@GUI/draw_grid2.m @@ -1,164 +1,166 @@ - %% draw_grid2 - % Draws the grid on the left onto the figure. - % inputs: - % obj:GUI - current GUI object - % grid:Grid - grid to be drawn, should be grid on left. - % load:boolean - 0 if grid is being refreshed, 1 if grid is being - % loaded for the firs time. - % outputs: - % none - function [] = draw_grid2(object,grid,load) - if (~isempty(grid)) - % generate a random pastel colour for the background, each - % grid has a different colour to help with readability - grid_color = [0.9+0.1*rand(1) 0.9+0.1*rand(1) 0.9+0.1*rand(1)]; - for i=1:size(grid.cells,2) - % check if the grid is the root grid - if (~isempty(grid.parent_cell)) - % grid is not the root grid location is derived - % from its parent. - parent_pos = grid.parent_cell.get_pos; - if i == 1 - % if we are at the first cell, location is the - % same as the parent but shifted to the right - % by one cell - pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; - pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; - pos(1) = parent_pos(1) + parent_pos(3); - pos(2) = parent_pos(2) + parent_pos(4) - pos(4); - else - % if we are not at the first cell, location is - % the same as the previous cell but we shift - % down by one cell - prev_pos = grid.cells(i-1).get_pos; - pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; - pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; - pos(1) = parent_pos(1) + parent_pos(3); - pos(2) = prev_pos(2) - pos(4); - grid_color = grid.cells(i-1).color; - - end - else - % grid is the root grid. - % position of the first cell is based on - % condition_text_x, and condition_text_y, as well - % as the height of the figure and header. - figpos = get(object.fig,'position'); - pos = [grid.cells(i).condition_text_x figpos(4)-object.header_height-grid.cells(i).condition_text_y grid.cells(i).condition_text_width grid.cells(i).condition_text_height]; - if i == 1 - pos(1) = pos(1); - pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; - - pos(2) = pos(2)-pos(4)-grid.cells(i).condition_text_height-grid.cells(i).condition_text_offset; - pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; - pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; - else - prev_pos = grid.cells(i-1).get_pos; - pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; - pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; - pos(1) = pos(1); - pos(2) = prev_pos(2) - pos(4); - grid_color = grid.cells(i-1).color; - end - end - - - % if the edit box does not exist, ie. it is just being - % created or we are loading the figure - if (isempty(grid.cells(i).cond) || ~ishandle(grid.cells(i).cond))%load == 1) - % create the new edit box - grid.cells(i).cond = object.create_std_text(object.fig,pos); - % if cell is the first in the grid use the new - % colour, else take the colour of the previous cell - % in the grid. - if(i==1) - set(grid.cells(i).cond,'BackgroundColor',grid_color); - else - set(grid.cells(i).cond,'BackgroundColor',get(grid.cells(i-1).cond,'BackgroundColor')) - end - grid.cells(i).color = grid_color; - % if we are loading the cell set the string of the - % edit box to be the value that we saved as a - % result of calling save_conditions - if (load == 1) - set(grid.cells(i).cond,'String',grid.cells(i).cond_text); - end - else - % if the edit box is already created change is - % position to newly determined position. - grid.cells(i).set_pos(pos); - end - % determine if we want to draw the new subgrid buttons, - % which is located to the right of each of the leaf - % cells. - if(grid.cells(i).pb_flag == 1 && object.edit == 1) - pb_pos = pos; - pb_pos(1) = pos(1)+pos(3); - pb_pos(3) = grid.cells(i).grid_push_width; - if (ishghandle(grid.cells(i).grid_pb)) - set(grid.cells(i).grid_pb,'Visible','on'); - end - grid.cells(i).set_pb(object.fig,pb_pos) - set(grid.cells(i).grid_pb,'UserData',object); - elseif(grid.cells(i).pb_flag == 1 && object.edit ~= 1) - if (ishghandle(grid.cells(i).grid_pb)) - set(grid.cells(i).grid_pb,'Visible','off') - end - end - - delete_pb_pos = []; - - - % detemine if we want to draw the new cell buttons, - % which are located at the botton of the set of cells. - if (i == size(grid.cells,2) && object.edit == 1) - new_pb_pos = pos; - new_pb_pos(4) = grid.cells(i).condition_text_height/2; - new_pb_pos(3) = pos(3)/2; - new_pb_pos(2) = pos(2) - new_pb_pos(4); - if (ishghandle(grid.new_cell_pb)) - set(grid.new_cell_pb,'Visible','on'); - end - grid.set_pb(object.fig,new_pb_pos); - set(grid.new_cell_pb,'userdata',object); - - - delete_pb_pos = new_pb_pos; - delete_pb_pos(1) = new_pb_pos(1) + new_pb_pos(3); - if (ishghandle(grid.delete_cell_pb)) - set(grid.delete_cell_pb,'Visible','on'); - end - grid.set_delete_pb(object.fig,delete_pb_pos); - set(grid.delete_cell_pb,'userdata',object); - elseif (i == size(grid.cells,2) && object.edit ~= 1) - - if (ishghandle(grid.new_cell_pb)) - set(grid.new_cell_pb,'Visible','off'); - end - - if (ishghandle(grid.delete_cell_pb)) - set(grid.delete_cell_pb,'Visible','off'); - end - end - - - - % recursively draw the subgrid of the cell if it - % exists. - object.draw_grid2(grid.cells(i).subgrid,load); - - if(object.edit == 0) - string = get(grid.cells(i).cond,'String') - if(isempty(string)) - set(grid.cells(i).cond,'Visible','off'); - end - else - set(grid.cells(i).cond,'Visible','on'); - end - - end +%% draw_grid2 +% Draws the grid on the left onto the figure. +% inputs: +% obj:GUI - current GUI object +% grid:Grid - grid to be drawn, should be grid on left. +% load:boolean - 0 if grid is being refreshed, 1 if grid is being +% loaded for the firs time. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = draw_grid2(object,grid,load) +if (~isempty(grid)) + % generate a random pastel colour for the background, each + % grid has a different colour to help with readability + grid_color = [0.9+0.1*rand(1) 0.9+0.1*rand(1) 0.9+0.1*rand(1)]; + for i=1:size(grid.cells,2) + % check if the grid is the root grid + if (~isempty(grid.parent_cell)) + % grid is not the root grid location is derived + % from its parent. + parent_pos = grid.parent_cell.get_pos; + if i == 1 + % if we are at the first cell, location is the + % same as the parent but shifted to the right + % by one cell + pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; + pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; + pos(1) = parent_pos(1) + parent_pos(3); + pos(2) = parent_pos(2) + parent_pos(4) - pos(4); + else + % if we are not at the first cell, location is + % the same as the previous cell but we shift + % down by one cell + prev_pos = grid.cells(i-1).get_pos; + pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; + pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; + pos(1) = parent_pos(1) + parent_pos(3); + pos(2) = prev_pos(2) - pos(4); + grid_color = grid.cells(i-1).color; - + end + else + % grid is the root grid. + % position of the first cell is based on + % condition_text_x, and condition_text_y, as well + % as the height of the figure and header. + figpos = get(object.fig,'position'); + pos = [grid.cells(i).condition_text_x figpos(4)-object.header_height-grid.cells(i).condition_text_y grid.cells(i).condition_text_width grid.cells(i).condition_text_height]; + if i == 1 + pos(1) = pos(1); + pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; + + pos(2) = pos(2)-pos(4)-grid.cells(i).condition_text_height-grid.cells(i).condition_text_offset; + pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; + pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; + else + prev_pos = grid.cells(i-1).get_pos; + pos(3) = grid.cells(i).width * grid.cells(i).condition_text_width; + pos(4) = grid.cells(i).height * grid.cells(i).condition_text_height; + pos(1) = pos(1); + pos(2) = prev_pos(2) - pos(4); + grid_color = grid.cells(i-1).color; + end + end + + + % if the edit box does not exist, ie. it is just being + % created or we are loading the figure + if (isempty(grid.cells(i).cond) || ~ishandle(grid.cells(i).cond))%load == 1) + % create the new edit box + grid.cells(i).cond = object.create_std_text(object.fig,pos); + % if cell is the first in the grid use the new + % colour, else take the colour of the previous cell + % in the grid. + if(i==1) + set(grid.cells(i).cond,'BackgroundColor',grid_color); + else + set(grid.cells(i).cond,'BackgroundColor',get(grid.cells(i-1).cond,'BackgroundColor')) + end + grid.cells(i).color = grid_color; + % if we are loading the cell set the string of the + % edit box to be the value that we saved as a + % result of calling save_conditions + if (load == 1) + set(grid.cells(i).cond,'String',grid.cells(i).cond_text); + end + else + % if the edit box is already created change is + % position to newly determined position. + grid.cells(i).set_pos(pos); + end + % determine if we want to draw the new subgrid buttons, + % which is located to the right of each of the leaf + % cells. + if(grid.cells(i).pb_flag == 1 && object.edit == 1) + pb_pos = pos; + pb_pos(1) = pos(1)+pos(3); + pb_pos(3) = grid.cells(i).grid_push_width; + if (ishghandle(grid.cells(i).grid_pb)) + set(grid.cells(i).grid_pb,'Visible','on'); + end + grid.cells(i).set_pb(object.fig,pb_pos) + set(grid.cells(i).grid_pb,'UserData',object); + elseif(grid.cells(i).pb_flag == 1 && object.edit ~= 1) + if (ishghandle(grid.cells(i).grid_pb)) + set(grid.cells(i).grid_pb,'Visible','off') + end + end + + delete_pb_pos = []; + + + % detemine if we want to draw the new cell buttons, + % which are located at the botton of the set of cells. + if (i == size(grid.cells,2) && object.edit == 1) + new_pb_pos = pos; + new_pb_pos(4) = grid.cells(i).condition_text_height/2; + new_pb_pos(3) = pos(3)/2; + new_pb_pos(2) = pos(2) - new_pb_pos(4); + if (ishghandle(grid.new_cell_pb)) + set(grid.new_cell_pb,'Visible','on'); + end + grid.set_pb(object.fig,new_pb_pos); + set(grid.new_cell_pb,'userdata',object); + + + delete_pb_pos = new_pb_pos; + delete_pb_pos(1) = new_pb_pos(1) + new_pb_pos(3); + if (ishghandle(grid.delete_cell_pb)) + set(grid.delete_cell_pb,'Visible','on'); + end + grid.set_delete_pb(object.fig,delete_pb_pos); + set(grid.delete_cell_pb,'userdata',object); + elseif (i == size(grid.cells,2) && object.edit ~= 1) + + if (ishghandle(grid.new_cell_pb)) + set(grid.new_cell_pb,'Visible','off'); + end + + if (ishghandle(grid.delete_cell_pb)) + set(grid.delete_cell_pb,'Visible','off'); end end + + + % recursively draw the subgrid of the cell if it + % exists. + object.draw_grid2(grid.cells(i).subgrid,load); + + if(object.edit == 0) + string = get(grid.cells(i).cond,'String') + if(isempty(string)) + set(grid.cells(i).cond,'Visible','off'); + end + else + set(grid.cells(i).cond,'Visible','on'); + end + + end + + +end +end + diff --git a/@GUI/edit_tog_call.m b/@GUI/edit_tog_call.m index 5e8197cb9f23addc528fcd2b45ea9f6bcd02766c..a21215b3feafda67429d889f9a4cd2e0242c8a6b 100644 --- a/@GUI/edit_tog_call.m +++ b/@GUI/edit_tog_call.m @@ -1,21 +1,23 @@ - %% edit_tog_call - % callback function for when the edit button is clicked. when - % edit is toggled we want to redraw the table with the edit - % button visible or not visible - % inputs: - % object - current GUI object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = edit_tog_call(object,src,event) - % save the value of the edit toggle - value = get(src,'Value'); - object.edit = value; - % reset the widths and heights of the grid then redraw all the - % grids. - object.reset_wh; - object.draw_allgrids(0); - - end - +%% edit_tog_call +% callback function for when the edit button is clicked. when +% edit is toggled we want to redraw the table with the edit +% button visible or not visible +% inputs: +% object - current GUI object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = edit_tog_call(object,src,event) +% save the value of the edit toggle +value = get(src,'Value'); +object.edit = value; +% reset the widths and heights of the grid then redraw all the +% grids. +object.reset_wh; +object.draw_allgrids(0); + +end + diff --git a/@GUI/evaluate_counter.m b/@GUI/evaluate_counter.m index 5fc7aa1dee4ba9dffd0391f70f8a66693f262c64..7fd54d33bdf227156a86a2c3dd48890c581ff3f2 100644 --- a/@GUI/evaluate_counter.m +++ b/@GUI/evaluate_counter.m @@ -1,18 +1,19 @@ - %% evaluate_counter - % function will call the evaluation function for a given counter - % example. - % inputs: - % object:GUI - current GUI object - % counter:string - string representing the counter example, ie. - % 'x = 3\ny = 5' - % outputs: - % none - function [] = evaluate_counter(object,counter) - - problem = object.evaluate_counter_grid(object.Grid2, counter); - if(~problem) - object.evaluate_counter_grid(object.Grid1, counter) - end - end - - \ No newline at end of file +%% evaluate_counter +% function will call the evaluation function for a given counter +% example. +% inputs: +% object:GUI - current GUI object +% counter:string - string representing the counter example, ie. +% 'x = 3\ny = 5' +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = evaluate_counter(object,counter) + +problem = object.evaluate_counter_grid(object.Grid2, counter); +if(~problem) + object.evaluate_counter_grid(object.Grid1, counter) +end +end + diff --git a/@GUI/evaluate_counter_grid.m b/@GUI/evaluate_counter_grid.m index 19cb3edf4f15db9ad3e66374f2e6e1e9ff339925..1990023975100f072857cae61c6ece3145f47475 100644 --- a/@GUI/evaluate_counter_grid.m +++ b/@GUI/evaluate_counter_grid.m @@ -1,86 +1,88 @@ %% evaluate_counter_grid - % function will evaluate a counter example for a given grid. - % inputs: - % object:GUI - current GUI object - % grid:Grid - the grid to evaluate - % counter:string - string representing the counter example, ie. - % 'x = 3\ny = 5' - % outputs: - % problem:boolean - 1 if grid has overlapping or underspecified - % cells, 0 if not. - function problem = evaluate_counter_grid(object,grid,counter) - % split the list of inputs to get inputs seperatly - inputs = get(object.function_inputs_control,'String'); - inputs2 = []; - for i=1:size(inputs,1) - inputs2 = [inputs2 inputs(i,:)] - end - inputs2 = regexprep(inputs2,'\s',''); - inputs = regexp(inputs2,',','split'); - check_string = []; - - % keep track of the number of condtitions that evaulate to true - true_conds = 0; - sub_problem = 0; - problem = 0; - empty_cell = 0; - % initialize inputs to zero - % functions are assumed to be total, so 0 is just for - % convienence - for i=1:size(inputs,2) - % set to zero +% function will evaluate a counter example for a given grid. +% inputs: +% object:GUI - current GUI object +% grid:Grid - the grid to evaluate +% counter:string - string representing the counter example, ie. +% 'x = 3\ny = 5' +% outputs: +% problem:boolean - 1 if grid has overlapping or underspecified +% cells, 0 if not. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function problem = evaluate_counter_grid(object,grid,counter) +% split the list of inputs to get inputs seperatly +inputs = get(object.function_inputs_control,'String'); +inputs2 = []; +for i=1:size(inputs,1) + inputs2 = [inputs2 inputs(i,:)] +end +inputs2 = regexprep(inputs2,'\s',''); +inputs = regexp(inputs2,',','split'); +check_string = []; + +% keep track of the number of condtitions that evaulate to true +true_conds = 0; +sub_problem = 0; +problem = 0; +empty_cell = 0; +% initialize inputs to zero +% functions are assumed to be total, so 0 is just for +% convienence +for i=1:size(inputs,2) + % set to zero + + %need to parse the types out of the inputs + inputi = regexp(char(inputs(i)),'\w*','match','once'); + check_string = [check_string sprintf('%s=0;\n',char(inputi))]; +end + +check_string = [check_string counter sprintf('\n')]; +for i=1:size(grid.cells,2) + condition_string = get(grid.cells(i).cond,'string'); + if(~isempty(condition_string)) + + eval([check_string 'result =(' char(condition_string) ');']) + if(result == 0) + grid.cells(i).flag_cell(1); + else + true_conds = true_conds + 1; + + grid.cells(i).flag_cell(2); + end + else + empty_cell = 1; + end +end + +if (true_conds == 1) + for i=1:size(grid.cells,2) + condition_string = get(grid.cells(i).cond,'string'); + if(~isempty(condition_string)) + + eval([check_string 'result =(' char(condition_string) ');']) + if(result == 0) + grid.cells(i).flag_cell(1); + else - %need to parse the types out of the inputs - inputi = regexp(char(inputs(i)),'\w*','match','once'); - check_string = [check_string sprintf('%s=0;\n',char(inputi))]; - end - - check_string = [check_string counter sprintf('\n')]; - for i=1:size(grid.cells,2) - condition_string = get(grid.cells(i).cond,'string'); - if(~isempty(condition_string)) - - eval([check_string 'result =(' char(condition_string) ');']) - if(result == 0) - grid.cells(i).flag_cell(1); - else - true_conds = true_conds + 1; - - grid.cells(i).flag_cell(2); - end - else - empty_cell = 1; + if (~isempty(grid.cells(i).subgrid)) + sub_problem = object.evaluate_counter_grid(grid.cells(i).subgrid,counter); end - end - - if (true_conds == 1) - for i=1:size(grid.cells,2) - condition_string = get(grid.cells(i).cond,'string'); - if(~isempty(condition_string)) + grid.cells(i).flag_cell(2); + end + else + empty_cell = 1; + end + end +end + + +if (true_conds ~= 1 || sub_problem == 1) + problem = 1; +end - eval([check_string 'result =(' char(condition_string) ');']) - if(result == 0) - grid.cells(i).flag_cell(1); - else +if (empty_cell) + problem = 0; +end - if (~isempty(grid.cells(i).subgrid)) - sub_problem = object.evaluate_counter_grid(grid.cells(i).subgrid,counter); - end - grid.cells(i).flag_cell(2); - end - else - empty_cell = 1; - end - end - end - - - if (true_conds ~= 1 || sub_problem == 1) - problem = 1; - end - - if (empty_cell) - problem = 0; - end - - end \ No newline at end of file +end \ No newline at end of file diff --git a/@GUI/help_call.m b/@GUI/help_call.m index c295aad036d3e433a3f61cb0a1e620a2c4692b61..907b5836eeb59129ed010b8239fc678ba2ad1fba 100644 --- a/@GUI/help_call.m +++ b/@GUI/help_call.m @@ -1,3 +1,12 @@ +%% help_call +% opens up the help browser and displays the help file for this program +% inputs: +% object:PVS_checker - PVS_checker object +% outputs: +% status:boolean - 0 if pvs file has been checked, 1 if it has +% not +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = help_call(object,src,event) web(fullfile(fileparts(which('TTdiag')),'html','html','TT_help.html'),'-helpbrowser') end \ No newline at end of file diff --git a/@GUI/init.m b/@GUI/init.m index d3b03b8d6d2127450578852f4fe89f308a503385..1050fcc98321de03e0bb4c31a26dcdefb24dce38 100644 --- a/@GUI/init.m +++ b/@GUI/init.m @@ -1,222 +1,223 @@ %% init - % initialize the gui - % inputs: - % obj:GUI - GUI object - % outputs: - % none - function [] = init(object) - - % create the handles for the gui objects - if object.mode == 1 - name = get_param(object.block_handle,'Name'); - elseif object.mode == 0 - name = 'Table Tool'; - end - % main figure - object.fig = figure('units','pixels',... - 'position',[0 0 object.fig_width object.fig_height],... - 'menubar','none',... - 'name','Table Tool',... - 'numbertitle','off',... - 'resize','on',... - 'Name',name,... - 'CloseRequestFcn',@(src,event)close_fig(object,src,event),... - 'ResizeFcn',@(src,event)resize_fig(object,src,event)); - - - % edit button - object.edit_tog = uicontrol('style','toggle',... - 'units','pix',... - 'string','Edit',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'Value',object.edit,... - 'callback',@(src,event)edit_tog_call(object,src,event)); - - % Save button - object.save_pb = uicontrol('style','push',... - 'units','pix',... - 'string','Save',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)save_call(object,src,event)); - - % Close button - object.close_pb = uicontrol('style','push',... - 'units','pix',... - 'string','Close',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)close_fig(object,src,event)); - - % Save external button - object.save_ext_pb = uicontrol('style','push',... - 'units','pix',... - 'string','Save Ext',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)save_ext_call(object,src,event)); - - % PVS button - object.pvs_pb = uicontrol('style','push',... - 'units','pix',... - 'string','PVS',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)pvs_ext_call(object,src,event)); - - % Check button - object.check_pb = uicontrol('style','push',... - 'units','pix',... - 'string','Check',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)check_call(object,src,event)); - - % Input/Output button - object.input_pb = uicontrol('style','push',... - 'units','pix',... - 'string','Ports',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)input_call(object,src,event)); - - % Settings button - object.settings_pb = uicontrol('style','push',... - 'units','pix',... - 'string','Settings',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)settings_call(object,src,event)); - - % Expression Name Label - object.name_label = uicontrol('style','text',... - 'string','Expression Name',... - 'HorizontalAlign','right',... - 'BackgroundColor',get(object.fig,'Color')); - - % Expression Name Edit box - object.function_name_control = uicontrol('style','edit',... - 'units','pix',... - 'Parent',object.fig,... - 'HorizontalAlign','center',... - 'FontWeight','bold',... - 'FontSize',12,... - 'Max',2.0,... - 'KeyPressFcn',@(src,event)textbox_callback(object,src,event),... - 'BackgroundColor',[1 1 1]); - - % input list label - object.input_label = uicontrol('style','text',... - 'string','Inputs',... - 'HorizontalAlign','right',... - 'BackgroundColor',get(object.fig,'Color')); - - % input list edit box - object.function_inputs_control = uicontrol('style','edit',... - 'units','pix',... - 'Parent',object.fig,... - 'HorizontalAlign','center',... - 'FontWeight','bold',... - 'Max',2.0,... - 'FontSize',12,... - 'KeyPressFcn',@(src,event)textbox_callback(object,src,event),... - 'BackgroundColor',[1 1 1]); - - %object.multi_grp = uibuttongroup(... - % 'units','pix',... - % 'Parent',object.fig,... - % 'SelectionChangeFcn',@(src,event)multi_select_call(object,src,event)); - - %object.multi_opt_out = uicontrol('style','radiobutton',... - % 'units','pix',... - % 'Parent',object.multi_grp,... - % 'HorizontalAlign','center',... - % 'FontWeight','bold',... - % 'String','Multiple Output',... - % 'FontSize',12,... - % 'BackgroundColor',[1 1 1]); - - %object.multi_opt_reg = uicontrol('style','radiobutton',... - % 'units','pix',... - % 'Parent',object.multi_grp,... - % 'HorizontalAlign','center',... - % 'FontWeight','bold',... - % 'String','One Output',... - % 'FontSize',12,... - % 'BackgroundColor',[1 1 1]); - - % load the function name and inputs - if (~isempty(object.function_name_text)) - set(object.function_name_control,'String',object.function_name_text); - end - if (~isempty(object.function_inputs_text)) - set(object.function_inputs_control,'String',object.function_inputs_text); - end - - - % Set up Menu - filemenu = uimenu('Label','File'); - editmenu = uimenu('Label','Edit'); - pvsmenu = uimenu('Label','PVS'); - helpmenu = uimenu('Label','Help'); - uimenu(filemenu,'Label','New','Accelerator','n','Callback',@(src,event)new_call(object,src,event)); - uimenu(filemenu,'Label','Open...','Callback',@(src,event)open_call(object,src,event)); - uimenu(filemenu,'Label','Save to Block','Separator','on','Accelerator','s','Callback',@(src,event)save_call(object,src,event)); - uimenu(filemenu,'Label','Save to M-File','Callback',@(src,event)save_ext_call(object,src,event)); - uimenu(filemenu,'Label','Close','Accelerator','w','Separator','on','Callback',@(src,event)close_fig(object,src,event)); - object.undo_opt = uimenu(editmenu,'Label','Undo','Accelerator','z','Callback',@(src,event)undo_call(object,src,event)); - object.redo_opt = uimenu(editmenu,'Label','Redo','Accelerator','r','Callback',@(src,event)redo_call(object,src,event)); - uimenu(editmenu,'Label','Show edit controls','Checked','on','Separator','on'); - uimenu(editmenu,'Label','Ports and Data Manager','Accelerator','p','Callback',@(src,event)input_call(object,src,event)); - multi_mode_menu = uimenu(editmenu,'Label','Output Mode'); - object.multi_opt_reg = uimenu(multi_mode_menu,'Label','One Output','Callback',@(src,event)multi_select_call(object,src,event)); - object.multi_opt_out = uimenu(multi_mode_menu,'Label','Multiple Outputs','Callback',@(src,event)multi_select_call(object,src,event)); - uimenu(pvsmenu,'Label','Typecheck','Accelerator','t','Callback',@(src,event)pvs_ext_call(object,src,event)); - uimenu(pvsmenu,'Label','PVS Settings','Callback',@(src,event)settings_call(object,src,event)); - uimenu(pvsmenu,'Label','Check Status','Callback',@(src,event)prf_file_call(object,src,event)); - uimenu(pvsmenu,'Label','Generate PVS file','Callback',@(src,event)pvs_file_call(object,src,event)); - - uimenu(helpmenu,'Label','Product Help','Callback',@(src,event)help_call(object,src,event)); - uimenu(helpmenu,'Label','About Table Tool','Callback',@(src,event)about_call(object,src,event)); - - object.set_command_pos; - object.reset_wh(); - object.draw_allgrids(1); - object.saved = 1; - object.setPBenable; - - - object.settings = Settings(); - if isfield(object.Data.settings,'set') - object.settings.setvalues(object.Data.settings); - else - object.settings.init(); - - end - - object.undo_man = UndoManager(); - - - - object.update_Statusbar; - object.update_multi_check_status; - object.update_undoredo; - - object.PVS = PVS_checker(object.Data); - object.EMLGen = EMLGenerator(object.Data); - - - - object.initialized = 1; - object.Data.open = 1; - object.Data.fig = object.fig; - - - - - end - - - - \ No newline at end of file +% initialize the gui +% inputs: +% obj:GUI - GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = init(object) + +% create the handles for the gui objects +if object.mode == 1 + name = get_param(object.block_handle,'Name'); +elseif object.mode == 0 + name = 'Table Tool'; +end +% main figure +object.fig = figure('units','pixels',... + 'position',[0 0 object.fig_width object.fig_height],... + 'menubar','none',... + 'name','Table Tool',... + 'numbertitle','off',... + 'resize','on',... + 'Name',name,... + 'CloseRequestFcn',@(src,event)close_fig(object,src,event),... + 'ResizeFcn',@(src,event)resize_fig(object,src,event)); + + +% edit button +object.edit_tog = uicontrol('style','toggle',... + 'units','pix',... + 'string','Edit',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'Value',object.edit,... + 'callback',@(src,event)edit_tog_call(object,src,event)); + +% Save button +object.save_pb = uicontrol('style','push',... + 'units','pix',... + 'string','Save',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)save_call(object,src,event)); + +% Close button +object.close_pb = uicontrol('style','push',... + 'units','pix',... + 'string','Close',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)close_fig(object,src,event)); + +% Save external button +object.save_ext_pb = uicontrol('style','push',... + 'units','pix',... + 'string','Save Ext',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)save_ext_call(object,src,event)); + +% PVS button +object.pvs_pb = uicontrol('style','push',... + 'units','pix',... + 'string','PVS',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)pvs_ext_call(object,src,event)); + +% Check button +object.check_pb = uicontrol('style','push',... + 'units','pix',... + 'string','Check',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)check_call(object,src,event)); + +% Input/Output button +object.input_pb = uicontrol('style','push',... + 'units','pix',... + 'string','Ports',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)input_call(object,src,event)); + +% Settings button +object.settings_pb = uicontrol('style','push',... + 'units','pix',... + 'string','Settings',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)settings_call(object,src,event)); + +% Expression Name Label +object.name_label = uicontrol('style','text',... + 'string','Expression Name',... + 'HorizontalAlign','right',... + 'BackgroundColor',get(object.fig,'Color')); + +% Expression Name Edit box +object.function_name_control = uicontrol('style','edit',... + 'units','pix',... + 'Parent',object.fig,... + 'HorizontalAlign','center',... + 'FontWeight','bold',... + 'FontSize',12,... + 'Max',2.0,... + 'KeyPressFcn',@(src,event)textbox_callback(object,src,event),... + 'BackgroundColor',[1 1 1]); + +% input list label +object.input_label = uicontrol('style','text',... + 'string','Inputs',... + 'HorizontalAlign','right',... + 'BackgroundColor',get(object.fig,'Color')); + +% input list edit box +object.function_inputs_control = uicontrol('style','edit',... + 'units','pix',... + 'Parent',object.fig,... + 'HorizontalAlign','center',... + 'FontWeight','bold',... + 'Max',2.0,... + 'FontSize',12,... + 'KeyPressFcn',@(src,event)textbox_callback(object,src,event),... + 'BackgroundColor',[1 1 1]); + +%object.multi_grp = uibuttongroup(... +% 'units','pix',... +% 'Parent',object.fig,... +% 'SelectionChangeFcn',@(src,event)multi_select_call(object,src,event)); + +%object.multi_opt_out = uicontrol('style','radiobutton',... +% 'units','pix',... +% 'Parent',object.multi_grp,... +% 'HorizontalAlign','center',... +% 'FontWeight','bold',... +% 'String','Multiple Output',... +% 'FontSize',12,... +% 'BackgroundColor',[1 1 1]); + +%object.multi_opt_reg = uicontrol('style','radiobutton',... +% 'units','pix',... +% 'Parent',object.multi_grp,... +% 'HorizontalAlign','center',... +% 'FontWeight','bold',... +% 'String','One Output',... +% 'FontSize',12,... +% 'BackgroundColor',[1 1 1]); + +% load the function name and inputs +if (~isempty(object.function_name_text)) + set(object.function_name_control,'String',object.function_name_text); +end +if (~isempty(object.function_inputs_text)) + set(object.function_inputs_control,'String',object.function_inputs_text); +end + + +% Set up Menu +filemenu = uimenu('Label','File'); +editmenu = uimenu('Label','Edit'); +pvsmenu = uimenu('Label','PVS'); +helpmenu = uimenu('Label','Help'); +uimenu(filemenu,'Label','New','Accelerator','n','Callback',@(src,event)new_call(object,src,event)); +uimenu(filemenu,'Label','Open...','Callback',@(src,event)open_call(object,src,event)); +uimenu(filemenu,'Label','Save to Block','Separator','on','Accelerator','s','Callback',@(src,event)save_call(object,src,event)); +uimenu(filemenu,'Label','Save to M-File','Callback',@(src,event)save_ext_call(object,src,event)); +uimenu(filemenu,'Label','Close','Accelerator','w','Separator','on','Callback',@(src,event)close_fig(object,src,event)); +object.undo_opt = uimenu(editmenu,'Label','Undo','Accelerator','z','Callback',@(src,event)undo_call(object,src,event)); +object.redo_opt = uimenu(editmenu,'Label','Redo','Accelerator','r','Callback',@(src,event)redo_call(object,src,event)); +uimenu(editmenu,'Label','Show edit controls','Checked','on','Separator','on'); +uimenu(editmenu,'Label','Ports and Data Manager','Accelerator','p','Callback',@(src,event)input_call(object,src,event)); +multi_mode_menu = uimenu(editmenu,'Label','Output Mode'); +object.multi_opt_reg = uimenu(multi_mode_menu,'Label','One Output','Callback',@(src,event)multi_select_call(object,src,event)); +object.multi_opt_out = uimenu(multi_mode_menu,'Label','Multiple Outputs','Callback',@(src,event)multi_select_call(object,src,event)); +uimenu(pvsmenu,'Label','Typecheck','Accelerator','t','Callback',@(src,event)pvs_ext_call(object,src,event)); +uimenu(pvsmenu,'Label','PVS Settings','Callback',@(src,event)settings_call(object,src,event)); +uimenu(pvsmenu,'Label','Check Status','Callback',@(src,event)prf_file_call(object,src,event)); +uimenu(pvsmenu,'Label','Generate PVS file','Callback',@(src,event)pvs_file_call(object,src,event)); + +uimenu(helpmenu,'Label','Product Help','Callback',@(src,event)help_call(object,src,event)); +uimenu(helpmenu,'Label','About Table Tool','Callback',@(src,event)about_call(object,src,event)); + +object.set_command_pos; +object.reset_wh(); +object.draw_allgrids(1); +object.saved = 1; +object.setPBenable; + + +object.settings = Settings(); +if isfield(object.Data.settings,'set') + object.settings.setvalues(object.Data.settings); +else + object.settings.init(); + +end + +object.undo_man = UndoManager(); + + + +object.update_Statusbar; +object.update_multi_check_status; +object.update_undoredo; + +object.PVS = PVS_checker(object.Data); +object.EMLGen = EMLGenerator(object.Data); + + + +object.initialized = 1; +object.Data.open = 1; +object.Data.fig = object.fig; + + + + +end + + + diff --git a/@GUI/input_call.m b/@GUI/input_call.m index 536100fd9a0ab55423454be7054a6df145963ae6..01bc4297c5da79d4da4f3d88ad6697fed525ea42 100644 --- a/@GUI/input_call.m +++ b/@GUI/input_call.m @@ -1,22 +1,23 @@ - %% input_call - % function will open up the ports and data management window if - % in simulink mode. - % inputs: - % obj:GUI - GUI objecto - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = input_call(object,src,event) - % make sure in simulink mode. - if object.mode == 1 - eml_handle = object.save_call([],[]); - currentDir = pwd; - cd([matlabroot filesep 'toolbox' filesep 'stateflow' filesep 'stateflow' filesep 'private']); - fHandle = @eml_man; - cd(currentDir); - fHandle('edit_data_ports', sf('get', get_param(char(eml_handle),'UserData'), '.chart')) - end - end - - \ No newline at end of file +%% input_call +% function will open up the ports and data management window if +% in simulink mode. +% inputs: +% obj:GUI - GUI objecto +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = input_call(object,src,event) +% make sure in simulink mode. +if object.mode == 1 + eml_handle = object.save_call([],[]); + currentDir = pwd; + cd([matlabroot filesep 'toolbox' filesep 'stateflow' filesep 'stateflow' filesep 'private']); + fHandle = @eml_man; + cd(currentDir); + fHandle('edit_data_ports', sf('get', get_param(char(eml_handle),'UserData'), '.chart')) +end +end + diff --git a/@GUI/input_data_type.m b/@GUI/input_data_type.m index 8baf7ac89859465acb0123d509851af388adce13..9f44f1c69825d49801d1f536321832084ab80dbf 100644 --- a/@GUI/input_data_type.m +++ b/@GUI/input_data_type.m @@ -8,6 +8,8 @@ % object:GUI - GUI objecto % outputs: % type:string - string representation of the output type. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function types = input_data_type(object) types = []; if (object.mode == 1) diff --git a/@GUI/msgbox_scroll.m b/@GUI/msgbox_scroll.m index b76a858609207e03b91d69a990d03cc39052441e..4874a1f6faf47d9e7b9941d4e1d82d55029302db 100644 --- a/@GUI/msgbox_scroll.m +++ b/@GUI/msgbox_scroll.m @@ -1,26 +1,28 @@ %% msgbox_scroll - % create a message box with a scrollable text area - % inputs: - % msg:string - string to put into the message box - % outputs: - % none - function [] = msgbox_scroll(msg) - fig = figure('units','pixels',... - 'position',[0 0 700 500],... - 'menubar','none',... - 'name','PVS Report',... - 'numbertitle','off'); - - uicontrol('style','edit',... - 'units','pix',... - 'Parent',fig,... - 'HorizontalAlign','center',... - 'FontWeight','bold',... - 'FontSize',12,... - 'Max',2.0,... - 'HorizontalAlign','left',... - 'String',msg,... - 'Position',[1 1 698 498],... - 'BackgroundColor',[1 1 1]); - - end \ No newline at end of file +% create a message box with a scrollable text area +% inputs: +% msg:string - string to put into the message box +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = msgbox_scroll(msg) +fig = figure('units','pixels',... + 'position',[0 0 700 500],... + 'menubar','none',... + 'name','PVS Report',... + 'numbertitle','off'); + +uicontrol('style','edit',... + 'units','pix',... + 'Parent',fig,... + 'HorizontalAlign','center',... + 'FontWeight','bold',... + 'FontSize',12,... + 'Max',2.0,... + 'HorizontalAlign','left',... + 'String',msg,... + 'Position',[1 1 698 498],... + 'BackgroundColor',[1 1 1]); + +end \ No newline at end of file diff --git a/@GUI/multi_select_call.m b/@GUI/multi_select_call.m index e910a0bf25d2a89a73d82ef3b89db0f1b3ef2c80..772a59404304ed3121c12dfc8137892442255ae3 100644 --- a/@GUI/multi_select_call.m +++ b/@GUI/multi_select_call.m @@ -1,4 +1,5 @@ - +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = multi_select_call(object,src,event) label = get(src,'Label'); if strcmp(label,'Multiple Outputs') diff --git a/@GUI/new_call.m b/@GUI/new_call.m index 6eb10d6f89b4d37f679df6d3e285db072f25292e..659e823f34ec644de53e75c5425884097063a6db 100644 --- a/@GUI/new_call.m +++ b/@GUI/new_call.m @@ -1,15 +1,16 @@ - - %% new_call - % callback for new button - % inputs: - % obj:GUI - GUI objecto - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = new_call(object,src,event) - TableToolMatlab - end - - - \ No newline at end of file + +%% new_call +% callback for new button +% inputs: +% obj:GUI - GUI objecto +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = new_call(object,src,event) +TableToolMatlab +end + + diff --git a/@GUI/open_call.m b/@GUI/open_call.m index 0faaf08aaec469035ee71fec61e36a9bede46461..1729da750cff9687498d50a39ab62b0f43a1b512 100644 --- a/@GUI/open_call.m +++ b/@GUI/open_call.m @@ -1,17 +1,18 @@ %% open_call - % callback for the open option, will show a file picker and - % attempt to load the file into a new window. - % inputs: - % obj:GUI - GUI objecto - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = open_call(object,src,event) - [FileName, PathName, FilterIndex] = uigetfile('*.table','Select pvs files'); - if ~isempty(FileName) - TTdiag('Load',[PathName FileName]); - end - end - - \ No newline at end of file +% callback for the open option, will show a file picker and +% attempt to load the file into a new window. +% inputs: +% obj:GUI - GUI objecto +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = open_call(object,src,event) +[FileName, PathName, FilterIndex] = uigetfile('*.table','Select pvs files'); +if ~isempty(FileName) + TTdiag('Load',[PathName FileName]); +end +end + diff --git a/@GUI/output_data_type.m b/@GUI/output_data_type.m index e1db24b90d364a270314e9c8ebe2a836aa0b191e..ee61f2f74e1bbee3bffd4e1ac579dce2c4a0b071 100644 --- a/@GUI/output_data_type.m +++ b/@GUI/output_data_type.m @@ -8,6 +8,8 @@ % object:GUI - GUI objecto % outputs: % type:string - string representation of the output type. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function types = output_data_type(object) types = []; if (object.mode == 1) @@ -26,13 +28,7 @@ if (object.mode == 1) typename = myState.Outputs(i).DataType; end types = [types;{myState.Outputs(i).Name, typename}] - % if strncmp(myState.Outputs.DataType,'Inherit',7); - % type = ''; - % elseif strncmp(myState.Outputs.DataType,'boolean',7); - % type = 'logical'; - % else - % type = myState.Outputs.DataType; - % end + end else types = []; diff --git a/@GUI/prf_file_call.m b/@GUI/prf_file_call.m index 4f3798aa3cd4f4ac0503fe8671937540785f395b..73789bd264ef3f2213287402f36396fcc2b7b740 100644 --- a/@GUI/prf_file_call.m +++ b/@GUI/prf_file_call.m @@ -1,66 +1,67 @@ %% prf_file_call - % callback for the check status menu option, this function will - % check the current status of the table, if the table has been - % proven it will alert the user and update the status, if it has - % not been proven it will alert the user. - % inputs: - % obj:GUI - GUI objecto - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = prf_file_call(object,src,event) - object.save_data; - % check if a pvs file exists - if (~exist([object.Data.function_name '.pvs'],'file')) - errordlg(['PVS theory file for this function does not exist' sprintf('\n') 'Nothing to check']); - return; - end - % check if prf file exists - if (~exist([object.Data.function_name '.prf'],'file')) - errordlg(['PVS proof (.prf) file for this function does not exist' sprintf('\n') 'Nothing to check']); - return; - end - % check if pvs file is different from current table - temp_pvs = [object.Data.function_name '_temp']; - object.PVS.generate_pvs_file(temp_pvs); +% callback for the check status menu option, this function will +% check the current status of the table, if the table has been +% proven it will alert the user and update the status, if it has +% not been proven it will alert the user. +% inputs: +% obj:GUI - GUI objecto +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = prf_file_call(object,src,event) +object.save_data; +% check if a pvs file exists +if (~exist([object.Data.function_name '.pvs'],'file')) + errordlg(['PVS theory file for this function does not exist' sprintf('\n') 'Nothing to check']); + return; +end +% check if prf file exists +if (~exist([object.Data.function_name '.prf'],'file')) + errordlg(['PVS proof (.prf) file for this function does not exist' sprintf('\n') 'Nothing to check']); + return; +end +% check if pvs file is different from current table +temp_pvs = [object.Data.function_name '_temp']; +object.PVS.generate_pvs_file(temp_pvs); - % read pvs theory on file - pvs1 = textread([object.Data.function_name '.pvs'], '%s', 'whitespace', '', 'bufsize', 268435456); - pvs2 = textread([temp_pvs '.pvs'], '%s', 'whitespace', '', 'bufsize', 268435456); - - if(size(pvs1{1},2) ~= size(pvs2{1},2)) - errordlg(['pvs-theory file is different from the given graphical representation, ' sprintf('\n') ' you will need to reprove']); - return; - else - - if ~all(pvs1{1} == pvs2{1}) - errordlg(['pvs-theory file is different from the given graphical representation, ' sprintf('\n') ' you will need to reprove']); - return; - end - - - end - delete([temp_pvs '.pvs']); +% read pvs theory on file +pvs1 = textread([object.Data.function_name '.pvs'], '%s', 'whitespace', '', 'bufsize', 268435456); +pvs2 = textread([temp_pvs '.pvs'], '%s', 'whitespace', '', 'bufsize', 268435456); - - status = object.PVS.check_status; - if (status ~= object.pvs_checked) +if(size(pvs1{1},2) ~= size(pvs2{1},2)) + errordlg(['pvs-theory file is different from the given graphical representation, ' sprintf('\n') ' you will need to reprove']); + return; +else + + if ~all(pvs1{1} == pvs2{1}) + errordlg(['pvs-theory file is different from the given graphical representation, ' sprintf('\n') ' you will need to reprove']); + return; + end + + +end +delete([temp_pvs '.pvs']); - object.pvs_checked = status; - object.update_Statusbar; - if (object.mode == 1) - TableBlock.set_block_display(object.block_handle,object.pvs_checked) - end - end +status = object.PVS.check_status; +if (status ~= object.pvs_checked) + + object.pvs_checked = status; + object.update_Statusbar; + if (object.mode == 1) + TableBlock.set_block_display(object.block_handle,object.pvs_checked) + end + +end - if (status == 1) - msgbox('Table has been proven'); - else - msgbox('Table has not been proven'); - end +if (status == 1) + msgbox('Table has been proven'); +else + msgbox('Table has not been proven'); +end + +end - end - - \ No newline at end of file diff --git a/@GUI/pvs_ext_call.m b/@GUI/pvs_ext_call.m index ae1c8ddc5a25ae8047714625449eecf14549d5e6..1c4e7890de0eb0b9990a35ffcafffc3b34292a55 100644 --- a/@GUI/pvs_ext_call.m +++ b/@GUI/pvs_ext_call.m @@ -1,44 +1,45 @@ - %% pvs_ext_call - % function will initiate the typechecking procedure for the table - % inputs: - % obj:GUI - GUI objecto - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = pvs_ext_call(object,src,event) - object.save_call([],[]); - object.save_data; - if (object.validation_report_handle ~= 0) - delete(object.validation_report_handle) - end - error = object.check_call; - - if(object.multi_mode == 0) - object.PVS.output_type = object.output_data_type; - - object.PVS.input_type = object.input_data_type; - end - - if (~error) - [check,result] = object.PVS.pvs_check; - if (check == 1) - msgbox('table is valid') - elseif (check == 0 && strcmp(result,'canceled')) - return; - else - Valid_Report = ValidationReport(object); - Valid_Report.set_results(result); - Valid_Report.init(); - end - object.pvs_checked = check; - object.update_Statusbar; - if (object.mode == 1) +%% pvs_ext_call +% function will initiate the typechecking procedure for the table +% inputs: +% obj:GUI - GUI objecto +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = pvs_ext_call(object,src,event) +object.save_call([],[]); +object.save_data; +if (object.validation_report_handle ~= 0) + delete(object.validation_report_handle) +end +error = object.check_call; - TableBlock.set_block_display(object.block_handle,object.pvs_checked) - end - end +if(object.multi_mode == 0) + object.PVS.output_type = object.output_data_type; + + object.PVS.input_type = object.input_data_type; +end - end +if (~error) + [check,result] = object.PVS.pvs_check; + if (check == 1) + msgbox('table is valid') + elseif (check == 0 && strcmp(result,'canceled')) + return; + else + Valid_Report = ValidationReport(object); + Valid_Report.set_results(result); + Valid_Report.init(); + end + object.pvs_checked = check; + object.update_Statusbar; + if (object.mode == 1) - \ No newline at end of file + TableBlock.set_block_display(object.block_handle,object.pvs_checked) + end +end + +end + diff --git a/@GUI/pvs_file_call.m b/@GUI/pvs_file_call.m index ca9e4048af921656b64091ca7cf8d934fd15176c..70f2e8f47c22c80fb52b372215c43fa582c3a4a9 100644 --- a/@GUI/pvs_file_call.m +++ b/@GUI/pvs_file_call.m @@ -1,17 +1,18 @@ - %% pvs_file_call - % callback for the generate pvs file button, generates a pvs file - % for the table, does not attempt to prove, overwrites. - % inputs: - % obj:GUI - GUI objecto - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = pvs_file_call(object,src,event) - object.save_data - object.PVS.generate_pvs_file(object.Data.function_name); - - - end - - \ No newline at end of file +%% pvs_file_call +% callback for the generate pvs file button, generates a pvs file +% for the table, does not attempt to prove, overwrites. +% inputs: +% obj:GUI - GUI objecto +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = pvs_file_call(object,src,event) +object.save_data +object.PVS.generate_pvs_file(object.Data.function_name); + + +end + diff --git a/@GUI/redo_call.m b/@GUI/redo_call.m index 25786563d86209f7f40470e022646b0835c245fe..81d50a507b4ade38aac79283dfea4194a3822de8 100644 --- a/@GUI/redo_call.m +++ b/@GUI/redo_call.m @@ -1,26 +1,28 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = redo_call(object,src,event) recalled_data = object.undo_man.redo; - if isempty(recalled_data); - return; - else - switch recalled_data.action - case 1 - try - set(recalled_data.cell,'String',recalled_data.text); - catch exception - end - case 2 - recalled_data.grid.pb_new_call(recalled_data.grid.new_cell_pb,1); - case 3 - recalled_data.grid.pb_delete_call(recalled_data.grid.delete_cell_pb,1); - case 4 - - %recalled_data.cell.pb_call(recalled_data.cell.grid_pb,1); - recalled_data.cell.subgrid = recalled_data.grid; - recalled_data.cell.subgrid = recalled_data.grid; +if isempty(recalled_data); + return; +else + switch recalled_data.action + case 1 + try + set(recalled_data.cell,'String',recalled_data.text); + catch exception + end + case 2 + recalled_data.grid.pb_new_call(recalled_data.grid.new_cell_pb,1); + case 3 + recalled_data.grid.pb_delete_call(recalled_data.grid.delete_cell_pb,1); + case 4 + + %recalled_data.cell.pb_call(recalled_data.cell.grid_pb,1); + recalled_data.cell.subgrid = recalled_data.grid; + recalled_data.cell.subgrid = recalled_data.grid; recalled_data.cell.pb_flag = 0; - if(~isempty(recalled_data.cell.parent_grid.rGrid)) + if(~isempty(recalled_data.cell.parent_grid.rGrid)) recalled_data.cell.parent_grid.rGrid.delete_g2s(recalled_data.cell); end if(~isempty(recalled_data.grid.rGrid)) @@ -29,12 +31,12 @@ recalled_data = object.undo_man.redo; object.reset_wh(); %gui.draw_grid2(gui.Grid2); object.draw_allgrids(1); - - - case 5 - recalled_data.grid.pb_delete_call(recalled_data.grid.delete_cell_pb,1); - end - end - object.update_undoredo; + + + case 5 + recalled_data.grid.pb_delete_call(recalled_data.grid.delete_cell_pb,1); + end +end +object.update_undoredo; end \ No newline at end of file diff --git a/@GUI/reset_wh.m b/@GUI/reset_wh.m index 9cdb8f1d2e7004c288dea200c1612b76fdc524e2..d3fa2024ad5c69691763d46f0dab50b9bdc4acf2 100644 --- a/@GUI/reset_wh.m +++ b/@GUI/reset_wh.m @@ -1,14 +1,16 @@ - %% reset_wh - % function will call the set_widths and set_heights methods on - % the left grid in the table. The height and width values are - % used to draw the grid. - % inputs: - % obj:GUI - current GUI object - % outputs: - % none - function [] = reset_wh(object) - width = object.Grid2.max_width(1); - object.Grid2.set_widths(width); - object.Grid2.set_heights(object.edit); - end - +%% reset_wh +% function will call the set_widths and set_heights methods on +% the left grid in the table. The height and width values are +% used to draw the grid. +% inputs: +% obj:GUI - current GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = reset_wh(object) +width = object.Grid2.max_width(1); +object.Grid2.set_widths(width); +object.Grid2.set_heights(object.edit); +end + diff --git a/@GUI/resize_fig.m b/@GUI/resize_fig.m index a84a66c61bb72909f9941996a64af2091fcadc62..e56960b1ecc199e182e8d1393d21c5d81a3cae45 100644 --- a/@GUI/resize_fig.m +++ b/@GUI/resize_fig.m @@ -1,18 +1,19 @@ - %% resize_fig - % callback function that is called whenever the main figure is - % resized. Ensures that the commands remain at the top of the - % screen and the grid below them. - % inputs: - % object:GUI - current GUI object - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = resize_fig(object,src,event) - if(object.initialized == 1) - object.draw_allgrids(0); - object.set_command_pos; - end - end - - \ No newline at end of file +%% resize_fig +% callback function that is called whenever the main figure is +% resized. Ensures that the commands remain at the top of the +% screen and the grid below them. +% inputs: +% object:GUI - current GUI object +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = resize_fig(object,src,event) +if(object.initialized == 1) + object.draw_allgrids(0); + object.set_command_pos; +end +end + diff --git a/@GUI/save_call.m b/@GUI/save_call.m index 50f83fdd1192974267ffd1c4662878e13eee649c..61f344f88b356dc50948c093606361fb65b57cea 100644 --- a/@GUI/save_call.m +++ b/@GUI/save_call.m @@ -1,74 +1,76 @@ - %% save_call - % callback function that is called whenever the save button is - % pressed. This function will generate code and store it in the - % embedded matlab block, it will then generate the corresponding - % input and output ports and connect them to the embedded matlab - % block. - % inputs: - % object:GUI - current GUI object - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function eml_handle = save_call(object,src,event) - if(object.check_call([],[]) == 1) - return; - end - - function_names = EMLGenerator.parse_inputs(get(object.function_name_control,'String')); - function_name = char(function_names{1}(1)); - object.save_data; - if object.mode == 0 - model = gcs; - %make sure we are not looking at the library model - %if (strcmp(model,'eml_lib') || strcmp(model,'simulink')) - %create a new model - found = any(ismember(find_system('type', 'block_diagram'),'Table')) - if found == 0 - - - new_system('Table','Model') +%% save_call +% callback function that is called whenever the save button is +% pressed. This function will generate code and store it in the +% embedded matlab block, it will then generate the corresponding +% input and output ports and connect them to the embedded matlab +% block. +% inputs: +% object:GUI - current GUI object +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function eml_handle = save_call(object,src,event) +if(object.check_call([],[]) == 1) + return; +end - end - model = 'Table' - %end - open_system(model); - load_system('TableLibrary'); - new_block = add_block('TableLibrary/Tabular Expression',[model '/' function_name]); - set_param(new_block,'UserData',object.Data) - set_param(new_block, 'UserDataPersistent', 'on'); - object.mode = 1; - object.block_handle = new_block; - object.save_call([],[]); - elseif object.mode == 1 - - load_system('simulink') - % generate the code - redo = object.check_output_consistent; - if redo - object.EMLGen.set_datatype(object.output_data_type); - else - object.EMLGen.set_datatype([]); - end - code = object.EMLGen.generate_eml_code; - - %code = [code object.generate_code(object.Grid1,object.Grid2,0)]; - %fprintf('%s',code); +function_names = EMLGenerator.parse_inputs(get(object.function_name_control,'String')); +function_name = char(function_names{1}(1)); +object.save_data; +if object.mode == 0 + model = gcs; + %make sure we are not looking at the library model + %if (strcmp(model,'eml_lib') || strcmp(model,'simulink')) + %create a new model + found = any(ismember(find_system('type', 'block_diagram'),'Table')) + if found == 0 + + + new_system('Table','Model') + + end + model = 'Table' + %end + open_system(model); + load_system('TableLibrary'); + new_block = add_block('TableLibrary/Tabular Expression',[model '/' function_name]); + set_param(new_block,'UserData',object.Data) + set_param(new_block, 'UserDataPersistent', 'on'); + object.mode = 1; + object.block_handle = new_block; + object.save_call([],[]); +elseif object.mode == 1 + + load_system('simulink') + % generate the code + redo = object.check_output_consistent; + if redo + object.EMLGen.set_datatype(object.output_data_type); + else + object.EMLGen.set_datatype([]); + end + code = object.EMLGen.generate_eml_code; + + %code = [code object.generate_code(object.Grid1,object.Grid2,0)]; + %fprintf('%s',code); + + eml_handle = TableBlock.set_code(object.block_handle,code,function_name); + + + + if (object.mode == 1) + + TableBlock.set_block_display(object.block_handle,object.pvs_checked); + end + + if ~redo + object.save_call([],[]); + end +end +end - eml_handle = TableBlock.set_code(object.block_handle,code,function_name); - - - if (object.mode == 1) - TableBlock.set_block_display(object.block_handle,object.pvs_checked); - end - - if ~redo - object.save_call([],[]); - end - end - end - - - diff --git a/@GUI/save_conditions.m b/@GUI/save_conditions.m index 6dc2f4117dccb5b07703b49b7dc61b0519161bba..ffc704f5c05b7dab6818a5fe6af72018c24f5da0 100644 --- a/@GUI/save_conditions.m +++ b/@GUI/save_conditions.m @@ -1,21 +1,23 @@ - %% save_conditions - % this function is used to save the strings that are in each of the - % condition edit boxes string field. We do this because when we - % want to reopen the gui we want to repopulate these fields but the - % handles to the edit boxes will disappear when we close the gui, - % so we need to save the strings into variables in each of the Cell - % objects. function is recursive. - % inputs: - % obj:GUI - current GUI object - % grid:Grid - grid to be saved. - % outputs: - % none - function [] = save_conditions(object,grid) - for i=1:size(grid.cells,2) - if ~isempty(grid.cells(i).subgrid) - object.save_conditions(grid.cells(i).subgrid); - end - grid.cells(i).cond_text = get(grid.cells(i).cond,'String'); - end - end - +%% save_conditions +% this function is used to save the strings that are in each of the +% condition edit boxes string field. We do this because when we +% want to reopen the gui we want to repopulate these fields but the +% handles to the edit boxes will disappear when we close the gui, +% so we need to save the strings into variables in each of the Cell +% objects. function is recursive. +% inputs: +% obj:GUI - current GUI object +% grid:Grid - grid to be saved. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = save_conditions(object,grid) +for i=1:size(grid.cells,2) + if ~isempty(grid.cells(i).subgrid) + object.save_conditions(grid.cells(i).subgrid); + end + grid.cells(i).cond_text = get(grid.cells(i).cond,'String'); +end +end + diff --git a/@GUI/save_data.m b/@GUI/save_data.m index c1a99cba9e96e7313506b0ae1096b63ab4aa84c6..d05a6936286be521982ea0270d5805411a1487b0 100644 --- a/@GUI/save_data.m +++ b/@GUI/save_data.m @@ -1,29 +1,31 @@ - %% save_data - % save the current state of the table to the data object so that - % it can be saved either in a block or in a binary file - % inputs: - % object:GUI - current GUI object - % outputs: - % none - function [] = save_data(object) - save_conditions(object,object.Grid2); - save_conditions(object,object.Grid1); - save_results(object,object.Grid0); - % depricated - object.function_name_text = get(object.function_name_control,'String'); - object.function_inputs_text = get(object.function_inputs_control,'String'); - % new storage - object.Data.function_name = get(object.function_name_control,'String'); - object.Data.function_inputs = get(object.function_inputs_control,'String'); - object.Data.checked = object.pvs_checked; - object.Data.multi_mode = object.multi_mode; - %object.Data.open = 0; - %object.Data.fig = []; - - set.set = 1; - set.inputs = object.settings.pvs_includes; - set.count = object.settings.counter_trials; - set.range = object.settings.counter_range; - object.Data.settings = set; - end - +%% save_data +% save the current state of the table to the data object so that +% it can be saved either in a block or in a binary file +% inputs: +% object:GUI - current GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = save_data(object) +save_conditions(object,object.Grid2); +save_conditions(object,object.Grid1); +save_results(object,object.Grid0); +% depricated +object.function_name_text = get(object.function_name_control,'String'); +object.function_inputs_text = get(object.function_inputs_control,'String'); +% new storage +object.Data.function_name = get(object.function_name_control,'String'); +object.Data.function_inputs = get(object.function_inputs_control,'String'); +object.Data.checked = object.pvs_checked; +object.Data.multi_mode = object.multi_mode; +%object.Data.open = 0; +%object.Data.fig = []; + +set.set = 1; +set.inputs = object.settings.pvs_includes; +set.count = object.settings.counter_trials; +set.range = object.settings.counter_range; +object.Data.settings = set; +end + diff --git a/@GUI/save_ext_call.m b/@GUI/save_ext_call.m index 7ab3e188fca7669c08eefd6cc8a5d3f38bd55b14..b9103cbbcd373604ee3071ccd0b5ce620c292e7d 100644 --- a/@GUI/save_ext_call.m +++ b/@GUI/save_ext_call.m @@ -1,35 +1,36 @@ - %% save_ext_call - % callback function that is called whenever the save ext button - % is pressed. This function will generate the code for the table - % and output it to an external embedded matlab file which can - % then be used in other functions. Filename of new file will be - % the same as the expression name, currently this function will - % overwrite an existing file of the same name. - % inputs: - % object:GUI - current GUI object - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = save_ext_call(object,src,event) - object.save_data; - % file name will be expression_name.m - fileid = fopen([get(object.function_name_control,'String') '.m'],'w'); - %code = []; - %code = sprintf('function output = %s(%s)\n%s\noutput=0;\n',get(object.function_name_control,'String'),get(object.function_inputs_control,'String'),'%%#eml'); - %code = [code object.generate_code(object.Grid1,object.Grid2,0)]; - code = object.EMLGen.generate_eml_code; - - fprintf(fileid,code); - % save an extra file called expression_name.data which - % contains a binary representation of the current gui object. - filename = [get(object.function_name_control,'String') '.table']; - %save(filename,'object'); - object.save_data; +%% save_ext_call +% callback function that is called whenever the save ext button +% is pressed. This function will generate the code for the table +% and output it to an external embedded matlab file which can +% then be used in other functions. Filename of new file will be +% the same as the expression name, currently this function will +% overwrite an existing file of the same name. +% inputs: +% object:GUI - current GUI object +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = save_ext_call(object,src,event) +object.save_data; +% file name will be expression_name.m +fileid = fopen([get(object.function_name_control,'String') '.m'],'w'); +%code = []; +%code = sprintf('function output = %s(%s)\n%s\noutput=0;\n',get(object.function_name_control,'String'),get(object.function_inputs_control,'String'),'%%#eml'); +%code = [code object.generate_code(object.Grid1,object.Grid2,0)]; +code = object.EMLGen.generate_eml_code; + +fprintf(fileid,code); +% save an extra file called expression_name.data which +% contains a binary representation of the current gui object. +filename = [get(object.function_name_control,'String') '.table']; +%save(filename,'object'); +object.save_data; + +object.save_settings; +object.Data.save; +fclose(fileid); +end - object.save_settings; - object.Data.save; - fclose(fileid); - end - - \ No newline at end of file diff --git a/@GUI/save_results.m b/@GUI/save_results.m index ae44757605267a81cbce66b9fad09bf1c4e1e13c..5644c2bc745a9231ff8570c3ca641194139e8358 100644 --- a/@GUI/save_results.m +++ b/@GUI/save_results.m @@ -1,14 +1,16 @@ - %% save_results - % Save as save_conditions but for the results grid, since not a - % recursive datatype we do not need to recurse. - % inputs: - % obj:GUI - current GUI object - % grid:RGrid - results grid to be saved. - % outputs: - % none - function [] = save_results(object,grid) - for i=1:size(grid.Cells,2) - grid.Cells(i).result_text = get(grid.Cells(i).result,'String'); - end - end - +%% save_results +% Save as save_conditions but for the results grid, since not a +% recursive datatype we do not need to recurse. +% inputs: +% obj:GUI - current GUI object +% grid:RGrid - results grid to be saved. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = save_results(object,grid) +for i=1:size(grid.Cells,2) + grid.Cells(i).result_text = get(grid.Cells(i).result,'String'); +end +end + diff --git a/@GUI/save_settings.m b/@GUI/save_settings.m index e5d5f21d7f329bd3477e32e963789e5f6ca2d5c9..ff588cd80af8c795ae0c6fb43821e31a82d5b9bc 100644 --- a/@GUI/save_settings.m +++ b/@GUI/save_settings.m @@ -1,16 +1,18 @@ - %% save_settings - % save just the settings to the data object - % inputs: - % object:GUI - current GUI object - % outputs: - % none - function [] = save_settings(object) - set.set = 1; - set.inputs = object.settings.pvs_includes; - set.count = object.settings.counter_trials; - set.range = object.settings.counter_range; - object.Data.settings = set; - object.Data.function_name = get(object.function_name_control,'String'); - object.Data.function_inputs = get(object.function_inputs_control,'String'); - end - +%% save_settings +% save just the settings to the data object +% inputs: +% object:GUI - current GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = save_settings(object) +set.set = 1; +set.inputs = object.settings.pvs_includes; +set.count = object.settings.counter_trials; +set.range = object.settings.counter_range; +object.Data.settings = set; +object.Data.function_name = get(object.function_name_control,'String'); +object.Data.function_inputs = get(object.function_inputs_control,'String'); +end + diff --git a/@GUI/setData.m b/@GUI/setData.m index 2041d56ea502b9c50c6b3309845a4f5b4127eaf1..f86079ca2c010c736901615fc8e9c478ef0fb740 100644 --- a/@GUI/setData.m +++ b/@GUI/setData.m @@ -1,22 +1,23 @@ %% setData - % set the gui data object based on inputed data structure - % inputs: - % obj:GUI - GUI object - % Data:Data - Data object - % outputs: - % object:GUI - object that is created - function [] = setData(object,Data) - object.Data = Data; - object.Grid0 = Data.Grid0; - object.Grid1 = Data.Grid1; - object.Grid2 = Data.Grid2; - object.pvs_checked = Data.checked; - object.function_name_text = Data.function_name; - object.function_inputs_text = Data.function_inputs; - object.multi_mode = Data.multi_mode; - if isempty(object.multi_mode) - object.multi_mode = 0; - end - end - - \ No newline at end of file +% set the gui data object based on inputed data structure +% inputs: +% obj:GUI - GUI object +% Data:Data - Data object +% outputs: +% object:GUI - object that is created +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = setData(object,Data) +object.Data = Data; +object.Grid0 = Data.Grid0; +object.Grid1 = Data.Grid1; +object.Grid2 = Data.Grid2; +object.pvs_checked = Data.checked; +object.function_name_text = Data.function_name; +object.function_inputs_text = Data.function_inputs; +object.multi_mode = Data.multi_mode; +if isempty(object.multi_mode) + object.multi_mode = 0; +end +end + diff --git a/@GUI/setPBenable.m b/@GUI/setPBenable.m index 8d1828d8af3a6698ac2112de7a0479f99cd4e6e7..6453143fd57b08e06fb9321e8b54f1170eabf803 100644 --- a/@GUI/setPBenable.m +++ b/@GUI/setPBenable.m @@ -1,22 +1,24 @@ - - %% setBPenable - % enable or diable the delete cell buttons based on the size of - % a grid, so that you can't delete below one cell. - % inputs: - % object:GUI - current GUI object - % outputs: - % none - function [] = setPBenable(object) - if size(object.Grid1.cells,2) > 1 - set(object.Grid1.delete_cell_pb,'Enable','on'); - else - set(object.Grid1.delete_cell_pb,'Enable','off'); - end - - if size(object.Grid2.cells,2) > 1 - set(object.Grid2.delete_cell_pb,'Enable','on'); - else - set(object.Grid2.delete_cell_pb,'Enable','off'); - end - - end \ No newline at end of file + +%% setBPenable +% enable or diable the delete cell buttons based on the size of +% a grid, so that you can't delete below one cell. +% inputs: +% object:GUI - current GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = setPBenable(object) +if size(object.Grid1.cells,2) > 1 + set(object.Grid1.delete_cell_pb,'Enable','on'); +else + set(object.Grid1.delete_cell_pb,'Enable','off'); +end + +if size(object.Grid2.cells,2) > 1 + set(object.Grid2.delete_cell_pb,'Enable','on'); +else + set(object.Grid2.delete_cell_pb,'Enable','off'); +end + +end \ No newline at end of file diff --git a/@GUI/set_command_pos.m b/@GUI/set_command_pos.m index bcbdf1874efefe44affe0585aa755d06ea365683..ca1eec8fe5264578d43161167fb84c8659955c6a 100644 --- a/@GUI/set_command_pos.m +++ b/@GUI/set_command_pos.m @@ -1,29 +1,30 @@ - %% set_command_pos - % sets the location of all the command buttons, labels and edit - % boxes, places objects at the top of the figure which it - % determines by looking at the height of the figure handle - % inputs: - % obj:GUI - current GUI object - % outputs: - % none - function [] = set_command_pos(object) - figpos = get(object.fig,'Position'); - % figure out the height of the figure - l_fig_height = figpos(4); - set(object.edit_tog,'Position',[object.pb_offset l_fig_height-object.pb_offset-object.pb_height object.pb_width object.pb_height]) - set(object.save_pb,'Position',[object.pb_offset*2+object.pb_width,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) - set(object.close_pb,'Position',[object.pb_offset*3+object.pb_width*2,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) - set(object.save_ext_pb,'Position',[object.pb_offset*4+object.pb_width*3,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) - set(object.check_pb,'Position',[object.pb_offset*5+object.pb_width*4,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) - set(object.pvs_pb,'Position',[object.pb_offset*6+object.pb_width*5,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) - set(object.input_pb,'Position',[object.pb_offset*7+object.pb_width*6,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) - set(object.settings_pb,'Position',[object.pb_offset*8+object.pb_width*7,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) +%% set_command_pos +% sets the location of all the command buttons, labels and edit +% boxes, places objects at the top of the figure which it +% determines by looking at the height of the figure handle +% inputs: +% obj:GUI - current GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_command_pos(object) +figpos = get(object.fig,'Position'); +% figure out the height of the figure +l_fig_height = figpos(4); +set(object.edit_tog,'Position',[object.pb_offset l_fig_height-object.pb_offset-object.pb_height object.pb_width object.pb_height]) +set(object.save_pb,'Position',[object.pb_offset*2+object.pb_width,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) +set(object.close_pb,'Position',[object.pb_offset*3+object.pb_width*2,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) +set(object.save_ext_pb,'Position',[object.pb_offset*4+object.pb_width*3,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) +set(object.check_pb,'Position',[object.pb_offset*5+object.pb_width*4,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) +set(object.pvs_pb,'Position',[object.pb_offset*6+object.pb_width*5,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) +set(object.input_pb,'Position',[object.pb_offset*7+object.pb_width*6,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) +set(object.settings_pb,'Position',[object.pb_offset*8+object.pb_width*7,l_fig_height-object.pb_offset-object.pb_height,object.pb_width,object.pb_height]) + +set(object.input_label,'Position',[object.pb_offset l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height object.pb_width object.htx_height]); +set(object.function_inputs_control,'Position',[object.pb_offset*2+object.pb_width l_fig_height-object.pb_offset*3-object.htx_height-object.pb_height object.text_width object.htx_height]); +set(object.name_label,'Position',[object.pb_offset*2+object.pb_width+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height object.pb_width object.htx_height]); +set(object.function_name_control,'Position',[object.pb_offset*3+object.pb_width*2+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height object.text_width object.htx_height]); +%set(object.multi_grp,'Position',[object.pb_offset*3+object.pb_width*2+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height*2 object.text_width object.htx_height]); +end - set(object.input_label,'Position',[object.pb_offset l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height object.pb_width object.htx_height]); - set(object.function_inputs_control,'Position',[object.pb_offset*2+object.pb_width l_fig_height-object.pb_offset*3-object.htx_height-object.pb_height object.text_width object.htx_height]); - set(object.name_label,'Position',[object.pb_offset*2+object.pb_width+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height object.pb_width object.htx_height]); - set(object.function_name_control,'Position',[object.pb_offset*3+object.pb_width*2+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height object.text_width object.htx_height]); - %set(object.multi_grp,'Position',[object.pb_offset*3+object.pb_width*2+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.htx_height*2 object.text_width object.htx_height]); - end - - \ No newline at end of file diff --git a/@GUI/set_grid.m b/@GUI/set_grid.m index 803a10975f98ebdd1e4b80e9b2e1fadeacbfd370..c6eb70086a7453f39fc2257156dce71ebd4ce8b1 100644 --- a/@GUI/set_grid.m +++ b/@GUI/set_grid.m @@ -1,16 +1,18 @@ - %% set_grid - % allows accessing objects to set the grid variables to the - % inputed objects - % inputs: - % obj:GUI - current GUI object - % grid2:Grid - Grid on the left - % grid1:Grid - Grid on the top - % grid0:RGrid - Results grid - % outputs: - % none - function [] = set_grid(object,grid2,grid1,grid0) - object.Grid2 = grid2; - object.Grid1 = grid1; - object.Grid0 = grid0; - end - +%% set_grid +% allows accessing objects to set the grid variables to the +% inputed objects +% inputs: +% obj:GUI - current GUI object +% grid2:Grid - Grid on the left +% grid1:Grid - Grid on the top +% grid0:RGrid - Results grid +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_grid(object,grid2,grid1,grid0) +object.Grid2 = grid2; +object.Grid1 = grid1; +object.Grid0 = grid0; +end + diff --git a/@GUI/settings_call.m b/@GUI/settings_call.m index 1a32f7026c3b433f36b914a8313827d0bc9d9058..ccbb260010654a0b34cc5e5ba3eecc64af96c693 100644 --- a/@GUI/settings_call.m +++ b/@GUI/settings_call.m @@ -1,14 +1,15 @@ - %% settings_call - % open up the settings window - % inputs: - % obj:GUI - GUI objecto - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = settings_call(object,src,event) - object.settings.show; - - end - - \ No newline at end of file +%% settings_call +% open up the settings window +% inputs: +% obj:GUI - GUI objecto +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = settings_call(object,src,event) +object.settings.show; + +end + diff --git a/@GUI/textbox_callback.m b/@GUI/textbox_callback.m index afec9062ead363e816b9545a4304daa5657b28f0..879f822bb8b74137e94e758fdde2de103326736b 100644 --- a/@GUI/textbox_callback.m +++ b/@GUI/textbox_callback.m @@ -1,57 +1,59 @@ %% textbox_callback - % callback for when the text of a callback is changed. - % inputs: - % object - current GUI object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = textbox_callback(object,src,event) - % make sure the character pressed isn't empty - - if((strcmp(event.Character,'z')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control'))) - return - end - if((strcmp(event.Character,'r')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control'))) - return - end - if(~isempty(unicode2native(event.Character))) - % make sure the character is a printable character - if event.Character > 33 || event.Character == 8 - if object.pvs_checked == 1 - object.pvs_checked = 0; - object.update_Statusbar - if (object.mode == 1) - TableBlock.set_block_display(object.block_handle,object.pvs_checked); - end - end - end - %if time > 0.2 - - %uicontrol(object.function_name_control); - - % hack because api does not update the string field of - % textbox until after it loses focus. temporarily focus on - % label, read string, refocus on textbox. - uicontrol(object.name_label); - - - undo_data.action = 1; - undo_data.grid = []; - undo_data.cell = src; - undo_data.text = get(src,'String'); - undo_data.subgrid = [] - - object.undo_man.new_state(undo_data); - %end - tic; - uicontrol(src); - figure(object.fig); - - %end - - object.update_undoredo +% callback for when the text of a callback is changed. +% inputs: +% object - current GUI object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = textbox_callback(object,src,event) +% make sure the character pressed isn't empty - - - end \ No newline at end of file +if((strcmp(event.Character,'z')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control'))) + return +end +if((strcmp(event.Character,'r')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control'))) + return +end +if(~isempty(unicode2native(event.Character))) + % make sure the character is a printable character + if event.Character > 33 || event.Character == 8 + if object.pvs_checked == 1 + object.pvs_checked = 0; + object.update_Statusbar + if (object.mode == 1) + TableBlock.set_block_display(object.block_handle,object.pvs_checked); + end + end + end + %if time > 0.2 + + %uicontrol(object.function_name_control); + + % hack because api does not update the string field of + % textbox until after it loses focus. temporarily focus on + % label, read string, refocus on textbox. + uicontrol(object.name_label); + + + undo_data.action = 1; + undo_data.grid = []; + undo_data.cell = src; + undo_data.text = get(src,'String'); + undo_data.subgrid = [] + + object.undo_man.new_state(undo_data); + %end + tic; + uicontrol(src); + figure(object.fig); + + %end + + object.update_undoredo + + + +end \ No newline at end of file diff --git a/@GUI/undo_call.m b/@GUI/undo_call.m index 3568ee8b6fa19778f3dfefa356b7734e1094367d..fbb4680686a3946dd42430606f9be6465493f62e 100644 --- a/@GUI/undo_call.m +++ b/@GUI/undo_call.m @@ -1,44 +1,46 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = undo_call(object,src,event) %UNTITLED Summary of this function goes here % Detailed explanation goes here object.undo_man - recalled_data = object.undo_man.undo; - if isempty(recalled_data); - return; - else - switch recalled_data.action - case 1 % changed cell contents - try - set(recalled_data.cell,'String',recalled_data.text); - catch exception - end - case 2 % created new cell in grid - recalled_data.grid.pb_delete_call(recalled_data.grid.delete_cell_pb,1); - case 3 % deleted cell in grid (not the last) - recalled_data.grid.cells = [recalled_data.grid.cells recalled_data.cell]; - recalled_data.grid.num_cells = recalled_data.grid.num_cells + 1; +recalled_data = object.undo_man.undo; +if isempty(recalled_data); + return; +else + switch recalled_data.action + case 1 % changed cell contents + try + set(recalled_data.cell,'String',recalled_data.text); + catch exception + end + case 2 % created new cell in grid + recalled_data.grid.pb_delete_call(recalled_data.grid.delete_cell_pb,1); + case 3 % deleted cell in grid (not the last) + recalled_data.grid.cells = [recalled_data.grid.cells recalled_data.cell]; + recalled_data.grid.num_cells = recalled_data.grid.num_cells + 1; % refresh the rGrid so that a new results cell is created if(~isempty(recalled_data.grid.rGrid)) recalled_data.grid.rGrid.refresh; end - object.reset_wh(); + object.reset_wh(); %gui.draw_grid2(gui.Grid2); object.draw_allgrids(1); object.undo_man.search_replace(1,recalled_data.subgrid,recalled_data.cell.cond); set(recalled_data.grid.delete_cell_pb,'Enable','on'); - - case 4 % new grid - recalled_data.grid.deep_delete; - recalled_data.cell.subgrid = []; - recalled_data.cell.pb_flag = 1; - object.reset_wh(); + + case 4 % new grid + recalled_data.grid.deep_delete; + recalled_data.cell.subgrid = []; + recalled_data.cell.pb_flag = 1; + object.reset_wh(); %gui.draw_grid2(gui.Grid2); object.draw_allgrids(1); - case 5 % deleting last cell in grid + case 5 % deleting last cell in grid recalled_data.cell.subgrid = recalled_data.grid; recalled_data.cell.pb_flag = 0; - if(~isempty(recalled_data.cell.parent_grid.rGrid)) + if(~isempty(recalled_data.cell.parent_grid.rGrid)) recalled_data.cell.parent_grid.rGrid.delete_g2s(recalled_data.cell); end if(~isempty(recalled_data.grid.rGrid)) @@ -47,20 +49,20 @@ object.undo_man object.reset_wh(); %gui.draw_grid2(gui.Grid2); object.draw_allgrids(1); -% object.undo_call([],[]); + % object.undo_call([],[]); recalled_data.grid.cells = [recalled_data.grid.cells recalled_data.subgrid]; - recalled_data.grid.num_cells = recalled_data.grid.num_cells + 1; + recalled_data.grid.num_cells = recalled_data.grid.num_cells + 1; % refresh the rGrid so that a new results cell is created if(~isempty(recalled_data.grid.rGrid)) recalled_data.grid.rGrid.refresh; end - object.reset_wh(); + object.reset_wh(); %gui.draw_grid2(gui.Grid2); object.draw_allgrids(1); set(recalled_data.grid.delete_cell_pb,'Enable','on'); - end - end + end +end % object.setData(recalled_data); % object.set_command_pos; % object.reset_wh(); diff --git a/@GUI/update_Statusbar.m b/@GUI/update_Statusbar.m index 2628999195193382a64a6da4f32c27429780f22b..d09d93c8a5ea1a655b257383e1d2c6401f7a7668 100644 --- a/@GUI/update_Statusbar.m +++ b/@GUI/update_Statusbar.m @@ -1,27 +1,28 @@ %% update_Statusbar - % update the statusbar located at bottom of window based on - % current state of typecheckness - % inputs: - % obj:GUI - GUI object - % outputs: - % none - function [] = update_Statusbar(object) - - warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame - % statusbar depends on JavaFrame which may be obsolete in - % future versions of Matlab, can still use in old versions - try - if (object.pvs_checked == 0) - sb = statusbar(object.fig, 'Status: Not Typechecked'); - set(sb.TextPanel,'Foreground',[1,0,0]); - elseif (object.pvs_checked == 1) - sb = statusbar(object.fig, 'Status: Typechecked'); - set(sb.TextPanel,'Foreground',[0,1,0]); +% update the statusbar located at bottom of window based on +% current state of typecheckness +% inputs: +% obj:GUI - GUI object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = update_Statusbar(object) - end - catch exception - % do nothing if exception found, may change in future. - - end - end - \ No newline at end of file +warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame +% statusbar depends on JavaFrame which may be obsolete in +% future versions of Matlab, can still use in old versions +try + if (object.pvs_checked == 0) + sb = statusbar(object.fig, 'Status: Not Typechecked'); + set(sb.TextPanel,'Foreground',[1,0,0]); + elseif (object.pvs_checked == 1) + sb = statusbar(object.fig, 'Status: Typechecked'); + set(sb.TextPanel,'Foreground',[0,1,0]); + + end +catch exception + % do nothing if exception found, may change in future. + +end +end diff --git a/@GUI/update_multi_check_status.m b/@GUI/update_multi_check_status.m index c566299e866db5ea4f15ef2fed36bc4e7fe4f181..4a0229ed5791d82f97202aa871402621a6e659af 100644 --- a/@GUI/update_multi_check_status.m +++ b/@GUI/update_multi_check_status.m @@ -1,7 +1,9 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function update_multi_check_status( object ) -if object.multi_mode == 0 +if object.multi_mode == 0 set(object.multi_opt_reg,'Checked','on'); set(object.multi_opt_out,'Checked','off'); else diff --git a/@GUI/update_undoredo.m b/@GUI/update_undoredo.m index 48d1d43b49c1a753cd36b85e8157508e965a53e1..7aa78341e66c9ccfa6da1a3e147f8bcf0019daf0 100644 --- a/@GUI/update_undoredo.m +++ b/@GUI/update_undoredo.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [ ] = update_undoredo( object ) % updates the menu options so that they are either enabled or disabled @@ -10,10 +12,10 @@ end if (object.undo_man.current_depth == 0) set(object.undo_opt,'Enable','off'); else - set(object.undo_opt,'Enable','on'); + set(object.undo_opt,'Enable','on'); end - + end diff --git a/@Grid/Grid.m b/@Grid/Grid.m index 8d91625ee8065aa60d18273f4c47d39e7b91bb69..9b4425c6c1cb2775450b370c917f70fa5eb07b10 100644 --- a/@Grid/Grid.m +++ b/@Grid/Grid.m @@ -1,5 +1,7 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef Grid < handle - + properties parent_cell = []; parent_grid = []; diff --git a/@Grid/clone.m b/@Grid/clone.m index c0ed182e31a0c7faf8bcd2c822b3b628f4d779c4..842e29efc65d33ee3d0245051aab84d5b2ff904f 100644 --- a/@Grid/clone.m +++ b/@Grid/clone.m @@ -1,25 +1,27 @@ - %% clone - % function will create a copy of the current grid and store it - % in dest_grid, since grid is a recursive datatype this is a - % recursive function in order to do a deep clone. - % inputs: - % object:Grid - current Grid object - % dest_grid:Grid - grid to copy contents to - % index:int - index of the current grid - % p_cell:Cell - parent cell of the current grid. - % outputs: - % none - function [] = clone(object,dest_grid,index,p_cell) - for i=1:size(object.cells,2) - dest_grid.new_Cell(); - dest_grid.cells(i).cond_text = object.cells(i).cond_text; - if (~isempty(object.cells(i).subgrid)) - dest_grid.cells(i).subgrid = Grid(dest_grid.cells(i).cell_index,dest_grid.cells(i)); - dest_grid.cells(i).subgrid.set_rGrid(dest_grid.cells(i).parent_grid.rGrid); - object.cells(i).subgrid.clone(dest_grid.cells(i).subgrid,object.cells(i).subgrid.grid_index,dest_grid.cells(i)) - else - - end - - end - end \ No newline at end of file +%% clone +% function will create a copy of the current grid and store it +% in dest_grid, since grid is a recursive datatype this is a +% recursive function in order to do a deep clone. +% inputs: +% object:Grid - current Grid object +% dest_grid:Grid - grid to copy contents to +% index:int - index of the current grid +% p_cell:Cell - parent cell of the current grid. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = clone(object,dest_grid,index,p_cell) +for i=1:size(object.cells,2) + dest_grid.new_Cell(); + dest_grid.cells(i).cond_text = object.cells(i).cond_text; + if (~isempty(object.cells(i).subgrid)) + dest_grid.cells(i).subgrid = Grid(dest_grid.cells(i).cell_index,dest_grid.cells(i)); + dest_grid.cells(i).subgrid.set_rGrid(dest_grid.cells(i).parent_grid.rGrid); + object.cells(i).subgrid.clone(dest_grid.cells(i).subgrid,object.cells(i).subgrid.grid_index,dest_grid.cells(i)) + else + + end + +end +end \ No newline at end of file diff --git a/@Grid/deep_delete.m b/@Grid/deep_delete.m index 4ee31856df78d788308048c7cdf95c619a935e66..2034a3aba2c177f8307e272ceb8bede3004ea111 100644 --- a/@Grid/deep_delete.m +++ b/@Grid/deep_delete.m @@ -1,24 +1,25 @@ %% deep_delete - % deletes an entire grid as well as all the subgrids associated - % with it. - % inputs: - % object:Grid - current Grid object - % outputs: - % none - function [] = deep_delete(object) - % loop through each cell and delete the associated result - % cells and call delete_Cell on each of the cells, which will - % then call deep_delete on its subgrids. - for i=size(object.cells,2):-1:1 - object.rGrid.delete_g2s(object.cells(i)); - object.cells(i).delete_Cell; - %object.cells(i) = []; - end - delete(object.new_cell_pb) - delete(object.delete_cell_pb) - object.new_cell_pb = []; - object.delete_cell_pb = []; - - end - - \ No newline at end of file +% deletes an entire grid as well as all the subgrids associated +% with it. +% inputs: +% object:Grid - current Grid object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = deep_delete(object) +% loop through each cell and delete the associated result +% cells and call delete_Cell on each of the cells, which will +% then call deep_delete on its subgrids. +for i=size(object.cells,2):-1:1 + object.rGrid.delete_g2s(object.cells(i)); + object.cells(i).delete_Cell; + %object.cells(i) = []; +end +delete(object.new_cell_pb) +delete(object.delete_cell_pb) +object.new_cell_pb = []; +object.delete_cell_pb = []; + +end + diff --git a/@Grid/delete_Cell.m b/@Grid/delete_Cell.m index d4d1f8de22baad38982d34d79d200bfd4141e0e6..2d9fe0c21292a6b9141f9571fabf33df960246c8 100644 --- a/@Grid/delete_Cell.m +++ b/@Grid/delete_Cell.m @@ -1,25 +1,26 @@ %% delete_Cell - % deletes the last cell in the grid, also deletes an associated - % new grid push button, - % TODO, need to implement the case where last cell is deleted. - % inputs: - % object:Grid - current Grid object - % outputs - % none - function [] = delete_Cell(object) - - - last_cell = object.num_cells; - object.rGrid.delete_g2s(object.cells(end)); - %delete(object.cells(end).cond) - object.cells(end).cond = []; - %delete(object.cells(end).grid_pb); - object.cells(end).grid_pb = []; - %delete(object.cells(end)) - object.cells(end) = []; - if(~isempty(object.rGrid)) - object.rGrid.refresh; - end - end - - \ No newline at end of file +% deletes the last cell in the grid, also deletes an associated +% new grid push button, +% TODO, need to implement the case where last cell is deleted. +% inputs: +% object:Grid - current Grid object +% outputs +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = delete_Cell(object) + + +last_cell = object.num_cells; +object.rGrid.delete_g2s(object.cells(end)); +%delete(object.cells(end).cond) +object.cells(end).cond = []; +%delete(object.cells(end).grid_pb); +object.cells(end).grid_pb = []; +%delete(object.cells(end)) +object.cells(end) = []; +if(~isempty(object.rGrid)) + object.rGrid.refresh; +end +end + diff --git a/@Grid/max_width.m b/@Grid/max_width.m index e4ee6165bd18f6d73808a65fb1b586fad6b48d0c..69610a043c3dbb734e5be13ce0751c69f1fe2cda 100644 --- a/@Grid/max_width.m +++ b/@Grid/max_width.m @@ -1,24 +1,25 @@ - %% max_width - % determines the maximum width from a current grid, the maximum - % widht represents the number of levels of subgrids from a given - % grid. - % inputs: - % object:Grid - current Grid object - % outputs: - % m:integer - value representing the maximum width from the - % current grid. - function m = max_width(object,width) - temp = []; - for i=1:size(object.cells,2) - if (~isempty(object.cells(i).subgrid)) - temp = [temp object.cells(i).subgrid.max_width(width+1)]; - else - temp = [temp width]; - end - - end - m = max(temp); - end - - \ No newline at end of file +%% max_width +% determines the maximum width from a current grid, the maximum +% widht represents the number of levels of subgrids from a given +% grid. +% inputs: +% object:Grid - current Grid object +% outputs: +% m:integer - value representing the maximum width from the +% current grid. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function m = max_width(object,width) +temp = []; +for i=1:size(object.cells,2) + if (~isempty(object.cells(i).subgrid)) + temp = [temp object.cells(i).subgrid.max_width(width+1)]; + else + temp = [temp width]; + end + +end +m = max(temp); +end + diff --git a/@Grid/new_Cell.m b/@Grid/new_Cell.m index 24a5b9be4654cf6fe016ebfa900956f153e0e324..8f1e325e1def4636c450ce797bbbc1f30d43309d 100644 --- a/@Grid/new_Cell.m +++ b/@Grid/new_Cell.m @@ -1,17 +1,18 @@ - %% new_Cell - % creates a new cell in the current grid. - % inputs: - % object:Grid - current Grid object - % outputs: - % none - function [] = new_Cell(object) - cell = Cell(object.num_cells+1,object); - object.num_cells = object.num_cells + 1; - object.cells = [object.cells cell]; - % refresh the rGrid so that a new results cell is created - if(~isempty(object.rGrid)) - object.rGrid.refresh; - end - end - - \ No newline at end of file +%% new_Cell +% creates a new cell in the current grid. +% inputs: +% object:Grid - current Grid object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = new_Cell(object) +cell = Cell(object.num_cells+1,object); +object.num_cells = object.num_cells + 1; +object.cells = [object.cells cell]; +% refresh the rGrid so that a new results cell is created +if(~isempty(object.rGrid)) + object.rGrid.refresh; +end +end + diff --git a/@Grid/pb_delete_call.m b/@Grid/pb_delete_call.m index e0719897fde308effbfcc598ee6e5568a5f156a5..af316c79cc8c25e2940456a0b963b2e2d3039d69 100644 --- a/@Grid/pb_delete_call.m +++ b/@Grid/pb_delete_call.m @@ -7,6 +7,8 @@ % event:eventdata - event that triggered the callback % outputs: % none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = pb_delete_call(object,src,event) gui = get(src,'userdata'); gui.save_data; @@ -20,22 +22,22 @@ if size(object.cells,2) == 1 if isempty(event) || event ~= 1 - + undo_data.action = 5; undo_data.grid = object; undo_data.cell = object.parent_cell; undo_data.text = deleted_cell.cond; undo_data.subgrid = deleted_cell; - + gui.undo_man.new_state(undo_data); - - end + + end end else - if isempty(event) || event ~= 1 + if isempty(event) || event ~= 1 undo_data.action = 3; undo_data.grid = object; @@ -46,7 +48,7 @@ else gui.undo_man.new_state(undo_data); end - + end % button could be pressed in the left or top grid so we need to @@ -73,7 +75,7 @@ if size(object.cells,2) == 0 end - + end diff --git a/@Grid/pb_new_call.m b/@Grid/pb_new_call.m index 2a9c4d78df5d2f8b8333e7dcc713956081ea14c4..e18a39a0d15d7f01bfd10bfd513e128766638fae 100644 --- a/@Grid/pb_new_call.m +++ b/@Grid/pb_new_call.m @@ -1,38 +1,39 @@ %% pb_new_call - % call back function for the new cell push button. When button - % is pressed a new cell object is created in the current grid - % and the table is redrawn - % inputs: - % object:Grid - current Grid object - % src:double - source of the callback calling - % event:eventdata - event that triggered the callback - % outputs: - % none - function [] = pb_new_call(object,src,event) - gui = get(src,'userdata'); - object.new_Cell; - gui.reset_wh(); - %gui.draw_grid2(gui.Grid2); - gui.draw_allgrids(0); - if size(object.cells,2) > 1 - set(object.delete_cell_pb,'Enable','on'); - else - set(object.delete_cell_pb,'Enable','off'); - end - - if isempty(event) || event ~= 1 - undo_data.action = 2; - undo_data.grid = object; - undo_data.cell = []; - undo_data.text = []; - undo_data.subgrid = [] - - - gui.undo_man.new_state(undo_data); - end - gui.update_undoredo +% call back function for the new cell push button. When button +% is pressed a new cell object is created in the current grid +% and the table is redrawn +% inputs: +% object:Grid - current Grid object +% src:double - source of the callback calling +% event:eventdata - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = pb_new_call(object,src,event) +gui = get(src,'userdata'); +object.new_Cell; +gui.reset_wh(); +%gui.draw_grid2(gui.Grid2); +gui.draw_allgrids(0); +if size(object.cells,2) > 1 + set(object.delete_cell_pb,'Enable','on'); +else + set(object.delete_cell_pb,'Enable','off'); +end + +if isempty(event) || event ~= 1 + undo_data.action = 2; + undo_data.grid = object; + undo_data.cell = []; + undo_data.text = []; + undo_data.subgrid = [] + + + gui.undo_man.new_state(undo_data); +end +gui.update_undoredo + + +end - - end - - \ No newline at end of file diff --git a/@Grid/set_delete_pb.m b/@Grid/set_delete_pb.m index 2a52f208b230e8f6276f6ccc04c263d1f950ad7b..3f817d4506699bc3b330132c945c68be94749fed 100644 --- a/@Grid/set_delete_pb.m +++ b/@Grid/set_delete_pb.m @@ -1,21 +1,22 @@ %% set_delete_pb - % create the delete cell push button - % inputs: - % object:Grid - current Grid object - % outputs: - % none - function [] = set_delete_pb(object,fig,pos) - if(isempty(object.delete_cell_pb) || ~ishghandle(object.delete_cell_pb)) - object.delete_cell_pb = uicontrol('style','push',... - 'units','pix',... - 'string','delete',... - 'HorizontalAlign','left',... - 'Parent',fig,... - 'position',pos,... - 'callback',@(src,event)pb_delete_call(object,src,event)); - else - set(object.delete_cell_pb,'position',pos); - end - end - - \ No newline at end of file +% create the delete cell push button +% inputs: +% object:Grid - current Grid object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_delete_pb(object,fig,pos) +if(isempty(object.delete_cell_pb) || ~ishghandle(object.delete_cell_pb)) + object.delete_cell_pb = uicontrol('style','push',... + 'units','pix',... + 'string','delete',... + 'HorizontalAlign','left',... + 'Parent',fig,... + 'position',pos,... + 'callback',@(src,event)pb_delete_call(object,src,event)); +else + set(object.delete_cell_pb,'position',pos); +end +end + diff --git a/@Grid/set_heights.m b/@Grid/set_heights.m index 1d4532a9d55e7d4269fe3eb1aa2ce3cb5e2e5ae3..a34b4b801f53ae643cd7eb35efd7f676d1b1cd17 100644 --- a/@Grid/set_heights.m +++ b/@Grid/set_heights.m @@ -1,20 +1,21 @@ - %% set_heights - % sets the heights for each of the cells and subcells of a grid, - % uses the cells cal_height method to determine what the heights - % should be. - % inputs: - % object:Grid - current Grid object - % edit:boolean - current value of the edit toggle. - % outputs: - % none - function [] = set_heights(object,edit) - for i = 1:size(object.cells,2) - if (~isempty(object.cells(i).subgrid)) - object.cells(i).subgrid.set_heights(edit); - end - object.cells(i).height = object.cells(i).cal_height(edit); - end - - end - - \ No newline at end of file +%% set_heights +% sets the heights for each of the cells and subcells of a grid, +% uses the cells cal_height method to determine what the heights +% should be. +% inputs: +% object:Grid - current Grid object +% edit:boolean - current value of the edit toggle. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_heights(object,edit) +for i = 1:size(object.cells,2) + if (~isempty(object.cells(i).subgrid)) + object.cells(i).subgrid.set_heights(edit); + end + object.cells(i).height = object.cells(i).cal_height(edit); +end + +end + diff --git a/@Grid/set_pb.m b/@Grid/set_pb.m index 70a43a95c50b07e6f3f31a8db35d22ae2a6d4def..e3f91033b59618c966d36ff6b947c44c3222cebb 100644 --- a/@Grid/set_pb.m +++ b/@Grid/set_pb.m @@ -1,21 +1,22 @@ - %% set_pb - % create the new cell push button - % inputs: - % object:Grid - current Grid object - % outputs: - % none - function [] = set_pb(object,fig,pos) - if(isempty(object.new_cell_pb) || ~ishghandle(object.new_cell_pb)) - object.new_cell_pb = uicontrol('style','push',... - 'units','pix',... - 'string','new',... - 'HorizontalAlign','left',... - 'Parent',fig,... - 'position',pos,... - 'callback',@(src,event)pb_new_call(object,src,event)); - else - set(object.new_cell_pb,'position',pos); - end - end - - \ No newline at end of file +%% set_pb +% create the new cell push button +% inputs: +% object:Grid - current Grid object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_pb(object,fig,pos) +if(isempty(object.new_cell_pb) || ~ishghandle(object.new_cell_pb)) + object.new_cell_pb = uicontrol('style','push',... + 'units','pix',... + 'string','new',... + 'HorizontalAlign','left',... + 'Parent',fig,... + 'position',pos,... + 'callback',@(src,event)pb_new_call(object,src,event)); +else + set(object.new_cell_pb,'position',pos); +end +end + diff --git a/@Grid/set_rGrid.m b/@Grid/set_rGrid.m index 833b9836bc3898559d97c9ba3e37deba61824ed4..6db6dadeb606cdee032b7ed86477e8e1e3209932 100644 --- a/@Grid/set_rGrid.m +++ b/@Grid/set_rGrid.m @@ -1,12 +1,13 @@ %% set_rGrid - % set the reference to the Results grid - % inputs: - % object:Grid - current Grid objectect - % r:RGrid - result Grid - % outputs: - % none - function [] = set_rGrid(object,r) - object.rGrid = r; - end - - \ No newline at end of file +% set the reference to the Results grid +% inputs: +% object:Grid - current Grid objectect +% r:RGrid - result Grid +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_rGrid(object,r) +object.rGrid = r; +end + diff --git a/@Grid/set_widths.m b/@Grid/set_widths.m index 7e8ffa15ca392c1cc68a6af291483bacb8f0f76c..c067c8dd42408ba4c892ee62f607ff1e900fabfc 100644 --- a/@Grid/set_widths.m +++ b/@Grid/set_widths.m @@ -1,21 +1,22 @@ %% set_widths - % sets the widths for each of the cells and subcells in a grid. - % the width of a cell is equal to the max width of the previous - % level - 1 if the cell has no subgrids, or 1 if the cell has a - % subgrid. - % inputs: - % object:Grid - current Grid object - % outputs: - % none - function [] = set_widths(object,max_width) - for i=1:size(object.cells,2) - if (~isempty(object.cells(i).subgrid)) - object.cells(i).subgrid.set_widths(max_width-1); - object.cells(i).width = 1; - else - object.cells(i).width = max_width; - end - end - end - - \ No newline at end of file +% sets the widths for each of the cells and subcells in a grid. +% the width of a cell is equal to the max width of the previous +% level - 1 if the cell has no subgrids, or 1 if the cell has a +% subgrid. +% inputs: +% object:Grid - current Grid object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_widths(object,max_width) +for i=1:size(object.cells,2) + if (~isempty(object.cells(i).subgrid)) + object.cells(i).subgrid.set_widths(max_width-1); + object.cells(i).width = 1; + else + object.cells(i).width = max_width; + end +end +end + diff --git a/@PVS_checker/PVS_checker.m b/@PVS_checker/PVS_checker.m index 47a90eb6ce31ee204542a194cc738201218e0af4..49a5f8414ab6e83ebfabe31f01ca182133eac243 100644 --- a/@PVS_checker/PVS_checker.m +++ b/@PVS_checker/PVS_checker.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef PVS_checker < handle % class contains all the functionality specific to the PVS theorem % prover @@ -28,7 +30,7 @@ classdef PVS_checker < handle [paren_string, new_pos] = parse_paren(string,pos) matlab_type = matlab_type_to_pvs_type( pvs_type ) - + version = get_pvs_version diff --git a/@PVS_checker/check_status.m b/@PVS_checker/check_status.m index d905d7c76ed45b12794b073daf554a721ed11ffd..0d1c059b42b9984e5b34928a59379fe054ff0744 100644 --- a/@PVS_checker/check_status.m +++ b/@PVS_checker/check_status.m @@ -1,28 +1,30 @@ - %% check_status - % checks the status of a pvs_checker object by generating a - % status script running it a checking the results to ensure that - % all the theories are proved. - % inputs: - % object:PVS_checker - PVS_checker object - % outputs: - % status:boolean - 0 if pvs file has been checked, 1 if it has - % not - function status = check_status(object) - script_name = object.generate_pvs_status_script(object.data.function_name); - [status, result] = system(['pvs -batch -v 3 -l ' script_name]); - parsed = object.parse_status(result); - pass = 1; - if (size(parsed,2) == 0) - pass = 0; - end - for i=1:2:size(parsed,2)-1 - if ~strncmp(parsed(i+1),'proved',6) - pass = 0; - end - end - - status = pass; - delete(script_name); - - end - +%% check_status +% checks the status of a pvs_checker object by generating a +% status script running it a checking the results to ensure that +% all the theories are proved. +% inputs: +% object:PVS_checker - PVS_checker object +% outputs: +% status:boolean - 0 if pvs file has been checked, 1 if it has +% not +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function status = check_status(object) +script_name = object.generate_pvs_status_script(object.data.function_name); +[status, result] = system(['pvs -batch -v 3 -l ' script_name]); +parsed = object.parse_status(result); +pass = 1; +if (size(parsed,2) == 0) + pass = 0; +end +for i=1:2:size(parsed,2)-1 + if ~strncmp(parsed(i+1),'proved',6) + pass = 0; + end +end + +status = pass; +delete(script_name); + +end + diff --git a/@PVS_checker/generate_pvs.m b/@PVS_checker/generate_pvs.m index 343eb72dd9f8c1ce322c957722bc38188040f7d2..4c12c1a98a31c03f4e14e70c3fefe215ae31b7bf 100644 --- a/@PVS_checker/generate_pvs.m +++ b/@PVS_checker/generate_pvs.m @@ -1,99 +1,100 @@ - %% genereate_pvs - % function will generate the pvs conditional code for a given - % table - % inputs: - % object:PVS_checker - PVS_checker object - % g1:Grid - left grid - % g2:Grid - top grid - % depth:int - number representing depth inside the table - % outputs: - % code:string - pvs code - % - function code = generate_pvs(object,g1,g2,depth) - g1cond1 = g1.cells(1).cond_text; - g2cond1 = g2.cells(1).cond_text; - code = []; - %1D horizontal - if(~isempty(g1cond1) && isempty(g2cond1)) - code = [code object.generate_pvs_horizontal(g1,g2.cells(1),depth)]; - % something in vertical column - else - - code = [code sprintf('COND\n')]; - elsecell = []; - for i=1:size(g2.cells,2) - g2cond = g2.cells(i).cond_text; - % condition string of otherwise corresponds to an else - % statement, we allow this statement to be in any order - % in the cells of the grid, so we need to find where it - % is, if it exists. - if (strcmp(g2cond,'otherwise')) - elsecell = g2.cells(i); - found = 1; - continue +%% genereate_pvs +% function will generate the pvs conditional code for a given +% table +% inputs: +% object:PVS_checker - PVS_checker object +% g1:Grid - left grid +% g2:Grid - top grid +% depth:int - number representing depth inside the table +% outputs: +% code:string - pvs code +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function code = generate_pvs(object,g1,g2,depth) +g1cond1 = g1.cells(1).cond_text; +g2cond1 = g2.cells(1).cond_text; +code = []; +%1D horizontal +if(~isempty(g1cond1) && isempty(g2cond1)) + code = [code object.generate_pvs_horizontal(g1,g2.cells(1),depth)]; + % something in vertical column +else + + code = [code sprintf('COND\n')]; + elsecell = []; + for i=1:size(g2.cells,2) + g2cond = g2.cells(i).cond_text; + % condition string of otherwise corresponds to an else + % statement, we allow this statement to be in any order + % in the cells of the grid, so we need to find where it + % is, if it exists. + if (strcmp(g2cond,'otherwise')) + elsecell = g2.cells(i); + found = 1; + continue + end + code = [code sprintf('%s->',object.matlab_to_pvs_syntax_translation(strtrim(char(g2.cells(i).cond_text))))]; + + if(~isempty(g2.cells(i).subgrid)) + code = [code object.generate_pvs(g1,g2.cells(i).subgrid,depth)]; + else + if (~isempty(g1cond1)) + if (object.data.multi_mode == 0) + code = [code object.generate_pvs_horizontal(g1,g2.cells(i),depth)]; + else + code = [code object.generate_pvs_multi_output(g1,g2.cells(i),depth)]; end - code = [code sprintf('%s->',object.matlab_to_pvs_syntax_translation(strtrim(char(g2.cells(i).cond_text))))]; + else - if(~isempty(g2.cells(i).subgrid)) - code = [code object.generate_pvs(g1,g2.cells(i).subgrid,depth)]; + resultcell = object.data.Grid0.search_return(g1.cells(1),g2.cells(i)); + if(~isempty(resultcell)) + code = [code object.matlab_to_pvs_syntax_translation(strtrim(char(resultcell.result_text)))]; + + else - if (~isempty(g1cond1)) - if (object.data.multi_mode == 0) - code = [code object.generate_pvs_horizontal(g1,g2.cells(i),depth)]; - else - code = [code object.generate_pvs_multi_output(g1,g2.cells(i),depth)]; - end - else - - resultcell = object.data.Grid0.search_return(g1.cells(1),g2.cells(i)); - if(~isempty(resultcell)) - code = [code object.matlab_to_pvs_syntax_translation(strtrim(char(resultcell.result_text)))]; - - - else - end - end end - if(isempty(elsecell)) - if(i~= size(g2.cells,2)) - code = [code sprintf(',\n')]; - else - code = [code sprintf('\n')]; - end - else - code = [code sprintf(',\n')]; - end - end - if(~isempty(elsecell)) - %resultcell = object.Grid0.search_return(elsecell,elsecell); - code = [code sprintf('ELSE->')]; - - if(~isempty(elsecell.subgrid)) - code = [code object.generate_pvs(g1,elsecell.subgrid,depth) sprintf('\n')]; + end + if(isempty(elsecell)) + if(i~= size(g2.cells,2)) + code = [code sprintf(',\n')]; + else + code = [code sprintf('\n')]; + end + else + code = [code sprintf(',\n')]; + end + + end + if(~isempty(elsecell)) + %resultcell = object.Grid0.search_return(elsecell,elsecell); + code = [code sprintf('ELSE->')]; + + if(~isempty(elsecell.subgrid)) + code = [code object.generate_pvs(g1,elsecell.subgrid,depth) sprintf('\n')]; + else + if (~isempty(g1cond1)) + if (object.data.multi_mode == 0) + code = [code object.generate_pvs_horizontal(g1,elsecell,depth) sprintf('\n')]; else - if (~isempty(g1cond1)) - if (object.data.multi_mode == 0) - code = [code object.generate_pvs_horizontal(g1,elsecell,depth) sprintf('\n')]; - else - code = [code object.generate_pvs_multi_output(g1,elsecell,depth) sprintf('\n')]; - - end - else - - resultcell = object.data.Grid0.search_return(g1.cells(1),elsecell); - if(~isempty(resultcell)) - code = [code object.matlab_to_pvs_syntax_translation(strtrim(char(resultcell.result_text))) sprintf('\n')]; - - end - end + code = [code object.generate_pvs_multi_output(g1,elsecell,depth) sprintf('\n')]; + end + else - end - - code = [code sprintf('ENDCOND')]; - - end + resultcell = object.data.Grid0.search_return(g1.cells(1),elsecell); + if(~isempty(resultcell)) + code = [code object.matlab_to_pvs_syntax_translation(strtrim(char(resultcell.result_text))) sprintf('\n')]; + + end + end end - + end + + code = [code sprintf('ENDCOND')]; + +end +end + + diff --git a/@PVS_checker/generate_pvs_file.m b/@PVS_checker/generate_pvs_file.m index a6dbf7f33f75f2aba8ab7ba7b626709b136d45c4..92830ef4f9844a71661bdcd978d1a0a4c93fc613 100644 --- a/@PVS_checker/generate_pvs_file.m +++ b/@PVS_checker/generate_pvs_file.m @@ -8,6 +8,8 @@ % extension % outputs; % none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = generate_pvs_file(object,filename) % type_mode = 0 -> use pvs types % type_mode = 1 -> use simulink typing information diff --git a/@PVS_checker/generate_pvs_horizontal.m b/@PVS_checker/generate_pvs_horizontal.m index 6aff7a110187175bc9c0f41439de90af8a9d6d7f..f49cc3dd104266c5597912024a01d628ee42d47b 100644 --- a/@PVS_checker/generate_pvs_horizontal.m +++ b/@PVS_checker/generate_pvs_horizontal.m @@ -10,6 +10,8 @@ % outputs: % code:string - pvs code % +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function code = generate_pvs_horizontal(object,g1,g2_cell,depth) code = []; diff --git a/@PVS_checker/generate_pvs_multi_output.m b/@PVS_checker/generate_pvs_multi_output.m index cc7a3c5bf944609b90aef74f5192365ecaf13585..1a45e46b9295a06a0b0bc3d45eb40b3f0545eca1 100644 --- a/@PVS_checker/generate_pvs_multi_output.m +++ b/@PVS_checker/generate_pvs_multi_output.m @@ -10,6 +10,8 @@ % use % outputs: % code:string - string of eml code +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function code = generate_eml_multi(object,g1,g2_cell,depth) @@ -28,14 +30,14 @@ for i=1:size(g1.cells,2) output = char(output_parsed{1}(1)) %if (i == 1) - code = [code sprintf('%s := ',output)]; + code = [code sprintf('%s := ',output)]; %else % code1 = [code1 sprintf(',%s',output)]; %end resultcell = object.data.Grid0.search_return(g1.cells(i),g2_cell); if(~isempty(resultcell)) %if (i == 1) - code = [code sprintf('%s',strtrim(char(resultcell.result_text)))]; + code = [code sprintf('%s',strtrim(char(resultcell.result_text)))]; %else % code2 = [code2 sprintf(',%s',strtrim(char(resultcell.result_text)))]; %end @@ -44,8 +46,8 @@ for i=1:size(g1.cells,2) else end if i ~= size(object.data.Grid1.cells,2) - code = [code ','] - end + code = [code ','] + end end code = ['(#' code '#)'] %code1 = [code1 ']']; diff --git a/@PVS_checker/generate_pvs_script.m b/@PVS_checker/generate_pvs_script.m index 48c7a331b77b75b65b01eb33430d225e1b20f0d9..83d277aac84109d6ca4708648684cb5345e09c22 100644 --- a/@PVS_checker/generate_pvs_script.m +++ b/@PVS_checker/generate_pvs_script.m @@ -1,18 +1,19 @@ - %% generate_pvs_script - % generate the pvs script used to prove and look for counter - % examples for a theory. script will have name filename.el - % inputs: - % object:PVS_checker - PVS_checker object - % filename:string - filename to save the script as, exclude - % extension. - % outputs: - % none - % - function [] = generate_pvs_script(object,filename) - fileid = fopen([filename '.el'],'w'); - code = ['(prove-tccs-pvs-file "' filename '" "(try (try (tcc) (try (assert) (skip) (fail) ) (fail))(skip) (random-test :count ' sprintf('%ld',object.data.settings.count) ' :size ' sprintf('%d',object.data.settings.range) '))" )' sprintf('\n')]; +%% generate_pvs_script +% generate the pvs script used to prove and look for counter +% examples for a theory. script will have name filename.el +% inputs: +% object:PVS_checker - PVS_checker object +% filename:string - filename to save the script as, exclude +% extension. +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = generate_pvs_script(object,filename) +fileid = fopen([filename '.el'],'w'); +code = ['(prove-tccs-pvs-file "' filename '" "(try (try (tcc) (try (assert) (skip) (fail) ) (fail))(skip) (random-test :count ' sprintf('%ld',object.data.settings.count) ' :size ' sprintf('%d',object.data.settings.range) '))" )' sprintf('\n')]; + +fprintf(fileid,code); +fclose(fileid); +end - fprintf(fileid,code); - fclose(fileid); - end - diff --git a/@PVS_checker/generate_pvs_status_script.m b/@PVS_checker/generate_pvs_status_script.m index 013416a092b548637b3cd2536668a6fa806a8079..b89e82015c1286d7e9868bae86f7f7c3c54f752b 100644 --- a/@PVS_checker/generate_pvs_status_script.m +++ b/@PVS_checker/generate_pvs_status_script.m @@ -1,17 +1,19 @@ - %% generate_pvs_status_script - % generate the script used for checking the status of a pvs file - % inputs: - % object:PVS_checker - PVS_checker object - % filename:string - filename of the pvs file to checkstatus of, - % excluding extension - % outputs: - % script_name:string - filename of the script of format name.el - function [script_name] = generate_pvs_status_script(object,filename) - script_name = [filename '_status' '.el']; - fileid = fopen(script_name,'w'); - code = ['(status-proof-pvs-file "' filename '")']; +%% generate_pvs_status_script +% generate the script used for checking the status of a pvs file +% inputs: +% object:PVS_checker - PVS_checker object +% filename:string - filename of the pvs file to checkstatus of, +% excluding extension +% outputs: +% script_name:string - filename of the script of format name.el +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [script_name] = generate_pvs_status_script(object,filename) +script_name = [filename '_status' '.el']; +fileid = fopen(script_name,'w'); +code = ['(status-proof-pvs-file "' filename '")']; + +fprintf(fileid,code); +fclose(fileid); +end - fprintf(fileid,code); - fclose(fileid); - end - diff --git a/@PVS_checker/get_pvs_version.m b/@PVS_checker/get_pvs_version.m index 8d6c8e1467480d58d048b9936633af07cb3fbbef..b9330eff4e5847314ccaa58ebebe20376e1e566e 100644 --- a/@PVS_checker/get_pvs_version.m +++ b/@PVS_checker/get_pvs_version.m @@ -1,4 +1,6 @@ - function version = get_pvs_version - [status, result] = system('pvs --version'); - version = result; - end \ No newline at end of file +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function version = get_pvs_version +[status, result] = system('pvs --version'); +version = result; +end \ No newline at end of file diff --git a/@PVS_checker/matlab_to_pvs_syntax_translation.m b/@PVS_checker/matlab_to_pvs_syntax_translation.m index c9bbd642d174bf33eb5f020d842f220795a6d8a2..3ebb69a22733852f36327f7a26428f80129f637b 100644 --- a/@PVS_checker/matlab_to_pvs_syntax_translation.m +++ b/@PVS_checker/matlab_to_pvs_syntax_translation.m @@ -1,23 +1,25 @@ - %% matlab_to_pvs_syntax_translation - %translate matlab syntax to pvs syntax, - % will be added to in the future - % will only work for functions in the prelude - % - % inputs: - % object:PVS_checker - PVS_checker object - % matlab_string:string - string to be converted from matlab - % syntax to pvs - % outputs; - % pvs_string:string - string converted to pvs syntax. - function pvs_string = matlab_to_pvs_syntax_translation(object,matlab_string) - pvs_string = regexprep(matlab_string,'&&',' AND '); - pvs_string = regexprep(pvs_string,'~(?!=)',' NOT '); - pvs_string = regexprep(pvs_string,'~=',' /= '); - pvs_string = regexprep(pvs_string,'==',' = '); - pvs_string = regexprep(pvs_string,'\|\|',' OR '); - pvs_string = regexprep(pvs_string,'ceil','ceiling'); - end - - - - +%% matlab_to_pvs_syntax_translation +%translate matlab syntax to pvs syntax, +% will be added to in the future +% will only work for functions in the prelude +% +% inputs: +% object:PVS_checker - PVS_checker object +% matlab_string:string - string to be converted from matlab +% syntax to pvs +% outputs; +% pvs_string:string - string converted to pvs syntax. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function pvs_string = matlab_to_pvs_syntax_translation(object,matlab_string) +pvs_string = regexprep(matlab_string,'&&',' AND '); +pvs_string = regexprep(pvs_string,'~(?!=)',' NOT '); +pvs_string = regexprep(pvs_string,'~=',' /= '); +pvs_string = regexprep(pvs_string,'==',' = '); +pvs_string = regexprep(pvs_string,'\|\|',' OR '); +pvs_string = regexprep(pvs_string,'ceil','ceiling'); +end + + + + diff --git a/@PVS_checker/matlab_type_to_pvs_type.m b/@PVS_checker/matlab_type_to_pvs_type.m index 70f198b07b644735ff303624c8c6e1ae4e636169..093ba9b3832e43f3f0d3d705fc6da7cf41c8e271 100644 --- a/@PVS_checker/matlab_type_to_pvs_type.m +++ b/@PVS_checker/matlab_type_to_pvs_type.m @@ -1,21 +1,23 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function matlab_type = matlab_type_to_pvs_type( pvs_type ) - if(strcmp(pvs_type,'logical')) - matlab_type = 'bool'; - elseif (strncmp(pvs_type, 'int',3)) - matlab_type = pvs_type; - elseif (strncmp(pvs_type, 'uint', 4)) - matlab_type = pvs_type; - elseif (strcmp(pvs_type,'single') || strcmp(pvs_type,'double')) - matlab_type = 'real'; - elseif (strncmp(pvs_type,'Inherit',7)) - matlab_type = 'real'; - elseif (strncmp(pvs_type,'fixdt',5)) - params = regexp(pvs_type,'(?<=\().*(?=\))','match'); - split_params = regexp(params,',','split'); - matlab_type = sprintf('fp2[%d,%d,%d]',eval(char(split_params{1}(2))),eval(char(split_params{1}(2)))-eval(char(split_params{1}(3)))-eval(char(split_params{1}(1))),eval(char(split_params{1}(1)))); - else - matlab_type = 'error'; - end +if(strcmp(pvs_type,'logical')) + matlab_type = 'bool'; +elseif (strncmp(pvs_type, 'int',3)) + matlab_type = pvs_type; +elseif (strncmp(pvs_type, 'uint', 4)) + matlab_type = pvs_type; +elseif (strcmp(pvs_type,'single') || strcmp(pvs_type,'double')) + matlab_type = 'real'; +elseif (strncmp(pvs_type,'Inherit',7)) + matlab_type = 'real'; +elseif (strncmp(pvs_type,'fixdt',5)) + params = regexp(pvs_type,'(?<=\().*(?=\))','match'); + split_params = regexp(params,',','split'); + matlab_type = sprintf('fp2[%d,%d,%d]',eval(char(split_params{1}(2))),eval(char(split_params{1}(2)))-eval(char(split_params{1}(3)))-eval(char(split_params{1}(1))),eval(char(split_params{1}(1)))); +else + matlab_type = 'error'; +end diff --git a/@PVS_checker/parse_decl_id.m b/@PVS_checker/parse_decl_id.m index edf2be5f546897d83d6ce8a8025f4603dc4642b3..5d4234997a4e66b8ac10a716fcfa10586cb8de36 100644 --- a/@PVS_checker/parse_decl_id.m +++ b/@PVS_checker/parse_decl_id.m @@ -7,6 +7,8 @@ % outputs; % decl_id:string - the declaration id name % new_pos:int - the position where the ending char was found. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [decl_id,new_pos] = parse_decl_id(string,pos) i = pos + 1; decl_id.id = []; diff --git a/@PVS_checker/parse_id.m b/@PVS_checker/parse_id.m index ac2ad9ab93d92d0e710f1eecd66e81aa37bfba19..21f3c6a7ff205b3e8571abc68c35e4f4dc31c663 100644 --- a/@PVS_checker/parse_id.m +++ b/@PVS_checker/parse_id.m @@ -6,6 +6,8 @@ % outputs; % id:structure - structure containing the parsed prf id section % new_pos:int - the position where the ending char was found. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [id,new_pos] = parse_id(string,pos) i = pos + 1; id.id = []; diff --git a/@PVS_checker/parse_paren.m b/@PVS_checker/parse_paren.m index b500ca961053fd874561f07accb76e013d6ce815..83111d23046266f783092d1a576fb827ea759e27 100644 --- a/@PVS_checker/parse_paren.m +++ b/@PVS_checker/parse_paren.m @@ -9,6 +9,8 @@ % paren_string:string - the string contained within the % parenthesis % new_pos:int - the position where the ending parenthesis was found. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [paren_string, new_pos] = parse_paren(string,pos) % pos points to opening ( paren_string = string(pos); diff --git a/@PVS_checker/parse_prf_file.m b/@PVS_checker/parse_prf_file.m index 16049af18661f0538f6047fae2192a77c166ac89..a5f53fab6c426e5ade5dbf747fc2f93ae64b18d3 100644 --- a/@PVS_checker/parse_prf_file.m +++ b/@PVS_checker/parse_prf_file.m @@ -7,6 +7,8 @@ % outputs; % theory_id:string - Theory name % decls:structure - structure of the declarations for the theory +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [theory_id, decls] = parse_prf_file(string) decls = []; diff --git a/@PVS_checker/parse_pvs_result.m b/@PVS_checker/parse_pvs_result.m index 802e05180133e8d8fbcb66b5af5cef8cff6af6d6..2ef3994e3eefe1f78b5f348ae4297a3a49fe7724 100644 --- a/@PVS_checker/parse_pvs_result.m +++ b/@PVS_checker/parse_pvs_result.m @@ -1,48 +1,50 @@ - %% parse_pvs_result - % parse the stuff that comes back from pvs batch mode, extract - % the counter examples and theorems. - % inputs: - % object:PVS_checker - PVS_checker object - % result:string - string containing text that comes back from pvs - % outputs: - % output:structure - results paresed into structure for easier - % manipulatings - % error:boolean - 0 if no error, 1 if error found during parsing. - function [output error] = parse_pvs_result(object,result) - found = regexp(result,'\w+(?=[\.]{4,})|(?<=[\.]{4,})\w+','match'); - if (isempty(found)) - error = 1; - output = []; - else - seqs = []; - for i = 1:2:size(found,2)-1 - if(~strcmp(char(found(i+1)),'proved')) - - found4 = []; - % These parsing depend on the version of PVS used, - % which may be a bad idea, although pvs is not - - if strncmp(object.pvs_version,'PVS Version 4.0',15) - % find the TCC that was unprovable - search_str = sprintf('(?<=Proving formula %s[\\n]*)%s.*?(?=[ \\n]*Rerunning step)',char(found(i)),char(found(i))); - elseif strncmp(object.pvs_version,'PVS Version 4.2',15) - search_str = sprintf('(?<=Installing rewrite rule singleton_rew\\s\\s)%s.*?(?=[ \\n]*Rerunning step)',char(found(i))); - end - found2 = regexp(result,char(search_str),'match','once'); - - - % find the counter examples - search_str = sprintf('(?<=%s.*?substitutions:).*?(?=This will undo the proof to: \\n%s)|(?<=%s.*?)No counter-examples(?=.*?%s)',char(found(i)),char(found(i)),char(found(i)),char(found(i))); - found3 = regexp(result,char(search_str),'match','once'); - if (~strcmp(found3,'No counter-examples')) - found4 = regexp(found3,'[^\n]*(?===>)|(?<===>)[^\n]*','match'); - end - seqs = [seqs struct('id', '1234a', 'TCC', found(i), 'seq', found2, 'ce', {found4})]; - end - - end - output = seqs; - error = 0; +%% parse_pvs_result +% parse the stuff that comes back from pvs batch mode, extract +% the counter examples and theorems. +% inputs: +% object:PVS_checker - PVS_checker object +% result:string - string containing text that comes back from pvs +% outputs: +% output:structure - results paresed into structure for easier +% manipulatings +% error:boolean - 0 if no error, 1 if error found during parsing. +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [output error] = parse_pvs_result(object,result) +found = regexp(result,'\w+(?=[\.]{4,})|(?<=[\.]{4,})\w+','match'); +if (isempty(found)) + error = 1; + output = []; +else + seqs = []; + for i = 1:2:size(found,2)-1 + if(~strcmp(char(found(i+1)),'proved')) + + found4 = []; + % These parsing depend on the version of PVS used, + % which may be a bad idea, although pvs is not + + if strncmp(object.pvs_version,'PVS Version 4.0',15) + % find the TCC that was unprovable + search_str = sprintf('(?<=Proving formula %s[\\n]*)%s.*?(?=[ \\n]*Rerunning step)',char(found(i)),char(found(i))); + elseif strncmp(object.pvs_version,'PVS Version 4.2',15) + search_str = sprintf('(?<=Installing rewrite rule singleton_rew\\s\\s)%s.*?(?=[ \\n]*Rerunning step)',char(found(i))); end + found2 = regexp(result,char(search_str),'match','once'); + + + % find the counter examples + search_str = sprintf('(?<=%s.*?substitutions:).*?(?=This will undo the proof to: \\n%s)|(?<=%s.*?)No counter-examples(?=.*?%s)',char(found(i)),char(found(i)),char(found(i)),char(found(i))); + found3 = regexp(result,char(search_str),'match','once'); + if (~strcmp(found3,'No counter-examples')) + found4 = regexp(found3,'[^\n]*(?===>)|(?<===>)[^\n]*','match'); + end + seqs = [seqs struct('id', '1234a', 'TCC', found(i), 'seq', found2, 'ce', {found4})]; end + end + output = seqs; + error = 0; +end +end + diff --git a/@PVS_checker/parse_status.m b/@PVS_checker/parse_status.m index 0f470cd05eed324d209a3a1c2dacdb6c485058e3..768fd27e84d42f4eec7e50e5bfbb0e43ddbdfc50 100644 --- a/@PVS_checker/parse_status.m +++ b/@PVS_checker/parse_status.m @@ -1,16 +1,18 @@ - %% parse_status - % parse the result of running the pvs status script. look for a - % list of theorems and associated status return that in parsed - % list. - % inputs: - % object:PVS_checker - PVS_checker object - % string:string - string containing output of runnign pvs script - % outputs: - % parsed:array - array containing each of the theorems of the pvs - % file followed by its status so will look something like - % ['TCC1' 'proved' 'TCC2' 'unfinished']... etc - function [parsed] = parse_status(object,string) - thrms_status = regexp(string,'\w+(?=[\.]{4,})|(?<=[\.]{4,})\w+','match'); - parsed = thrms_status; - - end \ No newline at end of file +%% parse_status +% parse the result of running the pvs status script. look for a +% list of theorems and associated status return that in parsed +% list. +% inputs: +% object:PVS_checker - PVS_checker object +% string:string - string containing output of runnign pvs script +% outputs: +% parsed:array - array containing each of the theorems of the pvs +% file followed by its status so will look something like +% ['TCC1' 'proved' 'TCC2' 'unfinished']... etc +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [parsed] = parse_status(object,string) +thrms_status = regexp(string,'\w+(?=[\.]{4,})|(?<=[\.]{4,})\w+','match'); +parsed = thrms_status; + +end \ No newline at end of file diff --git a/@PVS_checker/pvs_check.m b/@PVS_checker/pvs_check.m index ff865eba50469aa47e2a2d6646bdf06232f144fa..25347d357b2d0bc23544294c0804ac9654e7a15e 100644 --- a/@PVS_checker/pvs_check.m +++ b/@PVS_checker/pvs_check.m @@ -1,80 +1,82 @@ - %% pvs_check - % function will generate a pvs file for table, and depending on - % user input - % inputs: - % object:PVS_checker - PVS_checker object - % outputs; - % check:boolean - 0 if typecheck fails, 1 if succeds - % output:structure - if typecheck succeds then output contains - % parsed output from pvs - function [check,output] = pvs_check(object) - check = 0; - output = []; - % file name will be expression_name.m - - function_names = EMLGenerator.parse_inputs(object.data.function_name); - function_name = char(function_names{1}(1)); - object.generate_pvs_file(function_name); - - object.pvs_version = PVS_checker.get_pvs_version; - - - % THIS SECTION NEEDS SOME WORK - %------------- - % delete the existing proof - % update (22/07/10): - % has been fixed up now checks if prf file exists and prompts - % user to overwrite it. - - exists = 0; - button = ''; - if (exist([function_name '.prf'],'file')) - exists = 1; - button = questdlg(['A proof file already exists for function ' function_name sprintf('\n') ' What would you like to do' sprintf('\n') 'Note: Attempting to prove will delete existing prf file'],'prf exists','Attempt to prove','Open PVS','Cancel','Cancel') - end - - if (exists == 1 && (isempty(button) || strcmp(button,'Cancel'))) - output = 'canceled'; - return; - elseif (exists == 1 && (strcmp(button,'Open PVS'))); - [status, result] = system(['pvs ' function_name '.pvs']); - output = 'canceled'; - elseif (exists == 0 || strcmp(button,'Attempt to prove')) - box = waitbar(0,'Generating Proof Script') +%% pvs_check +% function will generate a pvs file for table, and depending on +% user input +% inputs: +% object:PVS_checker - PVS_checker object +% outputs; +% check:boolean - 0 if typecheck fails, 1 if succeds +% output:structure - if typecheck succeds then output contains +% parsed output from pvs +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [check,output] = pvs_check(object) +check = 0; +output = []; +% file name will be expression_name.m +function_names = EMLGenerator.parse_inputs(object.data.function_name); +function_name = char(function_names{1}(1)); +object.generate_pvs_file(function_name); - delete([function_name '.prf']) +object.pvs_version = PVS_checker.get_pvs_version; - % generate the proof script - object.generate_pvs_script(function_name) - waitbar(.10,box,'Running Proof') - %--------- - % call pvs in batch mode with script - % ADD check that pvs actually exists in system - [status, result] = system(['pvs -batch -v 3 -l ' function_name '.el']) - %objectect.msgbox_scroll(result); - waitbar(.70,box,'Parsing Results') - [parsed error] = object.parse_pvs_result(result); - - if (error == 1) - err_str = ['There was an error proving tabular expression ' sprintf('\n\n') 'Error string below:' sprintf('\n\n') result]; - GUI.msgbox_scroll(err_str); - else +% THIS SECTION NEEDS SOME WORK +%------------- +% delete the existing proof +% update (22/07/10): +% has been fixed up now checks if prf file exists and prompts +% user to overwrite it. - if (isempty(parsed)) - check = 1; - output = []; - else - output = parsed; - end - end - waitbar(.100,box,'Deleting Proof Script') +exists = 0; +button = ''; +if (exist([function_name '.prf'],'file')) + exists = 1; + button = questdlg(['A proof file already exists for function ' function_name sprintf('\n') ' What would you like to do' sprintf('\n') 'Note: Attempting to prove will delete existing prf file'],'prf exists','Attempt to prove','Open PVS','Cancel','Cancel') +end - delete([function_name '.el']); - - delete(box); - end - end - +if (exists == 1 && (isempty(button) || strcmp(button,'Cancel'))) + output = 'canceled'; + return; +elseif (exists == 1 && (strcmp(button,'Open PVS'))); + [status, result] = system(['pvs ' function_name '.pvs']); + output = 'canceled'; +elseif (exists == 0 || strcmp(button,'Attempt to prove')) + box = waitbar(0,'Generating Proof Script') + + + delete([function_name '.prf']) + + + % generate the proof script + object.generate_pvs_script(function_name) + waitbar(.10,box,'Running Proof') + %--------- + % call pvs in batch mode with script + % ADD check that pvs actually exists in system + [status, result] = system(['pvs -batch -v 3 -l ' function_name '.el']) + %objectect.msgbox_scroll(result); + waitbar(.70,box,'Parsing Results') + [parsed error] = object.parse_pvs_result(result); + + if (error == 1) + err_str = ['There was an error proving tabular expression ' sprintf('\n\n') 'Error string below:' sprintf('\n\n') result]; + GUI.msgbox_scroll(err_str); + else + if (isempty(parsed)) + check = 1; + output = []; + else + output = parsed; + end + end + waitbar(.100,box,'Deleting Proof Script') + + delete([function_name '.el']); + + delete(box); +end +end + + diff --git a/@PVS_checker/pvs_check_for_imports.m b/@PVS_checker/pvs_check_for_imports.m index 6d9a3bc7f2524c284937ccc0202120ba5364ce52..e917b8d3c398879773de53daa7665613adca162e 100644 --- a/@PVS_checker/pvs_check_for_imports.m +++ b/@PVS_checker/pvs_check_for_imports.m @@ -1,15 +1,17 @@ - %% pvs_check_for_imports - % checks both horizontal and vertical grids for functions for - % which there is a file on the path of the same name, in which - % case create pvs code to import the pvs file for that function - % inputs: - % object:PVS_checker - PVS_checker object - % outputs: - % string:string - pvs code of imports - % - function string = pvs_check_for_imports(object) - [string,found] = object.pvs_check_for_imports_g(object.data.Grid2,{}); - [string2,found2] = object.pvs_check_for_imports_g(object.data.Grid1,found); - string = [string string2]; - end - +%% pvs_check_for_imports +% checks both horizontal and vertical grids for functions for +% which there is a file on the path of the same name, in which +% case create pvs code to import the pvs file for that function +% inputs: +% object:PVS_checker - PVS_checker object +% outputs: +% string:string - pvs code of imports +% +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function string = pvs_check_for_imports(object) +[string,found] = object.pvs_check_for_imports_g(object.data.Grid2,{}); +[string2,found2] = object.pvs_check_for_imports_g(object.data.Grid1,found); +string = [string string2]; +end + diff --git a/@PVS_checker/pvs_check_for_imports_g.m b/@PVS_checker/pvs_check_for_imports_g.m index 983f2736333d7fef4998566c97130a0195e58e84..7084be4a432191f3fd4275c6e5c0a9cda5658c7a 100644 --- a/@PVS_checker/pvs_check_for_imports_g.m +++ b/@PVS_checker/pvs_check_for_imports_g.m @@ -1,37 +1,39 @@ - %% pvs_check_for_imports_g - % recursively check a grid for an imported functions, see comment - % for pvs_check_for_imports - % inputs: - % object:PVS_checker - PVS_checker object - % grid:Grid - grid to check - % found:array - list of functions already imported so we dont - % import the same thing twice. - % outputs: - % string:string - pvs code - % found:array - updated list of found functions to import - % - function [string,found] = pvs_check_for_imports_g(object,grid,found) - string = []; - for i=1:size(grid.cells,2) - % recurse through - if (~isempty(grid.cells(i).subgrid)) - string = [string object.pvs_check_for_imports_g(grid.cells(i).subgrid)]; - end - text = char(grid.cells(i).cond_text); - - vars = regexp(text,'([a-zA-Z][a-zA-Z0-9_]*)','match'); - - for j=1:size(vars,2) - if(exist(vars{j},'file')==2 && ~strcmp(vars{j},'otherwise')) - %check if already imported file - if (~any(ismember(found,vars{j}))) - string = [string 'IMPORTING ' vars{j} sprintf('\n')]; - found = [found vars{j}]; - end - end - end +%% pvs_check_for_imports_g +% recursively check a grid for an imported functions, see comment +% for pvs_check_for_imports +% inputs: +% object:PVS_checker - PVS_checker object +% grid:Grid - grid to check +% found:array - list of functions already imported so we dont +% import the same thing twice. +% outputs: +% string:string - pvs code +% found:array - updated list of found functions to import +% +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [string,found] = pvs_check_for_imports_g(object,grid,found) +string = []; +for i=1:size(grid.cells,2) + % recurse through + if (~isempty(grid.cells(i).subgrid)) + string = [string object.pvs_check_for_imports_g(grid.cells(i).subgrid)]; + end + text = char(grid.cells(i).cond_text); + + vars = regexp(text,'([a-zA-Z][a-zA-Z0-9_]*)','match'); + + for j=1:size(vars,2) + if(exist(vars{j},'file')==2 && ~strcmp(vars{j},'otherwise')) + %check if already imported file + if (~any(ismember(found,vars{j}))) + string = [string 'IMPORTING ' vars{j} sprintf('\n')]; + found = [found vars{j}]; end end - - - + end +end +end + + + diff --git a/@PVS_checker/user_imports.m b/@PVS_checker/user_imports.m index c30770fb21ebd4c1edca59734e83cf64b1013bb8..225f7ea663c6999cfa5968cecaa33ae8987b3f6a 100644 --- a/@PVS_checker/user_imports.m +++ b/@PVS_checker/user_imports.m @@ -1,18 +1,20 @@ - %% user_imports - % returns the string importing a user selected pvs file to import - % inputs: - % object:PVS_checker - PVS_checker object - % outputs; - % string:string - string of pvs code to add to generated file - function [string] = user_imports(object) - string = []; - if ~isempty(object.data.settings.inputs) - files = regexp(object.data.settings.inputs,',','split'); - - for i=1:size(files,2) - file_no_ext = regexp(files{i},'\w*(?=\.\w*)','match'); - string = [string sprintf('IMPORTING %s\n', char(file_no_ext)) ]; - end - end - end - +%% user_imports +% returns the string importing a user selected pvs file to import +% inputs: +% object:PVS_checker - PVS_checker object +% outputs; +% string:string - string of pvs code to add to generated file +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [string] = user_imports(object) +string = []; +if ~isempty(object.data.settings.inputs) + files = regexp(object.data.settings.inputs,',','split'); + + for i=1:size(files,2) + file_no_ext = regexp(files{i},'\w*(?=\.\w*)','match'); + string = [string sprintf('IMPORTING %s\n', char(file_no_ext)) ]; + end +end +end + diff --git a/@RCell/RCell.m b/@RCell/RCell.m index 04af5759603852b268b2d29b9a954a0e69b2d783..24ea3debffa034ce1bcd358979cab471fa4e5759 100644 --- a/@RCell/RCell.m +++ b/@RCell/RCell.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef RCell < handle %UNTITLED2 Summary of this class goes here % Detailed explanation goes here @@ -23,7 +25,7 @@ classdef RCell < handle n.Cell2 = cell2; end - + end end diff --git a/@RCell/flag_cell.m b/@RCell/flag_cell.m index 9dcf342c923cc1dc4d12acf3384094845feb6d5d..0ceff27cf760e72c5761d548296632a3d261dc67 100644 --- a/@RCell/flag_cell.m +++ b/@RCell/flag_cell.m @@ -1,27 +1,29 @@ - %% flag_cell - % allows changing the background color of a cell based on an - % inputed mode - % inputs - % object:RCell - current object - % mode:int - - % 0 - normal - % 1 - red (error/false) - % 2 - green (ok/true) - % outputs: - % none - function [] = flag_cell(object,mode) - - if (isempty(object.color)) - object.color = get(object.result,'BackgroundColor'); - end - if ishandle(object.result) - if (mode == 0) - set(object.result,'BackgroundColor',object.color); - elseif (mode == 1) - set(object.result,'BackgroundColor',[0.92 0.65 0.65]) - elseif (mode == 2) - set(object.result,'BackgroundColor',[0.03 1.0 0.32]); - end - end - - end \ No newline at end of file +%% flag_cell +% allows changing the background color of a cell based on an +% inputed mode +% inputs +% object:RCell - current object +% mode:int - +% 0 - normal +% 1 - red (error/false) +% 2 - green (ok/true) +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = flag_cell(object,mode) + +if (isempty(object.color)) + object.color = get(object.result,'BackgroundColor'); +end +if ishandle(object.result) + if (mode == 0) + set(object.result,'BackgroundColor',object.color); + elseif (mode == 1) + set(object.result,'BackgroundColor',[0.92 0.65 0.65]) + elseif (mode == 2) + set(object.result,'BackgroundColor',[0.03 1.0 0.32]); + end +end + +end \ No newline at end of file diff --git a/@RGrid/RGrid.m b/@RGrid/RGrid.m index 8eeae15fd28cf66e9252a13ec64620d71cfe3122..b3437de71a04d29761ee747b0da9de80c5ed5228 100644 --- a/@RGrid/RGrid.m +++ b/@RGrid/RGrid.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef RGrid < handle diff --git a/@RGrid/delete_g1s.m b/@RGrid/delete_g1s.m index 4f15a7b359e0fb8d8ff654f1ebc619e65265924e..2c5258b1578a6fd3ec9f24baf9026cd6430d9f49 100644 --- a/@RGrid/delete_g1s.m +++ b/@RGrid/delete_g1s.m @@ -1,22 +1,24 @@ - %% delete_g1s - % Same as delete_g2s but we are now deleting RCell with a - % reference to the inputed cell in their Cell1 - % inputs: - % object:RGrid - reference to current RGrid - % cell:Cell - reference to cell being deleted - % outputs; - % none - function [] = delete_g1s(object,cell) - deleted = []; - for i=1:size(object.Cells,2) - if (object.Cells(i).Cell1 == cell) - deleted = [deleted i]; - - end - end - if(~isempty(deleted)) - delete(object.Cells(deleted).result); - object.Cells(deleted) = []; - end - end +%% delete_g1s +% Same as delete_g2s but we are now deleting RCell with a +% reference to the inputed cell in their Cell1 +% inputs: +% object:RGrid - reference to current RGrid +% cell:Cell - reference to cell being deleted +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = delete_g1s(object,cell) +deleted = []; +for i=1:size(object.Cells,2) + if (object.Cells(i).Cell1 == cell) + deleted = [deleted i]; + end +end +if(~isempty(deleted)) + delete(object.Cells(deleted).result); + object.Cells(deleted) = []; +end +end + diff --git a/@RGrid/delete_g2s.m b/@RGrid/delete_g2s.m index b4c14271220c614344f5f487b5d42c39cc211e6c..cf356c529b4ee6309b79109ad4c0dc8bef7157af 100644 --- a/@RGrid/delete_g2s.m +++ b/@RGrid/delete_g2s.m @@ -1,25 +1,27 @@ - %% delete_g2s - % function will delete all the cells that reference an inputed - % condition cell as their Cell2. - % inputs: - % object:RGrid - reference to current RGrid - % cell:Cell - reference to cell being deleted - % outputs; - % none - function [] = delete_g2s(object,cell) - deleted = []; - % loop through all the cells, if we find any Rcell with cell as - % its Cell2 then add the index to the array, if we were to - % delete the cell right away the array size would decrease and - % we would get out of bounds issues. - for i=1:size(object.Cells,2) - if (object.Cells(i).Cell2 == cell) - deleted = [deleted i]; - end - end - if(~isempty(deleted)) - delete(object.Cells(deleted).result); - object.Cells(deleted) = []; - end - end - +%% delete_g2s +% function will delete all the cells that reference an inputed +% condition cell as their Cell2. +% inputs: +% object:RGrid - reference to current RGrid +% cell:Cell - reference to cell being deleted +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = delete_g2s(object,cell) +deleted = []; +% loop through all the cells, if we find any Rcell with cell as +% its Cell2 then add the index to the array, if we were to +% delete the cell right away the array size would decrease and +% we would get out of bounds issues. +for i=1:size(object.Cells,2) + if (object.Cells(i).Cell2 == cell) + deleted = [deleted i]; + end +end +if(~isempty(deleted)) + delete(object.Cells(deleted).result); + object.Cells(deleted) = []; +end +end + diff --git a/@RGrid/new_RCell.m b/@RGrid/new_RCell.m index 5fa77f38a0dd170f2372cb85963d4f58604f0a27..7aab7a3f45567883351def57d29c6719e030da2a 100644 --- a/@RGrid/new_RCell.m +++ b/@RGrid/new_RCell.m @@ -1,16 +1,17 @@ - %% new_RCell - % creates a new Cell in the current RGrid - % inputs: - % object:RGrid - current RGrid object - % cell1:Cell - reference to condition cell in top grid - % cell2:Cell - reference to condition cell in left grid - % outputs; - % none - function [] = new_RCell(object,cell1,cell2) - cell = RCell; - cell.Cell1 = cell1; - cell.Cell2 = cell2; - object.Cells = [object.Cells cell]; - end - - \ No newline at end of file +%% new_RCell +% creates a new Cell in the current RGrid +% inputs: +% object:RGrid - current RGrid object +% cell1:Cell - reference to condition cell in top grid +% cell2:Cell - reference to condition cell in left grid +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = new_RCell(object,cell1,cell2) +cell = RCell; +cell.Cell1 = cell1; +cell.Cell2 = cell2; +object.Cells = [object.Cells cell]; +end + diff --git a/@RGrid/refresh.m b/@RGrid/refresh.m index da8370720e039440c11da154132fea42162ab2ed..6a003dcf991986055189e36a7ccadd09b608fbbf 100644 --- a/@RGrid/refresh.m +++ b/@RGrid/refresh.m @@ -1,11 +1,13 @@ - %% refresh - % calls the setup function, might add furthur functionality in - % the future to this function - % inputs: - % object:RGrid - reference to current RGrid - % outputs; - % none - function [] = refresh(object) - object.setup(object.Grid1,object.Grid2); - end - +%% refresh +% calls the setup function, might add furthur functionality in +% the future to this function +% inputs: +% object:RGrid - reference to current RGrid +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = refresh(object) +object.setup(object.Grid1,object.Grid2); +end + diff --git a/@RGrid/search.m b/@RGrid/search.m index 7a155ebb5e9f92ca8ae93f75295d351d00f7934e..649ded7ae4a68bc9a692b3bbde76073ca129961e 100644 --- a/@RGrid/search.m +++ b/@RGrid/search.m @@ -1,19 +1,20 @@ - %% search - % determine wheter a results cell exists for a pair of condition - % cells. - % inputs: - % object:RGrid - reference to current RGrid - % cell1:Cell - reference to condition cell in top grid. - % cell2:Cell - reference to condition cell in left grid. - % outputs; - % cell:boolean - 1 if cell is found, 0 if cell is not found - function cell = search(object,cell1,cell2) - cell = 0; - for i=1:size(object.Cells,2) - if (object.Cells(i).Cell1 == cell1 && object.Cells(i).Cell2 == cell2); - cell = 1; - end - end - end - - \ No newline at end of file +%% search +% determine wheter a results cell exists for a pair of condition +% cells. +% inputs: +% object:RGrid - reference to current RGrid +% cell1:Cell - reference to condition cell in top grid. +% cell2:Cell - reference to condition cell in left grid. +% outputs; +% cell:boolean - 1 if cell is found, 0 if cell is not found +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function cell = search(object,cell1,cell2) +cell = 0; +for i=1:size(object.Cells,2) + if (object.Cells(i).Cell1 == cell1 && object.Cells(i).Cell2 == cell2); + cell = 1; + end +end +end + diff --git a/@RGrid/search_return.m b/@RGrid/search_return.m index aae6668555a10f864599ce25161f9a14fe6661a5..592c575bc5ff4bab927499f36baf8af6b16bf98d 100644 --- a/@RGrid/search_return.m +++ b/@RGrid/search_return.m @@ -1,19 +1,21 @@ %% search_return - % determine where a results cell exists for a pair of condition - % cells and returns the cell itself. - % inputs: - % object:RGrid - reference to current RGrid - % cell1:Cell - reference to condition cell in top grid. - % cell2:Cell - reference to condition cell in left grid. - % outputs; - % cell:RCell - if found returns reference to cell, if not returns - % empty - function cell = search_return(object,cell1,cell2) - cell = []; - for i=1:size(object.Cells,2) - if (object.Cells(i).Cell1 == cell1 && object.Cells(i).Cell2 == cell2); - cell = object.Cells(i); - end - end - end - +% determine where a results cell exists for a pair of condition +% cells and returns the cell itself. +% inputs: +% object:rgrid - reference to current rgrid +% cell1:cell - reference to condition cell in top grid. +% cell2:cell - reference to condition cell in left grid. +% outputs; +% cell:rcell - if found returns reference to cell, if not returns +% empty +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function cell = search_return(object,cell1,cell2) +cell = []; +for i=1:size(object.cells,2) + if (object.cells(i).cell1 == cell1 && object.cells(i).cell2 == cell2); + cell = object.cells(i); + end +end +end + diff --git a/@RGrid/setup.m b/@RGrid/setup.m index 34c85a375a8d8cf442a0a87644c7793ca0cabb0b..9dabc3ba29eb0eed5438e1f4d672ed0c5dc0d9aa 100644 --- a/@RGrid/setup.m +++ b/@RGrid/setup.m @@ -1,29 +1,31 @@ - %% setup - % this function will loop through all the cells in both the left - % grid and the top grid, once we reach a leaf cell for both - % grids, if there does not exist an RCell in the RGrid for both - % these leaf cells then we need to create one. - % inputs: - % object:RGrid - reference to current RGrid - % g1:Grid - reference to the top grid - % g2:Grid - reference to the left grid. - % outputs; - % - function [] = setup(object,g1,g2) - for i=1:size(g2.cells,2) - if (~isempty(g2.cells(i).subgrid)) - object.setup(g1,g2.cells(i).subgrid); - else - for j=1:size(g1.cells,2) - if(~isempty(g1.cells(j).subgrid)) - object.setup(g1.cells(j).subgrid,g2); - else - if (object.search(g1.cells(j),g2.cells(i)) == 0) - rcell = RCell(g1.cells(j),g2.cells(i)); - object.Cells = [object.Cells rcell]; - end - end - end +%% setup +% this function will loop through all the cells in both the left +% grid and the top grid, once we reach a leaf cell for both +% grids, if there does not exist an RCell in the RGrid for both +% these leaf cells then we need to create one. +% inputs: +% object:RGrid - reference to current RGrid +% g1:Grid - reference to the top grid +% g2:Grid - reference to the left grid. +% outputs; +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = setup(object,g1,g2) +for i=1:size(g2.cells,2) + if (~isempty(g2.cells(i).subgrid)) + object.setup(g1,g2.cells(i).subgrid); + else + for j=1:size(g1.cells,2) + if(~isempty(g1.cells(j).subgrid)) + object.setup(g1.cells(j).subgrid,g2); + else + if (object.search(g1.cells(j),g2.cells(i)) == 0) + rcell = RCell(g1.cells(j),g2.cells(i)); + object.Cells = [object.Cells rcell]; end end - end \ No newline at end of file + end + end +end +end \ No newline at end of file diff --git a/@Settings/Settings.m b/@Settings/Settings.m index 02f62d4d308c78f512027f80e150e878e2c5f5d0..00c0da904146dc4c78a851e7f4f20e165387757f 100644 --- a/@Settings/Settings.m +++ b/@Settings/Settings.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef Settings < handle %UNTITLED Summary of this class goes here % Detailed explanation goes here @@ -38,7 +40,7 @@ classdef Settings < handle end - + end end diff --git a/@Settings/apply_call.m b/@Settings/apply_call.m index bc15bdb90bde314b2b5125ae391cbd30eae3a99d..ce61188d04c900ff34c4e464f9828f6b046cfc2b 100644 --- a/@Settings/apply_call.m +++ b/@Settings/apply_call.m @@ -1,13 +1,15 @@ - %% apply_call - % callback for apply button, save the settings but do not close - % figure. - % inputs: - % object:Settings - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function err = apply_call(object,src,event) - object.save - end - +%% apply_call +% callback for apply button, save the settings but do not close +% figure. +% inputs: +% object:Settings - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function err = apply_call(object,src,event) +object.save +end + diff --git a/@Settings/cancel_call.m b/@Settings/cancel_call.m index 0b9deaf2334ec38bebe01083894ad625d4778973..ea47f52bea779dbf0adfa066dfe1a55721312667 100644 --- a/@Settings/cancel_call.m +++ b/@Settings/cancel_call.m @@ -1,11 +1,13 @@ - %% cancel_call - % callback for cancel button, cose figure don't save settings - % inputs: - % object:Settings - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = cancel_call(object,src,event) - object.close_fig([],[]); - end +%% cancel_call +% callback for cancel button, cose figure don't save settings +% inputs: +% object:Settings - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = cancel_call(object,src,event) +object.close_fig([],[]); +end diff --git a/@Settings/close_fig.m b/@Settings/close_fig.m index 416d324c5e4ae5bd2299273566d194fd53f0739e..d764de05b3d4e967dc429cc201b20faa4da5ff76 100644 --- a/@Settings/close_fig.m +++ b/@Settings/close_fig.m @@ -1,14 +1,16 @@ - %% close_fig - % when close button is pressed delete the figure, allow a new - % one to be opened - % inputs: - % object:Settings - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = close_fig(object,src,event) - delete(object.fig); - object.open = 0; - end - +%% close_fig +% when close button is pressed delete the figure, allow a new +% one to be opened +% inputs: +% object:Settings - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = close_fig(object,src,event) +delete(object.fig); +object.open = 0; +end + diff --git a/@Settings/elipse_call.m b/@Settings/elipse_call.m index d4705459e06eb0d3d212c0e2774b4b7b00483593..7166e1c9868f0114167752659be8d3c59408fe72 100644 --- a/@Settings/elipse_call.m +++ b/@Settings/elipse_call.m @@ -1,28 +1,30 @@ - %% elipse_call - % callback for when the elipses button is pressed, show file - % picker, update the textbox of selected files. - % inputs: - % object:Settings - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = elipse_call(object,src,event) - files = uigetfile('*.pvs','Select pvs files','MultiSelect','on'); - string = []; - if iscell(files) - for i = 1:size(files,2) - string = strcat(string,files(i)); - %string = [string, files(i)]; - if i ~= size(files,2) - string = strcat(string,', '); - %string = [string, ','] - end - end - - else - string = files; - end - set(object.include_text,'String',char(string)); +%% elipse_call +% callback for when the elipses button is pressed, show file +% picker, update the textbox of selected files. +% inputs: +% object:Settings - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = elipse_call(object,src,event) +files = uigetfile('*.pvs','Select pvs files','MultiSelect','on'); +string = []; +if iscell(files) + for i = 1:size(files,2) + string = strcat(string,files(i)); + %string = [string, files(i)]; + if i ~= size(files,2) + string = strcat(string,', '); + %string = [string, ','] end - + end + +else + string = files; +end +set(object.include_text,'String',char(string)); +end + diff --git a/@Settings/init.m b/@Settings/init.m index 9929ec50e3d8f229d1124a9c0fc38034e700004d..83b83c949354dac93e470f73dbcc86fe02baca1b 100644 --- a/@Settings/init.m +++ b/@Settings/init.m @@ -1,15 +1,16 @@ %% init - % - % inputs: - % object:Settings - current object - % outputs: - % none - function [] = init(object) - % initialize the default values of the properties - object.pvs_includes = []; - object.counter_trials = 1000; - object.counter_range = 100; - - end - - \ No newline at end of file +% +% inputs: +% object:Settings - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = init(object) +% initialize the default values of the properties +object.pvs_includes = []; +object.counter_trials = 1000; +object.counter_range = 100; + +end + diff --git a/@Settings/ok_call.m b/@Settings/ok_call.m index a03bb567dc17b370b812134049a65bd21449e7b2..5b295452e9d3087497272f0cf28e77a120bdf214 100644 --- a/@Settings/ok_call.m +++ b/@Settings/ok_call.m @@ -1,15 +1,17 @@ - - %% ok_call - % save settings and close figure - % inputs: - % object:Settings - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = ok_call(object,src,event) - if ~(object.save); - object.close_fig([],[]); - end - - end \ No newline at end of file + +%% ok_call +% save settings and close figure +% inputs: +% object:Settings - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = ok_call(object,src,event) +if ~(object.save); + object.close_fig([],[]); +end + +end \ No newline at end of file diff --git a/@Settings/save.m b/@Settings/save.m index 60be5dfd3884cee07a76849b103518717671b535..b0b52b3e160a957934ec24467d99f97335ee6fcb 100644 --- a/@Settings/save.m +++ b/@Settings/save.m @@ -1,30 +1,32 @@ - %% save - % save the settigns to the object properties, check to ensure - % that user input validates. - % inputs: - % object:Settings - current object - % outputs: - % none - function err = save(object) - msg = [] ; - err = 0; - if isempty(str2num(get(object.count_text,'String'))) - msg = [msg get(object.count_text,'String') ' is not a valid number']; - err = 1; - else - object.counter_trials = str2num(get(object.count_text,'String')); - end - - if isempty(str2num(get(object.range_text,'String'))) - msg = [msg sprintf('\n') get(object.count_text,'String') ' is not a valid number']; - err = 1; - else - object.counter_range = str2num(get(object.range_text,'String')); - end - object.pvs_includes = get(object.include_text,'String'); - - if err - msgbox(msg); - end - end - +%% save +% save the settigns to the object properties, check to ensure +% that user input validates. +% inputs: +% object:Settings - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function err = save(object) +msg = [] ; +err = 0; +if isempty(str2num(get(object.count_text,'String'))) + msg = [msg get(object.count_text,'String') ' is not a valid number']; + err = 1; +else + object.counter_trials = str2num(get(object.count_text,'String')); +end + +if isempty(str2num(get(object.range_text,'String'))) + msg = [msg sprintf('\n') get(object.count_text,'String') ' is not a valid number']; + err = 1; +else + object.counter_range = str2num(get(object.range_text,'String')); +end +object.pvs_includes = get(object.include_text,'String'); + +if err + msgbox(msg); +end +end + diff --git a/@Settings/setvalues.m b/@Settings/setvalues.m index dc26fbc3d32432d49eb719516bd513edc672c275..9d98617251458352f5d29c2e479f673b1cd5c934 100644 --- a/@Settings/setvalues.m +++ b/@Settings/setvalues.m @@ -1,15 +1,16 @@ - %% setvalues - % update the object settings based on an inputed structure - % containing these desired values - % inputs: - % object:Settings - current object - % outputs: - % none - function [] = setvalues(object,settings) - - object.pvs_includes = settings.inputs; - object.counter_trials = settings.count; - object.counter_range = settings.range; - end - - \ No newline at end of file +%% setvalues +% update the object settings based on an inputed structure +% containing these desired values +% inputs: +% object:Settings - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = setvalues(object,settings) + +object.pvs_includes = settings.inputs; +object.counter_trials = settings.count; +object.counter_range = settings.range; +end + diff --git a/@Settings/show.m b/@Settings/show.m index d2ae0be8394fa4893a74f645a3291cda4a6506a1..f498ce37c37c0a4cde72e8eaac111ebda29ef1b9 100644 --- a/@Settings/show.m +++ b/@Settings/show.m @@ -1,135 +1,137 @@ - %% show - % create the figure to show the gui used to change the settings - % inputs: - % object:Settings - current object - % outputs: - % none - function [] = show(object) - if (object.open) - figure(object.fig) - else - - object.fig = figure('units','pixels',... - 'position',[0 0 object.fig_width object.fig_height],... - 'menubar','none',... - 'name','Settings',... - 'numbertitle','off',... - 'resize','off',... - 'CloseRequestFcn',@(src,event)close_fig(object,src,event)); - end - - % Ok Button - uicontrol('style','push',... - 'units','pix',... - 'string','Ok',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'Position',[object.fig_width - object.button_width*3 - object.button_offset*3, object.button_offset, object.button_width, object.button_height],... - 'callback',@(src,event)ok_call(object,src,event)); - - % Cancel Button - uicontrol('style','push',... - 'units','pix',... - 'string','Cancel',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'Position',[object.fig_width - object.button_width*2 - object.button_offset*2, object.button_offset, object.button_width, object.button_height],... - 'callback',@(src,event)cancel_call(object,src,event)); - - - % Apply Button - uicontrol('style','push',... - 'units','pix',... - 'string','Apply',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'Position',[object.fig_width - object.button_width - object.button_offset, object.button_offset, object.button_width, object.button_height],... - 'callback',@(src,event)apply_call(object,src,event)); - - % main label - uicontrol('style','text',... - 'string','Table Tool Settings',... - 'HorizontalAlign','center',... - 'FontWeight','bold',... - 'Parent',object.fig,... - 'Position',[0, object.fig_height-object.text_offset-object.title_height, object.fig_width, object.title_height],... - 'BackgroundColor',get(object.fig,'Color')); - - panel_height = object.text_offset*6+object.label_height*3; - panel_width = object.fig_width-object.text_offset*2; - panel = uipanel('Title','PVS',... - 'visible','on',... - 'units','pix',... - 'BackgroundColor',get(object.fig,'Color'),... - 'Position',[object.text_offset,object.fig_height-object.text_offset-object.title_height-panel_height,panel_width,panel_height]); - - - % imports label - uicontrol('style','text',... - 'string','Imports:',... - 'HorizontalAlign','left',... - 'parent',panel,... - 'Position',[object.text_offset, panel_height-object.text_offset*3-object.label_height, object.label_width, object.label_height],... - 'BackgroundColor',get(object.fig,'Color')); - - elipse_width = 20; - % import text box - object.include_text = uicontrol('style','edit',... - 'units','pix',... - 'Parent',panel,... - 'String',object.pvs_includes,... - 'HorizontalAlign','center',... - 'BackgroundColor',get(object.fig,'Color'),... - 'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*2-object.label_height, panel_width - (object.text_offset*3+object.label_width+elipse_width), object.label_height]); - - % elipsis button - uicontrol('style','push',... - 'units','pix',... - 'string','...',... - 'HorizontalAlign','left',... - 'Parent',panel,... - 'Position',[panel_width-elipse_width-object.text_offset, panel_height-object.text_offset*2-object.label_height, elipse_width, object.label_height],... - 'callback',@(src,event)elipse_call(object,src,event)); - - - - % count label - uicontrol('style','text',... - 'string','Test Count:',... - 'HorizontalAlign','left',... - 'parent',panel,... - 'Position',[object.text_offset, panel_height-object.text_offset*4-object.label_height*2, object.label_width, object.label_height],... - 'BackgroundColor',get(object.fig,'Color')); - - % count text box - object.count_text = uicontrol('style','edit',... - 'units','pix',... - 'Parent',panel,... - 'String',object.counter_trials,... - 'HorizontalAlign','center',... - 'BackgroundColor',get(object.fig,'Color'),... - 'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*3-object.label_height*2, panel_width - (object.text_offset*2+object.label_width), object.label_height]); - - - % range label - uicontrol('style','text',... - 'string','Test Range:',... - 'HorizontalAlign','left',... - 'parent',panel,... - 'Position',[object.text_offset, panel_height-object.text_offset*5-object.label_height*3, object.label_width, object.label_height],... - 'BackgroundColor',get(object.fig,'Color')); - - % range text box - object.range_text = uicontrol('style','edit',... - 'units','pix',... - 'Parent',panel,... - 'String',object.counter_range,... - 'HorizontalAlign','center',... - 'BackgroundColor',get(object.fig,'Color'),... - 'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*4-object.label_height*3, panel_width - (object.text_offset*2+object.label_width), object.label_height]); - - - object.open = 1; - end - - +%% show +% create the figure to show the gui used to change the settings +% inputs: +% object:Settings - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = show(object) +if (object.open) + figure(object.fig) +else + + object.fig = figure('units','pixels',... + 'position',[0 0 object.fig_width object.fig_height],... + 'menubar','none',... + 'name','Settings',... + 'numbertitle','off',... + 'resize','off',... + 'CloseRequestFcn',@(src,event)close_fig(object,src,event)); +end + +% Ok Button +uicontrol('style','push',... + 'units','pix',... + 'string','Ok',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'Position',[object.fig_width - object.button_width*3 - object.button_offset*3, object.button_offset, object.button_width, object.button_height],... + 'callback',@(src,event)ok_call(object,src,event)); + +% Cancel Button +uicontrol('style','push',... + 'units','pix',... + 'string','Cancel',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'Position',[object.fig_width - object.button_width*2 - object.button_offset*2, object.button_offset, object.button_width, object.button_height],... + 'callback',@(src,event)cancel_call(object,src,event)); + + +% Apply Button +uicontrol('style','push',... + 'units','pix',... + 'string','Apply',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'Position',[object.fig_width - object.button_width - object.button_offset, object.button_offset, object.button_width, object.button_height],... + 'callback',@(src,event)apply_call(object,src,event)); + +% main label +uicontrol('style','text',... + 'string','Table Tool Settings',... + 'HorizontalAlign','center',... + 'FontWeight','bold',... + 'Parent',object.fig,... + 'Position',[0, object.fig_height-object.text_offset-object.title_height, object.fig_width, object.title_height],... + 'BackgroundColor',get(object.fig,'Color')); + +panel_height = object.text_offset*6+object.label_height*3; +panel_width = object.fig_width-object.text_offset*2; +panel = uipanel('Title','PVS',... + 'visible','on',... + 'units','pix',... + 'BackgroundColor',get(object.fig,'Color'),... + 'Position',[object.text_offset,object.fig_height-object.text_offset-object.title_height-panel_height,panel_width,panel_height]); + + +% imports label +uicontrol('style','text',... + 'string','Imports:',... + 'HorizontalAlign','left',... + 'parent',panel,... + 'Position',[object.text_offset, panel_height-object.text_offset*3-object.label_height, object.label_width, object.label_height],... + 'BackgroundColor',get(object.fig,'Color')); + +elipse_width = 20; +% import text box +object.include_text = uicontrol('style','edit',... + 'units','pix',... + 'Parent',panel,... + 'String',object.pvs_includes,... + 'HorizontalAlign','center',... + 'BackgroundColor',get(object.fig,'Color'),... + 'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*2-object.label_height, panel_width - (object.text_offset*3+object.label_width+elipse_width), object.label_height]); + +% elipsis button +uicontrol('style','push',... + 'units','pix',... + 'string','...',... + 'HorizontalAlign','left',... + 'Parent',panel,... + 'Position',[panel_width-elipse_width-object.text_offset, panel_height-object.text_offset*2-object.label_height, elipse_width, object.label_height],... + 'callback',@(src,event)elipse_call(object,src,event)); + + + +% count label +uicontrol('style','text',... + 'string','Test Count:',... + 'HorizontalAlign','left',... + 'parent',panel,... + 'Position',[object.text_offset, panel_height-object.text_offset*4-object.label_height*2, object.label_width, object.label_height],... + 'BackgroundColor',get(object.fig,'Color')); + +% count text box +object.count_text = uicontrol('style','edit',... + 'units','pix',... + 'Parent',panel,... + 'String',object.counter_trials,... + 'HorizontalAlign','center',... + 'BackgroundColor',get(object.fig,'Color'),... + 'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*3-object.label_height*2, panel_width - (object.text_offset*2+object.label_width), object.label_height]); + + +% range label +uicontrol('style','text',... + 'string','Test Range:',... + 'HorizontalAlign','left',... + 'parent',panel,... + 'Position',[object.text_offset, panel_height-object.text_offset*5-object.label_height*3, object.label_width, object.label_height],... + 'BackgroundColor',get(object.fig,'Color')); + +% range text box +object.range_text = uicontrol('style','edit',... + 'units','pix',... + 'Parent',panel,... + 'String',object.counter_range,... + 'HorizontalAlign','center',... + 'BackgroundColor',get(object.fig,'Color'),... + 'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*4-object.label_height*3, panel_width - (object.text_offset*2+object.label_width), object.label_height]); + + +object.open = 1; +end + + diff --git a/@UndoManager/UndoManager.m b/@UndoManager/UndoManager.m index 7fd92868917b65fff473abb9eb5097ffce0679bb..44c25d63b6e917b41c8d2f9b74b5965011408416 100644 --- a/@UndoManager/UndoManager.m +++ b/@UndoManager/UndoManager.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef UndoManager < handle %UNDOMANAGER Summary of this class goes here % Detailed explanation goes here diff --git a/@UndoManager/new_state.m b/@UndoManager/new_state.m index 6b4358766be3afb8104ecaafaad7bf8e65efb465..27443a7ee1a39df6e9c3dbe4eef4c92ff71c1159 100644 --- a/@UndoManager/new_state.m +++ b/@UndoManager/new_state.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [] = new_state( object, data ) %UNTITLED Summary of this function goes here % Detailed explanation goes here diff --git a/@ValidationReport/ValidationReport.m b/@ValidationReport/ValidationReport.m index bcee5f7274ce8ae67459ac2b492a6367a93e15b0..0d3b25bed2da537567f92a28590bebc2776e2793 100644 --- a/@ValidationReport/ValidationReport.m +++ b/@ValidationReport/ValidationReport.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification classdef ValidationReport < handle %UNTITLED Summary of this class goes here % Detailed explanation goes here @@ -29,7 +31,7 @@ classdef ValidationReport < handle gui = []; pb_nav_width = 60; pb_nav_height = 20; - + offset = 10; page = 1; keyword = '1234a'; @@ -43,13 +45,13 @@ classdef ValidationReport < handle % guinew:GUI - main gui object % outputs: % object:ValidationReport - current object - + function object = ValidationReport(guinew) object.gui = guinew; end - + end end diff --git a/@ValidationReport/close_req_call.m b/@ValidationReport/close_req_call.m index e01089d8d0335d9f74c21f784f455e6374fa16bd..4fb16b7f300f070efb9e2161dadc811c37b22908 100644 --- a/@ValidationReport/close_req_call.m +++ b/@ValidationReport/close_req_call.m @@ -1,18 +1,20 @@ - - %% close_req_call - % when request to close object comes, update the gui so that it - % doesn't show the colours and close the figure - % inputs: - % object:ValidationReport - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = close_req_call(object,src,event) - if (object.gui.Data.open) - object.gui.check_call([],[]); - end - object.gui.validation_report_handle = 0; - delete(object.fig); - end - + +%% close_req_call +% when request to close object comes, update the gui so that it +% doesn't show the colours and close the figure +% inputs: +% object:ValidationReport - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = close_req_call(object,src,event) +if (object.gui.Data.open) + object.gui.check_call([],[]); +end +object.gui.validation_report_handle = 0; +delete(object.fig); +end + diff --git a/@ValidationReport/init.m b/@ValidationReport/init.m index b4c16cc8782c2e85235e798ae813f3a38d7fa294..ad810cba248d04e1928f3c133619abf799faf4e4 100644 --- a/@ValidationReport/init.m +++ b/@ValidationReport/init.m @@ -1,121 +1,123 @@ - %% init - % initialize the Validation report, set up the gui - % inputs: - % object:ValidationReport - current object - % outputs: - % none - function [] = init(object) - - if size(object.PVS_results,2) == 0 - - else - - object.fig_width = object.offset + object.TCC_width + object.offset + object.seq_width + object.offset + object.ce_width + object.offset; - object.fig_height = object.offset + object.header_height + object.offset + object.seq_height + object.offset; - object.fig = figure('units','pixels',... - 'position',[0, 0, object.fig_width, object.fig_height ],... - 'menubar','none',... - 'name','PVS Report',... - 'numbertitle','off',... - 'resize','off',... - 'CloseRequestFcn',@(src,event)close_req_call(object,src,event)); +%% init +% initialize the Validation report, set up the gui +% inputs: +% object:ValidationReport - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = init(object) - stop = 0; - i = 1; - count = 0; +if size(object.PVS_results,2) == 0 + +else + + object.fig_width = object.offset + object.TCC_width + object.offset + object.seq_width + object.offset + object.ce_width + object.offset; + object.fig_height = object.offset + object.header_height + object.offset + object.seq_height + object.offset; + object.fig = figure('units','pixels',... + 'position',[0, 0, object.fig_width, object.fig_height ],... + 'menubar','none',... + 'name','PVS Report',... + 'numbertitle','off',... + 'resize','off',... + 'CloseRequestFcn',@(src,event)close_req_call(object,src,event)); + + stop = 0; + i = 1; + count = 0; + + %first i will be '1234a' + + + object.edit_tcc = uicontrol('style','edit',... + 'Parent',object.fig,... + 'units','pix',... + 'min',0,'max',1,... % This is the key to multiline edits. + 'Max',2.0,... + 'Clipping','on',... + 'fontweight','bold',... + 'BackgroundColor',[1 1 1],... + 'horizontalalign','center',... + 'fontsize',11); + + object.edit_seq = uicontrol('style','edit',... + 'Parent',object.fig,... + 'units','pix',... + 'min',0,'max',1,... % This is the key to multiline edits. + 'Max',2.0,... + 'Clipping','on',... + 'fontweight','bold',... + 'BackgroundColor',[1 1 1],... + 'horizontalalign','left',... + 'fontsize',11); + + + object.edit_ce = uicontrol('style','edit',... + 'Parent',object.fig,... + 'units','pix',... + 'min',0,'max',1,... % This is the key to multiline edits. + 'Max',2.0,... + 'Clipping','on',... + 'fontweight','bold',... + 'BackgroundColor',[1 1 1],... + 'horizontalalign','left',... + 'fontsize',11); + + object.pb_next = uicontrol('style','push',... + 'units','pix',... + 'string','Next',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'callback',@(src,event)pb_next_call(object,src,event)); + + if(size(object.PVS_results,2)<=1) + set(object.pb_next,'enable','off'); + end + + + object.pb_prev = uicontrol('style','push',... + 'units','pix',... + 'string','Prev',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'enable','off',... + 'callback',@(src,event)pb_prev_call(object,src,event)); + + object.label_tcc = uicontrol('style','text',... + 'string','TCC Name',... + 'HorizontalAlign','left',... + 'BackgroundColor',get(object.fig,'Color')); + object.label_seq = uicontrol('style','text',... + 'string','Sequent',... + 'HorizontalAlign','left',... + 'BackgroundColor',get(object.fig,'Color')); + object.label_ce = uicontrol('style','text',... + 'string','Counter Example',... + 'HorizontalAlign','left',... + 'BackgroundColor',get(object.fig,'Color')); + object.label_page = uicontrol('style','text',... + 'string','',... + 'HorizontalAlign','center',... + 'BackgroundColor',get(object.fig,'Color')); + object.label_title = uicontrol('style','text',... + 'string','Typecheck Summary',... + 'HorizontalAlign','left',... + 'FontWeight','bold',... + 'FontSize',15,... + 'BackgroundColor',get(object.fig,'Color')); + + object.pb_open = uicontrol('style','push',... + 'units','pix',... + 'string','Open PVS',... + 'HorizontalAlign','left',... + 'Parent',object.fig,... + 'enable','on',... + 'callback',@(src,event)pb_open_call(object,src,event)); + + object.position; + object.populate; + object.gui.validation_report_handle = object.fig; +end - %first i will be '1234a' +end - - object.edit_tcc = uicontrol('style','edit',... - 'Parent',object.fig,... - 'units','pix',... - 'min',0,'max',1,... % This is the key to multiline edits. - 'Max',2.0,... - 'Clipping','on',... - 'fontweight','bold',... - 'BackgroundColor',[1 1 1],... - 'horizontalalign','center',... - 'fontsize',11); - - object.edit_seq = uicontrol('style','edit',... - 'Parent',object.fig,... - 'units','pix',... - 'min',0,'max',1,... % This is the key to multiline edits. - 'Max',2.0,... - 'Clipping','on',... - 'fontweight','bold',... - 'BackgroundColor',[1 1 1],... - 'horizontalalign','left',... - 'fontsize',11); - - - object.edit_ce = uicontrol('style','edit',... - 'Parent',object.fig,... - 'units','pix',... - 'min',0,'max',1,... % This is the key to multiline edits. - 'Max',2.0,... - 'Clipping','on',... - 'fontweight','bold',... - 'BackgroundColor',[1 1 1],... - 'horizontalalign','left',... - 'fontsize',11); - - object.pb_next = uicontrol('style','push',... - 'units','pix',... - 'string','Next',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'callback',@(src,event)pb_next_call(object,src,event)); - - if(size(object.PVS_results,2)<=1) - set(object.pb_next,'enable','off'); - end - - - object.pb_prev = uicontrol('style','push',... - 'units','pix',... - 'string','Prev',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'enable','off',... - 'callback',@(src,event)pb_prev_call(object,src,event)); - - object.label_tcc = uicontrol('style','text',... - 'string','TCC Name',... - 'HorizontalAlign','left',... - 'BackgroundColor',get(object.fig,'Color')); - object.label_seq = uicontrol('style','text',... - 'string','Sequent',... - 'HorizontalAlign','left',... - 'BackgroundColor',get(object.fig,'Color')); - object.label_ce = uicontrol('style','text',... - 'string','Counter Example',... - 'HorizontalAlign','left',... - 'BackgroundColor',get(object.fig,'Color')); - object.label_page = uicontrol('style','text',... - 'string','',... - 'HorizontalAlign','center',... - 'BackgroundColor',get(object.fig,'Color')); - object.label_title = uicontrol('style','text',... - 'string','Typecheck Summary',... - 'HorizontalAlign','left',... - 'FontWeight','bold',... - 'FontSize',15,... - 'BackgroundColor',get(object.fig,'Color')); - - object.pb_open = uicontrol('style','push',... - 'units','pix',... - 'string','Open PVS',... - 'HorizontalAlign','left',... - 'Parent',object.fig,... - 'enable','on',... - 'callback',@(src,event)pb_open_call(object,src,event)); - - object.position; - object.populate; - object.gui.validation_report_handle = object.fig; - end - - end - diff --git a/@ValidationReport/pb_next_call.m b/@ValidationReport/pb_next_call.m index 0bd63b1bc22f9be19ccb45bb256dfa3a288537b8..b531f9ffd0ab3cd443e922662254e984c8507e5c 100644 --- a/@ValidationReport/pb_next_call.m +++ b/@ValidationReport/pb_next_call.m @@ -1,19 +1,21 @@ - %% pb_next_call - % callback for the next button, move to the next - % record, update the gui objects. - % inputs: - % objectect:Settings - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = pb_next_call(object,src,event) - object.page = object.page + 1; - object.populate; - if (object.page == size(object.PVS_results,2)) - set(src,'enable','off'); - - - end - set(object.pb_prev,'enable','on'); - end +%% pb_next_call +% callback for the next button, move to the next +% record, update the gui objects. +% inputs: +% objectect:Settings - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = pb_next_call(object,src,event) +object.page = object.page + 1; +object.populate; +if (object.page == size(object.PVS_results,2)) + set(src,'enable','off'); + + +end +set(object.pb_prev,'enable','on'); +end diff --git a/@ValidationReport/pb_open_call.m b/@ValidationReport/pb_open_call.m index 86f0f9971551c2762aa8ce2c090993c9e24bd26c..12fe10387dd65620ce86a104b8c0666d3c77bcd9 100644 --- a/@ValidationReport/pb_open_call.m +++ b/@ValidationReport/pb_open_call.m @@ -1,14 +1,16 @@ - %% pb_open_call - % callback for the open button, opens pvs to the pvs file being - % used. - % inputs: - % object:ValidationReport - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = pb_open_call(object,src,event) - [status, result] = system(['pvs ' get(object.gui.function_name_control,'String') '.pvs']); +%% pb_open_call +% callback for the open button, opens pvs to the pvs file being +% used. +% inputs: +% object:ValidationReport - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = pb_open_call(object,src,event) +[status, result] = system(['pvs ' get(object.gui.function_name_control,'String') '.pvs']); + +end - end - diff --git a/@ValidationReport/pb_prev_call.m b/@ValidationReport/pb_prev_call.m index 9f41cf97c9600716d5da6fc8b581f6a05f7fd965..57ebf44538055954879e002a1dca356ade322919 100644 --- a/@ValidationReport/pb_prev_call.m +++ b/@ValidationReport/pb_prev_call.m @@ -1,20 +1,22 @@ - %% pb_prev_call - % callback for the previous button, move to the previous - % record, update the gui objects. - % inputs: - % object:ValidationReport - current object - % src - source of the callback calling - % event - event that triggered the callback - % outputs: - % none - function [] = pb_prev_call(object,src,event) - object.page = object.page - 1; - object.populate - if(object.page == 1) - set(src,'enable','off'); - - end - set(object.pb_next,'enable','on'); - end - - +%% pb_prev_call +% callback for the previous button, move to the previous +% record, update the gui objects. +% inputs: +% object:ValidationReport - current object +% src - source of the callback calling +% event - event that triggered the callback +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = pb_prev_call(object,src,event) +object.page = object.page - 1; +object.populate +if(object.page == 1) + set(src,'enable','off'); + +end +set(object.pb_next,'enable','on'); +end + + diff --git a/@ValidationReport/populate.m b/@ValidationReport/populate.m index b986e5b96a87fe37efa64c8871d6f36b949c1e65..2176c7545bf941ff1713c06cfb1ad2506b9836c6 100644 --- a/@ValidationReport/populate.m +++ b/@ValidationReport/populate.m @@ -1,34 +1,36 @@ - %% populate - % update all the textboxes to the current page of the pvs - % results - % inputs: - % object:ValidationReport - current object - % outputs: - % none - function [] = populate(object) - % temporarily used to reset colours - object.gui.check_call([],[]); - set(object.edit_tcc,'string',char(object.PVS_results(object.page).TCC)); - set(object.edit_seq,'string',char(object.PVS_results(object.page).seq)); - set(object.label_page,'string',[num2str(object.page) ' of ' num2str(size(object.PVS_results,2))]); - counter = []; - if size(object.PVS_results(object.page).ce,2) == 0 - counter = ['no counter example generated']; - - else - for i = 1:2:size(object.PVS_results(object.page).ce,2) - - - % need to do some translation back to matlab syntax - new_value = regexprep(char(object.PVS_results(object.page).ce(i+1)),'FALSE',' 0 '); - new_value = regexprep(new_value,'TRUE',' 1 '); - eval(['value = ' char(new_value)]) - - counter = [counter char(object.PVS_results(object.page).ce(i)) ' = ' num2str(value) ';' sprintf('\n')]; - end - - - object.gui.evaluate_counter(counter); - end - set(object.edit_ce,'string',counter); - end \ No newline at end of file +%% populate +% update all the textboxes to the current page of the pvs +% results +% inputs: +% object:ValidationReport - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = populate(object) +% temporarily used to reset colours +object.gui.check_call([],[]); +set(object.edit_tcc,'string',char(object.PVS_results(object.page).TCC)); +set(object.edit_seq,'string',char(object.PVS_results(object.page).seq)); +set(object.label_page,'string',[num2str(object.page) ' of ' num2str(size(object.PVS_results,2))]); +counter = []; +if size(object.PVS_results(object.page).ce,2) == 0 + counter = ['no counter example generated']; + +else + for i = 1:2:size(object.PVS_results(object.page).ce,2) + + + % need to do some translation back to matlab syntax + new_value = regexprep(char(object.PVS_results(object.page).ce(i+1)),'FALSE',' 0 '); + new_value = regexprep(new_value,'TRUE',' 1 '); + eval(['value = ' char(new_value)]) + + counter = [counter char(object.PVS_results(object.page).ce(i)) ' = ' num2str(value) ';' sprintf('\n')]; + end + + + object.gui.evaluate_counter(counter); +end +set(object.edit_ce,'string',counter); +end \ No newline at end of file diff --git a/@ValidationReport/position.m b/@ValidationReport/position.m index 4adfbd314a0c3e635f00da17f9fbdc3a096268fa..0842253da5a19b6e300a8b6357cbf2863504cb0f 100644 --- a/@ValidationReport/position.m +++ b/@ValidationReport/position.m @@ -1,22 +1,24 @@ - %% position - % set the position of all the gui elements - % inputs: - % object:ValidationReport - current object - % outputs: - % none - function [] = position(object) - set(object.edit_tcc,'position',[object.offset, (object.fig_height - object.offset - object.header_height - object.offset - object.seq_height) ,object.TCC_width,object.TCC_height]) - set(object.edit_seq,'position',[object.offset + object.TCC_width + object.offset, (object.fig_height - object.offset - object.header_height - object.offset - object.seq_height),object.seq_width,object.seq_height]) - set(object.edit_ce, 'position',[object.offset + object.TCC_width + object.offset + object.seq_width + object.offset, (object.fig_height - object.offset - object.header_height - object.offset - object.seq_height) ,object.ce_width,object.ce_height]) - - set(object.label_tcc,'position',[object.offset, (object.fig_height - object.offset - object.header_height) ,object.TCC_width,object.label_height]) - set(object.label_seq,'position',[object.offset + object.TCC_width + object.offset, (object.fig_height - object.offset - object.header_height) ,object.TCC_width,object.label_height]) - set(object.label_ce,'position',[object.offset + object.TCC_width + object.offset + object.seq_width + object.offset, (object.fig_height - object.offset - object.header_height) ,object.TCC_width,object.label_height]) - - set(object.label_title,'position',[object.offset, (object.fig_height - object.offset - object.label_height*2) ,object.TCC_width,object.label_height*2]) - set(object.label_page,'position',[object.fig_width-object.pb_nav_width*2-object.offset*2, object.fig_height-object.offset-object.header_height+object.label_height+object.pb_nav_height+object.offset/2,object.pb_nav_width*2+object.offset,object.pb_nav_height]); - set(object.pb_next,'position',[object.fig_width - object.pb_nav_width - object.offset, object.fig_height - object.offset - object.header_height + object.label_height + object.offset/2, object.pb_nav_width, object.pb_nav_height]); - set(object.pb_prev,'position',[object.fig_width - object.pb_nav_width - object.offset - object.offset - object.pb_nav_width, object.fig_height - object.offset - object.header_height + object.label_height+object.offset/2, object.pb_nav_width, object.pb_nav_height]); - set(object.pb_open,'position',[object.fig_width - object.pb_nav_width - object.offset - object.offset - object.pb_nav_width - object.offset - object.pb_nav_width, object.fig_height - object.offset - object.header_height + object.label_height+object.offset/2, object.pb_nav_width, object.pb_nav_height]); - end - +%% position +% set the position of all the gui elements +% inputs: +% object:ValidationReport - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = position(object) +set(object.edit_tcc,'position',[object.offset, (object.fig_height - object.offset - object.header_height - object.offset - object.seq_height) ,object.TCC_width,object.TCC_height]) +set(object.edit_seq,'position',[object.offset + object.TCC_width + object.offset, (object.fig_height - object.offset - object.header_height - object.offset - object.seq_height),object.seq_width,object.seq_height]) +set(object.edit_ce, 'position',[object.offset + object.TCC_width + object.offset + object.seq_width + object.offset, (object.fig_height - object.offset - object.header_height - object.offset - object.seq_height) ,object.ce_width,object.ce_height]) + +set(object.label_tcc,'position',[object.offset, (object.fig_height - object.offset - object.header_height) ,object.TCC_width,object.label_height]) +set(object.label_seq,'position',[object.offset + object.TCC_width + object.offset, (object.fig_height - object.offset - object.header_height) ,object.TCC_width,object.label_height]) +set(object.label_ce,'position',[object.offset + object.TCC_width + object.offset + object.seq_width + object.offset, (object.fig_height - object.offset - object.header_height) ,object.TCC_width,object.label_height]) + +set(object.label_title,'position',[object.offset, (object.fig_height - object.offset - object.label_height*2) ,object.TCC_width,object.label_height*2]) +set(object.label_page,'position',[object.fig_width-object.pb_nav_width*2-object.offset*2, object.fig_height-object.offset-object.header_height+object.label_height+object.pb_nav_height+object.offset/2,object.pb_nav_width*2+object.offset,object.pb_nav_height]); +set(object.pb_next,'position',[object.fig_width - object.pb_nav_width - object.offset, object.fig_height - object.offset - object.header_height + object.label_height + object.offset/2, object.pb_nav_width, object.pb_nav_height]); +set(object.pb_prev,'position',[object.fig_width - object.pb_nav_width - object.offset - object.offset - object.pb_nav_width, object.fig_height - object.offset - object.header_height + object.label_height+object.offset/2, object.pb_nav_width, object.pb_nav_height]); +set(object.pb_open,'position',[object.fig_width - object.pb_nav_width - object.offset - object.offset - object.pb_nav_width - object.offset - object.pb_nav_width, object.fig_height - object.offset - object.header_height + object.label_height+object.offset/2, object.pb_nav_width, object.pb_nav_height]); +end + diff --git a/@ValidationReport/set_results.m b/@ValidationReport/set_results.m index 97ec340c3cfda6dd6f4a89f70b939518a85b006a..a4a3e19619719b6a7f702724ec1ef1f4f12ef87e 100644 --- a/@ValidationReport/set_results.m +++ b/@ValidationReport/set_results.m @@ -1,10 +1,12 @@ %% set_results - % set the results property - % inputs: - % object:ValidationReport - current object - % outputs: - % none - function [] = set_results(object,res) - object.PVS_results = res; - end - +% set the results property +% inputs: +% object:ValidationReport - current object +% outputs: +% none +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification +function [] = set_results(object,res) +object.PVS_results = res; +end + diff --git a/TTdiag.m b/TTdiag.m index 286f5fe59f04f336630a98a9084152bf22434654..3cef7c9825366f4922e288ace7b4401998f39872 100644 --- a/TTdiag.m +++ b/TTdiag.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function TTdiag(varargin) orig_gcbh = gcbh; @@ -10,7 +12,7 @@ Action = varargin{1}; switch Action, case 'Open', Mode = varargin{2}; - + if 2 ~= nargin DAStudio.warning('improper function use') end @@ -18,15 +20,15 @@ switch Action, switch Mode, case 'Simulink' - LocalOpenBlockFcn(blockHandleTTTopMask,1); + LocalOpenBlockFcn(blockHandleTTTopMask,1); case 'Matlab' - LocalOpenBlockFcn([],0); + LocalOpenBlockFcn([],0); end case 'Close', blockHandleTTTopMask = orig_gcbh; LocalCloseBlockFcn(blockHandleTTTopMask); - + case 'Copy', blockHandleTTTopMask = orig_gcbh; LocalCopyBlockFcn(blockHandleTTTopMask); @@ -36,7 +38,7 @@ switch Action, DAStudio.warning('improper function use') end file = varargin{2}; - try + try data = importdata(file); gui = GUI([],0); gui.setData(data) @@ -45,107 +47,107 @@ switch Action, msgbox(exception.identifier) end case 'Delete' - blockHandleTTTopMask = orig_gcbh; - data = get_param(blockHandleTTTopMask,'UserData'); - if isempty(data) - return - end + blockHandleTTTopMask = orig_gcbh; + data = get_param(blockHandleTTTopMask,'UserData'); + if isempty(data) + return + end if ~data.valid - errordlg(... - DAStudio.message('Block Data has been corputed'),... - 'Error', 'modal') + errordlg(... + DAStudio.message('Block Data has been corputed'),... + 'Error', 'modal') return end - + if data.open && ishandle(data.fig) delete(data.fig) data.fig = []; data.open = 0; - set_param(blockHandleTTTopMask,'UserData',data); - + set_param(blockHandleTTTopMask,'UserData',data); + end - otherwise, + otherwise, DAStudio.error('Simulink:dialog:UnknownAction',Action); - - + + end - + end function LocalCopyBlockFcn(blockHandleTTTopMask) - data = get(blockHandleTTTopMask,'UserData'); - if(~isempty(data)) - data_new = data.clone(blockHandleTTTopMask); - - set_param(blockHandleTTTopMask,'UserData',data_new) - end +data = get(blockHandleTTTopMask,'UserData'); +if(~isempty(data)) + data_new = data.clone(blockHandleTTTopMask); + + set_param(blockHandleTTTopMask,'UserData',data_new) +end end function LocalOpenBlockFcn(blockHandleTTTopMask,mode) - data = []; - if (mode == 1) - modelHandle = bdroot(blockHandleTTTopMask); - - - % check if the user is trying to open the block from the library - if strcmp(get_param(modelHandle,'Lock'), 'on') || ... - strcmp(get_param(blockHandleTTTopMask,'LinkStatus'),'implicit') - - errordlg(... - DAStudio.message('can not open Model Locked, Add to new model to use'),... - 'Error', 'modal') - return - end - - - - data = get_param(blockHandleTTTopMask,'UserData'); - end +data = []; +if (mode == 1) + modelHandle = bdroot(blockHandleTTTopMask); - if isempty(data) - data = Data(); - data.init(); - - else - if ~data.valid - errordlg(... - DAStudio.message('Block Data has been corputed'),... - 'Error', 'modal') - return - end - if data.open - if ishghandle(data.fig) - figure(data.fig) - - end - return - end + + % check if the user is trying to open the block from the library + if strcmp(get_param(modelHandle,'Lock'), 'on') || ... + strcmp(get_param(blockHandleTTTopMask,'LinkStatus'),'implicit') + errordlg(... + DAStudio.message('can not open Model Locked, Add to new model to use'),... + 'Error', 'modal') + return end - if mode == 1 - gui = GUI(blockHandleTTTopMask,1); - elseif mode == 0 - gui = GUI([],0); - end + + + + data = get_param(blockHandleTTTopMask,'UserData'); +end - gui.setData(data) - gui.init(); - if(mode == 1) - set_param(blockHandleTTTopMask,'UserData',data); - set_param(blockHandleTTTopMask, 'UserDataPersistent', 'on'); +if isempty(data) + data = Data(); + data.init(); + +else + if ~data.valid + errordlg(... + DAStudio.message('Block Data has been corputed'),... + 'Error', 'modal') + return + end + if data.open + if ishghandle(data.fig) + figure(data.fig) + end + return + end +end +if mode == 1 + gui = GUI(blockHandleTTTopMask,1); +elseif mode == 0 + gui = GUI([],0); +end + +gui.setData(data) +gui.init(); +if(mode == 1) + set_param(blockHandleTTTopMask,'UserData',data); + set_param(blockHandleTTTopMask, 'UserDataPersistent', 'on'); +end + end function LocalCloseRequestBlockFcn(blockHandleTTTopMask) - modelHandle = bdroot(blockHandleTTTopMask); +modelHandle = bdroot(blockHandleTTTopMask); - data = get_param(blockHandleTTTopMask,'UserData'); +data = get_param(blockHandleTTTopMask,'UserData'); @@ -154,7 +156,7 @@ if ~isempty(data) delete(data.fig) end end - %set_param(gui.fig,'Visible','off') +%set_param(gui.fig,'Visible','off') end diff --git a/TableToolMatlab.m b/TableToolMatlab.m index 3b305588409f515e437edc22cea571ef54def43a..1bbda4a194ceaf4e6a506186ed512bc8153457cd 100644 --- a/TableToolMatlab.m +++ b/TableToolMatlab.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [ output_args ] = TableToolMatlab( input_args ) %TABLETOOLMATLAB Summary of this function goes here % Detailed explanation goes here diff --git a/check_system.m b/check_system.m index 87636c9835e8cd93d78400730f43a4172ceb6de8..774b2835c12cadcee5cfc2c73099dba2f575ff6b 100644 --- a/check_system.m +++ b/check_system.m @@ -1,3 +1,5 @@ +% Author: Colin Eles elesc@mcmaster.ca +% Organization: McMaster Centre for Software Certification function [ output_args ] = check_system(system) %UNTITLED Summary of this function goes here % Detailed explanation goes here @@ -12,12 +14,12 @@ for i = 1:size(blocks,1) if (check == 1) msg = [msg char(blocks(i)) ' is valid' sprintf('\n')] - else + else msg = [msg char(blocks(i)) ' is not valid' sprintf('\n')] end block_data.checked = check; TableBlock.set_block_display(char(blocks(i)),block_data.checked) - + end end end diff --git a/html/TT_help.m b/html/TT_help.m index 2bc6354c78cc34c29aae8a338921feb5296a6892..51ef8dd37ca3a05ce2035da3166fab46baf0292b 100644 --- a/html/TT_help.m +++ b/html/TT_help.m @@ -3,6 +3,5 @@ % *Available Documentation* % % * -% * % % Copyright 2010 Colin Eles diff --git a/html/TT_ug.m b/html/TT_ug.m index 4ac2e045dd4a6f05b6768d296bc0e7b636225965..c9920f21809cc01ec33ea5ae1d7396f5b6536c36 100644 --- a/html/TT_ug.m +++ b/html/TT_ug.m @@ -1,4 +1,6 @@ %% User Guide % % * -% * \ No newline at end of file +% * +% +% Copyright 2010 Colin Eles \ No newline at end of file diff --git a/html/html/TT_help.html b/html/html/TT_help.html index 29ae52d738f7c647f8af9707e8966910fa11071e..14144969e5922fa47e6dbe1d68f78e0247767daa 100644 --- a/html/html/TT_help.html +++ b/html/html/TT_help.html @@ -6,7 +6,7 @@ Table Toolbox

Table Toolbox

Available Documentation

Copyright 2010 Colin Eles

Table Toolbox

Available Documentation

\ No newline at end of file