Xcos toolbox skeleton: implement a user defined modelica block 42/15642/5
Clément DAVID [Tue, 2 Dec 2014 20:24:41 +0000 (21:24 +0100)]
Change-Id: I5cf9fb094566fbb1fcfea6247604c8319b0a4332

14 files changed:
scilab/CHANGES_5.5.X
scilab/contrib/Makefile.am
scilab/contrib/Makefile.in
scilab/contrib/toolbox_skeleton.iss
scilab/contrib/xcos_toolbox_skeleton/demos/Blocks.zcos
scilab/contrib/xcos_toolbox_skeleton/etc/xcos_toolbox_skeleton.start
scilab/contrib/xcos_toolbox_skeleton/images/gif/TBX_SUM_modelica.gif [new file with mode: 0644]
scilab/contrib/xcos_toolbox_skeleton/images/svg/TBX_SUM_modelica.svg [new file with mode: 0644]
scilab/contrib/xcos_toolbox_skeleton/macros/TBX_SUM_modelica.sci [new file with mode: 0644]
scilab/contrib/xcos_toolbox_skeleton/macros/XcosToolboxSkeleton.mo [new file with mode: 0644]
scilab/contrib/xcos_toolbox_skeleton/macros/buildmacros.sce
scilab/modules/modules_manager/tests/unit_tests/xcos_toolbox_skeleton.macosx.dia.ref
scilab/modules/modules_manager/tests/unit_tests/xcos_toolbox_skeleton.unix.dia.ref
scilab/modules/modules_manager/tests/unit_tests/xcos_toolbox_skeleton.win.dia.ref

index b15c54d..601b834 100644 (file)
@@ -33,6 +33,12 @@ Removed Functions
 * xsetm removed. Please use ged instead.
 
 
+Toolbox Skeleton
+=================
+
+* Modelica user-defined block added in xcos_toolbox_skeleton.
+
+
 Compilation
 ===========
 
index c36b65f..2ed173b 100644 (file)
@@ -95,10 +95,12 @@ xcos_toolbox_skeleton/help/fr_FR/build_help.sce \
 xcos_toolbox_skeleton/images/gif/TBX_MUT_STYLE.gif \
 xcos_toolbox_skeleton/images/gif/TBX_NOOP.gif \
 xcos_toolbox_skeleton/images/gif/TBX_SUM_c.gif \
+xcos_toolbox_skeleton/images/gif/TBX_SUM_modelica.gif \
 xcos_toolbox_skeleton/images/gif/TBX_SUM_sci.gif \
 xcos_toolbox_skeleton/images/svg/TBX_MUT_STYLE.svg \
 xcos_toolbox_skeleton/images/svg/TBX_NOOP.svg \
 xcos_toolbox_skeleton/images/svg/TBX_SUM_c.svg \
+xcos_toolbox_skeleton/images/svg/TBX_SUM_modelica.svg \
 xcos_toolbox_skeleton/images/svg/TBX_SUM_sci.svg \
 xcos_toolbox_skeleton/license.txt \
 xcos_toolbox_skeleton/macros/buildmacros.sce \
@@ -108,8 +110,10 @@ xcos_toolbox_skeleton/macros/TBX_NOOP.sci \
 xcos_toolbox_skeleton/macros/TBX_NOOP_sci.sci \
 xcos_toolbox_skeleton/macros/TBX_NOOP_sim.sci \
 xcos_toolbox_skeleton/macros/TBX_SUM_c.sci \
+xcos_toolbox_skeleton/macros/TBX_SUM_modelica.sci \
 xcos_toolbox_skeleton/macros/TBX_SUM_sci.sci \
 xcos_toolbox_skeleton/macros/TBX_SUM_sim.sci \
+xcos_toolbox_skeleton/macros/XcosToolboxSkeleton.mo \
 xcos_toolbox_skeleton/sci_gateway/builder_gateway.sce \
 xcos_toolbox_skeleton/sci_gateway/c/builder_gateway_c.sce \
 xcos_toolbox_skeleton/sci_gateway/c/sci_tbx_sum.c \
index ee02b35..078b59c 100644 (file)
@@ -498,10 +498,12 @@ xcos_toolbox_skeleton/help/fr_FR/build_help.sce \
 xcos_toolbox_skeleton/images/gif/TBX_MUT_STYLE.gif \
 xcos_toolbox_skeleton/images/gif/TBX_NOOP.gif \
 xcos_toolbox_skeleton/images/gif/TBX_SUM_c.gif \
+xcos_toolbox_skeleton/images/gif/TBX_SUM_modelica.gif \
 xcos_toolbox_skeleton/images/gif/TBX_SUM_sci.gif \
 xcos_toolbox_skeleton/images/svg/TBX_MUT_STYLE.svg \
 xcos_toolbox_skeleton/images/svg/TBX_NOOP.svg \
 xcos_toolbox_skeleton/images/svg/TBX_SUM_c.svg \
+xcos_toolbox_skeleton/images/svg/TBX_SUM_modelica.svg \
 xcos_toolbox_skeleton/images/svg/TBX_SUM_sci.svg \
 xcos_toolbox_skeleton/license.txt \
 xcos_toolbox_skeleton/macros/buildmacros.sce \
@@ -511,8 +513,10 @@ xcos_toolbox_skeleton/macros/TBX_NOOP.sci \
 xcos_toolbox_skeleton/macros/TBX_NOOP_sci.sci \
 xcos_toolbox_skeleton/macros/TBX_NOOP_sim.sci \
 xcos_toolbox_skeleton/macros/TBX_SUM_c.sci \
+xcos_toolbox_skeleton/macros/TBX_SUM_modelica.sci \
 xcos_toolbox_skeleton/macros/TBX_SUM_sci.sci \
 xcos_toolbox_skeleton/macros/TBX_SUM_sim.sci \
+xcos_toolbox_skeleton/macros/XcosToolboxSkeleton.mo \
 xcos_toolbox_skeleton/sci_gateway/builder_gateway.sce \
 xcos_toolbox_skeleton/sci_gateway/c/builder_gateway_c.sce \
 xcos_toolbox_skeleton/sci_gateway/c/sci_tbx_sum.c \
index e562a76..9ff2bda 100644 (file)
@@ -77,6 +77,7 @@ Source: contrib\{#XCOS_TOOLBOX_SKELETON}\help\fr_FR\build_help.sce; DestDir: {ap
 Source: contrib\{#XCOS_TOOLBOX_SKELETON}\images\gif\*.gif; DestDir: {app}\contrib\{#XCOS_TOOLBOX_SKELETON}\images\gif; Flags: recursesubdirs; Components: {#COMPN_TOOLBOX_SKELETON} and {#COMPN_XCOS}
 Source: contrib\{#XCOS_TOOLBOX_SKELETON}\images\svg\*.svg; DestDir: {app}\contrib\{#XCOS_TOOLBOX_SKELETON}\images\svg; Flags: recursesubdirs; Components: {#COMPN_TOOLBOX_SKELETON} and {#COMPN_XCOS}
 Source: contrib\{#XCOS_TOOLBOX_SKELETON}\macros\*.sci; DestDir: {app}\contrib\{#XCOS_TOOLBOX_SKELETON}\macros; Flags: recursesubdirs; Components: {#COMPN_TOOLBOX_SKELETON} and {#COMPN_XCOS}
+Source: contrib\{#XCOS_TOOLBOX_SKELETON}\macros\*.mo; DestDir: {app}\contrib\{#XCOS_TOOLBOX_SKELETON}\macros; Flags: recursesubdirs; Components: {#COMPN_TOOLBOX_SKELETON} and {#COMPN_XCOS}
 Source: contrib\{#XCOS_TOOLBOX_SKELETON}\macros\buildmacros.sce; DestDir: {app}\contrib\{#XCOS_TOOLBOX_SKELETON}\macros; Flags: recursesubdirs; Components: {#COMPN_TOOLBOX_SKELETON} and {#COMPN_XCOS}
 Source: contrib\{#XCOS_TOOLBOX_SKELETON}\macros\cleanmacros.sce; DestDir: {app}\contrib\{#XCOS_TOOLBOX_SKELETON}\macros; Flags: recursesubdirs; Components: {#COMPN_TOOLBOX_SKELETON} and {#COMPN_XCOS}
 Source: contrib\{#XCOS_TOOLBOX_SKELETON}\sci_gateway\builder_gateway.sce; DestDir: {app}\contrib\{#XCOS_TOOLBOX_SKELETON}\sci_gateway; Flags: recursesubdirs; Components: {#COMPN_TOOLBOX_SKELETON} and {#COMPN_XCOS}
index 3afff4e..7676bee 100644 (file)
Binary files a/scilab/contrib/xcos_toolbox_skeleton/demos/Blocks.zcos and b/scilab/contrib/xcos_toolbox_skeleton/demos/Blocks.zcos differ
index da356b2..027851c 100644 (file)
@@ -52,6 +52,11 @@ function xcos_skeletonlib = startModule()
   exec(pathconvert(root_tlbx+"/sci_gateway/loader_gateway.sce", %f));
   ilib_verbose(verboseMode);
 
+// Append Modelica functionnals
+// =============================================================================
+  global %MODELICA_USER_LIBS;
+  %MODELICA_USER_LIBS = [%MODELICA_USER_LIBS ; root_tlbx+"/macros"];
+
 // Load and add help chapter
 // =============================================================================
   if or(getscilabmode() == ["NW";"STD"]) then
diff --git a/scilab/contrib/xcos_toolbox_skeleton/images/gif/TBX_SUM_modelica.gif b/scilab/contrib/xcos_toolbox_skeleton/images/gif/TBX_SUM_modelica.gif
new file mode 100644 (file)
index 0000000..e7b590c
Binary files /dev/null and b/scilab/contrib/xcos_toolbox_skeleton/images/gif/TBX_SUM_modelica.gif differ
diff --git a/scilab/contrib/xcos_toolbox_skeleton/images/svg/TBX_SUM_modelica.svg b/scilab/contrib/xcos_toolbox_skeleton/images/svg/TBX_SUM_modelica.svg
new file mode 100644 (file)
index 0000000..b284849
--- /dev/null
@@ -0,0 +1 @@
+<svg/>
diff --git a/scilab/contrib/xcos_toolbox_skeleton/macros/TBX_SUM_modelica.sci b/scilab/contrib/xcos_toolbox_skeleton/macros/TBX_SUM_modelica.sci
new file mode 100644 (file)
index 0000000..8a6ddda
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// This file is part of the Xcos skeleton toolbox
+//
+// see license.txt for more licensing information
+
+function [x,y,typ]=TBX_SUM_modelica(job,arg1,arg2)
+    x=[];y=[];typ=[]
+    select job
+    case "set" then
+        x=arg1;
+        // no parameters yet
+    case "define" then
+        model=scicos_model()
+        model.sim="XcosToolboxSkeleton.Sum"
+        // two inputs with a single "double" element
+        model.in=[1;1]
+        model.intyp=[1;1]
+        // one output with a single "double" element
+        model.out=1
+        model.outtyp=1
+
+        model.blocktype="c"
+        model.dep_ut=[%t %f]
+
+        mo=modelica();
+        mo.model="XcosToolboxSkeleton.Sum"
+        mo.inputs=["in1","in2"];
+        mo.outputs=["out"];
+        mo.parameters=list([],list())
+        model.equations=mo;
+
+        exprs=string([]);
+        gr_i=[]
+        x=standard_define([4 4],model,exprs,gr_i)
+        x.graphics.in_implicit=["E";"E"];
+        x.graphics.out_implicit=["E"];
+        x.graphics.style=["blockWithLabel;displayedLabel=TBX_SUM_modelica"]
+    end
+endfunction
+
diff --git a/scilab/contrib/xcos_toolbox_skeleton/macros/XcosToolboxSkeleton.mo b/scilab/contrib/xcos_toolbox_skeleton/macros/XcosToolboxSkeleton.mo
new file mode 100644 (file)
index 0000000..0398697
--- /dev/null
@@ -0,0 +1,18 @@
+//
+// This file is part of the Xcos skeleton toolbox
+//
+// see license.txt for more licensing information
+
+package XcosToolboxSkeleton
+
+  model Sum "Perfom the summation of the two inputs"
+    Real in1 "the first input";
+    Real in2 "the second input";
+    Real out "the output" ;
+  equation
+    out = in1 + in2;
+  end Sum;
+
+end XcosToolboxSkeleton;
+
+
index 8e66649..155410f 100644 (file)
@@ -3,7 +3,7 @@
 function buildmacros()
     macros_path = get_absolute_file_path("buildmacros.sce");
 
-    blocks = ["TBX_SUM_c" "TBX_MUT_STYLE", "TBX_SUM_sci", "TBX_NOOP"];
+    blocks = ["TBX_SUM_c", "TBX_SUM_sci", "TBX_SUM_modelica", "TBX_MUT_STYLE", "TBX_NOOP"];
 
     tbx_build_macros(TOOLBOX_NAME, macros_path);
     tbx_build_blocks(toolbox_dir, blocks);
index 113e560..e02a1b5 100644 (file)
@@ -21,6 +21,7 @@ genlib: Processing file: TBX_NOOP.sci
 genlib: Processing file: TBX_NOOP_sci.sci
 genlib: Processing file: TBX_NOOP_sim.sci
 genlib: Processing file: TBX_SUM_c.sci
+genlib: Processing file: TBX_SUM_modelica.sci
 genlib: Processing file: TBX_SUM_sci.sci
 genlib: Processing file: TBX_SUM_sim.sci
 genlib: Regenerate names and lib
index 113e560..e02a1b5 100644 (file)
@@ -21,6 +21,7 @@ genlib: Processing file: TBX_NOOP.sci
 genlib: Processing file: TBX_NOOP_sci.sci
 genlib: Processing file: TBX_NOOP_sim.sci
 genlib: Processing file: TBX_SUM_c.sci
+genlib: Processing file: TBX_SUM_modelica.sci
 genlib: Processing file: TBX_SUM_sci.sci
 genlib: Processing file: TBX_SUM_sim.sci
 genlib: Regenerate names and lib
index 1fda524..ef0ff27 100644 (file)
@@ -21,6 +21,7 @@ genlib: Processing file: TBX_NOOP.sci
 genlib: Processing file: TBX_NOOP_sci.sci
 genlib: Processing file: TBX_NOOP_sim.sci
 genlib: Processing file: TBX_SUM_c.sci
+genlib: Processing file: TBX_SUM_modelica.sci
 genlib: Processing file: TBX_SUM_sci.sci
 genlib: Processing file: TBX_SUM_sim.sci
 genlib: Regenerate names and lib