* Bug #10433 fixed - Xcos stop simulation button 32/9032/13
Alexandre HERISSE [Mon, 17 Sep 2012 15:47:50 +0000 (17:47 +0200)]
Change-Id: I92dde895cf49bad3f20ecd1c6467d3b71713b8aa

15 files changed:
scilab/CHANGES_5.4.X
scilab/modules/xcos/Makefile.am
scilab/modules/xcos/Makefile.in
scilab/modules/xcos/includes/gw_xcos.h
scilab/modules/xcos/macros/xcos_simulate.sci
scilab/modules/xcos/sci_gateway/c/gw_xcos.c
scilab/modules/xcos/sci_gateway/cpp/sci_xcosSimulationStarted.cpp [new file with mode: 0644]
scilab/modules/xcos/sci_gateway/xcos_gateway.xml
scilab/modules/xcos/src/c/xcos.vcxproj
scilab/modules/xcos/src/c/xcos.vcxproj.filters
scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/StartAction.java
scilab/modules/xcos/src/jni/Xcos.cpp
scilab/modules/xcos/src/jni/Xcos.giws.xml
scilab/modules/xcos/src/jni/Xcos.hxx

index 6bd90d1..f722ea6 100644 (file)
@@ -47,6 +47,8 @@ Xcos
 * Bug #9075 fixed - Demo Xcos/Control systems/inverted pendulum
                     opened a useless graphic windows
 
+* Bug #10433 fixed - Xcos stop simulation button
+
 * Bug #10943 fixed - Accented character in the file path broke file loading.
 
 * Bug #11717 fixed - Setting recent opened file number in preferences GUI
index bb6c7a0..b5802ad 100644 (file)
@@ -68,7 +68,8 @@ GATEWAY_CXX_SOURCES = \
        sci_gateway/cpp/sci_xcosConfigureXmlFile.cpp \
        sci_gateway/cpp/sci_xcosAddToolsMenu.cpp \
        sci_gateway/cpp/sci_xcosUpdateBlock.cpp \
-       sci_gateway/cpp/sci_loadXcos.cpp
+       sci_gateway/cpp/sci_loadXcos.cpp \
+       sci_gateway/cpp/sci_xcosSimulationStarted.cpp
 
 libscixcos_la_CPPFLAGS = \
                        -I$(srcdir)/includes/ \
index 6f66e41..f02502b 100644 (file)
@@ -168,7 +168,8 @@ am__objects_4 = libscixcos_la-sci_Xcos.lo \
        libscixcos_la-sci_xcosConfigureXmlFile.lo \
        libscixcos_la-sci_xcosAddToolsMenu.lo \
        libscixcos_la-sci_xcosUpdateBlock.lo \
-       libscixcos_la-sci_loadXcos.lo
+       libscixcos_la-sci_loadXcos.lo \
+       libscixcos_la-sci_xcosSimulationStarted.lo
 am_libscixcos_la_OBJECTS = $(am__objects_3) $(am__objects_4)
 libscixcos_la_OBJECTS = $(am_libscixcos_la_OBJECTS)
 @GUI_TRUE@@XCOS_TRUE@am_libscixcos_la_rpath = -rpath $(pkglibdir)
@@ -513,7 +514,8 @@ GATEWAY_CXX_SOURCES = \
        sci_gateway/cpp/sci_xcosConfigureXmlFile.cpp \
        sci_gateway/cpp/sci_xcosAddToolsMenu.cpp \
        sci_gateway/cpp/sci_xcosUpdateBlock.cpp \
-       sci_gateway/cpp/sci_loadXcos.cpp
+       sci_gateway/cpp/sci_loadXcos.cpp \
+       sci_gateway/cpp/sci_xcosSimulationStarted.cpp
 
 libscixcos_la_CPPFLAGS = \
                        -I$(srcdir)/includes/ \
@@ -1030,6 +1032,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosPalGenerateIcon.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosPalLoad.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosPalMove.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosSimulationStarted.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscixcos_la-sci_xcosUpdateBlock.Plo@am__quote@
 
 .c.o:
@@ -1221,6 +1224,13 @@ libscixcos_la-sci_loadXcos.lo: sci_gateway/cpp/sci_loadXcos.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscixcos_la-sci_loadXcos.lo `test -f 'sci_gateway/cpp/sci_loadXcos.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_loadXcos.cpp
 
+libscixcos_la-sci_xcosSimulationStarted.lo: sci_gateway/cpp/sci_xcosSimulationStarted.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscixcos_la-sci_xcosSimulationStarted.lo -MD -MP -MF $(DEPDIR)/libscixcos_la-sci_xcosSimulationStarted.Tpo -c -o libscixcos_la-sci_xcosSimulationStarted.lo `test -f 'sci_gateway/cpp/sci_xcosSimulationStarted.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosSimulationStarted.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscixcos_la-sci_xcosSimulationStarted.Tpo $(DEPDIR)/libscixcos_la-sci_xcosSimulationStarted.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_xcosSimulationStarted.cpp' object='libscixcos_la-sci_xcosSimulationStarted.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscixcos_la-sci_xcosSimulationStarted.lo `test -f 'sci_gateway/cpp/sci_xcosSimulationStarted.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_xcosSimulationStarted.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index dd89425..69e064c 100644 (file)
@@ -37,6 +37,7 @@ int sci_xcosConfigureXmlFile(char *fname, unsigned long l);
 int sci_xcosAddToolsMenu(char *fname, unsigned long l);
 int sci_xcosUpdateBlock(char *fname, unsigned long l);
 int sci_loadXcos(char *fname, unsigned long l);
+int sci_xcosSimulationStarted(char *fname, unsigned long l);
 
 /*--------------------------------------------------------------------------*/
 /**
index d3122cc..cdbd110 100644 (file)
@@ -272,6 +272,9 @@ function %cpr = xcos_simulate(scs_m, needcompile)
   //** scicos simulation
   tf = scs_m.props.tf
 
+  // inform Xcos the simulator is going to run
+  xcosSimulationStarted();
+
   //** run scicosim via 'start' flag
   ierr = execstr('[state,t]=scicosim(%cpr.state,%tcur,tf,%cpr.sim,'+..
                     '''run'',tolerances)','errcatch')
index c5ac759..879ab10 100644 (file)
@@ -41,7 +41,8 @@ static gw_generic_table Tab[] =
     {sci_xcosConfigureXmlFile, "xcosConfigureXmlFile"},
     {sci_xcosAddToolsMenu, "xcosAddToolsMenu"},
     {sci_xcosUpdateBlock, "xcosUpdateBlock"},
-    {sci_loadXcos, "loadXcos"}
+    {sci_loadXcos, "loadXcos"},
+    {sci_xcosSimulationStarted, "xcosSimulationStarted"}
 };
 
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/xcos/sci_gateway/cpp/sci_xcosSimulationStarted.cpp b/scilab/modules/xcos/sci_gateway/cpp/sci_xcosSimulationStarted.cpp
new file mode 100644 (file)
index 0000000..dfcf048
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2012 - Scilab Enterprises - Alexandre HERISSE
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "Xcos.hxx"
+#include "xcosUtilities.hxx"
+extern "C"
+{
+#include "gw_xcos.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "Scierror.h"
+#include "MALLOC.h"
+#include "freeArrayOfString.h"
+#include "getScilabJavaVM.h"
+}
+/*--------------------------------------------------------------------------*/
+using namespace org_scilab_modules_xcos;
+/*--------------------------------------------------------------------------*/
+int sci_xcosSimulationStarted(char *fname, unsigned long fname_len)
+{
+    CheckRhs(0, 0);
+    CheckLhs(0, 1);
+
+    /* call the implementation */
+    Xcos::xcosSimulationStarted(getScilabJavaVM());
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
+/*--------------------------------------------------------------------------*/
index c3bc6a5..ebca3e3 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE GATEWAY SYSTEM "../../functions/xml/gateway.dtd">
 <GATEWAY name="xcos">
-  <!-- =================== -->
-  <!--
+    <!-- =================== -->
+    <!--
  Scilab
  Interface description. In this file, we define the list of the function which
  will be available into Scilab and the link to the "native" function.
  ===================
  Don't touch if you do not know what you are doing
 -->
-  <!-- =================== -->
-  <PRIMITIVE gatewayId="64" primitiveId="1" primitiveName="xcos"/>
-  <PRIMITIVE gatewayId="64" primitiveId="2" primitiveName="warnBlockByUID"/>
-  <PRIMITIVE gatewayId="64" primitiveId="3" primitiveName="closeXcos"/>
-  <PRIMITIVE gatewayId="64" primitiveId="4" primitiveName="xcosDiagramToScilab"/>
-  <PRIMITIVE gatewayId="64" primitiveId="5" primitiveName="xcosPalLoad"/>
-  <PRIMITIVE gatewayId="64" primitiveId="6" primitiveName="xcosPalCategoryAdd"/>
-  <PRIMITIVE gatewayId="64" primitiveId="7" primitiveName="xcosPalDelete"/>
-  <PRIMITIVE gatewayId="64" primitiveId="8" primitiveName="xcosPalMove"/>
-  <PRIMITIVE gatewayId="64" primitiveId="9" primitiveName="xcosPalEnable"/>
-  <PRIMITIVE gatewayId="64" primitiveId="10" primitiveName="xcosPalDisable"/>
-  <PRIMITIVE gatewayId="64" primitiveId="11" primitiveName="xcosPalGenerateIcon"/>
-  <PRIMITIVE gatewayId="64" primitiveId="12" primitiveName="xcosConfigureXmlFile"/>
-  <PRIMITIVE gatewayId="64" primitiveId="13" primitiveName="xcosAddToolsMenu"/>
-  <PRIMITIVE gatewayId="64" primitiveId="14" primitiveName="xcosUpdateBlock"/>
-  <PRIMITIVE gatewayId="64" primitiveId="15" primitiveName="loadXcos"/>
+    <!-- =================== -->
+    <PRIMITIVE gatewayId="64" primitiveId="1" primitiveName="xcos"/>
+    <PRIMITIVE gatewayId="64" primitiveId="2" primitiveName="warnBlockByUID"/>
+    <PRIMITIVE gatewayId="64" primitiveId="3" primitiveName="closeXcos"/>
+    <PRIMITIVE gatewayId="64" primitiveId="4" primitiveName="xcosDiagramToScilab"/>
+    <PRIMITIVE gatewayId="64" primitiveId="5" primitiveName="xcosPalLoad"/>
+    <PRIMITIVE gatewayId="64" primitiveId="6" primitiveName="xcosPalCategoryAdd"/>
+    <PRIMITIVE gatewayId="64" primitiveId="7" primitiveName="xcosPalDelete"/>
+    <PRIMITIVE gatewayId="64" primitiveId="8" primitiveName="xcosPalMove"/>
+    <PRIMITIVE gatewayId="64" primitiveId="9" primitiveName="xcosPalEnable"/>
+    <PRIMITIVE gatewayId="64" primitiveId="10" primitiveName="xcosPalDisable"/>
+    <PRIMITIVE gatewayId="64" primitiveId="11" primitiveName="xcosPalGenerateIcon"/>
+    <PRIMITIVE gatewayId="64" primitiveId="12" primitiveName="xcosConfigureXmlFile"/>
+    <PRIMITIVE gatewayId="64" primitiveId="13" primitiveName="xcosAddToolsMenu"/>
+    <PRIMITIVE gatewayId="64" primitiveId="14" primitiveName="xcosUpdateBlock"/>
+    <PRIMITIVE gatewayId="64" primitiveId="15" primitiveName="loadXcos"/>
+    <PRIMITIVE gatewayId="64" primitiveId="16" primitiveName="xcosSimulationStarted"/>
 </GATEWAY>
index 027d6f3..16ed652 100644 (file)
     <ClCompile Include="..\..\sci_gateway\cpp\sci_xcosAddToolsMenu.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_xcosUpdateBlock.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_loadXcos.cpp" />
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_xcosSimulationStarted.cpp" />
     <ClCompile Include="..\jni\Xcos.cpp" />
     <ClCompile Include="..\cpp\xcosUtilities.cpp" />
   </ItemGroup>
index 06a2ab3..d734e89 100644 (file)
@@ -86,6 +86,9 @@
     <ClCompile Include="..\..\sci_gateway\cpp\sci_loadXcos.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_xcosSimulationStarted.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\dynlib_xcos.h">
index a337907..6cce63b 100644 (file)
@@ -37,6 +37,7 @@ import javax.swing.SwingUtilities;
 import org.scilab.modules.action_binding.InterpreterManagement;
 import org.scilab.modules.commons.xml.XConfiguration;
 import org.scilab.modules.core.Scilab;
+import org.scilab.modules.graph.actions.base.GraphActionManager;
 import org.scilab.modules.graph.utils.ScilabExported;
 import org.scilab.modules.gui.bridge.menu.SwingScilabMenu;
 import org.scilab.modules.gui.bridge.menubar.SwingScilabMenuBar;
@@ -53,6 +54,7 @@ import org.scilab.modules.gui.utils.ScilabSwingUtilities;
 import org.scilab.modules.gui.utils.WindowsConfigurationManager;
 import org.scilab.modules.localization.Messages;
 import org.scilab.modules.xcos.actions.ExternalAction;
+import org.scilab.modules.xcos.actions.StopAction;
 import org.scilab.modules.xcos.block.BasicBlock;
 import org.scilab.modules.xcos.block.SuperBlock;
 import org.scilab.modules.xcos.configuration.ConfigurationManager;
@@ -1138,6 +1140,15 @@ public final class Xcos {
     }
 
     /**
+     * Inform Xcos the simulator has just started
+     *
+     */
+    @ScilabExported(module = "xcos", filename = "Xcos.giws.xml")
+    public static void xcosSimulationStarted() {
+        GraphActionManager.setEnable(StopAction.class, true);
+    }
+
+    /**
      * Look for the parent diagram of the cell in the diagram hierarchy.
      *
      * @param cell
index f5d3003..179dff5 100644 (file)
@@ -173,7 +173,7 @@ public final class StartAction extends OneBlockDependantAction {
      */
     public void updateUI(boolean started) {
         GraphActionManager.setEnable(StartAction.class, !started);
-        GraphActionManager.setEnable(StopAction.class, started);
+        GraphActionManager.setEnable(StopAction.class, false);
         ((XcosDiagram) getGraph(null)).setReadOnly(started);
 
         if (started) {
index 3a8c55a..63b4ff2 100644 (file)
@@ -112,6 +112,7 @@ voidxcosDiagramOpenjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
 voidxcosDiagramClosejobjectArray_java_lang_Stringjava_lang_StringID=NULL;
 voidaddToolsMenujstringjava_lang_Stringjstringjava_lang_StringID=NULL;
 voidupdateBlockjstringjava_lang_StringID=NULL;
+voidxcosSimulationStartedID=NULL;
 
 
 }
@@ -142,6 +143,7 @@ voidxcosDiagramOpenjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
 voidxcosDiagramClosejobjectArray_java_lang_Stringjava_lang_StringID=NULL;
 voidaddToolsMenujstringjava_lang_Stringjstringjava_lang_StringID=NULL;
 voidupdateBlockjstringjava_lang_StringID=NULL;
+voidxcosSimulationStartedID=NULL;
 
 
 }
@@ -435,4 +437,22 @@ throw GiwsException::JniCallMethodException(curEnv);
 }
 }
 
+void Xcos::xcosSimulationStarted (JavaVM * jvm_){
+
+JNIEnv * curEnv = NULL;
+jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID voidxcosSimulationStartedID = curEnv->GetStaticMethodID(cls, "xcosSimulationStarted", "()V" ) ;
+if (voidxcosSimulationStartedID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "xcosSimulationStarted");
+}
+
+                         curEnv->CallStaticVoidMethod(cls, voidxcosSimulationStartedID );
+                        curEnv->DeleteLocalRef(cls);
+if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+}
+
 }
index e8f5d56..ba8e900 100644 (file)
@@ -1,30 +1,32 @@
 <?xml version="1.0"?>
 <package name="org.scilab.modules.xcos">
-  <object name="Xcos">
-    <method name="xcos" returnType="void" modifier="static">
-      <parameter name="file" type="String"/>
-      <parameter name="variable" type="String"/>
-    </method>
-    <method name="warnCellByUID" returnType="void" modifier="static">
-      <parameter name="uids" type="String[]"/>
-      <parameter name="message" type="String"/>
-    </method>
-    <method name="closeXcosFromScilab" returnType="void" modifier="static"/>
-    <method name="xcosDiagramToScilab" returnType="int" modifier="static">
-      <parameter name="xcosFile" type="String"/>
-    </method>
-    <method name="xcosDiagramOpen" returnType="void" modifier="static">
-      <parameter name="UID" type="String[]"/>
-    </method>
-    <method name="xcosDiagramClose" returnType="void" modifier="static">
-      <parameter name="UID" type="String[]"/>
-    </method>
-    <method name="addToolsMenu" returnType="void" modifier="static">
-      <parameter name="label" type="String"/>
-      <parameter name="command" type="String"/>
-    </method>
-    <method name="updateBlock" returnType="void" modifier="static">
-      <parameter name="h5File" type="String"/>
-    </method>
-  </object>
+    <object name="Xcos">
+        <method name="xcos" returnType="void" modifier="static">
+            <parameter name="file" type="String"/>
+            <parameter name="variable" type="String"/>
+        </method>
+        <method name="warnCellByUID" returnType="void" modifier="static">
+            <parameter name="uids" type="String[]"/>
+            <parameter name="message" type="String"/>
+        </method>
+        <method name="closeXcosFromScilab" returnType="void" modifier="static"/>
+        <method name="xcosDiagramToScilab" returnType="int" modifier="static">
+            <parameter name="xcosFile" type="String"/>
+        </method>
+        <method name="xcosDiagramOpen" returnType="void" modifier="static">
+            <parameter name="UID" type="String[]"/>
+        </method>
+        <method name="xcosDiagramClose" returnType="void" modifier="static">
+            <parameter name="UID" type="String[]"/>
+        </method>
+        <method name="addToolsMenu" returnType="void" modifier="static">
+            <parameter name="label" type="String"/>
+            <parameter name="command" type="String"/>
+        </method>
+        <method name="updateBlock" returnType="void" modifier="static">
+            <parameter name="h5File" type="String"/>
+        </method>
+        <method name="xcosSimulationStarted" returnType="void" modifier="static">
+        </method>
+    </object>
 </package>
index e7b5113..490c62f 100644 (file)
@@ -85,6 +85,7 @@ jmethodID voidxcosDiagramOpenjobjectArray_java_lang_Stringjava_lang_StringID; //
 jmethodID voidxcosDiagramClosejobjectArray_java_lang_Stringjava_lang_StringID; // cache method id
 jmethodID voidaddToolsMenujstringjava_lang_Stringjstringjava_lang_StringID; // cache method id
 jmethodID voidupdateBlockjstringjava_lang_StringID; // cache method id
+jmethodID voidxcosSimulationStartedID; // cache method id
 
 
 
@@ -160,6 +161,8 @@ static void addToolsMenu(JavaVM * jvm_, char const* label, char const* command);
 
 static void updateBlock(JavaVM * jvm_, char const* h5File);
 
+static void xcosSimulationStarted(JavaVM * jvm_);
+
 
                         /**
                         * Get class name to use for static methods