From bda1be750d470934696f45325045094078f4c113 Mon Sep 17 00:00:00 2001 From: Colin Eles Date: Tue, 17 Aug 2010 20:56:47 +0000 Subject: [PATCH] latest update git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@6114 57e6efec-57d4-0310-aeb1-a6c144bb1a8b --- @Data/Data.m | 1 + @Data/clone.m | 2 +- @Data/getData.m | 3 ++- @Data/init.m | 1 + @Data/setData.m | 3 ++- @EMLGenerator/generate_eml_cond.m | 10 ++++----- @EMLGenerator/generate_preamble.m | 4 ++-- @GUI/GUI.m | 8 ++++++- @GUI/check_call.m | 4 ++-- @GUI/draw_grid1.m | 9 ++++++++ @GUI/draw_grid2.m | 10 +++++++++ @GUI/init.m | 30 ++++++++++++++++++++++++- @GUI/input_data_type.m | 37 +++++++++++++++++++++++++++++++ @GUI/pvs_ext_call.m | 2 +- @GUI/save_data.m | 1 + @GUI/setData.m | 4 ++++ @GUI/set_command_pos.m | 1 + @GUI/update_multi_check_status.m | 13 +++++++++++ @PVS_checker/generate_pvs.m | 4 ++-- @PVS_checker/generate_pvs_file.m | 2 +- 20 files changed, 131 insertions(+), 18 deletions(-) create mode 100644 @GUI/input_data_type.m create mode 100644 @GUI/update_multi_check_status.m diff --git a/@Data/Data.m b/@Data/Data.m index b5ea145..8e9991f 100644 --- a/@Data/Data.m +++ b/@Data/Data.m @@ -12,6 +12,7 @@ classdef Data < handle checked = []; open = []; fig = []; + multi_mode = []; end diff --git a/@Data/clone.m b/@Data/clone.m index 3cfe6cc..0c647c9 100644 --- a/@Data/clone.m +++ b/@Data/clone.m @@ -22,7 +22,7 @@ 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,[]); diff --git a/@Data/getData.m b/@Data/getData.m index c557f29..6eefdbb 100644 --- a/@Data/getData.m +++ b/@Data/getData.m @@ -9,13 +9,14 @@ % name:string - Function name % inputs:string - input string % checked:boolean - typecheck status - function [grid0, grid1, grid2, name, inputs, checked] = getData(object) + 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 diff --git a/@Data/init.m b/@Data/init.m index 076b27c..2c20b6c 100644 --- a/@Data/init.m +++ b/@Data/init.m @@ -13,6 +13,7 @@ object.Grid2.new_Cell; object.Grid1.new_Cell; object.checked = 0; + object.multi_mode = 0; end \ No newline at end of file diff --git a/@Data/setData.m b/@Data/setData.m index 1136b4f..23628a9 100644 --- a/@Data/setData.m +++ b/@Data/setData.m @@ -10,13 +10,14 @@ % checked:boolean - typecheck status % outputs: % none - function [] = setData(object, grid0, grid1, grid2, name, inputs, checked) + 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 diff --git a/@EMLGenerator/generate_eml_cond.m b/@EMLGenerator/generate_eml_cond.m index 5de8bdf..15936e9 100644 --- a/@EMLGenerator/generate_eml_cond.m +++ b/@EMLGenerator/generate_eml_cond.m @@ -13,7 +13,7 @@ function code = generate_eml_cond(object,g1,g2,depth) - multi_output = 0; + space = ''; for i=1:depth @@ -24,7 +24,7 @@ code = []; %1D horizontal if(~isempty(g1cond1) && isempty(g2cond1)) - if object.multi_output == 0 + 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)]; @@ -54,10 +54,10 @@ code = [code object.generate_eml_cond(g1,g2.cells(i).subgrid,depth+1)]; else if (~isempty(g1cond1)) - if object.multi_output == 0 - code = [code object.generate_eml_horizontal(g1,g2.cells(1),depth+1)]; + 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(1),depth+1)]; + 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 diff --git a/@EMLGenerator/generate_preamble.m b/@EMLGenerator/generate_preamble.m index e5c1dea..4c5a012 100644 --- a/@EMLGenerator/generate_preamble.m +++ b/@EMLGenerator/generate_preamble.m @@ -21,7 +21,7 @@ end output = []; - if (object.multi_output == 1) + 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))); @@ -46,7 +46,7 @@ % guaranteed to % be filled in, regardless of the dimensionality of the table. - if (object.multi_output == 1) + 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))); diff --git a/@GUI/GUI.m b/@GUI/GUI.m index f98b091..5c95fe5 100644 --- a/@GUI/GUI.m +++ b/@GUI/GUI.m @@ -55,7 +55,13 @@ classdef GUI < handle saved = []; validation_report_handle = []; multi_type = 1; - + multi_mode = []; + multi_grp = []; + multi_opt_reg = []; + multi_opt_out = []; + + + end methods diff --git a/@GUI/check_call.m b/@GUI/check_call.m index e448b06..ab6cbbb 100644 --- a/@GUI/check_call.m +++ b/@GUI/check_call.m @@ -10,12 +10,12 @@ % none function error = check_call(object,src,event) error = 0; - multi_mode = 1; + msg = object.check_inputs; if (isempty(msg)) set(object.function_inputs_control,'BackgroundColor',[1 1 1]) msg = object.check_grid_condition(object.Grid2); - if multi_mode == 0 + if object.multi_mode == 0 msg = [msg object.check_grid_condition(object.Grid1)]; end msg = [msg object.check_grid_result(object.Grid0)]; diff --git a/@GUI/draw_grid1.m b/@GUI/draw_grid1.m index 7a30e81..51c01dd 100644 --- a/@GUI/draw_grid1.m +++ b/@GUI/draw_grid1.m @@ -40,6 +40,15 @@ 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 diff --git a/@GUI/draw_grid2.m b/@GUI/draw_grid2.m index 9ee3d78..0750f2c 100644 --- a/@GUI/draw_grid2.m +++ b/@GUI/draw_grid2.m @@ -146,6 +146,16 @@ % 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 diff --git a/@GUI/init.m b/@GUI/init.m index ae55c54..896fa0e 100644 --- a/@GUI/init.m +++ b/@GUI/init.m @@ -121,6 +121,29 @@ 'FontSize',12,... '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); @@ -143,12 +166,15 @@ uimenu(editmenu,'Label','Show edit controls','Checked','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)); - + object.set_command_pos; object.reset_wh(); @@ -167,6 +193,8 @@ object.update_Statusbar; + object.update_multi_check_status; + object.PVS = PVS_checker(object.Data); object.EMLGen = EMLGenerator(object.Data); diff --git a/@GUI/input_data_type.m b/@GUI/input_data_type.m new file mode 100644 index 0000000..03b2482 --- /dev/null +++ b/@GUI/input_data_type.m @@ -0,0 +1,37 @@ + %% input_data_type + % this function will determine what the desired output type of + % the function is, based on what the user has selected using the + % ports and datamanagement window. if the user has selected an + % unconvertable type, (inheret, fixed pt. etc.) it will return + % the empty string + % inputs: + % object:GUI - GUI objecto + % outputs: + % type:string - string representation of the output type. + function types = input_data_type(object) + types = []; + if (object.mode == 1) + + S = sfroot; + code_block = sprintf('%s/code',getfullname(object.block_handle)); + code_blocks = find_system(getfullname(object.block_handle),'LookUnderMasks','all','BlockType','SubSystem','Name','code'); + if ~isempty(code_blocks) + myState = S.find('-isa','Stateflow.EMChart', '-and', 'Path', code_block); % find which one we want to edit + for (i=1:size(myState.Inputs,1)) + if strncmp(myState.Inputs(i).DataType,'Inherit',7); + typename = 'Inherit'; + elseif strncmp(myState.Inputs(i).DataType,'boolean',7); + typename = 'logical'; + else + typename = myState.Inputs(i).DataType; + end + types = [types;{myState.Inputs(i).Name, typename}] + end + else + types = []; + end + else + types = []; + end + end + \ No newline at end of file diff --git a/@GUI/pvs_ext_call.m b/@GUI/pvs_ext_call.m index c865468..ae1c8dd 100644 --- a/@GUI/pvs_ext_call.m +++ b/@GUI/pvs_ext_call.m @@ -14,7 +14,7 @@ end error = object.check_call; - if(object.multi_type == 0) + if(object.multi_mode == 0) object.PVS.output_type = object.output_data_type; object.PVS.input_type = object.input_data_type; diff --git a/@GUI/save_data.m b/@GUI/save_data.m index 4bf3045..c1a99cb 100644 --- a/@GUI/save_data.m +++ b/@GUI/save_data.m @@ -16,6 +16,7 @@ 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 = []; diff --git a/@GUI/setData.m b/@GUI/setData.m index ab3be06..44b3214 100644 --- a/@GUI/setData.m +++ b/@GUI/setData.m @@ -14,6 +14,10 @@ object.function_name_text = Data.function_name; object.function_inputs_text = Data.function_inputs; object.settings = Data.settings; + object.multi_mode = Data.multi_mode; + if isempty(object.multi_mode) + object.multi_mode = 0; + end end \ No newline at end of file diff --git a/@GUI/set_command_pos.m b/@GUI/set_command_pos.m index f4fb90b..bcbdf18 100644 --- a/@GUI/set_command_pos.m +++ b/@GUI/set_command_pos.m @@ -23,6 +23,7 @@ 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/update_multi_check_status.m b/@GUI/update_multi_check_status.m new file mode 100644 index 0000000..c566299 --- /dev/null +++ b/@GUI/update_multi_check_status.m @@ -0,0 +1,13 @@ +function update_multi_check_status( object ) + + +if object.multi_mode == 0 + set(object.multi_opt_reg,'Checked','on'); + set(object.multi_opt_out,'Checked','off'); +else + set(object.multi_opt_reg,'Checked','off'); + set(object.multi_opt_out,'Checked','on'); +end + +end + diff --git a/@PVS_checker/generate_pvs.m b/@PVS_checker/generate_pvs.m index f104e7d..343eb72 100644 --- a/@PVS_checker/generate_pvs.m +++ b/@PVS_checker/generate_pvs.m @@ -38,7 +38,7 @@ code = [code object.generate_pvs(g1,g2.cells(i).subgrid,depth)]; else if (~isempty(g1cond1)) - if (object.multi_mode == 0) + 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)]; @@ -73,7 +73,7 @@ code = [code object.generate_pvs(g1,elsecell.subgrid,depth) sprintf('\n')]; else if (~isempty(g1cond1)) - if (object.multi_mode == 0) + 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')]; diff --git a/@PVS_checker/generate_pvs_file.m b/@PVS_checker/generate_pvs_file.m index 669bc2c..a6dbf7f 100644 --- a/@PVS_checker/generate_pvs_file.m +++ b/@PVS_checker/generate_pvs_file.m @@ -16,7 +16,7 @@ type_mode = 0; function_names = EMLGenerator.parse_inputs(object.data.function_name); function_name = char(function_names{1}(1)); -if object.multi_mode == 0 +if object.data.multi_mode == 0 if (size(function_names{1},2) == 2) function_name_type = char(function_names{1}(2)); -- GitLab