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
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ classdef EMLGenerator < handle
    properties
        data = [];
        datatype = [];
        multi_output = 1;
    end
    
    methods(Static)
+15 −2
Original line number Diff line number Diff line
@@ -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,7 +54,12 @@
                    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));
+33 −2
Original line number Diff line number Diff line
@@ -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,8 +45,22 @@
                % table, we will use the first cell because it is
                % guaranteed to
                % be filled in, regardless of the dimensionality of the table.
                
                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
        
       
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -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 = [];
+4 −2
Original line number Diff line number Diff line
@@ -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);
                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])
Loading