Generates MicroDAQ block from provided block structure
This function generates MicroDAQ block. The generated block will be avaliable in MicroDAQ User Xcos palette after Scilab restart. Function generates necessery macros and C source file which needs to be modified by adding custom user C code. Generated C source file contains three function which are executed during block initialization (init() funciton), computation(inout() function)and termination(end() function). Generated code contains pointers to block input and outputs. Block inputs are named with 'u' and input port number e.g u3 - third block input. Block outputs are named with 'y' and output port number. Code generated by mdaqBlockAdd() function also contains block parameter pointers with same names as defined in MicroDAQ block structure.
The mdaqBlockAdd() function generates three files - macros containing block code and simulation macro which can be modified to use block in simulation mode without running code on MicroDAQ. The C source file is compiled and linked with userlib.lib library which contains all precompiled MicroDAQ block C code. During code generation userlib.lib is linked with generated code which results DSP applications with custom functionality introduced by new MicroDAQ block.
mdaqBlockAdd(block);
block : structure containing MicroDAQ block description (returned by mdaqBlock() function)
Obtaining generated file paths
Generated C code
/* Generated with MicroDAQ toolbox ver: 1.0. */ #include "scicos_block4.h" extern double get_scicos_time( void ); /* This function will executed once at the beginning of model execution */ static void init(scicos_block *block) { /* Block parameters */ double *params = GetRparPtrs(block); /* param size = 1 */ double param1 = params[0]; int param2_size = 2; double *param2 = ¶ms[1]; int param3_size = 4; double *param3 = ¶ms[3]; /* Add block init code here */ } /* This function will be executed on every model step */ static void inout(scicos_block *block) { /* Block parameters */ double *params = GetRparPtrs(block); /* param size = 1 */ double param1 = params[0]; int param2_size = 2; double *param2 = ¶ms[1]; int param3_size = 4; double *param3 = ¶ms[3]; /* Block input ports */ double *u1 = GetRealInPortPtrs(block,1); int u1_size = GetInPortRows(block,1); /* u1_size = 1 */ double *u2 = GetRealInPortPtrs(block,2); int u2_size = GetInPortRows(block,2); /* u2_size = 1 */ /* Block output ports */ double *y1 = GetRealOutPortPtrs(block,1); int y1_size = GetOutPortRows(block,1); /* y1_size = 1 */ /* Add block code here (executed every model step) */ } /* This function will be executed once at the end of model execution (only in Ext mode) */ static void end(scicos_block *block) { /* Prameters */ double *params = GetRparPtrs(block); /* param size = 1 */ double param1 = params[0]; int param2_size = 2; double *param2 = ¶ms[1]; int param3_size = 4; double *param3 = ¶ms[3]; /* Add block end code here */ } void mdaq_test(scicos_block *block,int flag) { if (flag == 1){ /* set output */ inout(block); } else if (flag == 5){ /* termination */ end(block); } else if (flag == 4){ /* initialisation */ init(block); } }