Xcos: fix some issues on Xcos->Scilab actions 01/3601/5
Clément DAVID [Tue, 22 Mar 2011 08:48:52 +0000 (09:48 +0100)]
* store the compiled diagram into a variable (cpr)
* store the generated block code to a temporary variable.
* define %scicos_debug_gr on all scicos entry point

Change-Id: I1c4b4a1fc4985d358c037643cdcda6ff5050fe97

scilab/modules/xcos/macros/xcosBlockEval.sci
scilab/modules/xcos/macros/xcosCodeGeneration.sci
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/CompileAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/BlockModelElement.java

index b5ae2d3..61bfe24 100644 (file)
@@ -29,9 +29,13 @@ function xcosBlockEval(hdf5FileToLoad, hdf5FileToSave, interfaceAlias, hdf5Conte
         [str,n,line,func]=lasterror();
         printf('do_eval: error %d - %s in %s at line %d\n', n, str, func, line); 
     endfunction
-    %scicos_prob = %f
     funcprot(%mprt)
 
+    // define scicos variables
+    %scicos_prob = %f
+    %scicos_debug_gr = %f
+    needcompile = 4;
+
     // allocate the context
     import_from_hdf5(hdf5ContextFile);
     %scicos_context = struct();
index a5ff250..d5b4ea9 100644 (file)
 //
 
 function xcosCodeGeneration(hdf5FileToLoad, hdf5FileToSave)
-  
-//-- BJ : Alias Warning Function
-  prot = funcprot();
-  funcprot(0);
-  hilite_obj = xcosShowBlockWarning;
-  unhilite_obj = xcosClearBlockWarning;
-  funcprot(prot);
-  //-- end
-  
-  // This will create a scs_m variable.
-  status = import_from_hdf5(hdf5FileToLoad);
-  if ~status then
-    error(msprintf(gettext("%s: Unable to import data from %s"), "xcosCodeGeneration", hdf5FileToLoad));
-  end
-  
-  ierr = execstr("[ok] = do_compile_superblock42(scs_m, [], [], %f); ", 'errcatch');
-  if ierr <> 0 then
-         [msg, err] = lasterror();
-         disp(msg);
-         deletefile(hdf5FileToSave);
-         return;
-  end
-  
-  if ok then
-    status = export_to_hdf5(hdf5FileToSave, "XX");
+
+    //-- BJ : Alias Warning Function
+    prot = funcprot();
+    funcprot(0);
+    hilite_obj = xcosShowBlockWarning;
+    unhilite_obj = xcosClearBlockWarning;
+    funcprot(prot);
+    //-- end
+
+    // This will create a scs_m variable.
+    status = import_from_hdf5(hdf5FileToLoad);
     if ~status then
-      error(msprintf(gettext("%s: Unable to export ''XX'' to %s"), "xcosCodeGeneration", hdf5FileToSave));
+        error(msprintf(gettext("%s: Unable to import data from %s"), "xcosCodeGeneration", hdf5FileToLoad));
+    end
+
+    // define scicos variables
+    %scicos_prob = %f
+    %scicos_debug_gr = %f
+    needcompile = 4;
+
+    ierr = execstr("[ok, XX] = do_compile_superblock42(scs_m, [], [], %f); ", 'errcatch');
+    if ierr <> 0 then
+        [msg, err] = lasterror();
+        disp(msg);
+        deletefile(hdf5FileToSave);
+        return;
+    end
+
+    if ok then
+        status = export_to_hdf5(hdf5FileToSave, "XX");
+        if ~status then
+            error(msprintf(gettext("%s: Unable to export ''XX'' to %s"), "xcosCodeGeneration", hdf5FileToSave));
+        end
+    else
+        deletefile(hdf5FileToSave);
     end
-  else
-    deletefile(hdf5FileToSave);
-  end
 endfunction
 
index 20caa0b..5f42a8e 100644 (file)
@@ -92,7 +92,7 @@ public class CompileAction extends SimulationNotRunningAction {
                                ((XcosDiagram) getGraph(null)).info(XcosMessages.COMPILATION_IN_PROGRESS);
                                
                                String cmd = buildCall("import_from_hdf5", temp.getAbsolutePath()) 
-                                                    + "xcos_compile(scs_m);";
+                                                    + "cpr = xcos_compile(scs_m);";
                                
                                final ActionListener action = new ActionListener() {
                                        @Override
index 91ac01e..618b68b 100644 (file)
@@ -602,7 +602,7 @@ class BlockModelElement extends BlockPartsElement {
                field++; // equations
                property = from.getEquations();
                if (property == null) {
-                       property = new ScilabDouble();
+                       property = new ScilabList();
                }
                data.set(field, property);