Hello All,
I need help regarding code generation from level-2 c mex s-function. I have written an s-function c-file and a TLC file for code generation.
Here is my TLC file:
%implements "my_fun" "C"
%function BlockTypeSetup(block, system) void
%openfile buffer
some function prototype code; %closefile buffer
%<LibCacheFunctionPrototype(buffer)>
%openfile buffer #include "Some_Header.h" %closefile buffer %<LibCacheIncludes(buffer)>
%endfunction %%BlockTypeSetup
%function Outputs(block, system) Output
/* %<Type> Block: %<Name> */
%assign y = LibBlockOutputSignal(0, "", "", 0)
%assign SignalName = SFcnParamSettings.SignalName
%assign IsArray = CAST("Number",SFcnParamSettings.IsArray)
%assign ArrayIdx = CAST("Number",SFcnParamSettings.ArrayIdx)
%if (IsArray == 1)
%<y> = ApplicationShadow->%<SignalName>[%<ArrayIdx>];
%else
%<y> = ApplicationShadow->%<SignalName>;
%endif
%endfunction %%Outputs
Code generation works fine. It generates two functions: Init and Step.
I want to add some custom code lines in Init function. How do I do that? Where do I add those lines in TLC code? Which %<LibCache*******(buffer)> method do I use?
NOTE:I have multiple instances of this s-function block in my model and I want to put this custom code just once in Init function. At the moment I put these custom code lines via Model Congicuration Parameters->Code Generation->Custom Code->Insert custom C code in generated:->Initialize function
I hope my question is clear. Amy help is greatly appreciated.
Thanks, Nirav
Best Answer