Beispiel #1
0
 //=============================================================================
 /// <summary>
 /// Write a named matrix of string in scilab
 /// </summary>
 /// <param name="matrixName"> variable name</param>
 /// <param name="iRows"> Number of row</param>
 /// <param name="iCols"> Number of column</param>
 /// <param name="matrixDouble"> pointer on data</param>
 /// <returns> if the operation successes (0) or not ( !0 )</returns>
 public int createNamedMatrixOfString(string matrixName, int iRows, int iCols, string[] matrixString)
 {
     System.IntPtr ptrEmpty = new System.IntPtr();
     //cEngineDlls.api_Err SciErr = m_objScilabInvoker.createStrMat(ptrEmpty, matrixName, iRows, iCols, matrixString);
     Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.createNamedMatrixOfString(ptrEmpty, matrixName, iRows, iCols, matrixString);
     return(SciErr.iErr);
 }
Beispiel #2
0
 //=============================================================================
 /// <summary>
 /// Write a named matrix of boolean in Scilab
 /// </summary>
 /// <param name="matrixName"> variable name</param>
 /// <param name="iRows"> Number of row</param>
 /// <param name="iCols"> Number of column</param>
 /// <param name="matrixBoolean"> pointer on data</param>
 /// <returns> if the operation successes (0) or not ( !0 )</returns>
 //public int createNamedMatrixOfBoolean(string matrixName, int iRows, int iCols, Boolean[] matrixBoolean)
 //{
 //    int[] matrixInt = new int[matrixBoolean.Length];
 //    for (int i = 0; i < matrixBoolean.Length; i++)
 //    {
 //        if (matrixBoolean[i] == true)
 //        {
 //            matrixInt[i] = 1;
 //        }
 //        else
 //        {
 //            matrixInt[i] = 0;
 //        }
 //    }
 //    System.IntPtr ptrEmpty = new System.IntPtr();
 //    cEngineDlls.api_Err SciErr = cEngineDlls.createNamedMatrixOfBoolean(ptrEmpty, matrixName, iRows, iCols, matrixInt);
 //    return SciErr.iErr;
 //}
 //=============================================================================
 /// <summary>
 /// Write a named matrix of int(32) in Scilab
 /// </summary>
 /// <param name="matrixName"> variable name</param>
 /// <param name="iRows"> Number of row</param>
 /// <param name="iCols"> Number of column</param>
 /// <param name="matrixInt"> pointer on data</param>
 public int createNamedMatrixOfInt32(string matrixName, int iRows, int iCols, int[] matrixInt)
 {
     System.IntPtr ptrEmpty = new System.IntPtr();
     //cEngineDlls.api_Err SciErr = m_objScilabInvoker.createIntMat(ptrEmpty, matrixName, iRows, iCols, matrixInt);
     Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.createNamedMatrixOfInteger32(ptrEmpty, matrixName, iRows, iCols, matrixInt);
     return(SciErr.iErr);
 }
Beispiel #3
0
        //=============================================================================
        /// <summary>
        /// Read a named matrix of string from scilab
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns>a matrix of string from scilab. If Variable name does not exist returns null</returns>
        public unsafe string[] readNamedMatrixOfString(string matrixName)
        {
            string[] matrixString = null;

            int[] iDim = getNamedVarDimension(matrixName);

            if (iDim != null)
            {
                int iRows = iDim[0];
                int iCols = iDim[1];

                // we allocate lengthmatrixString
                int[] lengthmatrixString = new int[iRows * iCols];

                System.IntPtr ptrEmpty = new System.IntPtr();

                // we get length of strings
                //cEngineDlls.api_Err SciErr = m_objScilabInvoker.readStrMat(ptrEmpty, matrixName, &iRows, &iCols, lengthmatrixString, null);
                Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedMatrixOfString(ptrEmpty, matrixName, &iRows, &iCols, lengthmatrixString, null);

                // we allocate each string
                matrixString = new string[iRows * iCols];
                for (int i = 0; i < iRows * iCols; i++)
                {
                    matrixString[i] = new string(' ', lengthmatrixString[i]);
                }

                // we get strings from scilab
                //SciErr = m_objScilabInvoker.readStrMat(ptrEmpty, matrixName, &iRows, &iCols, lengthmatrixString, matrixString);
                SciErr = Scilab_cs_wrapper.readNamedMatrixOfString(ptrEmpty, matrixName, &iRows, &iCols, lengthmatrixString, matrixString);
            }
            return(matrixString);
        }
Beispiel #4
0
        //=============================================================================
        /// <summary>
        /// Constructor, initialize scilab engine.
        /// </summary>
        public Scilab()
        {
            // Disable TCL/TK and Java graphic interfaces
            Scilab_cs_wrapper.DisableInteractiveMode();
            withGraphics = false;

            // start Scilab engine configurated without java
            Scilab_cs_wrapper.StartScilab(null, null, null);
        }
Beispiel #5
0
        //=============================================================================
        /// <summary>
        /// Constructor, initialize scilab engine.
        /// </summary>
        public Scilab()
        {
            // Disable TCL/TK and Java graphic interfaces
            Scilab_cs_wrapper.DisableInteractiveMode();
            withGraphics = false;

            // start Scilab engine configurated without java
            string SCI = System.Environment.GetEnvironmentVariable("SCI");

            Scilab_cs_wrapper.StartScilab(SCI, null, null);
        }
Beispiel #6
0
 //=============================================================================
 /// <summary>
 /// Write a named matrix of complex double in Scilab
 /// </summary>
 /// <param name="matrixName"> variable name</param>
 /// <param name="iRows">Number of row</param>
 /// <param name="iCols">Number of column</param>
 /// <param name="matrixRealPart">real part</param>
 /// <param name="matrixImagPart">imag part</param>
 /// <returns></returns>
 public int createNamedComplexMatrixOfDouble(string matrixName,
                                             int iRows, int iCols,
                                             double[] matrixRealPart,
                                             double[] matrixImagPart)
 {
     System.IntPtr             ptrEmpty = new System.IntPtr();
     Scilab_cs_wrapper.api_Err SciErr   = Scilab_cs_wrapper.createNamedComplexMatrixOfDouble(ptrEmpty, matrixName,
                                                                                             iRows, iCols,
                                                                                             matrixRealPart,
                                                                                             matrixImagPart);
     return(SciErr.iErr);
 }
Beispiel #7
0
        //=============================================================================
        /// <summary>
        /// Constructor, initialize scilab engine.
        /// </summary>
        public cScilab()
        {
            // Disable TCL/TK and Java graphic interfaces
            //m_objScilabInvoker = new cEngineDlls();
            //m_objScilabInvoker.disableInteractive();
            Scilab_cs_wrapper.DisableInteractiveMode();
            withGraphics = false;

            // start Scilab engine configurated without java
            //m_objScilabInvoker.startEngine(null, null, null);
            Scilab_cs_wrapper.StartScilab(null, null, null);
        }//constructor
Beispiel #8
0
 //=============================================================================
 /// <summary>
 /// Detect if a Scilab graphic window is opened
 /// </summary>
 /// <returns>true or false</returns>
 public Boolean HaveAGraph()
 {
     if (withGraphics)
     {
         int ierr = Scilab_cs_wrapper.sciHasFigures();
         if (ierr == 1)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #9
0
        //=============================================================================
        /// <summary>
        /// get scilab type of named matrix
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns>scilab type (see enum ScilabType)</returns>
        public unsafe int getNamedVarType(string matrixName)
        {
            int iType = 0;

            System.IntPtr ptrEmpty = new System.IntPtr();

            Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.getNamedVarType(ptrEmpty, matrixName, &iType);
            if (SciErr.iErr == 0)
            {
                return(iType);
            }
            return(0);
        }
Beispiel #10
0
        //=============================================================================
        /// <summary>
        /// Detect if a variable name exists in Scilab
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns> true if exists</returns>
        public unsafe Boolean existNamedVariable(string matrixName)
        {
            int *piAdress = null;

            System.IntPtr ptrEmpty = new System.IntPtr();

            Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.getVarAddressFromName(ptrEmpty, matrixName, &piAdress);
            if (SciErr.iErr == 0)
            {
                return(true);
            }
            return(false);
        }
Beispiel #11
0
        //=============================================================================
        /// <summary>
        /// Get dimensions of a named matrix in scilab
        /// </summary>
        /// <returns>a int array.
        /// if variable name does not exist dimensions are null </returns>
        public unsafe int[] getNamedVarDimension(string matrixName)
        {
            int[] iDim  = null;
            int   iRows = 0;
            int   iCols = 0;

            System.IntPtr             ptrEmpty = new System.IntPtr();
            Scilab_cs_wrapper.api_Err SciErr   = Scilab_cs_wrapper.getNamedVarDimension(ptrEmpty, matrixName, &iRows, &iCols);
            if (SciErr.iErr == 0)
            {
                iDim    = new int[2];
                iDim[0] = iRows;
                iDim[1] = iCols;
            }
            return(iDim);
        }
Beispiel #12
0
        //=============================================================================
        public Scilab(Boolean _bWithGraphics)
        {
            // Disable TCL/TK and Java graphic interfaces
            if (_bWithGraphics == false)
            {
                Scilab_cs_wrapper.DisableInteractiveMode();
                withGraphics = false;
            }
            else
            {
                withGraphics = true;
            }

            // start Scilab engine
            Scilab_cs_wrapper.StartScilab(null, null, null);
        }
Beispiel #13
0
 //=============================================================================
 /// <summary>
 /// Write a named matrix of boolean in Scilab
 /// </summary>
 /// <param name="matrixName"> variable name</param>
 /// <param name="iRows"> Number of row</param>
 /// <param name="iCols"> Number of column</param>
 /// <param name="matrixBoolean"> pointer on data</param>
 /// <returns> if the operation successes (0) or not ( !0 )</returns>
 public int createNamedMatrixOfBoolean(string matrixName, int iRows, int iCols, Boolean[] matrixBoolean)
 {
     int[] matrixInt = new int[matrixBoolean.Length];
     for (int i = 0; i < matrixBoolean.Length; i++)
     {
         if (matrixBoolean[i] == true)
         {
             matrixInt[i] = 1;
         }
         else
         {
             matrixInt[i] = 0;
         }
     }
     System.IntPtr             ptrEmpty = new System.IntPtr();
     Scilab_cs_wrapper.api_Err SciErr   = Scilab_cs_wrapper.createNamedMatrixOfBoolean(ptrEmpty, matrixName, iRows, iCols, matrixInt);
     return(SciErr.iErr);
 }
Beispiel #14
0
        //=============================================================================
        public Scilab(Boolean _bWithGraphics)
        {
            // Disable TCL/TK and Java graphic interfaces
            if (_bWithGraphics == false)
            {
                Scilab_cs_wrapper.DisableInteractiveMode();
                withGraphics = false;
            }
            else
            {
                withGraphics = true;
            }

            // start Scilab engine
            string SCI = System.Environment.GetEnvironmentVariable("SCI");

            Scilab_cs_wrapper.StartScilab(SCI, null, null);
        }
Beispiel #15
0
        //=============================================================================
        /// <summary>
        /// Read a named matrix of int(32) in Scilab
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns>a matrix of int(32) from scilab. If Variable name does not exist returns null</returns>
        public unsafe int[] readNamedMatrixOfInt32(string matrixName)
        {
            int[] matrixInt = null;
            int[] iDim      = getNamedVarDimension(matrixName);
            if (iDim != null)
            {
                int iRows = iDim[0];
                int iCols = iDim[1];

                // we allocate matrixInt array
                matrixInt = new int[iRows * iCols];

                System.IntPtr ptrEmpty = new System.IntPtr();

                // get values in matrixInt
                Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedMatrixOfInteger32(ptrEmpty, matrixName, &iRows, &iCols, matrixInt);
            }
            return(matrixInt);
        }
Beispiel #16
0
        //=============================================================================
        /// <summary>
        /// Read a named matrix of complex double in Scilab (Imag part)
        /// </summary>
        /// <param name="matrixName">variable name</param>
        /// <returns> img part. If Variable name does not exist returns null</returns>
        public unsafe double[] readNamedComplexMatrixOfDoubleImgPart(string matrixName)
        {
            double[] dImagPart = null;
            int[]    iDim      = getNamedVarDimension(matrixName);
            if (iDim != null)
            {
                int iRows = iDim[0];
                int iCols = iDim[1];

                double[] dRealPart = new double[iRows * iCols];
                dImagPart = new double[iRows * iCols];

                System.IntPtr ptrEmpty = new System.IntPtr();

                Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedComplexMatrixOfDouble(ptrEmpty, matrixName,
                                                                                                    &iRows, &iCols,
                                                                                                    dRealPart,
                                                                                                    dImagPart);
            }
            return(dImagPart);
        }
Beispiel #17
0
        //=============================================================================
        /// <summary>
        /// Read a named matrix of double from Scilab
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns>a matrix of double from scilab. If Variable name does not exist returns null</returns>
        public unsafe double[] readNamedMatrixOfDouble(string matrixName)
        {
            int iRows = 0;
            int iCols = 0;

            System.IntPtr             ptrEmpty = new System.IntPtr();
            Scilab_cs_wrapper.api_Err SciErr   = Scilab_cs_wrapper.readNamedMatrixOfDouble(ptrEmpty, matrixName, &iRows, &iCols, null);

            if (iRows * iCols > 0)
            {
                double[] matrixDouble = new double[iRows * iCols];

                // get values in matrixDouble
                SciErr = Scilab_cs_wrapper.readNamedMatrixOfDouble(ptrEmpty, matrixName, &iRows, &iCols, matrixDouble);
                if (SciErr.iErr != 0)
                {
                    return(null);
                }
                return(matrixDouble);
            }
            return(null);
        }
Beispiel #18
0
        //=============================================================================
        /// <summary>
        /// Read a named matrix of boolean from Scilab
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns>a matrix of boolean from scilab. If Variable name does not exist returns null</returns>
        public unsafe Boolean[] getNamedMatrixOfBoolean(string matrixName)
        {
            Boolean[] matrixBoolean = null;
            int[]     iDim          = getNamedVarDimension(matrixName);

            if (iDim != null)
            {
                int   iRows     = iDim[0];
                int   iCols     = iDim[1];
                int[] matrixInt = new int[iRows * iCols];

                System.IntPtr ptrEmpty = new System.IntPtr();

                // get values in matrixDouble
                Scilab_cs_wrapper.api_Err SciErr = Scilab_cs_wrapper.readNamedMatrixOfBoolean(ptrEmpty, matrixName,
                                                                                              &iRows, &iCols,
                                                                                              matrixInt);

                if (matrixInt != null)
                {
                    matrixBoolean = new Boolean[iRows * iCols];
                    for (int i = 0; i < iRows * iCols; i++)
                    {
                        if (matrixInt[i] == 1)
                        {
                            matrixBoolean[i] = true;
                        }
                        else
                        {
                            matrixBoolean[i] = false;
                        }
                    }
                }
            }
            return(matrixBoolean);
        }
Beispiel #19
0
 //=============================================================================
 /// <summary>
 /// get scilab type of named matrix
 /// </summary>
 /// <param name="matrixName"> variable name</param>
 /// <returns>scilab type (see enum ScilabType)</returns>
 public int isNamedVarComplex(string matrixName)
 {
     System.IntPtr ptrEmpty = new System.IntPtr();
     return(Scilab_cs_wrapper.isNamedVarComplex(ptrEmpty, matrixName));
 }
Beispiel #20
0
        //=============================================================================
        /// <summary>
        /// get scilab type of named matrix
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns>scilab type (see enum ScilabType)</returns>
        //public unsafe int getNamedVarType(string matrixName)
        //{
        //    int iType = 0;
        //    System.IntPtr ptrEmpty = new System.IntPtr();

        //    cEngineDlls.api_Err SciErr = cEngineDlls.getNamedVarType(ptrEmpty, matrixName, &iType);
        //    if (SciErr.iErr == 0) return iType;
        //    return 0;
        //}
        //=============================================================================
        /// <summary>
        /// Detect if a variable name exists in Scilab
        /// </summary>
        /// <param name="matrixName"> variable name</param>
        /// <returns> true if exists</returns>
        //public unsafe Boolean existNamedVariable(string matrixName)
        //{
        //    int* piAdress = null;
        //    System.IntPtr ptrEmpty = new System.IntPtr();

        //    cEngineDlls.api_Err SciErr = cEngineDlls.getVarAddressFromName(ptrEmpty, matrixName, &piAdress);
        //    if (SciErr.iErr == 0) return true;
        //    return false;
        //}
        //=============================================================================
        /// <summary>
        /// Execute a scilab script .sce
        /// </summary>
        /// <param name="scriptFilename">the path to the .sce file</param>
        /// <returns>error code operation, 0 : OK</returns>
        public int execScilabScript(String scriptFilename)
        {
            //return m_objScilabInvoker.callEngineJob("exec('" + scriptFilename + "');");
            return(Scilab_cs_wrapper.SendScilabJob("exec('" + scriptFilename + "');"));
        }
Beispiel #21
0
 //=============================================================================
 /// <summary>
 /// Send a job to scilab
 /// </summary>
 /// <param name="command">command to send to scilab</param>
 /// <returns>error code operation, 0 : OK</returns>
 public int SendScilabJob(string command)
 {
     return(Scilab_cs_wrapper.SendScilabJob(command));
 }
Beispiel #22
0
 //=============================================================================
 /// <summary>
 ///  get last error code
 /// </summary>
 /// <returns>last error code</returns>
 public int GetLastErrorCode()
 {
     return(Scilab_cs_wrapper.GetLastErrorCode());
 }
Beispiel #23
0
 //=============================================================================
 /// <summary>
 /// Send a job to scilab
 /// </summary>
 /// <param name="command">command to send to scilab</param>
 /// <returns>error code operation, 0 : OK</returns>
 public int SendScilabJob(string command)
 {
     return(Scilab_cs_wrapper.SendScilabJob(command));
     //return m_objScilabInvoker.callEngineJob(command);
 }//SendScilabJob
Beispiel #24
0
 //=============================================================================
 /// <summary>
 /// Execute a scilab script .sce
 /// </summary>
 /// <param name="scriptFilename">the path to the .sce file</param>
 /// <returns>error code operation, 0 : OK</returns>
 public int execScilabScript(String scriptFilename)
 {
     return(Scilab_cs_wrapper.SendScilabJob("exec('" + scriptFilename + "');"));
 }