%include "utillib.tlc"
%if EXISTS("_SETUPLIB_") == 0
%assign _SETUPLIB_ = 1
%function isGRTMallocOnERT() void
%return SLibIsERTCodeFormat() && UsingMalloc
%endfunction
%function SLibSetupBasicDefaults() void
%language "C"
%assign ::matrixDimensionThreshhold = 2
%assign ::INVALID_COUNTER = -1
%assign ::INVALID_BUFFER = -1
%assign ::GenCPP = ...
(ISFIELD(::CompiledModel.ConfigSet, "TargetLang") && ...
(::CompiledModel.ConfigSet.TargetLang=="C++"))
%if ::GenCPP
%if CGMODEL_ACCESS("CGModel.isGpuCodeGen") == TLC_TRUE
%assign ::LangFileExt = "cu"
%else
%assign ::LangFileExt = "cpp"
%endif
%assign ::ExternCPrefix = "extern /"C/""
%else
%assign ::LangFileExt = "c"
%assign ::ExternCPrefix = ""
%endif
%assign ::EmulationHWComment = ""
%assign ::Memset2Zero = FEVAL("rtw_tfl_query_memset2zero", ::CompiledModel.Name)
%assign ::MatFileLogging = ::CompiledModel.ConfigSet.MatFileLogging
%assign ::AnyCross = TLC_FALSE
%assign ::ThisSubsysCross = TLC_FALSE
%assign ::GlobalCurrentTID = []
%assign ::GlobalGeneratingSubFunctions = TLC_FALSE
%assign ::CurrentModuleIdx = -1
%assign ::CurrentFunctionIdx = -1
%assign ::CurrentBlockFcnIdx = -1
%assign ::CurrentUtilsIncludesIdx = ""
%assign ::GlobalSharedUtilsIncludes = []
%assign ::IsSimBuild = FEVAL("slprivate", ...
"isSimulationBuild",LibGetModelName(),::CompiledModel.ModelReferenceTargetType)
%assign ChangeAutoForStorageClassToDefaultInComments = CGMODEL_ACCESS("CodeGenComments.AutoToDefault")
%assign ::AutoOrDefaultStorageClass = ""
%if ChangeAutoForStorageClassToDefaultInComments > 0
%assign ::AutoOrDefaultStorageClass = "default"
%else
%assign ::AutoOrDefaultStorageClass = "auto"
%endif
%endfunction
%function SLibERTFeatureSetup() void
%assign ::ConfigSet = ::CompiledModel.ConfigSet
%if !EXISTS("IgnoreCustomStorageClasses")
%assign ::IgnoreCustomStorageClasses = ConfigSet.IgnoreCustomStorageClasses
%endif
%<LibAddToCompiledModel("IgnoreCustomStorageClasses",IgnoreCustomStorageClasses)>
%<LibAddToCompiledModel("GenerateCodeInterfaceReport", TLC_FALSE)>
%if !EXISTS("IncludeMdlTerminateFcn")
%assign ::IncludeMdlTerminateFcn = ConfigSet.IncludeMdlTerminateFcn || SLibIsExportFcnDiagram()
%endif
%<LibAddToCompiledModel("IncludeMdlTerminateFcn",IncludeMdlTerminateFcn)>
%if !EXISTS("CombineOutputUpdateFcns")
%assign ::CombineOutputUpdateFcns = ConfigSet.CombineOutputUpdateFcns
%endif
%<LibAddToCompiledModel("CombineOutputUpdateFcns",CombineOutputUpdateFcns)>
%if !EXISTS("GRTInterface")
%assign ::GRTInterface = ConfigSet.GRTInterface
%endif
%<LibAddToCompiledModel("GRTInterface",GRTInterface)>
%if !EXISTS("SuppressErrorStatus")
%assign ::SuppressErrorStatus = ConfigSet.SuppressErrorStatus
%endif
%<LibAddToCompiledModel("SuppressErrorStatus",SuppressErrorStatus)>
%if !EXISTS("ZeroExternalMemoryAtStartup")
%assign ::ZeroExternalMemoryAtStartup = ConfigSet.ZeroExternalMemoryAtStartup
%endif
%<LibAddToCompiledModel("ZeroExternalMemoryAtStartup",ZeroExternalMemoryAtStartup)>
%if !EXISTS("ZeroInternalMemoryAtStartup")
%assign ::ZeroInternalMemoryAtStartup = ConfigSet.ZeroInternalMemoryAtStartup
%endif
%<LibAddToCompiledModel("ZeroInternalMemoryAtStartup",ZeroInternalMemoryAtStartup)>
%if !EXISTS("InitFltsAndDblsToZero")
%assign ::InitFltsAndDblsToZero = ConfigSet.InitFltsAndDblsToZero
%endif
%<LibAddToCompiledModel("InitFltsAndDblsToZero",InitFltsAndDblsToZero)>
%if !EXISTS("ForceBlockIOInitOptimize")
%assign ::ForceBlockIOInitOptimize = ConfigSet.ForceBlockIOInitOptimize
%endif
%<LibAddToCompiledModel("ForceBlockIOInitOptimize",ForceBlockIOInitOptimize)>
%if !EXISTS("InsertBlockDesc")
%assign ::InsertBlockDesc = ConfigSet.InsertBlockDesc
%endif
%<LibAddToCompiledModel("InsertBlockDesc",InsertBlockDesc)>
%if !EXISTS("InsertPolySpaceComments")
%assign ::InsertPolySpaceComments = ConfigSet.InsertPolySpaceComments
%endif
%<LibAddToCompiledModel("InsertPolySpaceComments",InsertPolySpaceComments)>
%if !SLibIsDeploymentDiagramType()
%if !EXISTS("SFDataObjDesc")
%assign ::SFDataObjDesc = ConfigSet.SFDataObjDesc
%endif
%<LibAddToCompiledModel("SFDataObjDesc",SFDataObjDesc)>
%endif
%if !EXISTS("SimulinkDataObjDesc")
%assign ::SimulinkDataObjDesc = ConfigSet.SimulinkDataObjDesc
%endif
%<LibAddToCompiledModel("SimulinkDataObjDesc",SimulinkDataObjDesc)>
%if !EXISTS("ERTCustomFileBanners")
%assign ::ERTCustomFileBanners = ConfigSet.ERTCustomFileBanners
%endif
%if IsModelReferenceSimTarget()
%assign ::ERTCustomFileBanners = TLC_FALSE
%endif
%<LibAddToCompiledModel("ERTCustomFileBanners",ERTCustomFileBanners)>
%if !SLibIsDeploymentDiagramType()
%if !EXISTS("DefineNamingRule")
%assign ::DefineNamingRule = ConfigSet.DefineNamingRule
%endif
%<LibAddToCompiledModel("DefineNamingRule",DefineNamingRule)>
%endif
%if !SLibIsDeploymentDiagramType()
%if !EXISTS("SignalNamingRule")
%assign ::SignalNamingRule = ConfigSet.SignalNamingRule
%endif
%<LibAddToCompiledModel("SignalNamingRule",SignalNamingRule)>
%endif
%if !SLibIsDeploymentDiagramType()
%if !EXISTS("ParamNamingRule")
%assign ::ParamNamingRule = ConfigSet.ParamNamingRule
%endif
%<LibAddToCompiledModel("ParamNamingRule",ParamNamingRule)>
%endif
%if !EXISTS("InlinedPrmAccess")
%assign ::InlinedPrmAccess = ConfigSet.InlinedPrmAccess
%endif
%<LibAddToCompiledModel("InlinedPrmAccess",InlinedPrmAccess)>
%if !EXISTS("GenerateSampleERTMain")
%assign ::GenerateSampleERTMain = ConfigSet.GenerateSampleERTMain
%endif
%<LibAddToCompiledModel("GenerateSampleERTMain",GenerateSampleERTMain)>
%if !EXISTS("MultiInstanceERTCode")
%assign ::MultiInstanceERTCode = ConfigSet.MultiInstanceERTCode
%endif
%<LibAddToCompiledModel("MultiInstanceERTCode",MultiInstanceERTCode)>
%if !EXISTS("PurelyIntegerCode")
%assign ::PurelyIntegerCode = ConfigSet.PurelyIntegerCode
%endif
%<LibAddToCompiledModel("PurelyIntegerCode",PurelyIntegerCode)>
%if !EXISTS("SupportNonFinite")
%assign ::SupportNonFinite = ConfigSet.SupportNonFinite
%endif
%<LibAddToCompiledModel("SupportNonFinite",SupportNonFinite)>
%if !EXISTS("SupportComplex")
%assign ::SupportComplex = ConfigSet.SupportComplex
%endif
%<LibAddToCompiledModel("SupportComplex",SupportComplex)>
%if !EXISTS("SupportContinuousTime")
%assign ::SupportContinuousTime = ConfigSet.SupportContinuousTime
%endif
%<LibAddToCompiledModel("SupportContinuousTime",SupportContinuousTime)>
%if !EXISTS("SupportNonInlinedSFcns")
%assign ::SupportNonInlinedSFcns = ConfigSet.SupportNonInlinedSFcns
%endif
%<LibAddToCompiledModel("SupportNonInlinedSFcns",SupportNonInlinedSFcns)>
%if !SLibIsDeploymentDiagramType()
%if !EXISTS("NoFixptDivByZeroProtection")
%assign ::NoFixptDivByZeroProtection = ConfigSet.NoFixptDivByZeroProtection
%endif
%<LibAddToCompiledModel("NoFixptDivByZeroProtection",NoFixptDivByZeroProtection)>
%endif
%if !EXISTS("CustomSymbolStrGlobalVar")
%assign ::CustomSymbolStrGlobalVar = ConfigSet.CustomSymbolStrGlobalVar
%endif
%<LibAddToCompiledModel("CustomSymbolStrGlobalVar",CustomSymbolStrGlobalVar)>
%if !EXISTS("CustomSymbolStrType")
%assign ::CustomSymbolStrType = ConfigSet.CustomSymbolStrType
%endif
%<LibAddToCompiledModel("CustomSymbolStrType",CustomSymbolStrType)>
%if !EXISTS("CustomSymbolStrField")
%assign ::CustomSymbolStrField = ConfigSet.CustomSymbolStrField
%endif
%<LibAddToCompiledModel("CustomSymbolStrField",CustomSymbolStrField)>
%if !EXISTS("CustomSymbolStrFcn")
%assign ::CustomSymbolStrFcn = ConfigSet.CustomSymbolStrFcn
%endif
%<LibAddToCompiledModel("CustomSymbolStrFcn",CustomSymbolStrFcn)>
%if !EXISTS("CustomSymbolStrBlkIO")
%assign ::CustomSymbolStrBlkIO = ConfigSet.CustomSymbolStrBlkIO
%endif
%<LibAddToCompiledModel("CustomSymbolStrBlkIO",CustomSymbolStrBlkIO)>
%if !EXISTS("CustomSymbolStrTmpVar")
%assign ::CustomSymbolStrTmpVar = ConfigSet.CustomSymbolStrTmpVar
%endif
%<LibAddToCompiledModel("CustomSymbolStrTmpVar",CustomSymbolStrTmpVar)>
%if !EXISTS("CustomSymbolStrMacro")
%assign ::CustomSymbolStrMacro = ConfigSet.CustomSymbolStrMacro
%endif
%<LibAddToCompiledModel("CustomSymbolStrMacro",CustomSymbolStrMacro)>
%if !EXISTS("ReqsInCode")
%assign ::ReqsInCode = ConfigSet.ReqsInCode
%endif
%<LibAddToCompiledModel("ReqsInCode",ReqsInCode)>
%if !EXISTS("ProdEqTarget")
%assign ::ProdEqTarget = ConfigSet.ProdEqTarget
%endif
%<LibAddToCompiledModel("ProdEqTarget",ProdEqTarget)>
%if !EXISTS("PortableWordSizes")
%assign ::PortableWordSizes = ConfigSet.PortableWordSizes
%endif
%<LibAddToCompiledModel("PortableWordSizes",PortableWordSizes)>
%assign HardwareBoardNone = ISEQUAL(::CompiledModel.ConfigSet.HardwareBoard,"None")
%if !SLibIsERTTarget() && !GRTInterface && !SLibSingleTasking() && HardwareBoardNone
%assign ::InlineSetEventsForThisBaseRateFcn = TLC_TRUE
%elseif !EXISTS("InlineSetEventsForThisBaseRateFcn")
%assign ::InlineSetEventsForThisBaseRateFcn = TLC_FALSE
%endif
%<LibAddToCompiledModel("InlineSetEventsForThisBaseRateFcn", InlineSetEventsForThisBaseRateFcn)>
%assign HardwareBoardNone = ISEQUAL(::CompiledModel.ConfigSet.HardwareBoard,"None")
%if (!SLibIsERTTarget() || SLibAutosarActive()) && !GRTInterface && !SLibSingleTasking() && HardwareBoardNone
%assign ::SuppressMultiTaskScheduler = TLC_TRUE
%else
%if !EXISTS("SuppressMultiTaskScheduler")
%assign ::SuppressMultiTaskScheduler = TLC_FALSE
%else
%assign ::SuppressMultiTaskScheduler = SuppressMultiTaskScheduler && !SLibSingleTasking() ...
&& !SLibIsExportFcnDiagram()
%endif
%endif
%<LibAddToCompiledModel("SuppressMultiTaskScheduler",SuppressMultiTaskScheduler)>
%createrecord CoderDataGroups {}
%createrecord CoderGroupInitLoop {}
%createrecord ChildGroupMap {}
%createrecord ChildGroupInitInForEachMap {}
%<LibAddToCompiledModel("CoderDataGroups", CoderDataGroups)>
%<LibAddToCompiledModel("CoderGroupInitLoop", CoderGroupInitLoop)>
%<LibAddToCompiledModel("ChildGroupMap", ChildGroupMap)>
%<LibAddToCompiledModel("ChildGroupInitInForEachMap", ChildGroupInitInForEachMap)>
%<LibAddToCompiledModel("ChildCoderDataGroupAssignmentForRegistration", "")>
%<LibAddToCompiledModel("ChildCoderDataGroupAssignmentForParamTs", "")>
%<LibAddToCompiledModel("ChildCoderDataGroupMemcpy", "")>
%assign ancestorAllocatesCoderDataGroups = TLC_FALSE
%foreach idx = ::CompiledModel.NumCoderDataGroups
%if !SLibAllocatesCoderDataGroup(::CompiledModel.CoderDataGroup[idx])
%assign ancestorAllocatesCoderDataGroups = TLC_TRUE
%break
%endif
%endforeach
%<LibAddToCompiledModel("AncestorAllocatesCoderDataGroups", ...
ancestorAllocatesCoderDataGroups)>
%if !EXISTS("SuppressSetEventsForThisBaseRateFcn")
%assign ::SuppressSetEventsForThisBaseRateFcn = 0
%endif
%if IsModelReferenceTarget()
%assign ::SuppressSetEventsForThisBaseRateFcn = 1
%endif
%<LibAddToCompiledModel("SuppressSetEventsForThisBaseRateFcn",...
SuppressSetEventsForThisBaseRateFcn)>
%if !EXISTS("GenerateClassInterface")
%if SLibRTWCPPClassActive()
%assign ::GenerateClassInterface = TLC_TRUE
%else
%assign ::GenerateClassInterface = TLC_FALSE
%endif
%endif
%if GenerateClassInterface
%assert GenCPP
%assert MultiInstanceERTCode
%if EXISTS(ExportFunctionsMode) && ExportFunctionsMode != 0
%<SLibReportErrorWithId("RTW:tlc:NoCppExportFcn")>
%endif
%endif
%if !EXISTS(ERTMainAccess)
%assign ::ERTMainAccess = TLC_FALSE
%endif
%if ::CombineOutputUpdateFcns == 1 && ...
(::CompiledModel.ConfigSet.MatFileLogging || ...
EXISTS("ExtMode") && ExtMode == 1)
%assign ::IncludeLoggingInstrumentation = TLC_TRUE
%else
%assign ::IncludeLoggingInstrumentation = TLC_FALSE
%endif
%assign usingMalloc = 0
%if ISFIELD(::CompiledModel,"RTWGenSettings")
%if ISFIELD(::CompiledModel.RTWGenSettings,"UsingMalloc")
%if ::CompiledModel.RTWGenSettings.UsingMalloc == "yes"
%assign usingMalloc = 1
%endif
%endif
%endif
%if ISFIELD(::CompiledModel.ConfigSet,"GenerateAllocFcn") && ...
::CompiledModel.ConfigSet.GenerateAllocFcn == TLC_TRUE
%assign usingMalloc = 1
%if !MultiInstanceERTCode
%<SLibReportErrorWithId("RTW:tlc:AllocFcnMultiInstance")>
%endif
%endif
%assign ::UsingMalloc = usingMalloc
%<LibAddToCompiledModel("UsingMalloc", UsingMalloc)>
%if MultiInstanceERTCode
%if !EXISTS("MultiInstanceErrorCode") && ISFIELD(::CompiledModel.ConfigSet,"MultiInstanceErrorCode")
%assign ::MultiInstanceErrorCode = ::CompiledModel.ConfigSet.MultiInstanceErrorCode
%endif
%endif
%assign hasStandSystem = TLC_FALSE
%assign numSystems = ::CompiledModel.NumSystems
%foreach idx = numSystems
%assign sys = ::CompiledModel.System[idx]
%<LibAddToSystem(sys, "NeedCPIInDisable", 0)>
%<LibAddToSystem(sys, "NeedCPIInEnable", 0)>
%if sys.StandaloneSubsystem == 1
%assign hasStandSystem = TLC_TRUE
%<LibAddToSystem(sys, "StandaloneConstBlockIOInit", "")>
%<LibAddToSystem(sys, "StandaloneParameterInit", "")>
%foreach idx = ::CompiledModel.NumCoderDataGroups
%if SLibDataGroupStaticInit(::CompiledModel.CoderDataGroup[idx])
%assign groupName = ::CompiledModel.CoderDataGroup[idx].Name
%assign groupToken = "CoderDataGroup" + groupName
%<LibAddToSystem(sys, "Standalone" + groupToken + "Init", "")>
%endif
%endforeach
%<LibAddToSystem(sys, "StandaloneDataInit", "")>
%<LibAddToSystem(sys, "CachedInitializeDataBody", "")>
%<LibAddToSystem(sys, "TempInitBuffer", "")>
%<LibAddToSystem(sys, "CachedNonFiniteParamAssignments", "")>
%<LibAddToSystem(sys, "CachedNonFiniteBlockIOAssignments", "")>
%elseif sys.FileNameOwnerIdx != numSystems && (sys.RTWSystemCode == 1 || sys.RTWSystemCode == 2)
%<LibAddToSystem(sys, "TempInitBuffer", "")>
%<LibAddToSystem(sys, "CachedInitializeDataBody", "")>
%endif
%endforeach
%<LibAddToCompiledModel("HasStandaloneSubsystem",hasStandSystem)>
%<LibAddToCompiledModel("HasBlockIOArg", 0)>
%<LibAddToCompiledModel("HasConstBlockIOArg", 0)>
%<LibAddToCompiledModel("HasDWorkArg", 0)>
%<LibAddToCompiledModel("HasParametersArg", 0)>
%<LibAddToCompiledModel("HasZCEventArg", 0)>
%foreach idx = ::CompiledModel.NumCoderDataGroups
%assign groupToken = "HasCoderDataGroup" + ::CompiledModel.CoderDataGroup[idx].Name + "Arg"
%<LibAddToCompiledModel(groupToken, 0)>
%endforeach
%if !EXISTS(CalledTflTlcCallbacks)
%assign ::CalledTflTlcCallbacks = ""
%else
%assign ::CalledTflTlcCallbacks = CalledTflTlcCallbacks
%endif
%if (!SLibIsERTTarget())
%if (IgnoreCustomStorageClasses == 0)
%assign ::ShowErrorStackTrace = TLC_TRUE
%<SLibReportErrorWithId("RTW:tlc:CSCNeedERT")>
%endif
%if (IncludeMdlTerminateFcn == 0) && !SLibIsExportFcnDiagram()
%assign errMsg = "To suppress generating model terminate function, you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (SuppressErrorStatus == 1)
%assign errMsg = "To suppress error status codes, you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (SuppressMultiTaskScheduler == 1) && (GRTInterface == 1)
%assign errMsg = "To suppress scheduler with classic call interface, "...
"you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (ZeroExternalMemoryAtStartup == 0) && !::GenerateClassInterface
%assign errMsg = "To remove root i/o zero initialization, you need to use an "...
"ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (ZeroInternalMemoryAtStartup == 0) && !::GenerateClassInterface
%assign errMsg = "To remove internal state zero initialization, you need to "...
"use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (InsertBlockDesc == 1)
%assign errMsg = "To include block description in the generated code, you "...
"need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if EXISTS("SFDataObjDesc") && (SFDataObjDesc == 1)
%assign errMsg = "To include description for stateflow data object in the "...
"generated code, you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (SimulinkDataObjDesc == 1)
%assign errMsg = "To include description for Simulink data object in the "...
"generated code, you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (ERTCustomFileBanners == 1)
%assign errMsg = "To generate customize file banners, you need to use an ERT "...
"or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if EXISTS(DefineNamingRule) && (DefineNamingRule != "None")
%assign errMsg = "To apply naming rule to #define declaration, you need to "...
"use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if EXISTS("SignalNamingRule") && (SignalNamingRule != "None")
%assign errMsg = "To apply naming rule to signal declaration, you need to use "...
"an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if EXISTS("ParamNamingRule") && (ParamNamingRule != "None")
%assign errMsg = "To apply naming rule to parameter declaration, you need to "...
"use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (InlinedPrmAccess != "Literals")
%assign errMsg = "To access inlined parameters through macros, you need to "...
"use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if EXISTS("GenerateSampleERTMain") && (GenerateSampleERTMain == 1)
%assign errMsg = "To generate sample ert main, you need to use an ERT or "...
"ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (PurelyIntegerCode == 1)
%assign errMsg = "To generate purely integer code, you need to use an ERT "...
"or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (SupportComplex == 0)
%assign errMsg = "To suppress complex math support, you need to use an "...
"ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (SupportContinuousTime == 0)
%assign errMsg = "To suppress continuous time support, you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (SupportNonInlinedSFcns == 0)
%assign errMsg = "To suppress non-inlined s-function support, you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if EXISTS(NoFixptDivByZeroProtection) && (NoFixptDivByZeroProtection == 1)
%assign errMsg = "To remove code that protects division against "...
"arithmetic exceptions, you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%if (CustomSymbolStrGlobalVar != "$R$N$M" || ...
CustomSymbolStrType != "$N$R$M_T" || ...
(CustomSymbolStrField != "$N$M" && CustomSymbolStrField != "$H$N$M")|| ...
(CustomSymbolStrBlkIO != "rtb_$N$M" && CustomSymbolStrBlkIO != "rtb_$H$N$M") || ...
CustomSymbolStrTmpVar != "$N$M" || ...
(CustomSymbolStrFcn != "$R$N$M$F" && CustomSymbolStrFcn != "$R$H$N$M$F")|| ...
CustomSymbolStrMacro != "$R$N$M")
%assign errMsg = "To customize the symbol mangling rule, "...
"you need to use an ERT or ERT-based target."
%<LibReportFatalError(errMsg)>
%endif
%endif
%assign targetCannotHaveTIDArg = GenerateClassInterface || SLibFcnProtoCtrlActive()
%if EXISTS(ERTRemoveTidArgForSingleTaskingModel)
%if !ERTRemoveTidArgForSingleTaskingModel && targetCannotHaveTIDArg
%assign errMsg = "Function Prototype Control or C++ class interface: "...
"-a option ERTRemoveTidArgForSingleTaskingModel = 0 is not supported."...
"Consider removing this option "
%<LibReportFatalError(errMsg)>
%endif
%else
%assign ::ERTRemoveTidArgForSingleTaskingModel = TLC_TRUE
%endif
%endfunction
%function SLibSetupDiagnosticDefaults() void
%if !EXISTS("RTWVerbose")
%assign ::RTWVerbose = 1
%endif
%if !EXISTS("ShowObsoleteWarnings")
%assign ::ShowObsoleteWarnings = 0
%endif
%if !EXISTS("WarnNonSaturatedBlocks")
%assign ::WarnNonSaturatedBlocks = 2
%endif
%if !EXISTS("ResetTLCGlobalsAfterUse")
%assign ::ResetTLCGlobalsAfterUse = 1
%endif
%endfunction
%function SLibSetupPrintStatusMsgs(statusID) void
%if !RTWVerbose
%return
%endif
%selectfile STDOUT
%switch statusID
%case "libload"
### Loading TLC function libraries
%break
%default
%break
%endswitch
%selectfile NULL_FILE
%endfunction
%function SLibSetupLayoutOptions() void
%assert (!IsModelReferenceTarget() || GenerateSampleERTMain == 0)
%assert (!IsModelReferenceTarget() || MultiInstanceERTCode == 0 || GenerateClassInterface || ...
(MultiInstanceERTCode == 1 && UsingMalloc))
%if !EXISTS("MultiInstanceErrorCode")
%assign ::MultiInstanceErrorCode = "None"
%endif
%<LibAddToCompiledModel("MultiInstanceErrorCode",MultiInstanceErrorCode)>
%if !EXISTS("RootIOStructures")
%if GenerateClassInterface
%assign ::RootIOStructures = 1
%else
%assign ::RootIOStructures = 0
%endif
%endif
%<LibAddToCompiledModel("RootIOStructures",RootIOStructures)>
%if SLibIsERTTarget() && ISFIELD(::CompiledModel.ConfigSet, "RootIOFormat")
%<LibAddToCompiledModel("RootIOFormat", ::CompiledModel.ConfigSet.RootIOFormat)>
%else
%<LibAddToCompiledModel("RootIOFormat", "Individual arguments")>
%endif
%if !EXISTS("GenerateEnableDisable")
%assign ::GenerateEnableDisable = 0
%endif
%<LibAddToCompiledModel("GenerateEnableDisable", GenerateEnableDisable)>
%if EXISTS("ExtMode") && ...
ExtMode == 1 && ...
SuppressErrorStatus == 1
%assign errMsg = "Cannot select ERT option 'Remove error status field in " + ...
"real-time model data structure' when selecting ERT option 'External mode'"
%<LibReportFatalError(errMsg)>
%endif
%if !EXISTS("ExportFunctionsMode")
%assign ::ExportFunctionsMode = 0
%endif
%if !EXISTS("GenerateComments")
%assign ::GenerateComments = 1
%endif
%<LibAddToCompiledModel("GenerateComments",GenerateComments)>
%if !EXISTS("ForceParamTrailComments")
%assign ::ForceParamTrailComments = 0
%endif
%<LibAddToCompiledModel("ForceParamTrailComments", ForceParamTrailComments)>
%if !EXISTS("ShowEliminatedStatements")
%assign ::ShowEliminatedStatements = 1
%endif
%<LibAddToCompiledModel("ShowEliminatedStatements", ShowEliminatedStatements)>
%if !EXISTS("HaveSeparateSourceFiles")
%assign ::HaveSeparateSourceFiles = 0
%endif
%<LibAddToCompiledModel("HaveSeparateSourceFiles", HaveSeparateSourceFiles)>
%if !EXISTS("ProtectCallInitFcnTwice")
%assign ::ProtectCallInitFcnTwice = 0
%endif
%<LibAddToCompiledModel("ProtectCallInitFcnTwice", ProtectCallInitFcnTwice)>`
%if !EXISTS("GenerateInterfaceAPI")
%assign ::GenerateInterfaceAPI = 0
%endif
%<LibAddToCompiledModel("GenerateInterfaceAPI", GenerateInterfaceAPI)>
%if !EXISTS("GenerateASAP2")
%assign ::GenerateASAP2 = 0
%endif
%<LibAddToCompiledModel("GenerateASAP2", GenerateASAP2)>
%if GenerateASAP2 == 1
%assign ::CompiledModel.GenerateInterfaceAPI = 1
%endif
%if !EXISTS("GenerateMDX")
%assign ::GenerateMDX = 0
%endif
%<LibAddToCompiledModel("GenerateMDX", GenerateMDX)>
%if !EXISTS("InlineParameters")
%assign ::InlineParameters = 0
%endif
%<LibAddToCompiledModel("InlineParameters", InlineParameters)>
%if !EXISTS("InlineInvariantSignals")
%if InlineParameters == 1
%assign ::InlineInvariantSignals = 1
%else
%assign ::InlineInvariantSignals = 0
%endif
%endif
%<LibAddToCompiledModel("InlineInvariantSignals", InlineInvariantSignals)>
%if !EXISTS("MaxStackSize")
%assign ::MaxStackSize = rtInf
%else
%if EXISTS("DivideStackByRate") && DivideStackByRate == TLC_TRUE
%assign ::MaxStackSize = MaxStackSize / ::CompiledModel.NumRuntimeExportedRates
%endif
%endif
%<LibAddToCompiledModel("MaxStackSize", MaxStackSize)>
%if !EXISTS("MaxStackVariableSize")
%assign ::MaxStackVariableSize = rtInf
%endif
%<LibAddToCompiledModel("MaxStackVariableSize", MaxStackVariableSize)>
%if !EXISTS("DoAsserts")
%assign ::DoAsserts = 0
%endif
%<LibAddToCompiledModel("DoAsserts", DoAsserts)>
%if !EXISTS("RateBasedStepFcn")
%assign ::RateBasedStepFcn = 0
%endif
%<LibAddToCompiledModel("RateBasedStepFcn", RateBasedStepFcn)>
%assign rootSystem = ::CompiledModel.System[CompiledModel.NumSystems-1]
%if LibIsSingleRateSystem(rootSystem)
%assign singleRate = 1
%else
%assign singleRate = 0
%endif
%<LibAddToCompiledModel("RootSystemIsSingleRate", singleRate)>
%endfunction
%function SLibSetupRollingInfo() void
%if !EXISTS("RollThreshold")
%assign ::RollThreshold = 5
%endif
%<LibAddToCompiledModel("RollThreshold", RollThreshold)>
%if !ISFIELD(::CompiledModel, "LoopControlIdx")
%<LibAddToCompiledModel("LoopControlIdx", 0)>
%endif
%if !ISFIELD(::CompiledModel, "CurrentLoopOffset")
%<LibAddToCompiledModel("CurrentLoopOffset", 0)>
%endif
%if !ISFIELD(::CompiledModel, "CurrentSymbolicLoopOffset")
%<LibAddToCompiledModel("CurrentSymbolicLoopOffset", "")>
%endif
%if !ISFIELD(::CompiledModel, "CurrentRollRegionOffset")
%<LibAddToCompiledModel("CurrentRollRegionOffset", -1)>
%endif
%if !ISFIELD(::CompiledModel, "RollInputIsWritable")
%<LibAddToCompiledModel("RollInputIsWritable", 0)>
%endif
%endfunction
%function SLibSetupLoggingInfo() void
%if MatFileLogging == 1 && IsModelReferenceTarget()
%<SLibReportErrorWithId("RTW:tlc:NoMdlRefMatFileLogging")>
%endif
%<LibAddToCompiledModel("MatFileLogging", MatFileLogging)>
%assert EXISTS(MultiInstanceERTCode) && EXISTS(MultiInstanceErrorCode)
%if ( MatFileLogging && MultiInstanceERTCode && (GenerateClassInterface || !UsingMalloc) )
%if MultiInstanceErrorCode == "Warning"
%<SLibReportWarningWithId("RTW:tlc:MatFileLoggingNotForGenReusableCodeWarning")>
%elseif MultiInstanceErrorCode == "Error"
%<SLibReportErrorWithId("RTW:tlc:MatFileLoggingNotForGenReusableCodeError")>
%endif
%endif
%if !EXISTS("LogVarNameModifier")
%assign ::LogVarNameModifier = "rt_"
%endif
%<LibAddToCompiledModel("LogVarNameModifier", LogVarNameModifier)>
%if !EXISTS("BlockIOSignals")
%assign ::BlockIOSignals = 0
%endif
%if !EXISTS("ParameterTuning")
%assign ::ParameterTuning = 0
%endif
%if EXISTS(::ErrorXMLMode)
%assign ::CompiledModel.ErrorXMLMode = ::ErrorXMLMode
%endif
%if IsModelReferenceSimTarget()
%assign ::RTWMaxStringLength = 2000
%else
%if !EXISTS("RTWMaxStringLength")
%assign ::RTWMaxStringLength = 509
%endif
%endif
%endfunction
%function FcnSetupHdrsAndSources() void
%assign numSrcs = 0
%<LibAddToCompiledModel("Sources", [])>
%<LibAddToCompiledModel("StaticSources", [])>
%<LibAddToCompiledModel("ReusableLibSources", [])>
%if !IsModelReferenceTarget()
%assign ::CompiledModel.Sources = CompiledModel.Sources+LibGetMdlSrcBaseName()
%assign numSrcs = 1
%endif
%<LibAddToCompiledModel("NumSources", numSrcs)>
%<LibAddToCompiledModel("NumStaticSources", 0)>
%<LibAddToCompiledModel("NumReusableLibSources", 0)>
%<LibAddToCompiledModel("Headers", [])>
%<LibAddToCompiledModel("NumHeaders", 0)>
%<LibAddToCompiledModel("SysPathHeaders", [])>
%<LibAddToCompiledModel("NumSysPathHeaders", 0)>
%<LibAddToCompiledModel("SysLocalHeaders", [])>
%<LibAddToCompiledModel("NumSysLocalHeaders", 0)>
%<LibAddToCompiledModel("BlockPathHeaders", [])>
%<LibAddToCompiledModel("NumBlockPathHeaders", 0)>
%<LibAddToCompiledModel("BlockLocalHeaders", [])>
%<LibAddToCompiledModel("NumBlockLocalHeaders", 0)>
%<LibAddToCompiledModel("NonSharedPathHeaders", [])>
%<LibAddToCompiledModel("NumNonSharedPathHeaders", 0)>
%<LibAddToCompiledModel("NonSharedLocalHeaders", [])>
%<LibAddToCompiledModel("NumNonSharedLocalHeaders", 0)>
%endfunction
%function SLibSetupCodeGenTrackingFields() void
%assign tmpVar = FunctionNamesRepository { dummy 1 }
%<LibAddToCompiledModel("FunctionNamesRepository", FunctionNamesRepository)>
%<LibAddToCompiledModel("IntegerSizesExists", EXISTS("IntegerSizes"))>
%if ::CompiledModel.IntegerSizesExists
%switch IntegerSizes.IntNumBits
%case 8
%case 16
%case 32
%assign ::TargetMaxInt = INT%<IntegerSizes.IntNumBits>MAX
%assign ::TargetMaxUInt = UINT%<IntegerSizes.IntNumBits>MAX
%break
%default
%assign ::TargetMaxInt = (1 << (IntegerSizes.IntNumBits-1)) - 1
%assign ::TargetMaxUInt = (TargetMaxInt << 1) + 1
%endswitch
%else
%assign ::TargetMaxInt = 0
%assign ::TargetMaxUInt = 0
%endif
%<LibAddToCompiledModel("GeneratingDeadCode", 0)>
%<LibAddToCompiledModel("GeneratingOutputsCode", 0)>
%<LibAddToCompiledModel("NumChildSFunctions", 0)>
%<LibAddToCompiledModel("ChildSFunctionList", [])>
%<LibAddToCompiledModel("NeedRealInf", 0)>
%<LibAddToCompiledModel("NeedRealMinusInf", 0)>
%<LibAddToCompiledModel("NeedRealNaN", 0)>
%<FcnSetupHdrsAndSources()>
%<LibAddToCompiledModel("NeedTID", 0)>
%<LibAddToCompiledModel("CustomCodeNeedTID", TLC_FALSE)>
%<LibAddToCompiledModel("NeedFirstTime", 0)>
%<LibAddToCompiledModel("EmptyModelRefInitializeFcn", 0)>
%endfunction
%function SLibNeedGenerateGRTWrapper() void
%assign retVal = TLC_FALSE
%assign ::isGRTMalloc = TLC_FALSE
%if CodeFormat == "RealTime" || CodeFormat == "RealTimeMalloc" || (CodeFormat == "Embedded-C" && !SLibIsERTTarget())
%if UsingMalloc
%if GenRTModel
%assert ::MultiInstanceERTCode == 1
%assign ::RootIOStructures = 1
%assign ::CompiledModel.RootIOStructures = 1
%assign ::CompiledModel.HasSimStructVars = 0
%assign ::CompiledModel.RootIOFormat = "Part of model data structure"
%else
%assign errMsg = "Real-Time malloc target doesn't support SimStruct, target "...
"must use rtModel. Malloc based targets must not have GenRTModel = 0 in " ...
"sytem target file."
%<LibReportFatalError(errMsg)>
%endif
%if CodeFormat == "RealTimeMalloc"
%assign ::isGRTMalloc = TLC_TRUE
%endif
%endif
%if GenRTModel && !IsModelReferenceTarget()
%assign ::CodeFormat = "Embedded-C"
%assign retVal = TLC_TRUE
%assign ::TargetOS = "BareBoardExample"
%assign ::CombineOutputUpdateFcns = 0
%if ::GRTInterface==TLC_FALSE
%assign retVal = TLC_FALSE
%assign ::CombineOutputUpdateFcns = ConfigSet.CombineOutputUpdateFcns
%endif
%endif
%elseif SLibIsERTCodeFormat() && !IsModelReferenceTarget()
%assign retVal = ::CompiledModel.ConfigSet.GRTInterface
%if retVal
%if CombineOutputUpdateFcns
%<SLibReportErrorWithId("RTW:tlc:GRTInterface")>
%endif
%if PurelyIntegerCode
%<SLibReportErrorWithId("RTW:tlc:GRTInterface2")>
%endif
%endif
%if UsingMalloc
%assert ::MultiInstanceERTCode == 1
%if ::CompiledModel.RootIOFormat == "Part of model data structure" || ...
::CompiledModel.RootIOFormat == "Structure reference"
%assign ::RootIOStructures = 1
%assign ::CompiledModel.RootIOStructures = 1
%else
%assign ::RootIOStructures = 0
%assign ::CompiledModel.RootIOStructures = 0
%endif
%assign ::CompiledModel.HasSimStructVars = 0
%endif
%endif
%if retVal
%if EXISTS(MultiInstanceERTCode) && MultiInstanceERTCode && !isGRTMalloc
%<SLibReportErrorWithId("RTW:tlc:GRTInterface3")>
%endif
%foreach tid = ::CompiledModel.NumRuntimeExportedRates
%<SLibSetNeedFloatAbsoluteTime(tid)>
%endforeach
%endif
%assign ::SeparateRegistrationFcn = 0
%assign ::PackageModelDataIntoRTM = 0
%if retVal==TLC_TRUE || ::UsingMalloc
%assign ::SeparateRegistrationFcn = 1
%endif
%if ::UsingMalloc
%assign ::PackageModelDataIntoRTM = 1
%endif
%return retVal
%endfunction
%function SLibSetupCodeFormat() void
%<SLibSetupSharedGlobalVariables()>
%if !EXISTS("CodeFormat")
%assign ::CodeFormat = "RealTime"
%endif
%if !EXISTS("_RSIM_")
%assign ::isRSim = TLC_FALSE
%else
%assign ::isRSim = TLC_TRUE
%endif
%if !EXISTS("_RSIM_FULL_")
%assign ::isRSimWithSolverModule = TLC_FALSE
%else
%assign ::isRSimWithSolverModule = TLC_TRUE
%endif
%if !EXISTS("_RACCEL_")
%assign ::isRAccel = TLC_FALSE
%else
%assign ::isRAccel = TLC_TRUE
%endif
%if ::isRAccel
%assign ::raccelObserverLog = ...
::CompiledModel.ObserversInstrumentationInjection
%else
%assign ::raccelObserverLog = 0
%endif
%if !EXISTS("SLCGUseRTWContext")
%assign ::SLCGUseRTWContext = 0
%endif
%if SLibIsERTCodeFormat()
%assign ::GenRTModel = 1
%endif
%if !EXISTS(GenRTModel)
%assign ::GenRTModel = 0
%endif
%if (GenRTModel == 0) && EXISTS("_GRT_")
%assign warnMsg = "Support of SimStruct will be discontinued "...
"for the Real-Time code format. Real-Time based target must use rtModel in "...
"a future release. Please follow the instructions for "...
"'Converting Your Target to Use rtModel' in the Users Guide of "...
"Simulink Coder to update your target"
%<LibReportWarning(warnMsg)>
%endif
%if EXISTS("ExtMode") && ...
ISFIELD(::CompiledModel.ConfigSet, "ExtModeMexFile") && ...
(::CompiledModel.ConfigSet.ExtModeMexFile == "ext_xcp")
%assign ::ExtModeXCP = TLC_TRUE
%else
%assign ::ExtModeXCP = TLC_FALSE
%endif
%if !EXISTS("ExtModeXCPClassicInterface")
%assign ::ExtModeXCPClassicInterface = !GenerateSampleERTMain
%endif
%if EXISTS("ExtMode") && (ExtMode == 1) && ExtModeXCP
%if ExtModeXCPClassicInterface == 1
%if !FEVAL("rtw.connectivity.Utils.buildInfoAddSrcFileToExtModeGroup", ::CompiledModel.Name, "xcp_ext_work.c")
%<SLibReportErrorWithId("RTW:tlc:ExtModeModifyBuildInfo")>
%endif
%else
%if !FEVAL("rtw.connectivity.Utils.buildInfoAddSrcFileToExtModeGroup", ::CompiledModel.Name, "xcp_ext_mode.c")
%<SLibReportErrorWithId("RTW:tlc:ExtModeModifyBuildInfo")>
%endif
%endif
%endif
%if !EXISTS("ExtMode") || ...
(EXISTS("xPC") && (xPC == 1)) || ...
(EXISTS("slrealtime") && (slrealtime == 1)) || ...
(ISFIELD(::CompiledModel.ConfigSet, "ExtModeIntrfLevel") && ...
::CompiledModel.ConfigSet.ExtModeIntrfLevel != "Level1" && ...
!ExtModeXCP)
%assign ::ExtMode = 0
%endif
%if ExtMode == 1 || isRSim
%assign ::CompiledModel.HaveSeparateSourceFiles = 1
%endif
%assign ::CreateTransitionTable = 0
%if ((ExtMode == 1) && !ExtModeXCP) || ...
((isRSim && !IsModelReferenceTarget() && RSIM_PARAMETER_LOADING == 1))
%assign ::CreateTransitionTable = 1
%endif
%assign ::CreateExtModeTaskInfo = 0
%assign ::CreateExtModeTypes = 0
%if (ExtMode == 1) && ExtModeXCP
%assign ::CreateExtModeTaskInfo = 1
%assign ::CreateExtModeTypes = 1
%endif
%if SLibNeedGenerateGRTWrapper()
%assign ::GenerateGRTWrapper = TLC_TRUE
%addtorecord ::CompiledModel GRTWrapper ""
%addtorecord ::CompiledModel GRTWrapperFcnDef ""
%if ::CompiledModel.HasStandaloneSubsystem
%<SLibReportErrorWithId("RTW:tlc:GRTInterface4")>
%endif
%else
%assign ::GenerateGRTWrapper = TLC_FALSE
%endif
%assign name = "rtCP"
%<LibAddToCompiledModel("tUnstructConstParameters", name)>
%<LibAddToCompiledModel("HasSharedConstants", TLC_FALSE)>
%if EXISTS("SimstructBasedTarget") && ...
(SimstructBasedTarget == TLC_FALSE && GenRTModel == 0)
%<SLibReportErrorWithId("RTW:tlc:SimStructBasedTarget")>
%endif
%if !EXISTS("SimstructBasedTarget")
%if ::GenRTModel == 0
%assign ::SimstructBasedTarget = TLC_TRUE
%else
%assign ::SimstructBasedTarget = TLC_FALSE
%endif
%endif
%if (IsModelReferenceTarget() && IsSimstructBasedTarget())
%assign ::ModelReferenceForASimstructBasedTarget = TLC_TRUE
%assert (EXISTS("tMdlRefSfcnS"))
%else
%assign ::ModelReferenceForASimstructBasedTarget = TLC_FALSE
%endif
%if IsModelReferenceRTWTarget()
%if !( SLibIsERTCodeFormat() || ...
CodeFormat == "RealTime" || ...
isRSim ) || ...
UsingMalloc
%<SLibReportErrorWithIdAndArgs("RTW:tlc:MRCodeFormat", CodeFormat)>
%endif
%assign ::CodeFormat = "Embedded-C"
%if ::GenRTModel == 0
%assign ::GenRTModel = 1
%assign msgTxt = "### Turning on GenRTModel setting to use " ...
"rtModel data structure"
%<LibWriteToStandardOutput(msgTxt)>
%endif
%endif
%assign ::NumModelBlocksWithCAPI = 0
%if HasModelReferenceBlocks()
%if !SLibIsERTCodeFormat() && !::SimstructBasedTarget
%<SLibReportErrorWithId("RTW:tlc:InvalidSTF")>
%endif
%assign mdlRefBlks = ::CompiledModel.ModelReferenceBlocks
%assign nMdlRefBlks = SIZE(mdlRefBlks,0)
%foreach rowIdx = nMdlRefBlks
%assign mdlRefInfo = mdlRefBlks[rowIdx]
%assign mdlBlk = ::CompiledModel.System[mdlRefInfo[0]].Block[mdlRefInfo[1]]
%if mdlBlk.ParamSettings.SupportsCAPI
%assign ::NumModelBlocksWithCAPI = ::NumModelBlocksWithCAPI + 1
%endif
%endforeach
%endif
%<LibAddToCompiledModel("CodeFormat", CodeFormat)>
%assign ::GenerateInitCodeRemoved = TLC_FALSE
%if !EXISTS(TargetRegistMutexOp)
%assign ::TargetRegistMutexOp = 0
%endif
%if !EXISTS(TargetRegistSynchroOp)
%assign ::TargetRegistSynchroOp = 0
%endif
%switch CodeFormat
%case "RealTime"
%assign IOQualifier = "."
%if UsingMalloc != 0
%assign errTxt = "UsingMalloc setting passed in from gensettings " ...
"is not consistent with selected CodeFormat"
%<LibReportFatalError(errTxt)>
%endif
%break
%case "RealTimeMalloc"
%assign IOQualifier = "->"
%if UsingMalloc != 1
%assign errTxt = "UsingMalloc setting passed in from gensettings " ...
"is not consistent with selected CodeFormat"
%<LibReportFatalError(errTxt)>
%endif
%break
%case "Embedded-C"
%if UsingMalloc
%assign IOQualifier = "->"
%else
%assign IOQualifier = "."
%endif
%if UsingMalloc != 0 && !SLibIsERTCodeFormat()
%assign errTxt = "UsingMalloc setting passed in from gensettings " ...
"is not consistent with selected CodeFormat"
%<LibReportFatalError(errTxt)>
%endif
%break
%case "S-Function"
%assign IOQualifier = "->"
%if UsingMalloc != 1
%assign errTxt = "UsingMalloc setting passed in from gensettings " ...
"is not consistent with selected CodeFormat"
%<LibReportFatalError(errTxt)>
%endif
%if !Accelerator
%assign ::CompiledModel.Name = "%<CompiledModel.Name>_sf"
%else
%assign ::CompiledModel.Name = "%<CompiledModel.Name>_acc"
%endif
%break
%default
%<SLibReportErrorWithIdAndArgs("RTW:tlc:UnknownCodeFormat", CodeFormat)>
%endswitch
%assign errTxt = "Must specify UsingMalloc as 0 or 1."
%if !EXISTS("UsingMalloc")
%elseif !ISEQUAL(UsingMalloc, 0) && !ISEQUAL(UsingMalloc, 1)
%else
%assign errTxt = ""
%endif
%if !EXISTS("IOQualifier")
%assign errTxt = "Must specify IOQualifier corresponding to " ...
"UsingMalloc. Value should be . or -> for UsingMalloc equal " ...
"to 0 and 1, respectively."
%endif
%if errTxt != ""
%<LibReportFatalError(errTxt)>
%endif
%assign ::IOQualifier = IOQualifier
%<LibAddToCompiledModel("IOQualifier", IOQualifier)>
%if !EXISTS("PreStructDeclarePragma")
%assign ::PreStructDeclarePragma = ""
%endif
%<LibAddToCompiledModel("PreStructDeclarePragma", PreStructDeclarePragma)>
%if !EXISTS("PostStructDeclarePragma")
%assign ::PostStructDeclarePragma = ""
%endif
%<LibAddToCompiledModel("PostStructDeclarePragma", PostStructDeclarePragma)>
%with ::CompiledModel
%<LoadModelReferenceBlocksInterface()>
%endwith
%if GenRTModel
%<SLibInitRTMdlRecs()>
%endif
%assign cs = ::CompiledModel.ConfigSet
%if SLibIsERTTarget()
%assign srcCTemplate = FEVAL("rtw_cgt_name_conv",cs.ERTSrcFileBannerTemplate,"cgt2tlc")
%assign srcHTemplate = FEVAL("rtw_cgt_name_conv",cs.ERTHdrFileBannerTemplate,"cgt2tlc")
%assign dataCTemplate = FEVAL("rtw_cgt_name_conv",cs.ERTDataSrcFileTemplate,"cgt2tlc")
%assign dataHTemplate = FEVAL("rtw_cgt_name_conv",cs.ERTDataHdrFileTemplate,"cgt2tlc")
%if !EXISTS("ERTSrcFileBannerTemplate")
%assign ::ERTSrcFileBannerTemplate = srcCTemplate
%endif
%if !EXISTS("ERTHdrFileBannerTemplate")
%assign ::ERTHdrFileBannerTemplate = srcHTemplate
%endif
%if !EXISTS("ERTCustomFileTemplate")
%assign ::ERTCustomFileTemplate = cs.ERTCustomFileTemplate
%endif
%<LibAddToCompiledModel("ERTSrcFileBannerTemplate",ERTSrcFileBannerTemplate)>
%<LibAddToCompiledModel("ERTHdrFileBannerTemplate",ERTHdrFileBannerTemplate)>
%<LibAddToCompiledModel("ERTDataSrcFileTemplate",dataCTemplate)>
%<LibAddToCompiledModel("ERTDataHdrFileTemplate",dataHTemplate)>
%<LibAddToCompiledModel("ERTCustomFileTemplate",ERTCustomFileTemplate)>
%else
%<LibAddToCompiledModel("ERTSrcFileBannerTemplate","n/a")>
%<LibAddToCompiledModel("ERTHdrFileBannerTemplate","n/a")>
%<LibAddToCompiledModel("ERTDataSrcFileTemplate","n/a")>
%<LibAddToCompiledModel("ERTDataHdrFileTemplate","n/a")>
%<LibAddToCompiledModel("ERTCustomFileTemplate","n/a")>
%endif
%if SLibIsERTCodeFormat()
%assign numSyncTs = ::CompiledModel.NumRuntimeExportedRates
%if numSyncTs > 1
%assign tmp = FEVAL("zeros", numSyncTs, numSyncTs)
%else
%assign tmp = Matrix(1,1)[[0]]
%endif
%addtorecord ::CompiledModel RequireMultiRateSampleHits 0
%addtorecord ::CompiledModel RequireRateInteraction 0
%addtorecord ::CompiledModel MatrixOfRequireRateInteraction tmp
%endif
%endfunction
%function FcnSetupCommonCodeIdents() void
%if !EXISTS("tRealPart")
%assign ::tRealPart = "re"
%endif
%<LibAddToCompiledModel("tRealPart", tRealPart)>
%if !EXISTS("tImagPart")
%assign ::tImagPart = "im"
%endif
%<LibAddToCompiledModel("tImagPart", tImagPart)>
%assign ::tMdlRefTimingBridgeAccessed = TLC_FALSE
%assign ::tMdlRefGlobalTIDMapAccessed = ...
(IsModelReferenceForASimstructBasedTarget()) ? TLC_TRUE : TLC_FALSE
%assign ::tMdlRefNeedTIDArgs = ::tMdlRefGlobalTIDMapAccessed
%if (!SLibIsERTTarget())
%assign ::PrefixModelToStructs = 1
%else
%assign ::PrefixModelToStructs = !ISEMPTY(FEVAL("strfind",CustomSymbolStrMacro,"$R"))
%endif
%if IsModelReferenceTarget()
%assign ::PrefixModelToStructs = 1
%endif
%<LibAddToCompiledModel("PrefixModelToStructs", PrefixModelToStructs)>
%if !EXISTS("GenerateFullHeader")
%assign ::GenerateFullHeader = 1
%else
%assign ::GenerateFullHeader = %<GenerateFullHeader>
%endif
%<LibAddToCompiledModel("GenerateFullHeader", GenerateFullHeader)>
%if !EXISTS("IncludeFileBanners")
%assign IncludeFileBanners = 1
%endif
%<LibAddToCompiledModel("IncludeFileBanners", IncludeFileBanners)>
%if !EXISTS("ConfigCheckComments")
%assign ::ConfigCheckComments = ""
%else
%assign ::ConfigCheckComments = %<ConfigCheckComments>
%endif
%if !EXISTS("GenerateDefaultFcnBanner")
%assign ::GenerateDefaultFcnBanner = 0
%else
%assign ::GenerateDefaultFcnBanner = %<GenerateDefaultFcnBanner>
%endif
%if !EXISTS("GenerateDefaultFcnBannerSharedUtil")
%assign ::GenerateDefaultFcnBannerSharedUtil = 0
%else
%assign ::GenerateDefaultFcnBannerSharedUtil = %<GenerateDefaultFcnBannerSharedUtil>
%endif
%if !EXISTS("GeneratedFileList")
%assign ::GeneratedFileList = ""
%else
%assign ::GeneratedFileList = GeneratedFileList
%endif
%endfunction
%function FcnSetupRTModelNames() void
%if !EXISTS("::tSimStruct")
%assign ::tSimStruct = GenRTModel ? "rtM_%<::CompiledModel.Name>" : "rtS"
%endif
%if !EXISTS("::tSimStructType")
%assign ::tSimStructType = GenRTModel ? "rtModel_%<::CompiledModel.Name>" : ...
"SimStruct"
%endif
%<LibAddToCompiledModel("::tSimStruct", tSimStruct)>
%endfunction
%function SLibSetupCoderTypesInfo() void
%assign potentialBaseNames = []
%assign rtwtypesBaseName = SLibGetFileNameForCode("rtwtypes_hdr")
%assign rtwtypesFileName = rtwtypesBaseName + ".h"
%assign rtwtypesFilePath = FcnOutputFilePath(rtwtypesFileName)
%assign potentialBaseNames = potentialBaseNames + rtwtypesBaseName
%assign mdlrefTypesBaseName = SLibGetFileNameForCode("mdlrefTypes_hdr")
%assign mdlrefTypesFileName = mdlrefTypesBaseName + ".h"
%assign mdlrefTypesFilePath = FcnOutputFilePath(mdlrefTypesFileName)
%assign potentialBaseNames = potentialBaseNames + mdlrefTypesBaseName
%assign builtinTypeidTypesBaseName = SLibGetFileNameForCode("builtinTypeidTypes_hdr")
%assign builtinTypeidTypesFileName = builtinTypeidTypesBaseName + ".h"
%assign builtinTypeidTypesFilePath = FcnOutputFilePath(builtinTypeidTypesFileName)
%assign potentialBaseNames = potentialBaseNames + builtinTypeidTypesBaseName
%assign multiwordTypesBaseName = SLibGetFileNameForCode("multiwordTypes_hdr")
%assign multiwordTypesFileName = multiwordTypesBaseName + ".h"
%assign multiwordTypesFilePath = FcnOutputFilePath(multiwordTypesFileName)
%assign potentialBaseNames = potentialBaseNames + multiwordTypesBaseName
%assign zerocrossingTypesBaseName = SLibGetFileNameForCode("zerocrossingTypes_hdr")
%assign zerocrossingTypesFileName = zerocrossingTypesBaseName + ".h"
%assign zerocrossingTypesFilePath = FcnOutputFilePath(zerocrossingTypesFileName)
%assign potentialBaseNames = potentialBaseNames + zerocrossingTypesBaseName
%assign halfTypeHdrBaseName = SLibGetFileNameForCode("halfType_hdr")
%assign halfTypeHdrFileName = halfTypeHdrBaseName + ".h"
%assign halfTypeHdrFilePath = FcnOutputFilePath(halfTypeHdrFileName)
%assign potentialBaseNames = potentialBaseNames + halfTypeHdrBaseName
%assign halfTypeSrcBaseName = SLibGetFileNameForCode("halfType_src")
%assign halfTypeSrcFileName = halfTypeSrcBaseName + "." + ::LangFileExt
%assign halfTypeSrcFilePath = FcnOutputFilePath(halfTypeSrcFileName)
%assign potentialBaseNames = potentialBaseNames + halfTypeSrcBaseName
%createrecord coderTypesInfo {}
%addtorecord coderTypesInfo BaseName rtwtypesBaseName
%addtorecord coderTypesInfo ModelReferenceTypesBaseName mdlrefTypesBaseName
%addtorecord coderTypesInfo BuiltinTypeidTypesBaseName builtinTypeidTypesBaseName
%addtorecord coderTypesInfo MultiwordTypesBaseName multiwordTypesBaseName
%addtorecord coderTypesInfo ZerocrossingTypesBaseName zerocrossingTypesBaseName
%addtorecord coderTypesInfo HalfTypeHdrBaseName halfTypeHdrBaseName
%addtorecord coderTypesInfo HalfTypeSrcBaseName halfTypeSrcBaseName
%addtorecord coderTypesInfo FileName rtwtypesFileName
%addtorecord coderTypesInfo ModelReferenceTypesFileName mdlrefTypesFileName
%addtorecord coderTypesInfo BuiltinTypeidTypesFileName builtinTypeidTypesFileName
%addtorecord coderTypesInfo MultiwordTypesFileName multiwordTypesFileName
%addtorecord coderTypesInfo ZerocrossingTypesFileName zerocrossingTypesFileName
%addtorecord coderTypesInfo HalfTypeHdrFileName halfTypeHdrFileName
%addtorecord coderTypesInfo HalfTypeSrcFileName halfTypeSrcFileName
%addtorecord coderTypesInfo FilePath rtwtypesFilePath
%addtorecord coderTypesInfo ModelReferenceTypesFilePath mdlrefTypesFilePath
%addtorecord coderTypesInfo BuiltinTypeidTypesFilePath builtinTypeidTypesFilePath
%addtorecord coderTypesInfo MultiwordTypesFilePath multiwordTypesFilePath
%addtorecord coderTypesInfo ZerocrossingTypesFilePath zerocrossingTypesFilePath
%addtorecord coderTypesInfo HalfTypeHdrFilePath halfTypeHdrFilePath
%addtorecord coderTypesInfo HalfTypeSrcFilePath halfTypeSrcFilePath
%addtorecord coderTypesInfo PotentialBaseNames potentialBaseNames
%<LibAddToCompiledModel("CoderTypesInfo", coderTypesInfo)>
%endfunction
%function SLibSetupCodeIdentifiers() void
%<FcnSetupCommonCodeIdents()>
%assign dummy = FEVAL("rtwprivate", "retrieveMultiWordUtilitiesAndFunctions", "%<::CompiledModel.MasterSharedCodeManagerFile>", 0, "")
%assign gShared = 0
%assign gReusedLibs = 0
%if LibHasClientsOrServers() || ...
HasModelReferenceBlocksInModel() || ...
IsModelReferenceTarget() || ...
(::CompiledModel.ConfigSet.UtilityFuncGeneration == "Shared location") || ...
(::CompiledModel.ConfigSet.ExistingSharedCode != "")
%if !ISFIELD(::CompiledModel, "RTWInfoMatFile")
%<LoadRTWInfoMatFileforTLC()>
%endif
%assign gShared = 1
%assign gPath = ::CompiledModel.RTWInfoMatFile.sharedSourcesDir
%else
%assign gPath = FEVAL("rtwprivate", "rtwattic","getBuildDir")
%endif
%assign rtwgenshared = FEVAL("rtw_gen_shared_utils", LibGetModelName())
%assert (rtwgenshared == gShared || ::CompiledModel.IsAnyModelRefRemoved)
%<LibAddToCompiledModel("GenUtilsSrcInSharedLocation", gShared)>
%<LibAddToCompiledModel("GenUtilsPath", gPath)>
%<LibAddToCompiledModel("GenReusedLibsOutsideModel", gReusedLibs)>
%matlab rtwprivate("rtwattic","AtticData","genDirForTFL","%<::CompiledModel.GenUtilsPath>")
%assign ::Tid01Eq = ISEQUAL(::CompiledModel.SolverType, "FixedStep") && ...
::CompiledModel.FixedStepOpts.TID01EQ
%<LibAddToCompiledModel("Tid01Eq", Tid01Eq)>
%if IsModelReferenceTarget() || HasModelReferenceBlocks()
%assign name = "rtP"
%<LibAddToCompiledModel("tUnstructParameters", name)>
%endif
%switch ::CompiledModel.CodeFormat
%case "Embedded-C"
%if !EXISTS("AutoBuildProcedure")
%assign ::AutoBuildProcedure = 0
%endif
%if IsModelReferenceTarget()
%assign ::AutoBuildProcedure = 0
%endif
%<LibAddToCompiledModel("AutoBuildProcedure", AutoBuildProcedure)>
%assign varPrefix = PrefixModelToStructs ? "%<::CompiledModel.Name>_" : "rt"
%assign tdPostfix = PrefixModelToStructs ? "_%<::CompiledModel.Name>" : ""
%<LibAddToCompiledModel("tLogObject", "rtL")>
%<LibAddToCompiledModel("tLogObjectType", "LogObject")>
%<LibAddToCompiledModel("tExtModeObject", "rtE")>
%<LibAddToCompiledModel("tExtModeObjectType", "ExtModeObject")>
%assign ::logObject = "logObject"
%assign ::logObjectAddr = "&%<logObject>"
%assign upperSolver = FEVAL("upper", ::CompiledModel.Solver)
%<LibAddToCompiledModel("upperSolver", upperSolver)>
%assign solverOrder = IDNUM(::CompiledModel.Solver)[1]
%<LibAddToCompiledModel("solverOrder", solverOrder)>
%break
%case "RealTime"
%if !EXISTS("AutoBuildProcedure")
%assign ::AutoBuildProcedure = 0
%endif
%<LibAddToCompiledModel("AutoBuildProcedure", AutoBuildProcedure)>
%assign upperSolver = FEVAL("upper", ::CompiledModel.Solver)
%<LibAddToCompiledModel("upperSolver", upperSolver)>
%assign solverOrder = IDNUM(::CompiledModel.Solver)[1]
%<LibAddToCompiledModel("solverOrder", solverOrder)>
%break
%case "S-Function"
%assign varPrefix = PrefixModelToStructs ? "%<::CompiledModel.Name>_" : ""
%assign tdPostfix = PrefixModelToStructs ? "_%<::CompiledModel.Name>" : ""
%if !EXISTS("AutoBuildProcedure")
%assign ::AutoBuildProcedure = 0
%endif
%<LibAddToCompiledModel("AutoBuildProcedure", AutoBuildProcedure)>
%break
%endswitch
%if !EXISTS("tConstPrms")
%assign ::tConstPrms = "rtCP"
%endif
%if !EXISTS("logObject")
%assign ::logObject = ::tSimStruct
%assign ::logObjectAddr = ::tSimStruct
%endif
%endfunction
%function SLibSetupLibSrcFcnNames() void
%if !EXISTS("tCreateLogVar")
%assign ::tCreateLogVar = "rt_CreateLogVar"
%endif
%if !EXISTS("tCreateLogVarWithConvert")
%assign ::tCreateLogVarWithConvert = "rt_CreateLogVarWithConvert"
%endif
%if !EXISTS("tUpdateLogVar")
%assign ::tUpdateLogVar = "rt_UpdateLogVar"
%endif
%if !EXISTS("tCreateStructLogVar")
%assign ::tCreateStructLogVar = /
"rt_CreateStructLogVar"
%endif
%if !EXISTS("tUpdateStructLogVar")
%assign ::tUpdateStructLogVar = /
"rt_UpdateStructLogVar"
%endif
%<LibAddToCompiledModel("tCreateLogVar", tCreateLogVar)>
%<LibAddToCompiledModel("tUpdateLogVar", tUpdateLogVar)>
%<LibAddToCompiledModel("tCreateStructLogVar", tCreateStructLogVar)>
%<LibAddToCompiledModel("tUpdateStructLogVar", tUpdateStructLogVar)>
%endfunction
%function SLibCheckCompiledMdl() void
%if ::CompiledModel.NumAlgebraicLoops > 0
%if !Accelerator
%<SLibReportErrorWithIdAndArgs("RTW:tlc:AlgebraicLoop", "Simulink Coder")>
%endif
%endif
%endfunction
%function SLibSetupDoCodeFmtChecks() void
%if !EXISTS("GenerateErtSFunction")
%assign ::GenerateErtSFunction = 0
%endif
%if GenerateErtSFunction == 1
%if !SLibIsERTCodeFormat()
%<SLibReportErrorWithId("RTW:tlc:ERTSfcn")>
%elseif LibIsContinuous(0)
%<SLibReportErrorWithId("RTW:tlc:ERTSfcn2")>
%endif
%endif
%<LibAddToCompiledModel("GenerateErtSFunction", GenerateErtSFunction)>
%<LibAddToCompiledModel("EmptyRealTimeObject", 0)>
%if PurelyIntegerCode == 1 && !SLibIsERTCodeFormat()
%<SLibReportErrorWithId("RTW:tlc:IntegerOnly")>
%endif
%if CodeFormat == "S-Function" && !Accelerator
%assign InvalidSTF = 1
%if ISFIELD(::CompiledModel.RTWGenSettings,"IsRTWSfcn")
%if ::CompiledModel.RTWGenSettings.IsRTWSfcn == "yes"
%assign InvalidSTF = 0
%endif
%endif
%if InvalidSTF == 1
%<SLibReportErrorWithId("RTW:tlc:SfcnCodeFormat")>
%endif
%endif
%if GenCPP == 1
%assign ::cppxPC = 0
%if EXISTS("xPC") && (xPC == 1)
%assign ::cppxPC = 1
%endif
%if cppxPC == 1
%<SLibReportErrorWithId("RTW:tlc:CPPForxPC")>
%endif
%endif
%endfunction
%function SLibSetupAdaCGTrackingFields() void
%if !EXISTS("WithRTlook")
%assign ::WithRTlook = 0
%endif
%<LibAddToCompiledModel("WithRTlook", WithRTlook)>
%if !EXISTS("WithRTlook2D")
%assign ::WithRTlook2D = 0
%endif
%<LibAddToCompiledModel("WithRTlook2D", WithRTlook2D)>
%if !EXISTS("WithRTLookupND")
%assign ::WithRTLookupND = 0
%endif
%<LibAddToCompiledModel("WithRTLookupND", WithRTLookupND)>
%if !EXISTS("WithRTLookupND32")
%assign ::WithRTLookupND32 = 0
%endif
%<LibAddToCompiledModel("WithRTLookupND32", WithRTLookupND32)>
%if !EXISTS("WithRTSplineND")
%assign ::WithRTSplineND = 0
%endif
%<LibAddToCompiledModel("WithRTSplineND", WithRTSplineND)>
%if !EXISTS("WithRTSplineND32")
%assign ::WithRTSplineND32 = 0
%endif
%<LibAddToCompiledModel("WithRTSplineND32", WithRTSplineND32)>
%if !EXISTS("WithRTrand")
%assign ::WithRTrand = 0
%endif
%<LibAddToCompiledModel("WithRTrand", WithRTrand)>
%if !EXISTS("WithRTsat")
%assign ::WithRTsat = 0
%endif
%<LibAddToCompiledModel("WithRTsat", WithRTsat)>
%if !EXISTS("WithRTmat")
%assign ::WithRTmat = 0
%endif
%<LibAddToCompiledModel("WithRTmat", WithRTmat)>
%if !EXISTS("WithCstreams")
%assign ::WithCstreams = 0
%endif
%<LibAddToCompiledModel("WithCstreams", WithCstreams)>
%if !EXISTS("MathConstantDefines")
%assign Pi = PiRec { Required 0 }
%assign E = ERec { Required 0 }
%assign LN10 = LN10Rec { Required 0 }
%assign LOG10E = LOG10E { Required 0 }
%assign MathConstantDefines = MathConstantDefinesRec { Stub 0 }
%assign MathConstantDefines = MathConstantDefines + Pi
%assign MathConstantDefines = MathConstantDefines + E
%assign MathConstantDefines = MathConstantDefines + LN10
%assign MathConstantDefines = MathConstantDefines + LOG10E
%endif
%assign ::MathConstantDefines = MathConstantDefines
%<LibAddToCompiledModel("MathConstantDefines", MathConstantDefines)>
%endfunction
%function SLibSetupBIOAPI() void
%if !EXISTS("BlockIOSignals")
%assign ::BlockIOSignals = 0
%endif
%if BlockIOSignals == 1
%<SLibReportErrorWithId("RTW:tlc:DeprecatedParamTuningAndBlockIOSig")>
%endif
%endfunction
%function SLibSetupPrmAPI() void
%if !EXISTS("ParameterTuning")
%assign ::ParameterTuning = 0
%endif
%if ParameterTuning == 1
%<SLibReportErrorWithId("RTW:tlc:DeprecatedParamTuningAndBlockIOSig")>
%endif
%endfunction
%function SLibSetupCAPI() void
%if !EXISTS("RTWCAPITestPtSignals")
%assign ::RTWCAPITestPtSignals = 0
%endif
%if !EXISTS("RTWCAPISignals")
%assign ::RTWCAPISignals = 0
%endif
%if IsModelReferenceSimTarget()
%assert (::RTWCAPISignals)
%assign ::RTWCAPITestPtSignals = 1
%endif
%if !EXISTS("RTWCAPIParams")
%assign ::RTWCAPIParams = 0
%endif
%if !EXISTS("WriteCAPIUsingTemplates")
%assign ::WriteCAPIUsingTemplates = 1
%endif
%if !EXISTS("MatFileLogging")
%assign ::MatFileLogging = 0
%endif
%assign RTWStatesLogging = 0
%if !IsModelReferenceTarget() && HasModelReferenceBlocks()
%assign dlo = ::CompiledModel.DataLoggingOpts
%if (MatFileLogging == 1)
%if ((dlo.StateSaveName != "" || dlo.FinalStateName != "") || ::isRAccel)
%assign RTWStatesLogging = 1
%endif
%endif
%endif
%<LibAddToCompiledModel("RTWStatesLogging",RTWStatesLogging)>
%if ISFIELD(::CompiledModel.ConfigSet, "RTWCAPIStates")
%assign ConfigSetCAPIStates = ::CompiledModel.ConfigSet.RTWCAPIStates
%else
%assign ConfigSetCAPIStates = 0
%endif
%if !EXISTS("RTWCAPIStates")
%assign ::RTWCAPIStates = 0
%endif
%assign ::RTWCAPIRootIO = 0
%if ISFIELD(::CompiledModel.ConfigSet, "RTWCAPIRootIO") && ...
::CompiledModel.ConfigSet.RTWCAPIRootIO==TLC_TRUE
%assign ::RTWCAPIRootIO = 1
%endif
%if RTWCAPIStates==0
%assign ::RTWCAPIStates = RTWStatesLogging || ConfigSetCAPIStates
%endif
%assign ::RTWCAPI = ::RTWCAPISignals || ::RTWCAPIParams || ::RTWCAPIStates ...
|| ::RTWCAPIRootIO
%if RTWCAPI
%assign ::CompiledModel.HaveSeparateSourceFiles = 1
%endif
%if (RTWCAPIParams) && (CodeFormat == "S-Function")
%<SLibReportErrorWithId("RTW:tlc:CAPIAccel2")>
%endif
%if PurelyIntegerCode && RTWCAPI
%<SLibReportErrorWithId("RTW:tlc:CAPIIntegerOnly")>
%endif
%if !EXISTS("xPC")
%assign ::xPC = 0
%endif
%assign ::tBlockSignals = "rtBlockSignals"
%assign ::tBlockSignalsType = "rtwCAPI_Signals"
%assign ::tBlockStates = "rtBlockStates"
%assign ::tBlockStatesType = "rtwCAPI_States"
%assign ::tBlockParams = "rtBlockParameters"
%assign ::tBlockParamsType = "rtwCAPI_BlockParameters"
%assign ::tModelParams = "rtModelParameters"
%assign ::tModelParamsType = "rtwCAPI_ModelParameters"
%assign ::tRootInputs = "rtRootInputs"
%assign ::tRootOutputs = "rtRootOutputs"
%assign ::tDataAddrType = "void* "
%assign ::tDataAddrMap = "rtDataAddrMap"
%assign ::tDataTypeMapType = "rtwCAPI_DataTypeMap"
%assign ::tDataTypeMap = "rtDataTypeMap"
%assign ::tDimensionMapType = "rtwCAPI_DimensionMap"
%assign ::tDimensionMap = "rtDimensionMap"
%assign ::tDimensionArrayType = "uint_T"
%assign ::tDimensionArray = "rtDimensionArray"
%assign ::tFixPtMapType = "rtwCAPI_FixPtMap"
%assign ::tFixPtMap = "rtFixPtMap"
%assign ::tElementMapType = "rtwCAPI_ElementMap"
%assign ::tElementMap = "rtElementMap"
%assign ::tSampleTimeMapType = "rtwCAPI_SampleTimeMap"
%assign ::tSampleTimeMap = "rtSampleTimeMap"
%assign ::tVarDimsAddrMapType = "int32_T* "
%assign ::tVarDimsAddrMap = "rtVarDimsAddrMap"
%assign ::SupportTunableStructParam = 1
%<LibAddToCompiledModel("RTWCAPI", RTWCAPI)>
%<LibAddToCompiledModel("RTWCAPISignals", RTWCAPISignals)>
%<LibAddToCompiledModel("RTWCAPIParams", RTWCAPIParams)>
%<LibAddToCompiledModel("RTWCAPITestPtSignals", RTWCAPITestPtSignals)>
%<LibAddToCompiledModel("RTWCAPIStates", RTWCAPIStates)>
%if RTWCAPI
%assign ::CompiledModel.GenerateInterfaceAPI = 1
%endif
%if RTWCAPISignals
%assign ::CompiledModel.MapBlockOutputs = 1
%endif
%if RTWCAPIParams
%assign ::CompiledModel.MapParameters = 1
%assign ::CompiledModel.MapStateflow = 1
%endif
%if RTWCAPIStates
%assign ::CompiledModel.MapDWork = 1
%assign ::CompiledModel.MapContStates = 1
%endif
%if RTWCAPIRootIO
%assign ::CompiledModel.MapExternalInputs = 1
%assign ::CompiledModel.MapExternalOutputs = 1
%endif
%if EXISTS("GenerateASAP2") && GenerateASAP2==1
%assign ::CompiledModel.MapExternalOutputs = 1
%endif
%endfunction
%function SLibSetupAndCheckCustomSC() void
%if !ISFIELD(::CompiledModel.ConfigSet, "MemSecPackage")
%addtorecord ::CompiledModel CoderDictionary {DefaultMemorySections ""}
%return
%endif
%if SLibIsCoderDictionaryActiveForDefaults()
%assign msPackage = ::CompiledModel.CoderDictionary.PackageForDefaults
%if msPackage == "--- None ---"
%assign msPackage = ::CompiledModel.ConfigSet.MemSecPackage
%endif
%assign fcnDefaults = ::CompiledModel.CoderDictionary.FunctionDefaults
%assign msInitTerm = FcnGetMemorySection(fcnDefaults.InitializeTerminate)
%assign msExec = FcnGetMemorySection(fcnDefaults.Execution)
%assign msSharedUtil = FcnGetMemorySection(fcnDefaults.SharedUtility)
%assign dataDefaults = ::CompiledModel.CoderDictionary.DataDefaults
%assign msInputs = FcnGetMemorySection(dataDefaults.Inputs)
%assign msOutputs = FcnGetMemorySection(dataDefaults.Outputs)
%assign msConstants = FcnGetMemorySection(dataDefaults.Constants)
%assign msInternal = FcnGetMemorySection(dataDefaults.InternalData)
%assign msParameters = "Default"
%assign parametersMSRec = ""
%if ISFIELD(dataDefaults.LocalParameters, "MemorySection")
%assign parametersMSRec = dataDefaults.LocalParameters
%elseif ISFIELD(dataDefaults.GlobalParameters, "MemorySection")
%assign parametersMSRec = dataDefaults.GlobalParameters
%endif
%if (!ISEMPTY(parametersMSRec))
%assign msParameters = FcnGetMemorySection(parametersMSRec)
%endif
%else
%assign msPackage = ::CompiledModel.ConfigSet.MemSecPackage
%assign msInitTerm = ::CompiledModel.ConfigSet.MemSecFuncInitTerm
%assign msExec = ::CompiledModel.ConfigSet.MemSecFuncExecute
%assign msSharedUtil = ::CompiledModel.ConfigSet.MemSecFuncSharedUtil
%assign msInputs = ::CompiledModel.MemorySectionsFromMapping.MemSecDataInputs
%assign msOutputs = ::CompiledModel.MemorySectionsFromMapping.MemSecDataOutputs
%assign msConstants = ::CompiledModel.MemorySectionsFromMapping.MemSecDataConstants
%assign msInternal = ::CompiledModel.MemorySectionsFromMapping.MemSecDataInternal
%assign msParameters = ::CompiledModel.MemorySectionsFromMapping.MemSecDataParameters
%endif
%if !ISFIELD(::CompiledModel, "CoderDictionary")
%addtorecord ::CompiledModel CoderDictionary {DefaultMemorySections ""}
%addtorecord ::CompiledModel.CoderDictionary AllPackages ""
%else
%addtorecord ::CompiledModel.CoderDictionary DefaultMemorySections ""
%if !ISFIELD(::CompiledModel.CoderDictionary, "AllPackages")
%addtorecord ::CompiledModel.CoderDictionary AllPackages ""
%endif
%endif
%createrecord msRecords { MemSecPackage "%<msPackage>" ; ...
MemSecFuncInitTerm msInitTerm; ...
MemSecFuncExecute msExec; ...
MemSecFuncSharedUtil msSharedUtil; ...
MemSecDataInputs msInputs; ...
MemSecDataOutputs msOutputs; ...
MemSecDataConstants msConstants; ...
MemSecDataInternal msInternal; ...
MemSecDataParameters msParameters }
%assign ::CompiledModel.CoderDictionary.DefaultMemorySections = msRecords
%with ::CompiledModel
%if ( (CustomStorageClasses.NumCustomStorageClasses > 0) || ...
((ISFIELD(::CompiledModel.ConfigSet, "MemSecPackage")) && ...
("--- None ---" != ::CompiledModel.ConfigSet.MemSecPackage)) || ...
(SLibIsCoderDictionaryActiveForDefaults() && ...
(SIZE(::CompiledModel.CoderDictionary.AllPackages, 1) > 0)) )
%<SLibSetupCustomStorageClasses()>
%endif
%endwith
%endfunction
%function FcnGetMemorySection(categoryRec) void
%assign ms = "Default"
%if ISFIELD(categoryRec, "MemorySection")
%assign msRec = categoryRec.MemorySection
%assign ms = SLibGetMemorySectionForUUID(msRec.UUID)
%endif
%return ms
%endfunction
%function FcnCacheRootBodyMthNames(rootSys,useCaps,useMdlName,reqMethods) void
%assign mPrefix = useCaps ? "M" : "m"
%if !ISFIELD(rootSys,"OutputFcn") && reqMethods.OutputFcn
%if useMdlName
%addtorecord rootSys OutputFcn "%<Name>_output"
%else
%addtorecord rootSys OutputFcn "%<mPrefix>dlOutputs"
%endif
%endif
%if !ISFIELD(rootSys,"UpdateFcn") && reqMethods.UpdateFcn
%if useMdlName
%addtorecord rootSys UpdateFcn "%<Name>_update"
%else
%addtorecord rootSys UpdateFcn "%<mPrefix>dlUpdate"
%endif
%endif
%if !ISFIELD(rootSys,"DerivativeFcn") && reqMethods.DerivativeFcn
%if useMdlName
%addtorecord rootSys DerivativeFcn "%<Name>_derivatives"
%else
%addtorecord rootSys DerivativeFcn "%<mPrefix>dlDerivatives"
%endif
%endif
%if !ISFIELD(rootSys,"ProjectionFcn") && reqMethods.ProjectionFcn
%if useMdlName
%addtorecord rootSys ProjectionFcn "%<Name>_projection"
%else
%addtorecord rootSys ProjectionFcn "%<mPrefix>dlProjection"
%endif
%endif
%if !ISFIELD(rootSys,"ForcingFunctionFcn") && reqMethods.ForcingFunctionFcn
%if useMdlName
%addtorecord rootSys ForcingFunctionFcn "%<Name>_forcingfunction"
%else
%addtorecord rootSys ForcingFunctionFcn "%<mPrefix>dlForcingFunction"
%endif
%endif
%if !ISFIELD(rootSys,"MassMatrixFcn") && reqMethods.MassMatrixFcn
%if useMdlName
%addtorecord rootSys MassMatrixFcn "%<Name>_massmatrix"
%else
%addtorecord rootSys MassMatrixFcn "%<mPrefix>dlMassMatrix"
%endif
%endif
%if !ISFIELD(rootSys,"InitSystemMatricesFcn") && reqMethods.InitSystemMatricesFcn
%if useMdlName
%addtorecord rootSys InitSystemMatricesFcn "%<Name>_initsystemmatrices"
%else
%addtorecord rootSys InitSystemMatricesFcn "%<mPrefix>dlInitSystemMatrices"
%endif
%endif
%if !ISFIELD(rootSys,"SetupRuntimeResourcesFcn") && reqMethods.SetupRuntimeResourcesFcn
%if useMdlName
%addtorecord rootSys SetupRuntimeResourcesFcn "%<Name>_setupruntimeresources"
%else
%addtorecord rootSys SetupRuntimeResourcesFcn "%<mPrefix>dlSetupRuntimeResources"
%endif
%endif
%if !ISFIELD(rootSys,"InitializeFcn") && reqMethods.InitializeFcn
%if useMdlName
%addtorecord rootSys InitializeFcn "%<Name>_initialize"
%else
%if CodeFormat == "S-Function"
%addtorecord rootSys InitializeFcn "%<mPrefix>dlInitializeConditions"
%else
%addtorecord rootSys InitializeFcn "%<mPrefix>dlInitialize"
%endif
%endif
%endif
%if !ISFIELD(rootSys,"SystemInitializeFcn") && reqMethods.SystemInitializeFcn
%if useMdlName
%addtorecord rootSys SystemInitializeFcn "%<Name>_initialize"
%else
%if CodeFormat == "S-Function"
%addtorecord rootSys SystemInitializeFcn "%<mPrefix>dlInitializeConditions"
%else
%addtorecord rootSys SystemInitializeFcn "%<mPrefix>dlInitialize"
%endif
%endif
%endif
%if !ISFIELD(rootSys,"SystemResetFcn") && reqMethods.SystemResetFcn
%if useMdlName
%addtorecord rootSys SystemResetFcn "%<Name>_reset"
%else
%addtorecord rootSys SystemResetFcn "%<mPrefix>dlReset"
%endif
%endif
%if !ISFIELD(rootSys,"SharedInitializeFcn") && reqMethods.SharedInitializeFcn
%if useMdlName
%addtorecord rootSys SharedInitializeFcn "%<Name>_sharedInitialize"
%else
%addtorecord rootSys SharedInitializeFcn "%<mPrefix>dlSharedInitialize"
%endif
%endif
%if !ISFIELD(rootSys,"EnableFcn") && reqMethods.EnableFcn
%if useMdlName
%addtorecord rootSys EnableFcn "%<Name>_enable"
%else
%addtorecord rootSys EnableFcn "%<mPrefix>dlEnable"
%endif
%endif
%if !ISFIELD(rootSys,"DisableFcn") && reqMethods.DisableFcn
%if useMdlName
%addtorecord rootSys DisableFcn "%<Name>_disable"
%else
%addtorecord rootSys DisableFcn "%<mPrefix>dlDisable"
%endif
%endif
%if !ISFIELD(rootSys,"ZeroCrossingFcn") && reqMethods.ZeroCrossingFcn
%if useMdlName
%addtorecord rootSys ZeroCrossingFcn "%<Name>_zeroCrossings"
%else
%addtorecord rootSys ZeroCrossingFcn "%<mPrefix>dlZeroCrossings"
%endif
%endif
%if !ISFIELD(rootSys,"StartFcn") && reqMethods.StartFcn
%if useMdlName
%addtorecord rootSys StartFcn "%<Name>_start"
%else
%addtorecord rootSys StartFcn "%<mPrefix>dlStart"
%endif
%endif
%if !ISFIELD(rootSys,"CleanupRuntimeResourcesFcn") && reqMethods.CleanupRuntimeResourcesFcn
%if useMdlName
%addtorecord rootSys CleanupRuntimeResourcesFcn "%<Name>_cleanupruntimeresources"
%else
%addtorecord rootSys CleanupRuntimeResourcesFcn "%<mPrefix>dlCleanupRuntimeResources"
%endif
%endif
%if !ISFIELD(rootSys,"TerminateFcn") && reqMethods.TerminateFcn
%if useMdlName
%addtorecord rootSys TerminateFcn "%<Name>_terminate"
%else
%addtorecord rootSys TerminateFcn "%<mPrefix>dlTerminate"
%endif
%endif
%if !ISFIELD(rootSys,"ConstCodeFcn") && reqMethods.ConstCodeFcn
%if useMdlName
%addtorecord rootSys ConstCodeFcn "%<Name>_Const"
%else
%addtorecord rootSys ConstCodeFcn "%<mPrefix>dlConst"
%endif
%endif
%if !ISFIELD(rootSys,"ModelInitialize") && reqMethods.ModelInitializeFcn
%if useMdlName
%addtorecord rootSys ModelInitializeFcn "%<Name>_Initialize"
%else
%addtorecord rootSys ModelInitializeFcn "%<mPrefix>dlInitialize"
%endif
%endif
%endfunction
%function FcnSetupRootBodyReqMths() void
%createrecord reqBodyMethods /
{/
EnableFcn TLC_FALSE;/
DisableFcn TLC_FALSE;/
SetupRuntimeResourcesFcn TLC_FALSE;/
InitializeFcn TLC_FALSE;/
SystemInitializeFcn TLC_FALSE;/
SystemResetFcn TLC_FALSE;/
SharedInitializeFcn TLC_FALSE;/
StartFcn TLC_FALSE;/
OutputFcn TLC_FALSE;/
UpdateFcn TLC_FALSE;/
OutputUpdateFcn TLC_FALSE;/
DerivativeFcn TLC_FALSE;/
ProjectionFcn TLC_FALSE;/
ForcingFunctionFcn TLC_FALSE;/
MassMatrixFcn TLC_FALSE;/
InitSystemMatricesFcn TLC_FALSE;/
CleanupRuntimeResourcesFcn TLC_FALSE;/
TerminateFcn TLC_FALSE;/
ConstCodeFcn TLC_FALSE;/
ModelInitializeFcn TLC_FALSE;/
ZeroCrossingFcn TLC_FALSE/
}
%switch CodeFormat
%case "RealTime"
%assign reqBodyMethods.StartFcn = TLC_TRUE
%assign reqBodyMethods.SystemInitializeFcn = TLC_TRUE
%assign reqBodyMethods.SystemResetFcn = TLC_TRUE
%assign reqBodyMethods.EnableFcn = TLC_TRUE
%assign reqBodyMethods.OutputFcn = TLC_TRUE
%assign reqBodyMethods.UpdateFcn = TLC_TRUE
%assign reqBodyMethods.DerivativeFcn = TLC_TRUE
%assign reqBodyMethods.ProjectionFcn = TLC_TRUE
%assign reqBodyMethods.ForcingFunctionFcn = TLC_TRUE
%assign reqBodyMethods.MassMatrixFcn = TLC_TRUE
%assign reqBodyMethods.InitSystemMatricesFcn = TLC_TRUE
%assign reqBodyMethods.TerminateFcn = TLC_TRUE
%if isRSimWithSolverModule
%assign reqBodyMethods.ZeroCrossingFcn = TLC_TRUE
%endif
%assign reqBodyMethods.ConstCodeFcn = TLC_TRUE
%break
%case "S-Function"
%if Accelerator
%assign reqBodyMethods.OutputFcn = TLC_TRUE
%assign reqBodyMethods.UpdateFcn = TLC_TRUE
%assign reqBodyMethods.DerivativeFcn = TLC_TRUE
%assign reqBodyMethods.ProjectionFcn = TLC_TRUE
%assign reqBodyMethods.ForcingFunctionFcn = TLC_TRUE
%assign reqBodyMethods.MassMatrixFcn = TLC_TRUE
%assign reqBodyMethods.InitSystemMatricesFcn = TLC_TRUE
%assign reqBodyMethods.ZeroCrossingFcn = TLC_TRUE
%assign reqBodyMethods.TerminateFcn = TLC_TRUE
%assign reqBodyMethods.SetupRuntimeResourcesFcn = TLC_TRUE
%assign reqBodyMethods.CleanupRuntimeResourcesFcn = TLC_TRUE
%else
%assign reqBodyMethods.StartFcn = TLC_TRUE
%assign reqBodyMethods.SystemInitializeFcn = TLC_TRUE
%assign reqBodyMethods.SystemResetFcn = TLC_TRUE
%assign reqBodyMethods.EnableFcn = TLC_TRUE
%assign reqBodyMethods.DisableFcn = TLC_TRUE
%assign reqBodyMethods.OutputFcn = TLC_TRUE
%assign reqBodyMethods.UpdateFcn = TLC_TRUE
%assign reqBodyMethods.DerivativeFcn = TLC_TRUE
%assign reqBodyMethods.ProjectionFcn = TLC_TRUE
%assign reqBodyMethods.ForcingFunctionFcn = TLC_TRUE
%assign reqBodyMethods.MassMatrixFcn = TLC_TRUE
%assign reqBodyMethods.InitSystemMatricesFcn = TLC_TRUE
%assign reqBodyMethods.ZeroCrossingFcn = TLC_TRUE
%assign reqBodyMethods.TerminateFcn = TLC_TRUE
%assign reqBodyMethods.ConstCodeFcn = TLC_TRUE
%assign reqBodyMethods.SetupRuntimeResourcesFcn = TLC_TRUE
%assign reqBodyMethods.CleanupRuntimeResourcesFcn = TLC_TRUE
%endif
%break
%case "Embedded-C"
%case "Ada"
%assign reqBodyMethods.StartFcn = TLC_TRUE
%assign reqBodyMethods.SystemInitializeFcn = TLC_TRUE
%assign reqBodyMethods.SystemResetFcn = TLC_TRUE
%assign reqBodyMethods.EnableFcn = TLC_TRUE
%if EXISTS("GenerateErtSFunction") && ...
::GenerateErtSFunction == 1
%assign reqBodyMethods.DisableFcn = TLC_TRUE
%endif
%assign reqBodyMethods.OutputFcn = TLC_TRUE
%assign reqBodyMethods.UpdateFcn = TLC_TRUE
%assign reqBodyMethods.DerivativeFcn = TLC_TRUE
%assign reqBodyMethods.ProjectionFcn = TLC_TRUE
%assign reqBodyMethods.ForcingFunctionFcn = TLC_TRUE
%assign reqBodyMethods.MassMatrixFcn = TLC_TRUE
%assign reqBodyMethods.InitSystemMatricesFcn = TLC_TRUE
%assign reqBodyMethods.ZeroCrossingFcn = TLC_TRUE
%assign reqBodyMethods.TerminateFcn = TLC_TRUE
%assign reqBodyMethods.ConstCodeFcn = TLC_TRUE
%assign reqBodyMethods.ModelInitializeFcn = TLC_TRUE
%break
%default
%break
%endswitch
%return reqBodyMethods
%endfunction
%function FcnParamsAreGlobalStruct() void
%switch CodeFormat
%case "RealTime"
%return TLC_TRUE
%break
%case "S-Function"
%return TLC_TRUE
%break
%case "Embedded-C"
%return TLC_TRUE
%break
%default
%return TLC_FALSE
%break
%endswitch
%endfunction
%function FcnSetupRootPrmHdrReqInstances(rootSys) void
%<LibAddToCompiledModel("XQualifier", IOQualifier)>
%<LibAddToCompiledModel("UQualifier", IOQualifier)>
%<LibAddToCompiledModel("YQualifier", IOQualifier)>
%<LibAddToCompiledModel("PQualifier", IOQualifier)>
%<LibAddToCompiledModel("BQualifier", IOQualifier)>
%<LibAddToCompiledModel("DWorkQualifier", IOQualifier)>
%<LibAddToCompiledModel("PrevZCQualifier",IOQualifier)>
%<LibAddToCompiledModel("ConstBQualifier",IOQualifier)>
%<LibAddToCompiledModel("ConstPQualifier",".")>
%createrecord reqPrmHdrInsts /
{/
GroupedCustomDataInst TLC_FALSE;/
ParamsInst TLC_FALSE;/
ConstBlockIOInst TLC_FALSE;/
ConstParamInst TLC_FALSE;/
ExpGlobalSigsInst TLC_FALSE;/
ExpGlobalPrmsInst TLC_FALSE;/
BlockIOInst TLC_FALSE;/
ExpGlobalDworkInst TLC_FALSE;/
ContStatesInst TLC_FALSE;/
PeriodicContStatesInst TLC_FALSE;/
MassMatricesInst TLC_FALSE;/
DworkInst TLC_FALSE;/
PrevZCStatesInst TLC_FALSE;/
ExtInpsInst TLC_FALSE;/
ExtOutputsInst TLC_FALSE;/
SimStructInst TLC_FALSE;/
GlobalPrmDataCacheInst TLC_FALSE/
}
%switch CodeFormat
%case "RealTime"
%assign reqPrmHdrInsts.GroupedCustomDataInst = TLC_TRUE
%assign reqPrmHdrInsts.ParamsInst = FcnParamsAreGlobalStruct()
%assign reqPrmHdrInsts.ConstBlockIOInst = TLC_TRUE
%assign reqPrmHdrInsts.ConstParamInst = TLC_TRUE
%assign reqPrmHdrInsts.ExpGlobalSigsInst = TLC_TRUE
%assign reqPrmHdrInsts.ExpGlobalPrmsInst = TLC_TRUE
%assign reqPrmHdrInsts.BlockIOInst = TLC_TRUE
%assign reqPrmHdrInsts.ExpGlobalDworkInst = TLC_TRUE
%assign reqPrmHdrInsts.ContStatesInst = TLC_TRUE
%assign reqPrmHdrInsts.PeriodicContStatesInst = TLC_TRUE
%assign reqPrmHdrInsts.MassMatricesInst = TLC_TRUE
%assign reqPrmHdrInsts.DworkInst = TLC_TRUE
%assign reqPrmHdrInsts.PrevZCStatesInst = TLC_TRUE
%assign reqPrmHdrInsts.ExtInpsInst = TLC_TRUE
%assign reqPrmHdrInsts.ExtOutputsInst = TLC_TRUE
%assign reqPrmHdrInsts.SimStructInst = TLC_TRUE
%assign reqPrmHdrInsts.GlobalPrmDataCacheInst = TLC_TRUE
%break
%case "S-Function"
%if Accelerator
%assign reqPrmHdrInsts.ParamsInst = FcnParamsAreGlobalStruct()
%assign reqPrmHdrInsts.ConstBlockIOInst = TLC_TRUE
%assign reqPrmHdrInsts.ConstParamInst = TLC_TRUE
%assign reqPrmHdrInsts.GlobalPrmDataCacheInst = TLC_TRUE
%else
%assign reqPrmHdrInsts.ParamsInst = FcnParamsAreGlobalStruct()
%assign reqPrmHdrInsts.ConstBlockIOInst = TLC_TRUE
%assign reqPrmHdrInsts.ConstParamInst = TLC_TRUE
%assign reqPrmHdrInsts.ExpGlobalSigsInst = TLC_TRUE
%assign reqPrmHdrInsts.ExpGlobalPrmsInst = TLC_TRUE
%endif
%break
%case "Embedded-C"
%assign mdlRef = IsModelReferenceTarget()
%assign multiOrMdlref = MultiInstanceERTCode || mdlRef
%assign genUnstrParamInsts = !mdlRef
%assign reqPrmHdrInsts.GroupedCustomDataInst = TLC_TRUE
%assign reqPrmHdrInsts.ExpGlobalSigsInst = TLC_TRUE
%assign reqPrmHdrInsts.ExpGlobalPrmsInst = genUnstrParamInsts
%assign reqPrmHdrInsts.ExpGlobalDworkInst = TLC_TRUE
%assign reqPrmHdrInsts.DworkInst = !multiOrMdlref
%assign reqPrmHdrInsts.PrevZCStatesInst = !multiOrMdlref
%assign reqPrmHdrInsts.ContStatesInst = !multiOrMdlref
%assign reqPrmHdrInsts.PeriodicContStatesInst = !multiOrMdlref
%assign reqPrmHdrInsts.MassMatricesInst = !multiOrMdlref
%assign reqPrmHdrInsts.BlockIOInst = !multiOrMdlref
%assign reqPrmHdrInsts.ExtInpsInst = !multiOrMdlref
%assign reqPrmHdrInsts.ExtOutputsInst = !multiOrMdlref
%assign reqPrmHdrInsts.SimStructInst = !multiOrMdlref
%assign reqPrmHdrInsts.ConstBlockIOInst = TLC_TRUE
%assign reqPrmHdrInsts.ConstParamInst = TLC_TRUE
%assign reqPrmHdrInsts.ParamsInst = FcnParamsAreGlobalStruct()
%assign reqPrmHdrInsts.GlobalPrmDataCacheInst = TLC_TRUE
%if MultiInstanceERTCode
%assign ::CompiledModel.BQualifier = "->"
%assign ::CompiledModel.PQualifier = FcnParamsAreGlobalStruct() ? "." : "->"
%assign ::CompiledModel.DWorkQualifier = "->"
%assign ::CompiledModel.XQualifier = "->"
%assign ::CompiledModel.PrevZCQualifier = "->"
%if RootIOStructures
%if !GenerateClassInterface
%assign ::CompiledModel.UQualifier = "->"
%assign ::CompiledModel.YQualifier = "->"
%else
%assign ::CompiledModel.UQualifier = "."
%assign ::CompiledModel.YQualifier = "."
%endif
%else
%if SLibHasGlobalExternalInputsWithFPC()
%assign ::CompiledModel.UQualifier = "->"
%else
%assign ::CompiledModel.UQualifier = "_"
%endif
%if SLibHasGlobalExternalOutputsWithFPC()
%assign ::CompiledModel.YQualifier = "->"
%else
%assign ::CompiledModel.YQualifier = "_"
%endif
%endif
%endif
%break
%default
%break
%endswitch
%<LibAddToSystem(rootSys, "ReqRootPrmHdrDataInsts", reqPrmHdrInsts)>
%endfunction
%function SLibRootSystemMethodProps() void
%with ::CompiledModel
%assign rootIdx = NumSystems-1
%assign rootSystem = System[rootIdx]
%assign rootBodyMthsStatic = TLC_FALSE
%assign rootBodyMthsCaps = TLC_FALSE
%assign rootBodyMthUseMdlName = TLC_FALSE
%assign rootBodyStartCallsInitEnab = TLC_FALSE
%assign rootBodyTIDneeded = TLC_FALSE
%assign rootHdrVerboseCmnts = TLC_TRUE
%assign rootHdrGenericDefines = TLC_FALSE
%assign rootPrmHdrInstsStatic = TLC_FALSE
%switch CodeFormat
%case "RealTime"
%assign rootBodyMthsCaps = TLC_TRUE
%assign rootBodyStartCallsInitEnab = TLC_TRUE
%assign rootBodyTIDneeded = TLC_TRUE
%assign rootHdrGenericDefines = TLC_TRUE
%break
%case "Embedded-C"
%assign rootBodyMthUseMdlName = TLC_TRUE
%assign tid01Eq = ISEQUAL(SolverType, "FixedStep") && ...
FixedStepOpts.TID01EQ
%if SLibFcnProtoCtrlActive() || ...
GenerateClassInterface
%assign rootBodyTIDneeded = TLC_FALSE
%elseif GenerateGRTWrapper
%assign rootBodyTIDneeded = TLC_FALSE
%elseif NumRuntimeExportedRates == 1
%assign rootBodyTIDneeded = TLC_FALSE
%elseif NumRuntimeExportedRates == 2 && tid01Eq && ...
NumContStates == 0
%assign rootBodyTIDneeded = TLC_FALSE
%elseif SLibSingleTasking()
%assign rootBodyTIDneeded = !ERTRemoveTidArgForSingleTaskingModel
%endif
%if UsingMalloc && isGRTMalloc
%assign rootPrmHdrInstsStatic = TLC_TRUE
%endif
%break
%case "S-Function"
%assign rootBodyMthsStatic = TLC_TRUE
%assign rootBodyTIDneeded = TLC_TRUE
%if Accelerator
%assign rootHdrVerboseCmnts = TLC_FALSE
%endif
%break
%case "Ada"
%default
%break
%endswitch
%assign ::RootBodyMthsStatic = rootBodyMthsStatic
%assign ::RootBodyStartCallsInitEnab = rootBodyStartCallsInitEnab
%assign ::RootBodyTIDneeded = rootBodyTIDneeded
%assign ::RootHdrVerboseCmnts = rootHdrVerboseCmnts
%assign ::RootHdrGenericDefines = rootHdrGenericDefines
%assign ::RootPrmHdrInstsStatic = rootPrmHdrInstsStatic
%with ::CompiledModel
%assign rootIdx = NumSystems-1
%assign rootSystem = System[rootIdx]
%assign reqMethods = FcnSetupRootBodyReqMths()
%<FcnCacheRootBodyMthNames(rootSystem, rootBodyMthsCaps, ...
rootBodyMthUseMdlName, reqMethods)>
%<FcnSetupRootPrmHdrReqInstances(rootSystem)>
%endwith
%endwith
%endfunction
%function SLibSetupTLCvtable() void
%with ::CompiledModel
%if !EXISTS(productOutputsFixptType)
%assign productOutputsFixptType = "Product"
%<LibAddToCompiledModel("productOutputsFixptType",productOutputsFixptType)>
%endif
%if !EXISTS(productOutputsFixptFunc)
%assign productOutputsFixptFunc = "OutputsFixpt"
%<LibAddToCompiledModel("productOutputsFixptFunc",productOutputsFixptFunc)>
%endif
%if !EXISTS(sumOutputsFixptType)
%assign sumOutputsFixptType = "Sum"
%<LibAddToCompiledModel("sumOutputsFixptType",sumOutputsFixptType)>
%endif
%if !EXISTS(sumOutputsFixptFunc)
%assign sumOutputsFixptFunc = "OutputsFixpt"
%<LibAddToCompiledModel("sumOutputsFixptFunc",sumOutputsFixptFunc)>
%endif
%if !EXISTS(gainOutputsFixptType)
%assign gainOutputsFixptType = "Gain"
%<LibAddToCompiledModel("gainOutputsFixptType",gainOutputsFixptType)>
%endif
%if !EXISTS(gainOutputsFixptFunc)
%assign gainOutputsFixptFunc = "FixptOutputs"
%<LibAddToCompiledModel("gainOutputsFixptFunc",gainOutputsFixptFunc)>
%endif
%endwith
%endfunction
%function SLibSetupCustomCode() void
%with ConfigSet
%if EXISTS("CustomSourceCode")
%<LibSourceFileCustomCode(CustomSourceCode, "header")>
%endif
%if EXISTS("CustomHeaderCode")
%if isRAccel
%assign CustomHeaderCodeRAccel = "#ifndef IN_RACCEL_MAIN/n%<CustomHeaderCode>/n#endif"
%<LibHeaderFileCustomCode(CustomHeaderCodeRAccel, "header")>
%else
%<LibHeaderFileCustomCode(CustomHeaderCode, "header")>
%endif
%endif
%if EXISTS("CustomInitializer")
%assign rootSys = ::CompiledModel.System[CompiledModel.NumSystems-1]
%if !WHITE_SPACE(CustomInitializer)
%assign rootSys.InitializeMethodHasUserData = TLC_TRUE
%endif
%<LibSystemInitializeCustomCode(rootSys, CustomInitializer, "execution")>
%endif
%if EXISTS("CustomTerminator")
%with ::CompiledModel
%<LibMdlTerminateCustomCode(CustomTerminator, "execution")>
%endwith
%endif
%endwith
%endfunction
%function SLibIsCPPEncapMdlRefBuild() void
%return GenerateClassInterface && IsModelReferenceTarget()
%endfunction
%function SLibIsValidCoderContext() void
%return 1 == ::SLCGUseRTWContext
%endfunction
%function SLibCacheDataAlignmentFlags() void
%assign ::fieldDAFlag = FEVAL("rtwprivate", "da_support", ::CompiledModel.Name, "DATA_ALIGNMENT_STRUCT_FIELD")
%assign ::structDAFlag = FEVAL("rtwprivate", "da_support", ::CompiledModel.Name, "DATA_ALIGNMENT_WHOLE_STRUCT")
%assign ::localDAFlag = FEVAL("rtwprivate", "da_support", ::CompiledModel.Name, "DATA_ALIGNMENT_LOCAL_VAR")
%assign ::globalDAFlag = FEVAL("rtwprivate", "da_support", ::CompiledModel.Name, "DATA_ALIGNMENT_GLOBAL_VAR")
%assign ::fieldAlign = fieldDAFlag.supported
%assign ::structAlign = structDAFlag.supported
%assign ::localAlign = localDAFlag.supported
%endfunction
%function SLibGetTypeLimitIdReplacementMap() void
%assign typeLimitIdMap = []
%foreach dtidx = ::CompiledModel.DataTypes.NumDataTypes
%switch ::CompiledModel.DataTypes.DataType[dtidx].DTName
%case "int8"
%assign maxId = "MAX_int8_T"
%assign minId = "MIN_int8_T"
%break
%case "uint8"
%assign maxId = "MAX_uint8_T"
%assign minId = "MIN_uint8_T"
%break
%case "int16"
%assign maxId = "MAX_int16_T"
%assign minId = "MIN_int16_T"
%break
%case "uint16"
%assign maxId = "MAX_uint16_T"
%assign minId = "MIN_uint16_T"
%break
%case "int32"
%assign maxId = "MAX_int32_T"
%assign minId = "MIN_int32_T"
%break
%case "uint32"
%assign maxId = "MAX_uint32_T"
%assign minId = "MIN_uint32_T"
%break
%case "boolean"
%assign maxId = ""
%assign minId = ""
%assign trueRep = ::CompiledModel.DataTypes.DataType[dtidx].BooleanTrueId
%assign falseRep = ::CompiledModel.DataTypes.DataType[dtidx].BooleanFalseId
%assign typeLimitIdMap = typeLimitIdMap + "true"
%assign typeLimitIdMap = typeLimitIdMap + trueRep
%assign typeLimitIdMap = typeLimitIdMap + "false"
%assign typeLimitIdMap = typeLimitIdMap + falseRep
%break
%default
%assign maxId = ""
%assign minId = ""
%break
%endswitch
%if (maxId != "") && (minId != "")
%assign typeLimitIdMap = typeLimitIdMap + maxId
%assign typeLimitIdMap = typeLimitIdMap + ::CompiledModel.DataTypes.DataType[dtidx].TypeMaxId
%assign typeLimitIdMap = typeLimitIdMap + minId
%assign typeLimitIdMap = typeLimitIdMap + ::CompiledModel.DataTypes.DataType[dtidx].TypeMinId
%endif
%endforeach
%if SLibIsERTTarget()
%if (::CompiledModel.ConfigSet.MaxIdInt64 != "")
%assign typeLimitIdMap = typeLimitIdMap + "MAX_int64_T"
%assign typeLimitIdMap = typeLimitIdMap + ::CompiledModel.ConfigSet.MaxIdInt64
%endif
%if (::CompiledModel.ConfigSet.MaxIdUint64 != "")
%assign typeLimitIdMap = typeLimitIdMap + "MAX_uint64_T"
%assign typeLimitIdMap = typeLimitIdMap + ::CompiledModel.ConfigSet.MaxIdUint64
%endif
%if (::CompiledModel.ConfigSet.MinIdInt64 != "")
%assign typeLimitIdMap = typeLimitIdMap + "MIN_int64_T"
%assign typeLimitIdMap = typeLimitIdMap + ::CompiledModel.ConfigSet.MinIdInt64
%endif
%endif
%return typeLimitIdMap
%endfunction
%function SLibSetupSimulinkFunctionFPC() void
%addtorecord ::CompiledModel /
eSLFARG_PASSBYTYPE { /
AUTO 0 /
CONST_DATA 1 /
ARR_SIZEONE 2 /
CONST_ARR_SIZEONE 3 /
POINTER 4 /
POINTER_VOID 5 /
POINTER_CONST_DATA 6 /
POINTER_CONST_VOID 7 /
CONST_POINTER_CONST_DATA 8 /
}
%endfunction
%function SLibGetMemorySectionForUUID(msUUID) void
%assign ms = "Default"
%if CGMODEL_ACCESS("MemorySection.IsLegacy", msUUID)
%assign ms = CGMODEL_ACCESS("MemorySection.ClassName", msUUID)
%else
%assign comment = FcnHandleNewLineForMemSec(CGMODEL_ACCESS("MemorySection.Comment", msUUID))
%assign preStatement = FcnHandleNewLineForMemSec(CGMODEL_ACCESS("MemorySection.PrePragma", msUUID))
%assign postStatement = FcnHandleNewLineForMemSec(CGMODEL_ACCESS("MemorySection.PostPragma", msUUID))
%createrecord ms { /
IsConst TLC_FALSE /
IsVolatile TLC_FALSE /
Qualifier "" /
Comment comment /
PrePragma preStatement /
PostPragma postStatement /
PragmaPerVar %}
%endif
%return ms
%endfunction
%endif