function Component_C_genSfn()
%
%% Generates Sfunction wrapper and tlc file from information in the header file. 
% NOTE: This file needs a licensed script file see include statement in this script
% Please contact hartmut.schorrig@vishia.de to get more information.
% The generated wrapper and tlc should be stored additionally, so you can% compile 
% mex files nevertheless with unchanged S-function wrapper (unchanged interface of the Sfunction)
%
rootPath = evalin('base', 'rootPath');
display(rootPath);
clc
clear mex
currdir_ = pwd;
cd(rootPath);
disp('Generate S-Fuctions for Test_ObjOModules ...');
system('java.exe -cp ../../ZBNF/zbnfjax/zbnf.jar org.vishia.jztxtcmd.JZtxtcmd test/+ObjOModule_ExmplCtrl/+mkSfn/Component_C_genSfn.m');
ObjOModule_ExmplCtrl.genBus.genBus();  %just generated script
ObjOModule_ExmplCtrl.genSfn.Sfn_mex();    %just generated script.
%ObjOModule_ExmplCtrl.genSfn.Sfn_mexdbg();    %just generated script.
disp('successfull')
cd(currdir_);
end
%{
==JZtxtcmd==
currdir = <:><&scriptdir>/../../..<.>;                             ##the scriptdir is the simulink root dir.
include D:/vishia/smlk/SmlkSfunc_jzTc/simulinkSfuncBusGen.jzTc;  ##out of the box, see below

##Important note: To complile the Inspector-Sfunctions newly you need three things outside of this simulink box.
##They should be placed in file system parallel to this this current dir 'smlk/SMLK_PRJ/Simulink'.
##1. The JZtxtcmd script engine. It is contained in 'ZBNF/zbnfjax/zbnfjax.zbnf'.
##   It is only used in the Java invocation as class path.
##2. Sources of Inspector. They are part of the 'emC' source pool, hosted on Github /jzHartmut.
##   That sources are used here in a directory parallel to this current dir 'smlk/*/Simulink' in 'emc/*'
##3. The scripts to generate S-Funtion wrapper. This script is included above with relative path.
##   This scripts are not open source. you can get it with a low fee (one week coaching) from vishia.org.


Fileset srcHeader =          ##from this header Sfunctions are generated.
( test/+ObjOModule_ExmplCtrl/srcC:Component_C_Sfn.h
);


Fileset includepath = 
( test/+ObjOModule_ExmplCtrl/srcC
, test/+ObjOModule_ExmplCtrl/Cprj 
, test/+ObjOModule_ExmplCtrl/Cprj/genSrc 
, emc/source
, emc/incApplSpecific/stdef_SmlkSfuncExcH
, emc/incComplSpecific/cc_SmlkSfunc_64bit
, emc
, genRefl
);



## All sources for compilation to the named header file, except the generated Sfunc-wrapper.
Fileset srcTlc_Component_C_Sfn = 
( test/+ObjOModule_ExmplCtrl/srcC/Component_C_Sfn.c
);

## All sources for compilation to the named header file, except the generated Sfunc-wrapper.
Fileset src_Component_C_Sfn = 
( &srcTlc_Component_C_Sfn
, emc/sourceApplSpecific/applConv/ApplSimpleStop_emC.c
, emc/sourceApplSpecific/applConv/Exception_emC.c
, emc/sourceApplSpecific/applConv/ExceptionPrintStacktrace_emC.c
, emc/sourceApplSpecific/applConv/ExcThCxtStacksize.c
, emc/sourceApplSpecific/applConv/ThreadContextSingle_emC.c
, emc/sourceApplSpecific/applConv/ThreadContextUserBuffer_emC.c
, emc/source/emC/MemC_emC.c
, emc/source/emC/Memfree_ThreadAndBlockHeap.c
, emc/source/emC/Object_emC.c
, emc/source/emC/CheckStack_emC.c
, emc/source/emC/time_emC.c
, emc/source/emC/DefPortTypes_emC.c
, emc/source/emC/Reflection_emC.c
, emc/source/emC/ReflectionBaseTypes_emC.c
, emc/source/emC/StringBase_emC.c
, emc/source/emC/Handle_ptr64_emC.c
, emc/sourceSpecials/osal_Windows/os_sharedmem.c
, emc/sourceSpecials/osal_Windows/os_file.c
, emc/sourceSpecials/osal_Windows/os_mem.c
, emc/sourceSpecials/osal_Windows_Msc15/os_time.c
);



##Docu: if this Subtextvar is found, the memory for the Object Function Blocks is gotten in the function InitializeConditions.
##If the genAllocmem is not existing or null, The Sfunctions will get a second output for a bus which presents the internal data.
##Because the code generation provides a memory space with pointer, that is used.
##Note that some special condition 'don't reuse' etc. should be set for code generation optimizations.
##
Subtextvar genAllocmem(String dst, String nameStruct, Num ident) =
<:>(<&nameStruct>*) malloc(sizeof(<&nameStruct>))  /*JZtc: user-specific ExampleObjO*/ <.>;

main() { ##main routine for the JZtxtcmd:

  zmake "test/+ObjOModule_ExmplCtrl:Sfn" := simulinkSfuncBusGen(&srcHeader
    , coptions = "-P"
    , dirRefl = "genRefl"
    , dirMexDbg = "../mexDbg", dirMex = "test/mex"
    , dirMexcc=":+genSfn", dirSfunc = ":+genSfn/Sfn", dirTlc = ":+genSfn/Sfn"
    , html=":+genSfn/test.html"
    );

}

==endJZcmd==
%}
