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.
block : structure containing MicroDAQ block description (returned by mdaqBlock() function)
// call mdaqBlock to initialize block structure describing new MicroDAQ block block = mdaqBlock(); block.name = "test"; // set block name block.param_name = [ "param1" "param2" "param3" ]; // set block parameters block.param_size = [ 1 2 4 ]; // set block parameters sizes block.param_def_val(1) = 1; // assign default values to defined block parameters according to block.param_size block.param_def_val(2) = [ 2; 3 ]; block.param_def_val(3) = [ 4; 5; 6; 7 ]; block.use_sim_script = %F; // define block inputs (four inputs: input 1 - vec size 1, input 2 - vec size 2, input 3 - vec size 4, input 4 - vec size 1) block.in = [1 2 4 1]; // define block outputs (two outputs both with vector size 1) block.out = [1 1]; // create block - generate block code and corresponding C source file mdaqBlockAdd(block);
Obtaining generated file paths
Generated C code