[10122] | 1 | /*
|
---|
| 2 | * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
|
---|
| 3 | * Copyright (C) 2009 - DIGITEO - Allan CORNET
|
---|
| 4 | *
|
---|
| 5 | * This file must be used under the terms of the CeCILL.
|
---|
| 6 | * This source file is licensed as described in the file COPYING, which
|
---|
| 7 | * you should have received as part of this distribution. The terms
|
---|
| 8 | * are also available at
|
---|
| 9 | * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
|
---|
| 10 | *
|
---|
| 11 | */
|
---|
| 12 | //=============================================================================
|
---|
| 13 | using System;
|
---|
| 14 | using System.Runtime.InteropServices;
|
---|
| 15 | //=============================================================================
|
---|
| 16 | namespace DotNetScilab {
|
---|
| 17 | class Scilab_cs_wrapper {
|
---|
| 18 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
---|
| 19 | public unsafe struct api_Ctx {
|
---|
| 20 | public String pstName; /**< Function name */
|
---|
| 21 | }
|
---|
| 22 | //=============================================================================
|
---|
| 23 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
---|
| 24 | public unsafe struct api_Err {
|
---|
| 25 | public int iErr;
|
---|
| 26 | public int iMsgCount;
|
---|
| 27 | public fixed int pstructMsg[5];
|
---|
| 28 | }
|
---|
| 29 | //=============================================================================
|
---|
| 30 | private const string CALL_SCILAB_DLL = "call_scilab.dll";
|
---|
| 31 | private const string API_SCILAB_DLL = "api_scilab.dll";
|
---|
| 32 | private const string GRAPHICS_DLL = "graphics.dll";
|
---|
| 33 | private const string OUTPUT_STREAM_DLL = "scioutput_stream.dll";
|
---|
| 34 | //=============================================================================
|
---|
| 35 | /// <summary>
|
---|
| 36 | /// import SendScilabJob from C (see call_scilab.h)
|
---|
| 37 | /// </summary>
|
---|
| 38 | [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 39 | public static extern int SendScilabJob([In]String job);
|
---|
| 40 | //=============================================================================
|
---|
| 41 | /// <summary>
|
---|
| 42 | /// import StartScilab from C (see call_scilab.h)
|
---|
| 43 | /// </summary>
|
---|
| 44 | [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 45 | public static extern int StartScilab([In] String SCIpath,
|
---|
| 46 | [In] String ScilabStartup,
|
---|
| 47 | [In] Int32[] Stacksize);
|
---|
| 48 | //=============================================================================
|
---|
| 49 | /// <summary>
|
---|
| 50 | /// import TerminateScilab from C (see call_scilab.h)
|
---|
| 51 | /// </summary>
|
---|
| 52 | [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 53 | public static extern int TerminateScilab([In] String ScilabQuit);
|
---|
| 54 | //=============================================================================
|
---|
| 55 | /// <summary>
|
---|
| 56 | /// import DisableInteractiveMode from C (see call_scilab.h)
|
---|
| 57 | /// </summary>
|
---|
| 58 | [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 59 | public static extern void DisableInteractiveMode();
|
---|
| 60 | //=============================================================================
|
---|
| 61 | /// <summary>
|
---|
| 62 | /// import createNamedMatrixOfString from C (see api_string.h)
|
---|
| 63 | /// </summary>
|
---|
| 64 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 65 | public static extern api_Err createNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 66 | [In] int _iRows, [In] int _iCols,
|
---|
| 67 | [In] String[] _pstStrings);
|
---|
| 68 | //=============================================================================
|
---|
| 69 | /// <summary>
|
---|
| 70 | /// import createNamedMatrixOfWideString from C (see api_string.h)
|
---|
| 71 | /// </summary>
|
---|
| 72 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)]
|
---|
| 73 | public static extern api_Err createNamedMatrixOfWideString([In]IntPtr pvApiCtx,
|
---|
| 74 | [In] String _pstName,
|
---|
| 75 | [In] int _iRows, [In] int _iCols,
|
---|
| 76 | [In] String[] _pstStrings);
|
---|
| 77 | //=============================================================================
|
---|
| 78 | /// <summary>
|
---|
| 79 | /// import createNamedMatrixOfDouble from C (see api_double.h)
|
---|
| 80 | /// </summary>
|
---|
| 81 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 82 | [return: MarshalAs(UnmanagedType.Struct)]
|
---|
| 83 | public static extern api_Err createNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 84 | [In] int _iRows, [In] int _iCols,
|
---|
| 85 | [In] double[] _pdblReal);
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | //=============================================================================
|
---|
| 89 | /// <summary>
|
---|
| 90 | /// import createNamedMatrixOfBoolean from C (see api_boolean.h)
|
---|
| 91 | /// </summary>
|
---|
| 92 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 93 | public static extern api_Err createNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 94 | [In] int _iRows, [In] int _iCols,
|
---|
| 95 | [In] int[] _piBool);
|
---|
| 96 | //=============================================================================
|
---|
| 97 | /// <summary>
|
---|
| 98 | /// import createNamedMatrixOfInteger32 from C (see api_int.h)
|
---|
| 99 | /// </summary>
|
---|
| 100 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 101 | public unsafe static extern api_Err createNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 102 | [In] int _iRows, [In] int _iCols,
|
---|
| 103 | [In] int[] _piData);
|
---|
| 104 | //=============================================================================
|
---|
| 105 | /// <summary>
|
---|
| 106 | /// import createNamedComplexMatrixOfDouble from C (see api_double.h)
|
---|
| 107 | /// </summary>
|
---|
| 108 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 109 | public unsafe static extern api_Err createNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 110 | [In] int _iRows, [In] int _iCols,
|
---|
| 111 | [In] double[] _pdblReal,
|
---|
| 112 | [In] double[] _pdblImg);
|
---|
| 113 | //=============================================================================
|
---|
| 114 | /// <summary>
|
---|
| 115 | /// import readNamedMatrixOfString from C (see api_string.h)
|
---|
| 116 | /// </summary>
|
---|
| 117 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 118 | public unsafe static extern api_Err readNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 119 | [Out] Int32* _piRows, [Out] Int32* _piCols,
|
---|
| 120 | [In, Out] int[] _piLength,
|
---|
| 121 | [In, Out] String[] _pstStrings);
|
---|
| 122 | //=============================================================================
|
---|
| 123 | /// <summary>
|
---|
| 124 | /// import readNamedMatrixOfWideString from C (see api_string.h)
|
---|
| 125 | /// </summary>
|
---|
| 126 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)]
|
---|
| 127 | public unsafe static extern api_Err readNamedMatrixOfWideString([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 128 | [Out] Int32* _piRows, [Out] Int32* _piCols,
|
---|
| 129 | [In, Out] int[] _piLength,
|
---|
| 130 | [In, Out] String[] _pstStrings);
|
---|
| 131 | //=============================================================================
|
---|
| 132 | /// <summary>
|
---|
| 133 | /// import readNamedMatrixOfDouble from C (see api_double.h)
|
---|
| 134 | /// </summary>
|
---|
| 135 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 136 | public unsafe static extern api_Err readNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 137 | [Out] Int32* _piRows, [Out] Int32* _piCols,
|
---|
| 138 | [In, Out] Double[] _pdblReal);
|
---|
| 139 | //=============================================================================
|
---|
| 140 | /// <summary>
|
---|
| 141 | /// import readNamedMatrixOfBoolean from C (see api_boolean.h)
|
---|
| 142 | /// </summary>
|
---|
| 143 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 144 | public unsafe static extern api_Err readNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 145 | [Out] Int32* _piRows, [Out] Int32* _piCols,
|
---|
| 146 | [In, Out] int[] _piBool);
|
---|
| 147 | //=============================================================================
|
---|
| 148 | /// <summary>
|
---|
| 149 | /// import readNamedMatrixOfInteger32 from C (see api_int.h)
|
---|
| 150 | /// </summary>
|
---|
| 151 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 152 | public unsafe static extern api_Err readNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 153 | [Out] Int32* _piRows, [Out] Int32* _piCols,
|
---|
| 154 | [In, Out] int[] _piData);
|
---|
| 155 |
|
---|
| 156 | //=============================================================================
|
---|
| 157 | /// <summary>
|
---|
| 158 | /// import readNamedComplexMatrixOfDouble from C (see api_double.h)
|
---|
| 159 | /// </summary>
|
---|
| 160 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 161 | public unsafe static extern api_Err readNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 162 | [Out] Int32* _piRows, [Out] Int32* _piCols,
|
---|
| 163 | [In, Out] double[] _pdblReal,
|
---|
| 164 | [In, Out] double[] _pdblImg);
|
---|
| 165 | //=============================================================================
|
---|
| 166 | /// <summary>
|
---|
| 167 | /// get Variable Adress in scilab stack from name
|
---|
| 168 | /// used for getNamedMatrixType (internal)
|
---|
| 169 | /// </summary>
|
---|
| 170 | /// <param name="_pstName">variable name</param>
|
---|
| 171 | /// <param name="_piAddress"> stack address</param>
|
---|
| 172 | /// <returns>1 if ok</returns>
|
---|
| 173 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 174 | public unsafe static extern api_Err getVarAddressFromName([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 175 | [Out] Int32** _piAddress);
|
---|
| 176 | //=============================================================================
|
---|
| 177 | /// <summary>
|
---|
| 178 | /// get Variable type in scilab stack from name
|
---|
| 179 | /// </summary>
|
---|
| 180 | /// <param name="_pstName">variable name</param>
|
---|
| 181 | /// <returns>type or -1</returns>
|
---|
| 182 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 183 | public unsafe static extern api_Err getNamedVarType([In]IntPtr pvApiCtx, [In] String _pstName, [Out]Int32* _piType);
|
---|
| 184 | //=============================================================================
|
---|
| 185 | /// <summary>
|
---|
| 186 | /// get variable type with adress in scilab stack
|
---|
| 187 | /// used for getNamedMatrixType (internal)
|
---|
| 188 | /// </summary>
|
---|
| 189 | /// <param name="_piAddress"> stack address</param>
|
---|
| 190 | /// <returns>scilab type, 0 fails</returns>
|
---|
| 191 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 192 | public unsafe static extern api_Err getVarType([In]IntPtr pvApiCtx, [In] Int32* _piAddress, [Out]Int32* _piType);
|
---|
| 193 | //=============================================================================
|
---|
| 194 | /// <summary>
|
---|
| 195 | /// Detect if a Scilab graphic window is opened
|
---|
| 196 | /// </summary>
|
---|
| 197 | /// <returns>0 (FALSE) or 1 (TRUE)</returns>
|
---|
| 198 | [DllImport(GRAPHICS_DLL, CharSet = CharSet.Ansi)]
|
---|
| 199 | public unsafe static extern int sciHasFigures();
|
---|
| 200 | //=============================================================================
|
---|
| 201 | /// <summary>
|
---|
| 202 | /// get last error code
|
---|
| 203 | /// </summary>
|
---|
| 204 | /// <returns>last error code</returns>
|
---|
| 205 | [DllImport(OUTPUT_STREAM_DLL, CharSet = CharSet.Ansi)]
|
---|
| 206 | public unsafe static extern int GetLastErrorCode();
|
---|
| 207 | //=============================================================================
|
---|
| 208 | /// <summary>
|
---|
| 209 | /// Get variable dimension
|
---|
| 210 | /// </summary>
|
---|
| 211 | /// import getNamedVarDimension from C (see api_common.h)
|
---|
| 212 | /// <returns>int last error code</returns>
|
---|
| 213 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 214 | public unsafe static extern api_Err getNamedVarDimension([In]IntPtr pvApiCtx, [In] String _pstName,
|
---|
| 215 | [Out] Int32* _piRows, [Out] Int32* _piCols);
|
---|
| 216 | //=============================================================================
|
---|
| 217 | /// <summary>
|
---|
| 218 | /// Get named complex information
|
---|
| 219 | /// </summary>
|
---|
| 220 | /// import isNamedVarComplex from C (see api_common.h)
|
---|
| 221 | /// <returns>int if complex 1 otherwise 0</returns>
|
---|
| 222 | [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
|
---|
| 223 | public unsafe static extern int isNamedVarComplex([In]IntPtr pvApiCtx, [In] String _pstName);
|
---|
| 224 | //=============================================================================
|
---|
| 225 |
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
| 228 | //=============================================================================
|
---|