Skip to content
Snippets Groups Projects
Commit a8cb82c2 authored by Colin Eles's avatar Colin Eles
Browse files

support for multiple outputs in simulink, toggle currently hardcoded need some...

support for multiple outputs in simulink, toggle currently hardcoded need some sort of gui element for this, does not work with pvs yet

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@6064 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 004091be
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ classdef EMLGenerator < handle
properties
data = [];
datatype = [];
multi_output = 1;
end
methods(Static)
......
......@@ -11,6 +11,10 @@
% outputs:
% code:string - string of eml code
function code = generate_eml_cond(object,g1,g2,depth)
multi_output = 0;
space = '';
for i=1:depth
space = [space sprintf(' ')];
......@@ -20,7 +24,11 @@
code = [];
%1D horizontal
if(~isempty(g1cond1) && isempty(g2cond1))
if object.multi_output == 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
......@@ -46,9 +54,14 @@
code = [code object.generate_eml_cond(g1,g2.cells(i).subgrid,depth+1)];
else
if (~isempty(g1cond1))
code = [code object.generate_eml_horizontal(g1,g2.cells(i),depth+1)];
if object.multi_output == 0
code = [code object.generate_eml_horizontal(g1,g2.cells(1),depth+1)];
else
code = [code object.generate_eml_multi(g1,g2.cells(1),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(object.datatype,strtrim(char(resultcell.result_text))))];
......
......@@ -7,6 +7,7 @@
% 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
......@@ -18,7 +19,23 @@
input = [input ',']
end
end
code = sprintf('function output = %s(%s)\n%s\n',char(function_name{1}(1)),input,'%%#eml');
output = [];
if (object.multi_output == 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
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
......@@ -28,7 +45,21 @@
% table, we will use the first cell because it is
% guaranteed to
% be filled in, regardless of the dimensionality of the table.
code = [code sprintf('output=%s;\n',EMLGenerator.type_convert(object.datatype,char(object.data.Grid0.Cells(1).result_text)))];
if (object.multi_output == 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_str = char(parsed_output{1}(1));
code = [code sprintf('%s=%s;\n',output_str,char(object.data.Grid0.Cells(i).result_text))];
end
else
code = [code sprintf('output=%s;\n',EMLGenerator.type_convert(object.datatype,char(object.data.Grid0.Cells(1).result_text)))];
end
end
......@@ -30,7 +30,7 @@ classdef GUI < handle
block_handle = [];
settings = [];
% height of header where buttons and text is
header_height = 100;
header_height = 120;
% window size
fig_height = 600;
fig_width = 800;
......@@ -40,6 +40,8 @@ classdef GUI < handle
pb_width = 80;
% height of push buttons in header
pb_height = 40;
% height of header text boxes
htx_height = 60;
% width of text boxes
text_width = 250;
name_label = [];
......
......@@ -10,12 +10,14 @@
% 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);
msg = [msg object.check_grid_condition(object.Grid1)];
if 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])
......
......@@ -11,6 +11,7 @@
% outputs:
% none
function eml_handle = save_call(object,src,event)
multi_type = 1;
if(object.check_call([],[]) == 1)
return;
end
......@@ -44,7 +45,9 @@
load_system('simulink')
% generate the code
if multi_type == 0
object.EMLGen.set_datatype(object.output_data_type);
end
code = object.EMLGen.generate_eml_code;
%code = [code object.generate_code(object.Grid1,object.Grid2,0)];
......
......@@ -19,10 +19,10 @@
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.name_label,'Position',[object.pb_offset l_fig_height-object.pb_offset*3-object.pb_height-object.pb_height object.pb_width object.pb_height]);
set(object.function_name_control,'Position',[object.pb_offset*2+object.pb_width l_fig_height-object.pb_offset*3-object.pb_height-object.pb_height object.text_width object.pb_height]);
set(object.input_label,'Position',[object.pb_offset*2+object.pb_width+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.pb_height object.pb_width object.pb_height]);
set(object.function_inputs_control,'Position',[object.pb_offset*3+object.pb_width*2+object.text_width l_fig_height-object.pb_offset*3-object.pb_height-object.pb_height object.text_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]);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment