Skip to content
%% setvalues
% 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
function top_grid_added_cell( object, src, event )
%LEFT_GRID_ADDED_CELL Handler for when a new left condition is added.
object.outputs_grid.add_column(event.changed_cell);
end
%% 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
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
function code = generate_eml_code(object) function code = generate_eml_code(object)
code = []; code = [];
code = [code object.generate_preamble]; code = [code object.generate_preamble];
code = [code object.generate_eml_cond(object.data.Grid1,object.data.Grid2,0)]; code = [code object.generate_eml_cond(object.data.top_cond,object.data.left_cond,0)];
end end
......
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
% code:string - string of eml code % code:string - string of eml code
% Author: Colin Eles elesc@mcmaster.ca % Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification % Organization: McMaster Centre for Software Certification
function code = generate_eml_cond(object,g1,g2,depth) function code = generate_eml_cond(object,g1,g2,depth,g2p)
if nargin == 4
g2p = [];
end
...@@ -21,8 +23,8 @@ space = ''; ...@@ -21,8 +23,8 @@ space = '';
for i=1:depth for i=1:depth
space = [space sprintf(' ')]; space = [space sprintf(' ')];
end end
g1cond1 = g1.cells(1).cond_text; g1cond1 = g1.get_cell(1).get_matlab_string;
g2cond1 = g2.cells(1).cond_text; g2cond1 = g2.get_cell(1).get_matlab_string;
code = []; code = [];
%1D horizontal %1D horizontal
if(~isempty(g1cond1) && isempty(g2cond1)) if(~isempty(g1cond1) && isempty(g2cond1))
...@@ -35,8 +37,8 @@ if(~isempty(g1cond1) && isempty(g2cond1)) ...@@ -35,8 +37,8 @@ if(~isempty(g1cond1) && isempty(g2cond1))
else else
elsecell = []; elsecell = [];
for i=1:size(g2.cells,2) for i=1:g2.get_children_count(g2p)
g2cond = g2.cells(i).cond_text; g2cond = g2.get_child_cell(g2p, i).get_matlab_string;
% condition string of otherwise corresponds to an else % condition string of otherwise corresponds to an else
% statement, we allow this statement to be in any order % statement, we allow this statement to be in any order
% in the cells of the grid, so we need to find where it % in the cells of the grid, so we need to find where it
...@@ -47,17 +49,17 @@ else ...@@ -47,17 +49,17 @@ else
continue continue
end end
if (i == 1) if (i == 1)
code = [code sprintf('%sif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))]; code = [code sprintf('%sif(%s)\n',space,(strtrim(g2cond)))];
else else
code = [code sprintf('%selseif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))]; code = [code sprintf('%selseif(%s)\n',space,(strtrim(g2cond)))];
end end
if(~isempty(g2.cells(i).subgrid)) if g2.get_children_count(g2.get_child_cell(g2p, i)) ~= 0
code = [code object.generate_eml_cond(g1,g2.cells(i).subgrid,depth+1)]; code = [code object.generate_eml_cond(g1,g2.cells(i).subgrid,depth+1)];
else else
if (~isempty(g1cond1)) if (~isempty(g1cond1))
if object.data.multi_mode == 0 if object.data.multi_mode == 0
code = [code object.generate_eml_horizontal(g1,g2.cells(i),depth+1)]; code = [code object.generate_eml_horizontal(g1,i,depth+1)];
else else
code = [code object.generate_eml_multi(g1,g2.cells(i),depth+1)]; code = [code object.generate_eml_multi(g1,g2.cells(i),depth+1)];
end end
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
% code:string - string of eml code % code:string - string of eml code
% Author: Colin Eles elesc@mcmaster.ca % Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification % Organization: McMaster Centre for Software Certification
function code = generate_eml_horizontal(object,g1,g2_cell,depth) function code = generate_eml_horizontal(object,g1,g2_cell_index,depth)
space = ''; space = '';
for i=1:depth for i=1:depth
space = [space sprintf(' ')]; space = [space sprintf(' ')];
...@@ -20,8 +20,8 @@ end ...@@ -20,8 +20,8 @@ end
code = []; code = [];
elsecell = []; elsecell = [];
for i=1:size(g1.cells,2) for i=1:g1.length
g1cond = g1.cells(i).cond_text; g1cond = g1.get_cell(i).get_matlab_string;
% condition string of otherwise corresponds to an else % condition string of otherwise corresponds to an else
% statement, we allow this statement to be in any order % statement, we allow this statement to be in any order
% in the cells of the grid, so we need to find where it % in the cells of the grid, so we need to find where it
...@@ -32,13 +32,13 @@ for i=1:size(g1.cells,2) ...@@ -32,13 +32,13 @@ for i=1:size(g1.cells,2)
continue continue
end end
if (i == 1) if (i == 1)
code = [code sprintf('%sif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))]; code = [code sprintf('%sif(%s)\n',space,strtrim(char(g1cond)))];
else else
code = [code sprintf('%selseif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))]; code = [code sprintf('%selseif(%s)\n',space,strtrim(char(g1cond)))];
end end
resultcell = object.data.Grid0.search_return(g1.cells(i),g2_cell); resultcell = object.data.outputs_grid.get_cell(g2_cell_index, i);
if(~isempty(resultcell)) if(~isempty(resultcell))
code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))]; code = [code sprintf('%soutput = %s;\n',[space ' '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.get_matlab_string))))];
else else
end end
......
...@@ -61,17 +61,17 @@ end ...@@ -61,17 +61,17 @@ end
if (object.data.multi_mode == 1) if (object.data.multi_mode == 1)
for i=1:size(object.data.Grid1.cells,2) for i=1:size(object.data.Grid1.cells,2)
parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.Grid1.cells(i).cond_text))); parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.top_cond.get_cell(i))));
output_str = char(parsed_output{1}(1)); 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)))]; code = [code sprintf('%s=%s;\n',output_str,EMLGenerator.type_convert(output_str,object.datatype,char(object.data.Grid0.search_return(object.data.Grid1.cells(i), left_top_right_top_cell).result_text)))];
end end
else else
test = 'output'; test = 'output';
output_string = EMLGenerator.type_convert(test,object.datatype,char(object.data.Grid0.Cells(1).result_text) ); output_string = EMLGenerator.type_convert(test,object.datatype,char(object.data.outputs_grid.get_cell(1, 1).get_matlab_string) );
code = [code sprintf('output=%s;\n', output_string )]; code = [code sprintf('output=%s;\n', output_string )];
end end
......
...@@ -5,12 +5,24 @@ classdef GUI < handle ...@@ -5,12 +5,24 @@ classdef GUI < handle
properties properties
% vertical grid % vertical grid
Grid2 = []; vertical_grid = [];
% horizontal grid % horizontal grid
Grid1 = []; horizontal_grid = [];
%output grid %output grid
Grid0 = []; outputs_grid = [];
%Let statements grid
let_statments_grid = [];
%grid layouter
grid_layout = [];
%Box layouter
vbox_layout = [];
%And its panel ...
vbox_layout_panel = [];
main_fig = []; main_fig = [];
frame = []; frame = [];
fig = []; fig = [];
...@@ -24,8 +36,6 @@ classdef GUI < handle ...@@ -24,8 +36,6 @@ classdef GUI < handle
input_pb = []; input_pb = [];
settings_pb = []; settings_pb = [];
function_name_control = []; function_name_control = [];
function_name_text = [];
function_inputs_text = [];
function_inputs_control = []; function_inputs_control = [];
edit = 1; edit = 1;
initialized = 0; initialized = 0;
...@@ -48,7 +58,7 @@ classdef GUI < handle ...@@ -48,7 +58,7 @@ classdef GUI < handle
text_width = 250; text_width = 250;
name_label = []; name_label = [];
input_label = []; input_label = [];
Data = []; data = [];
PVS = []; PVS = [];
CVC = []; CVC = [];
pvs_checked = []; pvs_checked = [];
...@@ -79,11 +89,13 @@ classdef GUI < handle ...@@ -79,11 +89,13 @@ classdef GUI < handle
%% GUI %% GUI
% constructor % constructor
% inputs: % inputs:
% d:Data - The data to display.
% h:double - handle to Tabular block in model % h:double - handle to Tabular block in model
% mode:boolean - the mode of the gui, 1 for simuink, 0 for matlab % mode:boolean - the mode of the gui, 1 for simuink, 0 for matlab
% outputs: % outputs:
% object:GUI - object that is created % object:GUI - object that is created
function object = GUI(h,mode) function object = GUI(data, h,mode)
object.data = data;
object.block_handle = h; object.block_handle = h;
object.mode = mode; object.mode = mode;
end end
......
...@@ -16,11 +16,12 @@ error = 0; ...@@ -16,11 +16,12 @@ error = 0;
msg = object.check_inputs; msg = object.check_inputs;
if (isempty(msg)) if (isempty(msg))
set(object.function_inputs_control,'BackgroundColor',[1 1 1]); set(object.function_inputs_control,'BackgroundColor',[1 1 1]);
msg = object.check_grid_condition(object.Grid2); msg = object.check_grid_condition(object.data.left_cond); %TODO: Rename this function
if object.multi_mode == 0
msg = [msg object.check_grid_condition(object.Grid1)]; if object.multi_mode == 0 && ~(object.data.top_cond.length == 1 && object.data.top_cond.max_width == 1 && (strcmp(object.data.top_cond.get_cell(1).get_user_string, '') || isempty(object.data.top_cond.get_cell(1).get_user_string)))
msg = [msg object.check_grid_condition(object.data.top_cond)];
end end
msg = [msg object.check_grid_result(object.Grid0)]; msg = [msg object.check_grid_result(object.data.outputs_grid)];
else else
set(object.function_inputs_control,'BackgroundColor',[0.92 0.65 0.65]); set(object.function_inputs_control,'BackgroundColor',[0.92 0.65 0.65]);
end end
......
...@@ -10,22 +10,19 @@ ...@@ -10,22 +10,19 @@
% none % none
% Author: Colin Eles elesc@mcmaster.ca % Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification % 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');
s = [string(1,:)]; %TODO: Merge this back into the grid itself
for j = 2:size(string,1) function msg = check_grid_condition(object,grid_container,grid)
s = [s ' ' string(j,:)]; if nargin == 2
msg = check_grid_condition(object, grid_container, grid_container.grid);
return ;
end end
string = s;
if ( strcmp(string,'') || isempty(string)) && i == 1 && isempty(grid.parent_grid) && size(grid.cells,2) == 1 msg = [];
break; for i = 1:size(grid,2)
end
error = '';
string = grid{i}.get_matlab_string();
% if the string is empty indicating that the table is 1 % if the string is empty indicating that the table is 1
% dimensional or the string is "otherwise" skip the syntax % dimensional or the string is "otherwise" skip the syntax
...@@ -46,20 +43,22 @@ for i = 1:size(grid.cells,2) ...@@ -46,20 +43,22 @@ for i = 1:size(grid.cells,2)
msg = [msg error sprintf('\n')]; msg = [msg error sprintf('\n')];
% set tooltip string of cell to error msg % set tooltip string of cell to error msg
set(grid.cells(i).cond,'TooltipString',error); % TODO Renenable
% set(grid.cells(i).cond,'TooltipString',error);
% change background colour % change background colour
grid.cells(i).flag_cell(1); % TODO Renenable
% grid.cells(i).flag_cell(1);
else else
% reset tooltip and colour if no error found % reset tooltip and colour if no error found
set(grid.cells(i).cond,'TooltipString','') % TODO Renenable
grid.cells(i).flag_cell(0); % set(grid.cells(i).cond,'TooltipString','')
% TODO Renenable
% grid.cells(i).flag_cell(0);
end end
% recurse through subgrid % recurse through subgrid
if(~isempty(grid.cells(i).subgrid)) msg = [msg object.check_grid_condition(grid_container, grid{i}.grid)];
msg = [msg object.check_grid_condition(grid.cells(i).subgrid)];
end
end end
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
% Organization: McMaster Centre for Software Certification % Organization: McMaster Centre for Software Certification
function msg = check_grid_result(object,grid) function msg = check_grid_result(object,grid)
msg = []; msg = [];
for i = 1:size(grid.Cells,2) for i = 1:grid.width
error = ''; for j = 1:grid.height
string = get(grid.Cells(i).result,'String'); string = grid.get_cell(j, i).get_matlab_string();
error = object.check_matlab_syntax_condition(char(string),1); error = object.check_matlab_syntax_condition(char(string),1);
...@@ -28,14 +28,14 @@ for i = 1:size(grid.Cells,2) ...@@ -28,14 +28,14 @@ for i = 1:size(grid.Cells,2)
msg = [msg 'Result -> ' char(string) sprintf('\n')]; msg = [msg 'Result -> ' char(string) sprintf('\n')];
msg = [msg error sprintf('\n')]; msg = [msg error sprintf('\n')];
% TODO Re-enable!
set(grid.Cells(i).result,'TooltipString',error); %set(grid.Cells(i).result,'TooltipString',error);
grid.Cells(i).flag_cell(1); %grid.Cells(i).flag_cell(1);
else else
set(grid.Cells(i).result,'TooltipString',''); %set(grid.Cells(i).result,'TooltipString','');
grid.Cells(i).flag_cell(0); %grid.Cells(i).flag_cell(0);
end
end end
end end
end end
...@@ -15,8 +15,8 @@ if (object.validation_report_handle ~= 0) ...@@ -15,8 +15,8 @@ if (object.validation_report_handle ~= 0)
object.validation_report_handle = 0; object.validation_report_handle = 0;
end end
object.save_data; object.save_data;
object.Data.open = 0; object.data.open = 0;
object.Data.fig = []; object.data.fig = [];
delete(object.fig); delete(object.fig);
% remove reference to the old figure. % remove reference to the old figure.
object.fig = []; object.fig = [];
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
% Organization: McMaster Centre for Software Certification % Organization: McMaster Centre for Software Certification
function [] = evaluate_counter(object,counter) function [] = evaluate_counter(object,counter)
problem = object.evaluate_counter_grid(object.Grid2, counter); problem = object.evaluate_counter_grid(object.data.left_cond, counter);
if(~problem && object.multi_mode == 0) if(~problem && object.multi_mode == 0)
object.evaluate_counter_grid(object.Grid1, counter); object.evaluate_counter_grid(object.data.top_cond, counter);
end end
end end
...@@ -132,11 +132,11 @@ object.function_inputs_control = uicontrol('style','edit',... ...@@ -132,11 +132,11 @@ object.function_inputs_control = uicontrol('style','edit',...
% load the function name and inputs % load the function name and inputs
if (~isempty(object.function_name_text)) if (~isempty(object.data.function_name))
set(object.function_name_control,'String',object.function_name_text); set(object.function_name_control,'String',object.data.function_name);
end end
if (~isempty(object.function_inputs_text)) if (~isempty(object.data.function_inputs))
set(object.function_inputs_control,'String',object.function_inputs_text); set(object.function_inputs_control,'String',object.data.function_inputs);
end end
...@@ -176,21 +176,16 @@ uimenu(checkmenu,'Label','PVS Typecheck SimTypes','Callback',@(src,event)pvs_ext ...@@ -176,21 +176,16 @@ uimenu(checkmenu,'Label','PVS Typecheck SimTypes','Callback',@(src,event)pvs_ext
uimenu(helpmenu,'Label','Product Help','Callback',@(src,event)help_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)); 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.saved = 1;
object.setPBenable;
object.default_prover = object.CVC_const; object.default_prover = object.CVC_const;
object.settings = TTSettings(); object.settings = TTSettings();
if isfield(object.Data.settings,'set') if isfield(object.data.settings, 'set')
object.settings.setvalues(object.Data.settings); object.settings.setvalues(object.data.settings);
else else
object.settings.init(); object.settings.init();
end end
object.undo_man = UndoManager(); object.undo_man = UndoManager();
...@@ -202,16 +197,44 @@ object.update_multi_check_status; ...@@ -202,16 +197,44 @@ object.update_multi_check_status;
object.update_prover_check_status; object.update_prover_check_status;
object.update_undoredo; object.update_undoredo;
object.PVS = PVS_checker(object.Data); object.PVS = PVS_checker(object.data);
object.EMLGen = EMLGenerator(object.Data); object.EMLGen = EMLGenerator(object.data);
object.CVC = CVC_checker(object.data);
object.vertical_grid = VerticalHierarchicalGridDraw(object.data.left_cond);
object.horizontal_grid = HorizontalLineGridDraw(object.data.top_cond);
object.outputs_grid = TableGridDraw(object.data.outputs_grid);
object.let_statments_grid = LetStatmentsDraw(object.data.let_statements);
object.grid_layout = GridLayout();
object.grid_layout.insert_drawable(object.vertical_grid, 1, 2);
object.grid_layout.insert_drawable(object.horizontal_grid, 2, 1);
object.grid_layout.insert_drawable(object.outputs_grid, 2, 2);
object.CVC = CVC_checker(object.Data);
object.vbox_layout = VLayout();
object.vbox_layout.add_child(object.grid_layout);
object.vbox_layout.add_child(object.let_statments_grid);
object.vbox_layout_panel = uipanel(object.fig);
object.vbox_layout.draw(object.vbox_layout_panel);
object.vbox_layout.addlistener('BoundingBoxChanged', @(src, event)set_command_pos(object) );
object.set_command_pos;
object.pvs_checked = object.data.checked;
object.multi_mode = object.data.multi_mode;
if isempty(object.multi_mode)
object.multi_mode = 0;
end
object.initialized = 1; object.initialized = 1;
object.Data.open = 1; object.data.open = 1;
object.Data.fig = object.fig; object.data.fig = object.fig;
......
%% 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
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
% Organization: McMaster Centre for Software Certification % Organization: McMaster Centre for Software Certification
function [] = resize_fig(object,src,event) function [] = resize_fig(object,src,event)
if(object.initialized == 1) if(object.initialized == 1)
object.draw_allgrids(0); object.vbox_layout.redraw;
object.set_command_pos; object.set_command_pos;
end end
end end
......
...@@ -35,7 +35,7 @@ if object.mode == 0 ...@@ -35,7 +35,7 @@ if object.mode == 0
open_system(model); open_system(model);
load_system('TableLibrary'); load_system('TableLibrary');
new_block = add_block('TableLibrary/Tabular Expression',[model '/' function_name]); new_block = add_block('TableLibrary/Tabular Expression',[model '/' function_name]);
set_param(new_block,'UserData',object.Data); set_param(new_block,'UserData',object.data);
set_param(new_block, 'UserDataPersistent', 'on'); set_param(new_block, 'UserDataPersistent', 'on');
object.mode = 1; object.mode = 1;
object.block_handle = new_block; object.block_handle = new_block;
......
...@@ -8,23 +8,17 @@ ...@@ -8,23 +8,17 @@
% Author: Colin Eles elesc@mcmaster.ca % Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification % Organization: McMaster Centre for Software Certification
function [] = save_data(object) 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 % new storage
object.Data.function_name = get(object.function_name_control,'String'); object.data.function_name = get(object.function_name_control,'String');
object.Data.function_inputs = get(object.function_inputs_control,'String'); object.data.function_inputs = get(object.function_inputs_control,'String');
object.Data.checked = object.pvs_checked; object.data.checked = object.pvs_checked;
object.Data.multi_mode = object.multi_mode; object.data.multi_mode = object.multi_mode;
set.set = 1; set.set = 1;
set.inputs = object.settings.pvs_includes; set.inputs = object.settings.pvs_includes;
set.count = object.settings.counter_trials; set.count = object.settings.counter_trials;
set.range = object.settings.counter_range; set.range = object.settings.counter_range;
set.except = object.settings.except; set.except = object.settings.except;
object.Data.settings = set; object.data.settings = set;
end end
%% 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
% 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
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
% Author: Colin Eles elesc@mcmaster.ca % Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification % Organization: McMaster Centre for Software Certification
function [] = setPBenable(object) function [] = setPBenable(object)
assert(false, 'Old dead code needing move, do not call!');
%% TODO Move this code into the appropriate draw code.
if size(object.Grid1.cells,2) > 1 if size(object.Grid1.cells,2) > 1
set(object.Grid1.delete_cell_pb,'Enable','on'); set(object.Grid1.delete_cell_pb,'Enable','on');
else else
......