

Delegating the build process to Scilab, this code is multiplaform. To build this code and load it to Scilab, we use the dynamic link capabilities of Scilab.
#Plc that run from scilab full#
Full source can be found in the sci_gateway/c/ directory of the // toolbox skeleton #include " api_scilab.h " #include " Scierror.h " #include " BOOL.h " #include " localization.h " static const char fname = " foo6 " /* = */ int sci_foo6 ( scilabEnv env, int nin, scilabVar * in, int nopt, scilabOpt * opt, int nout, scilabVar * out ) Once the application code has been executed, usually, some data will be returned to the Scilab interpreter.įor example, to create in the Scilab engine memory a matrix of double, the C functionīy default, Scilab numerical values are stored with the C type double.Īs convention, gateways are stored in sci_gateway/c/ (or /cpp/) and are called sci_functionName.c. Virtually, any library could be linked to Scilab.Ĭreate the output arguments for the Scilab engine This can be done through a thirdparty code stored and built in src/c, src/cpp or src/fortran but also under the form of a library. The actual intelligence (processes, data transformations, etc) will be performed here. Once all the checks and data retrieval have been performed, the actual core code can be called. 58-69, 2018Modeling and control of processes using theEMSO simulator and SIMATIC PLC as OPCinter-faceModelado y control de procesos usando el simulador EMSO. Please note that it is usually a performance killer. A classical example is changing the storage of a matrix from column-stored to line-stored. Other checks can be done like specific values expected, consistency between the first and second input arguments, etc.ĭepending on the code or library targeted, some transformations can be applied to the data. If it is relevant, check if the input argument is complex or not with scilab_isComplexĭealing with integer, further checks should be done on the precision of the integer with scilab_getIntegerPrecisionĬheck the dimensions of the variable: square matrix, scalar, etcĪlmost all Scilab datatypes have an equivalent C function to perform such task. Most of the time, the process is always the same:Ĭheck the number of arguments (both input and output) provided by the user.įor example, if the function foo(x) is called with foo() or foo(2,3), the user must get an answer.Ĭheck the type of the variable: matrix of double (complex or not), string, etc with Return 0 or STATUS_OK for OK and other value or STATUS_ERROR to trigger an error. Nout: number of expected output paramters.
