bug 12731 fix 25/12125/3
Serge STEER [Wed, 24 Jul 2013 13:00:58 +0000 (15:00 +0200)]
Change-Id: If13544b4ed4abb37beb79ac7ccc823a5f383c72a

scilab/CHANGES_5.5.X
scilab/modules/scicos/macros/scicos_scicos/do_compile_superblock42.sci
scilab/modules/xcos/tests/nonreg_tests/bug_12731.tst [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_12731.zcos [new file with mode: 0644]

index 5f5ac97..19fcad0 100644 (file)
@@ -151,6 +151,9 @@ Xcos
 
 * Bug #12667 fixed - 'Recent Files' menu was not localized.
 
+* Bug #12731 fixed - Code generation produces erroneous block
+
+* Bug #12732 fixed - Improper Copyright comments in the files generated by the code generation tool
 
 Toolbox skeleton
 =================
index 0f07df5..cb35d28 100644 (file)
@@ -726,9 +726,6 @@ function ok=gen_ccode42();
         fd = mopen(rpat+"/"+rdnom+"_void_io.c", "wt")
 
         mputl(["/*";
-        "**    Copyright (c) 1989 - 2012 (INRIA)";
-        "**    Copyright (c) 2011 - 2013 (Scilab Enterprises)";
-        "**";
         "**    Generated by Code_Generation toolbox of Xcos with "+getversion();
         "**    Date : "+date();
         "*/"], fd);
@@ -816,9 +813,6 @@ function ok=gen_ccode42();
 
     //** Generate _act_sens_events.c
     Code=["/*"
-    "**    Copyright (c) 1989 - 2012 (INRIA)"
-    "**    Copyright (c) 2011 - 2012 (Scilab Enterprises)"
-    "**"
     "**    Generated by Code_Generation toolbox of Xcos with "+getversion()
     "**    Date :"+date()
     "*/"
@@ -857,8 +851,6 @@ function ok=gen_ccode42();
         if (readGlobal <> [] | writeGlobal <> [])
             fd = mopen(rpat+"/"+rdnom+"_read_write_global.c", "wt")
             mputl(["/*"
-            "**    Copyright (c) 2012 - 2013 (Scilab Enterprises)"
-            "**"
             "**    Generated by Code_Generation toolbox of Xcos with "+getversion()
             "**    Date :"+date()
             "*/"
@@ -1091,95 +1083,73 @@ endfunction
 function ok=gen_gui42();
     clkinput=ones(clkIN)';
     clkoutput=ones(clkOUT)';
-    //outtb=outtb;
-    oz=cpr.state.oz;
-
-    new_oz=list();
-    for i=1:lstsize(oz)
-        new_oz($+1) = oz(i)
-    end
-    for i=1:lstsize(outtb)
-        new_oz($+1) = outtb(i)
-    end
-
-    //outtb($+1) = zeros(nblk,1);
-    Code=["//";
-    "//    Copyright (c) 1989 - 2012 (INRIA)";
-    "//    Copyright (c) 2011 - 2013 (Scilab Enterprises)";
-    "//";
-    "//    Generated by Code_Generation toolbox of Xcos with "+getversion();
-    "//    Date : "+date();
-    "//"
-    "function [x,y,typ]="+rdnom+"_c(job,arg1,arg2)";
-    " x=[];y=[];typ=[];";
-    " select job";
-    " case ''plot'' then";
-    "   standard_draw(arg1)";
-    " case ''getinputs'' then";
-    "   [x,y,typ]=standard_inputs(arg1)";
-    " case ''getoutputs'' then";
-    "   [x,y,typ]=standard_outputs(arg1)";
-    " case ''getorigin'' then";
-    "   [x,y]=standard_origin(arg1)";
-    " case ''set'' then";
-    "   x=arg1;";
-    " case ''define'' then"
-    "   "+sci2exp(capt(:,3),"in",70); //input ports sizes 1
-    "   "+sci2exp(capt(:,4),"in2",70); //input ports sizes 2
-    "   "+sci2exp(scs_c_nb2scs_nb(capt(:,5)),"intyp",70); //input ports type
-    "   "+sci2exp(actt(:,3),"out",70); //output ports sizes 1
-    "   "+sci2exp(actt(:,4),"out2",70); //output ports sizes 2
-    "   "+sci2exp(scs_c_nb2scs_nb(actt(:,5)),"outtyp",70); //output ports type
-    "   "+sci2exp(x,"x",70); //initial continuous state
-    "   "+sci2exp(z,"z",70); //initial discrete state
-    "   work=zeros("+string(nblk)+",1)";
-    "   Z=[z;work]";
-    "   "+sci2exp(new_oz,"odstate",70);
-    "   "+sci2exp(cpr.sim.rpar,"rpar",70); //real parameters
-    "   "+sci2exp(cpr.sim.ipar,"ipar",70); //integer parameters
-    "   "+sci2exp(cpr.sim.opar,"opar",70); //object parameters
-    "   "+sci2exp(clkinput,"clkinput",70);
-    "   "+sci2exp(clkoutput,"clkoutput",70);
-    "   "+sci2exp(FIRING,"firing",70);
-    "   nzcross="+string(sum(cpr.sim.zcptr(2:$)-cpr.sim.zcptr(1:$-1)))';
-    "   nmode="+string(sum(cpr.sim.modptr(2:$)-cpr.sim.modptr(1:$-1)))';]
-
     for i=1:length(bllst)
-        deput=[%t,%f]
-        if (bllst(i).dep_ut(2) == %t) then
-            deput(1,2)=%t;
-            break;
-        end
-    end
-    Code($+1)="   "+sci2exp(deput,"dep_ut",70);
-    Code=[Code
-    "   model=scicos_model(sim=list(''"+rdnom+"'',4),.."
-    "                      in=in,.."
-    "                      in2=in2,.."
-    "                      intyp=intyp,.."
-    "                      out=out,.."
-    "                      out2=out2,.."
-    "                      outtyp=outtyp,.."
-    "                      evtin=clkinput,.."
-    "                      evtout=clkoutput,.."
-    "                      firing=firing,.."
-    "                      state=x,.."
-    "                      dstate=Z,.."
-    "                      odstate=odstate,.."
-    "                      rpar=rpar,.."
-    "                      ipar=ipar,.."
-    "                      opar=opar,.."
-    "                      blocktype=''c'',.."
-    "                      dep_ut=dep_ut,.."
-    "                      nzcross=nzcross,.."
-    "                      nmode=nmode)"
-    "   gr_i=''xstringb(orig(1),orig(2),''''"+rdnom+"'''',sz(1),.."
-    "          sz(2),''''fill'''')''";
-    "   x=standard_define([2 2],model,[],gr_i)";
-    " end"
-    "endfunction"];
+      deput=[%t,%f]
+      if (bllst(i).dep_ut(2) == %t) then
+        deput(1,2)=%t;
+        break;
+      end
+    end
+    Code=["function [sciblk, s1, s2] = "+rdnom+"_c(job,sciblk,e1)"
+          "// Interfacing function  of generated Xcos block "+rdnom
+          "//    Generated by the Xcos Code_Generation tool with "+getversion();
+          "//    Date : "+date();
+          "//"
+          "  s1= []; s2 = [];"
+          "  select job";
+          "  case ""set"" then";
+          "  case ""define"" then"
+          "    "+sci2exp(capt(:,3),"in",70); //input ports sizes 1
+          "    "+sci2exp(capt(:,4),"in2",70); //input ports sizes 2
+          "    "+sci2exp(scs_c_nb2scs_nb(capt(:,5)),"intyp",70); //input ports type
+          "    "+sci2exp(actt(:,3),"out",70); //output ports sizes 1
+          "    "+sci2exp(actt(:,4),"out2",70); //output ports sizes 2
+          "    "+sci2exp(scs_c_nb2scs_nb(actt(:,5)),"outtyp",70); //output ports type
+          "    "+sci2exp(cpr.state.x,"x",70); //initial continuous state
+          "    "+sci2exp(cpr.state.z,"z",70); //initial discrete state
+          "    work=zeros("+string(nblk)+",1)";
+          "    Z=[z;work]";
+          "    "+sci2exp(lstcat(cpr.state.oz,cpr.state.outtb),"odstate",70);
+          "    "+sci2exp(cpr.sim.rpar,"rpar",70); //real parameters
+          "    "+sci2exp(cpr.sim.ipar,"ipar",70); //integer parameters
+          "    "+sci2exp(cpr.sim.opar,"opar",70); //object parameters
+          "    "+sci2exp(clkinput,"clkinput",70);
+          "    "+sci2exp(clkoutput,"clkoutput",70);
+          "    "+sci2exp(FIRING,"firing",70);
+          "    nzcross="+string(sum(cpr.sim.zcptr(2:$)-cpr.sim.zcptr(1:$-1)))';
+          "    nmode="+string(sum(cpr.sim.modptr(2:$)-cpr.sim.modptr(1:$-1)))';
+          "    "+sci2exp(deput,"dep_ut",70);
+          "    model=scicos_model(sim=list(''"+rdnom+"'',4),...";
+          "                       in=in,..."
+          "                       in2=in2,..."
+          "                       intyp=intyp,..."
+          "                       out=out,..."
+          "                       out2=out2,..."
+          "                       outtyp=outtyp,..."
+          "                       evtin=clkinput,..."
+          "                       evtout=clkoutput,..."
+          "                       firing=firing,..."
+          "                       state=x,..."
+          "                       dstate=Z,..."
+          "                       odstate=odstate,..."
+          "                       rpar=rpar,..."
+          "                       ipar=ipar,..."
+          "                       opar=opar,..."
+          "                       blocktype=''c'',..."
+          "                       dep_ut=dep_ut,..."
+          "                       nzcross=nzcross,..."
+          "                       nmode=nmode)";
+          "    gr_i=""xstringb(orig(1),orig(2),"""""+rdnom+""""",sz(1),sz(2),""""fill"""")""";
+          "    sciblk = standard_define([2 2],model,[],gr_i);";
+          "    style_properties = [""blockWithLabel"";";
+          "                        ""verticalLabelPosition=middle"";";
+          "                        ""verticalAlign=middle"";";
+          "                        ""displayedLabel="+rdnom+"""];";
+          "    sciblk.graphics.style = strcat(style_properties,"";"");";
+          "  end"
+          "endfunction"];
     //Create file
-    ierr=execstr("mputl(Code,rpat+''/''+rdnom+''_c.sci'')","errcatch")
+    ierr=execstr("mputl(Code,rpat+""/""+rdnom+""_c.sci"")","errcatch")
     if ierr<>0 then
         message(lasterror())
         ok=%f
@@ -1970,9 +1940,6 @@ endfunction
 //actt=[i uk nuk_1 nuk_2 uk_t bllst(i).ipar]
 function Code=make_actuator(standalone)
     Call=["/*"
-    "**    Copyright (c) 1989 - 2012 (INRIA)"
-    "**    Copyright (c) 2011 - 2013 (Scilab Enterprises)"
-    "**"
     "**    Generated by Code_Generation toolbox of Xcos with "+getversion()
     "**    Date : "+date()
     "*/"
@@ -2274,9 +2241,6 @@ function make_computational42(filename)
 
     mputl(["/*"
     "**    SCILAB Computational function"
-    "**    Copyright (c) 1989 - 2012 (INRIA)"
-    "**    Copyright (c) 2011 - 2013 (Scilab Enterprises)"
-    "**"
     "**    Generated by Code_Generation toolbox of Xcos with "+getversion()
     "**    Date : "+date()
     "*/"
@@ -2675,7 +2639,7 @@ function make_computational42(filename)
             "    block_"+rdnom+"["+string(kf-1)+"].x      = &(x["+...
             string(xptr(kf)-1)+"]);"], fd);
         else
-            mputl(["    block_"+rdnom+"["+string(kf-1)+"].nx     = 1;";
+            mputl(["    block_"+rdnom+"["+string(kf-1)+"].nx     = 0;";
             "    block_"+rdnom+"["+string(kf-1)+"].x      = &(zero);"
             "    block_"+rdnom+"["+string(kf-1)+"].xd     = w;"], fd);
         end
@@ -3430,10 +3394,6 @@ function make_standalone42(filename)
 
     mputl(["/*"
     "**    Code prototype for standalone use"
-    "**"
-    "**    Copyright (c) 1989 - 2012 (INRIA)"
-    "**    Copyright (c) 2011 - 2013 (Scilab Enterprises)"
-    "**"
     "**    Generated by Code_Generation toolbox of Xcos with "+getversion()
     "**    Date : "+date()
     "*/"
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_12731.tst b/scilab/modules/xcos/tests/nonreg_tests/bug_12731.tst
new file mode 100644 (file)
index 0000000..37bc20d
--- /dev/null
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - INRIA - Serge Steer
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- XCOS TEST -->
+//
+// <-- Non-regression test for bug 12731 -->
+//
+// <-- INTERACTIVE TEST -->
+
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12731
+//
+// <-- Short Description -->
+// Code generation produces erroneous block
+atomsInstall("Coselica")
+xcos(SCI + "/modules/xcos/tests/nonreg_tests/bug_12731.zcos");
+
+//now run the simulation, then generate code for the Asservissement super_block and run simulation again
+
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_12731.zcos b/scilab/modules/xcos/tests/nonreg_tests/bug_12731.zcos
new file mode 100644 (file)
index 0000000..43debb0
Binary files /dev/null and b/scilab/modules/xcos/tests/nonreg_tests/bug_12731.zcos differ