%function ModelrefHandleConstBIOAndPrm() void
%assert( SLibAreSimulinkGlobalParamsUnstructured() || IsModelReferenceInlineOffTarget())
%assign baseSystem = ::CompiledModel.System[GetBaseSystemIdx()]
%if IsModelReferenceTarget()
%if !SLibPrmBufferIsEmpty("SimulinkGlobal", "Instance")
%openfile dataBuf
%assign paramsType = SLibGetModelTypesNamespacePrefix() + ::tParametersType
%if !GenerateClassInterface
%assign paramsStaticName = ...
FcnSysVarGroupNonreusedName(baseSystem,"Parameter")
%else
%assign oldStrNames = SLibGetOldStrNames()
%assign paramsStaticName = ...
SLibGetPrmsName(oldStrNames)
%endif
%assign classNamePrefix = ""
%if GenerateClassInterface
%if !ISEMPTY(::NamespaceName)
%assign classNamePrefix = ::NamespaceName + "::" + ::CPPClassName + "::"
%else
%assign classNamePrefix = ::CPPClassName + "::"
%endif
%endif
%<paramsType> %<classNamePrefix>%<paramsStaticName> = {
%<SLibGetPrmBuffer("SimulinkGlobal", "Instance")>
};/
%closefile dataBuf
%<SLibCacheCodeToFile("mdl_data_defn", dataBuf)>
%assign prmExternDecl = GetHideChildDefineSymbol("ifndef") + "/n" + ...
"extern " + paramsType + " " + paramsStaticName + ";/n" + ...
GetHideChildDefineSymbol("endif")
%if SLibIsModelTypesModelClassNamespace()
%<SLibCacheCPPEncapModelData("ExternData", prmExternDecl)>
%else
%<SLibCacheCodeToFile("mdl_priv_extern_data_decl", prmExternDecl)>
%endif
%endif
%endif
%openfile constPrmDef
%if !SLibPrmBufferIsEmpty("Const", "Typedef")
/* Constant parameters (%<::AutoOrDefaultStorageClass> storage) */
%<SLibGetPrmBuffer("Const", "Typedef")>/
%endif
%if !SLibPrmBufferIsEmpty("ConstWithInit", "Typedef")
/* Constant parameters with dynamic initialization (%<::AutoOrDefaultStorageClass> storage) */
%<SLibGetPrmBuffer("ConstWithInit", "Typedef")>/
%endif
%closefile constPrmDef
%if !WHITE_SPACE(constPrmDef)
%if SLibIsModelTypesModelClassNamespace()
%<SLibCacheCPPEncapModelData("Typedefs", constPrmDef)>
%else
%<SLibCacheCodeToFile("mdl_priv_constParam_typedef", constPrmDef)>
%endif
%endif
%openfile constPrmInst
%if !SLibPrmBufferIsEmpty("Const", "Instance")
/* Constant parameters (%<::AutoOrDefaultStorageClass> storage) */
%<SLibGetPrmBuffer("Const", "Instance")>
%endif
%if !SLibPrmBufferIsEmpty("ConstWithInit", "Instance")
/* Constant parameters with dynamic initialization (%<::AutoOrDefaultStorageClass> storage) */
%<SLibGetPrmBuffer("ConstWithInit", "Instance")>
%endif
%closefile constPrmInst
%if !WHITE_SPACE(constPrmInst)
%<SLibCacheCodeToFile("mdl_constParam_with_initialization", constPrmInst)>
%endif
%assign constPrmDecl = GetConstPrmExternBuf()
%assign constPrmDecl = constPrmDecl + GetConstPrmWithInitExternBuf()
%if !WHITE_SPACE(constPrmDecl)
%if SLibIsCompactFileFormat()
%assign constPrmDecl = GetHideChildDefineSymbol("ifndef") + "/n" + ...
constPrmDecl + "/n" + GetHideChildDefineSymbol("endif")
%endif
%if SLibIsModelTypesModelClassNamespace()
%<SLibCacheCPPEncapModelData("ExternData", constPrmDecl)>
%else
%<SLibCacheCodeToFile("mdl_priv_constParam_decl", constPrmDecl)>
%endif
%endif
%openfile cioBuf
%if !LibConstBlockIOInstanceIsEmpty()
%openfile cioDefBuf
/* Invariant block signals (%<::AutoOrDefaultStorageClass> storage) */
%assign qualifiers = SLibGetConstBlockIOQualifiers()
%assign typePrefix = SLibGetModelTypesNamespacePrefix()
%<qualifiers> %<typePrefix>%<FcnSysVarGroupType(baseSystem,"ConstBlockIO")> %<::tConstBlockIOStruct> = {
%<LibDumpConstBlockIOInstance()>
};
%closefile cioDefBuf
%<SLibAddPreStructDeclarePragma(::tConstBlockIOStruct)>/
%<SLibApplyMemSecToDataDefn(cioDefBuf, ...
"MemSecDataConstants", "%<::tConstBlockIOStruct>")>/
%<SLibAddPostStructDeclarePragma(::tConstBlockIOStruct)>/
%endif
%closefile cioBuf
%if !WHITE_SPACE(cioBuf)
%<SLibCacheCodeToFile("data_constBIO_decl", cioBuf)>
%endif
%assign cBIOExtBuf = GetConstBIOExternBuf()
%if !WHITE_SPACE(cBIOExtBuf)
%if SLibIsCompactFileFormat()
%assign cBIOExtBuf = GetHideChildDefineSymbol("ifndef") + "/n" + ...
cBIOExtBuf + "/n" + GetHideChildDefineSymbol("endif")
%endif
%if SLibIsModelTypesModelClassNamespace()
%<SLibCacheCPPEncapModelData("ExternData", cBIOExtBuf)>
%else
%<SLibCacheCodeToFile("mdl_priv_extern_data_decl", cBIOExtBuf)>
%endif
%endif
%assign defGndBuf = LibDumpGroundDeclarations(0)
%<SLibCacheCodeToFile("data_ground_defn", defGndBuf)>
%endfunction
%function ModelrefHandleRTModel() void
%assert(IsModelReferenceTarget() && GenRTModel)
%openfile rtmTypedefs
%assign rtmTypedefsStr = RTMGenRtMdlTypedef()
%if !WHITE_SPACE(rtmTypedefsStr)
%assign needRtmExported = SLibModelHasServicePortDWork()
%if !needRtmExported
%<GetHideChildDefineSymbol("ifndef")>
%endif
%<rtmTypedefsStr>
%if !needRtmExported
%<GetHideChildDefineSymbol("endif")>
%endif
%endif
%closefile rtmTypedefs
%if SLibIsModelTypesModelClassNamespace()
%<SLibCacheCPPEncapModelData("Typedefs", rtmTypedefs)>
%else
%<SLibCacheCodeToFile("data_rtmodel_typedef", rtmTypedefs)>
%endif
%undef rtmTypedefs
%openfile rtmMacros
%assign rtmMacrosStr = RTMGenMacroDefines("PUBLIC")
%if !WHITE_SPACE(rtmMacrosStr)
/* Macros for accessing real-time model data structure */
%<rtmMacrosStr>
%endif
%closefile rtmMacros
%<SLibCacheCodeToFile("mdl_priv_rtm_macro_define", rtmMacros)>
%undef rtmMacros
%if !EmptyRealTimeObject
%openfile opaqTypedefBuf
%<RTMsGenOpaqueTypedef(::CompiledModel.System[NumSystems-1])>/
%closefile opaqTypedefBuf
%<SLibCacheCodeToFile("mdl_data_typedef", opaqTypedefBuf)>
%endif
%endfunction
%function ModelrefDumpDataFileBannerAndInclude() void
%openfile dataBanBuf
/*
* %<Name>_data.%<LangFileExt>
*
%<SLibCommonHeaderInfo()>/
*/
%closefile dataBanBuf
%openfile inclBuf
%assign fileName = SLibGetSystemOutputHdrFileBaseName(System[NumSystems-2])
#include "%<fileName>.h"
%<SLibIncludePrivateHeader()>
%closefile inclBuf
%<SLibCacheCodeToFile("mdldata_src_ban", dataBanBuf)>
%<SLibCacheCodeToFile("mdldata_src_incl", inclBuf)>
%endfunction
%function ModelrefGenSfcnAndHandleConstPrmAndBIO() void
%if IsModelReferenceSimTarget()
%include "modelrefsfcnbody.tlc"
%endif
%<ModelrefHandleConstBIOAndPrm()>
%assign dataFile = SLibGetFileRecForCode("mdldata_src")
%if !ISEMPTY(dataFile) && !SLibGetModelFileIsEmpty(dataFile)
%<ModelrefDumpDataFileBannerAndInclude()>
%if ERTCustomFileBanners
%<LibSetSourceFileCodeTemplate(dataFile,ERTDataSrcFileTemplate)>
%endif
%endif
%endfunction
%function ModelrefHandleExportFileInfo() void
%openfile mdlRefRegFcn
%if !SLibGetEmptyModelRefInitializeFcn()
/* Model reference registration function */
%if CGMODEL_ACCESS("CGModel.isIndividualFunctionMappingEnabled")
%<SLibGetFcnMemSecPragmaForFunction(GetModelRefRegistrationFcnName(), "Initialize", "", "Pre")>/
%else
%<SLibGetFcnMemSecPragmaOnDecl(GetModelRefRegistrationFcnName(), "MemSecFuncInitTerm", "Pre")>/
%endif
%<LibExternInFcnDecls()>void %<GetModelRefRegistrationFcnName()>(%<SLibModelReferenceRegFcnArgs()>);
%if CGMODEL_ACCESS("CGModel.isIndividualFunctionMappingEnabled")
%<SLibGetFcnMemSecPragmaForFunction(GetModelRefRegistrationFcnName(), "Initialize", "", "Post")>/
%else
%<SLibGetFcnMemSecPragmaOnDecl(GetModelRefRegistrationFcnName(), "MemSecFuncInitTerm", "Post")>/
%endif
%endif
%<LibDumpGroundExterns()>/
%closefile mdlRefRegFcn
%if !GenerateClassInterface
%<SLibCacheCodeToFile("baseMdl_reg_fcn_prototype", mdlRefRegFcn)>
%endif
%<ModelrefHandleRTModel()>
%endfunction