%%============================================================================
%%
%%
%%
%%Abstract:
%%Thissystemfilecreates_msf.cfortheS-Functionwrapper.
%%
%%Copyright1994-2018TheMathWorks,Inc.
%%
 
%include "sfcnutil.tlc"
 
%%============================================================================
%%Setupofsomecommonvariables
%%
%with ::CompiledModel
 
%assign thisSystem = System[GetBaseSystemIdx()]
%assign sFunctionName = GetModelrefSFunctionName(Name)
   
%openfile tmpBuf
#if !defined(S_FUNCTION_NAME)
#define S_FUNCTION_NAME %<sFunctionName>
#endif
#define S_FUNCTION_LEVEL 2
/* So mdlEnable and mdlDisable will be defined in the simstruc.h */
#if !defined(RTW_GENERATED_S_FUNCTION)
#define RTW_GENERATED_S_FUNCTION
#endif
%if LibIsSystemField(thisSystem, "FcnCallInputInfo")
  #define S_FUNCTION_EXPORTS_FUNCTION_CALLS
  #define MODELREF_EXPORTS_FUNCTION_CALLS
%endif
 
#include
#include
#include "simstruc.h"
#include "fixedpoint.h"
 
%%Wedonotneedthefollowing.hfile.However,
%%model_mdl.hincludesrt_logging.h
#define rt_logging_h
%assign mdlTypesHdrFileName = SLibGetFileNameForCode("mdl_types_hdr")
%if !WHITE_SPACE(mdlTypesHdrFileName)
  #include "%<mdlTypesHdrFileName>.h"
%endif
 
%%Includesubsystem.h
%assign fileName = SLibGetSystemOutputHdrFileBaseName(thisSystem)
#include "%<fileName>.h"
 
%%Privatefileisrequiredforconstparametertypede
%<SLibIncludePrivateHeader()>
 
%closefile tmpBuf
%<SLibCacheCodeToFile("mdlsfcn_src_incl", tmpBuf)>
 
%%Globalparameterdefinitions(allinSimulinkGlobal)
%if !SLibPrmBufferIsEmpty("UnstructuredSimulinkGlobal", "Instance")
  %openfile tmpBuf
  /* Model block global parameters (%<::AutoOrDefaultStorageClass> storage) */
  %<SLibGetPrmBuffer("UnstructuredSimulinkGlobal", "Instance")>
  %closefile tmpBuf
  %<SLibCacheCodeToFile("mdlsfcn_data_defn", tmpBuf)>
%endif
 
%%Forprotectedmodels,wemayputdefinitionsinmodel.c
%if !SLibPrmBufferIsEmpty("UnstructuredSimulinkGlobalProtInlined", "Instance")
  %assert SLibIsGeneratingSimTargetForProtectedModel()
  %assign instance = SLibGetPrmBuffer("UnstructuredSimulinkGlobalProtInlined", "Instance")
  %<SLibCacheCodeToFile("mdl_data_defn", instance)>
%endif
   
%%CacheinformationforwritingouttheSimTargetSfunctionwrapper(model_msf.c)
%<SLibWriteMdlRefExportedMdlInfo()> %% TODO: Do we need to do this?
%endwith