%selectfile NULL_FILE
%if EXISTS("_PARALLELDEPLOYMENT_") == 0
%assign _PARALLELDEPLOYMENT_ = 1
%endif
%function SLibDeploymentSchedulerName()
%assert (LibIsDeploymentDiagram())
%assign fcnName = "AdvanceTaskCounters"
%return fcnName
%endfunction
%function FcnGetSampleTimeIndexVarName()
%assign varName = "taskTID"
%return varName
%endfunction
%function FcnGetTaskSampleTimeIndex(task)
%assign idx = -1
%if !ISFIELD(task, "Name") && !ISFIELD(task, "RTWIndex")
%foreach tid = NumRuntimeExportedRates
%assign taskSampleTime = LibGetSampleTimePeriodAndOffset(tid, 0)
%if ISEQUAL(taskSampleTime, task.Period)
%assign idx = tid
%break
%endif
%endforeach
%else
%assign idx = task.EntryPointInfo[0].SampleTimeIndices[0]
%endif
%if idx == 1 && LibGetTID01EQ()
%assign idx = 0
%endif
%return idx
%endfunction
%function SLibDeploymentGetNumPeriodicTasks() void
%assert (LibIsDeploymentDiagram())
%assign retVal = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%if ISEQUAL(::CompiledModel.EventHandler[tgIdx].Periodicity.Type, "PeriodicTrigger")
%assign retVal = retVal + ::CompiledModel.EventHandler[tgIdx].NumTasks
%endif
%endforeach
%return retVal
%endfunction
%function SLibGetMDSPIDFromTid(tid) void
%assign mdsPID = []
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%with ::CompiledModel.EventHandler[tgIdx]
%if ISEQUAL(Periodicity.Type, "PeriodicTrigger")
%foreach taskIdx = NumTasks
%assign task = Task[taskIdx]
%if tid == FcnGetTaskSampleTimeIndex(task)
%assign mdsPID = mdsPID + task.PID
%endif
%endforeach
%if NumTasks == 0 && ...
tid == FcnGetTaskSampleTimeIndex(::CompiledModel.EventHandler[tgIdx])
%assign mdsPID = mdsPID + PID
%endif
%else
%if NumTasks == 0 && ...
tid == FcnGetTaskSampleTimeIndex(::CompiledModel.EventHandler[tgIdx])
%assign mdsPID = mdsPID + PID
%elseif NumTasks == 1 && ...
tid == FcnGetTaskSampleTimeIndex(Task[0])
%assign mdsPID = mdsPID + Task[0].PID
%endif
%endif
%endwith
%endforeach
%return mdsPID
%endfunction
%function SLibGetMDSTaskTID() void
%assign mdsTaskTid = []
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%with ::CompiledModel.EventHandler[tgIdx]
%if ISEQUAL(Periodicity.Type, "PeriodicTrigger")
%foreach taskIdx = NumTasks
%assign task = Task[taskIdx]
%assign mdsTaskTid = mdsTaskTid + FcnGetTaskSampleTimeIndex(task)
%endforeach
%else
%if ISFIELD(::CompiledModel.EventHandler[tgIdx], "PID")
%assign mdsTaskTid = mdsTaskTid + ...
FcnGetTaskSampleTimeIndex(::CompiledModel.EventHandler[tgIdx])
%else
%assert NumTasks == 1
%assign mdsTaskTid = mdsTaskTid + FcnGetTaskSampleTimeIndex(Task[0])
%endif
%endif
%endwith
%endforeach
%return mdsTaskTid
%endfunction
%function SLibMDSTaskNeedFcnDecl(pid) void
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%with ::CompiledModel.EventHandler[tgIdx]
%foreach taskIdx = NumTasks
%if Task[taskIdx].PID == pid && ...
SLibDeploymentIsSynthesizedTask(tgIdx, taskIdx)
%return TLC_TRUE
%endif
%endforeach
%endwith
%endforeach
%return TLC_FALSE
%endfunction
%function SLibGetMDSRootSyntPIDForContRate() void
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%with ::CompiledModel.EventHandler[tgIdx]
%foreach taskIdx = NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, taskIdx) && ...
FcnGetTaskSampleTimeIndex(Task[taskIdx]) == 0 && ...
Task[taskIdx].NumContStates > 0
%return Task[taskIdx].PID
%endif
%endforeach
%endwith
%endforeach
%return -1
%endfunction
%function SLibMDSTaskIsSynthesized(pid) void
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%with ::CompiledModel.EventHandler[tgIdx]
%foreach taskIdx = NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, taskIdx) && ...
Task[taskIdx].PID == pid
%return TLC_TRUE
%endif
%endforeach
%endwith
%endforeach
%return TLC_FALSE
%endfunction
%function SLibDeploymentGetNumPeriodicMappedEntities() void
%assert (LibIsDeploymentDiagram())
%assign retVal = 0
%foreach ehIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[ehIdx]
%if ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%assign nTasks = tg.NumTasks
%if ISEQUAL(nTasks, 0)
%assign retVal = retVal + 1
%else
%assign retVal = retVal + nTasks
%endif
%endif
%endforeach
%return retVal
%endfunction
%function SLibDeploymentIsSynthesizedTask(ehIdx, taskIdx) void
%assert (LibIsDeploymentDiagram())
%return (ISEMPTY(SLibDeploymentGetTaskName(ehIdx,taskIdx)) && ...
!ISFIELD(::CompiledModel.EventHandler[ehIdx].Task[taskIdx], "RTWIndex"))
%endfunction
%function FcnGetNumPeriodicUserMappedEntities() void
%assert (LibIsDeploymentDiagram())
%assign retVal = 0
%foreach ehIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[ehIdx]
%if ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%foreach tIdx = tg.NumTasks
%if !SLibDeploymentIsSynthesizedTask(ehIdx, tIdx)
%assign retVal = retVal + 1
%endif
%endforeach
%if ISEQUAL(tg.NumTasks, 0)
%assign retVal = retVal + 1
%endif
%endif
%endforeach
%return retVal
%endfunction
%function SLibDeploymentGetNumAperiodicTriggersAndTasks() void
%assert (LibIsDeploymentDiagram())
%assign retVal = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%with ::CompiledModel.EventHandler[tgIdx]
%if ISEQUAL(Periodicity.Type, "AperiodicTrigger")
%if NumTasks > 0
%assign numTasks = NumTasks
%elseif NumEntryPointInfos > 0
%assign numTasks = 1
%else
%assign numTasks = 0
%endif
%assign retVal = retVal + numTasks
%endif
%endwith
%endforeach
%return retVal
%endfunction
%function SLibDeploymentGetNumAperiodicTasks() void
%assert (LibIsDeploymentDiagram())
%assign retVal = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%if ISEQUAL(::CompiledModel.EventHandler[tgIdx].Periodicity.Type, "AperiodicTrigger")
%assign retVal = retVal + ::CompiledModel.EventHandler[tgIdx].NumTasks
%endif
%endforeach
%return retVal
%endfunction
%function SLibDeploymentGetTaskRTMVarName()
%assert (LibIsDeploymentDiagram())
%assign varName = "task_M"
%return varName
%endfunction
%function SLibDeploymentGetTasksRTMVarName(entryPointIdx)
%assert (LibIsDeploymentDiagram())
%assign varName = SLibDeploymentGetTaskRTMVarName()
%if GenerateClassInterface
%assign varName = "(&" + varName + "[%<entryPointIdx>]" + ")"
%else
%assign varName = varName + "[%<entryPointIdx>]"
%endif
%return varName
%endfunction
%function FcnGetTasksContStatesVarName()
%assert (LibIsDeploymentDiagram())
%assign varName = "%<::tContState>"
%return varName
%endfunction
%function FcnGetTasksPeriodicContStateIndicesVarName()
%assert (LibIsDeploymentDiagram())
%assign varName = "%<::tPeriodicStateInd>"
%return varName
%endfunction
%function FcnGetTasksPeriodicContStateRangesVarName()
%assert (LibIsDeploymentDiagram())
%assign varName = "%<::tPeriodicStateRng>"
%return varName
%endfunction
%function SLibDeploymentGetTasksMassMatricesVarName(tIdx)
%assert (LibIsDeploymentDiagram())
%assign varName = "task_MassMatrix_%<tIdx>"
%return varName
%endfunction
%function SLibDeploymentGetTasksSfcnInfoVarName()
%assert (LibIsDeploymentDiagram())
%assign varName = "sfcnInfo"
%return varName
%endfunction
%function SLibDeploymentDiagramIsMapped(systemIdx) void
%if (systemIdx == NumSystems-1)
%return TLC_TRUE
%else
%return TLC_FALSE
%endif
%endfunction
%function SLibDeploymentRTMGet(recordName, rtmName)
%assert (LibIsDeploymentDiagram())
%assign rtRecs = RTMGetRTModelRecShell()
%assign theRec = rtRecs.%<recordName>
%switch (theRec.RecType)
%case "Variable"
%assign buf = FcnGenFieldAccessString(theRec, "get", "", "", rtmName)
%break
%case "IndexedAccess"
%assign refRec = rtRecs.%<theRec.AccessedRec>
%assign buf = FcnGenFieldAccessString(refRec, "get", "", "", rtmName)
%break
%case "SpecialAccess"
%assign optIdx = ""
%assign nArgs = (optIdx == "") ? 0 : 1
%assign buf = FcnGenSpecialAccess(NumSystems-1, recordName, "get", ...
nArgs, ["%<optIdx>"], "", rtmName)
%break
%default
%assign buf = ""
%break
%endswitch
%return buf
%endfunction
%function FcnRTMSet(recordName, fldIdx, initVal, rtmName)
%if TYPE(initVal) != "String"
%assign initVal = "%<initVal>"
%endif
%assign rtRecs = RTMGetRTModelRecShell()
%assign theRec = rtRecs.%<recordName>
%switch (theRec.RecType)
%case "Variable"
%assign buf = FcnGenFieldAccessString(theRec, "set", fldIdx, initVal, ...
rtmName)
%break
%case "IndexedAccess"
%assign refRec = rtRecs.%<theRec.AccessedRec>
%assign buf = FcnGenFieldAccessString(refRec, "set", fldIdx, initVal, ...
rtmName)
%break
%case "SpecialAccess"
%assign optIdx = ""
%assign nArgs = (optIdx == "") ? 0 : 1
%assign buf = FcnGenSpecialAccess(NumSystems-1, recordName, "set", ...
nArgs, ["%<optIdx>"], initVal, rtmName)
%break
%default
%assign buf = ""
%break
%endswitch
%return buf
%endfunction
%function FcnRTMGetSolverInfo(rtmName) void
%assert (!IsModelReferenceNonSimstructBasedRTWTarget() && ...
SLibIsERTCodeFormat() && !UsingMalloc)
%assign retVal = "&%<SLibDeploymentRTMGet("RTWSolverInfo", rtmName)>"
%return retVal
%endfunction
%function FcnRTMSolverSet(fldName, sVal, rtmName) void
%assign rts = FcnRTMGetSolverInfo(rtmName)
%assign setStr = "rtsiSet%<fldName>(%<rts>, %<sVal>)"
%return setStr
%endfunction
%function FcnERTSetSolverStopTime(rtmName)
%openfile retBuf
%assign needGuard = TLC_FALSE
/* set solver stop time */
%assign ct = SLibDeploymentRTMGet("ClockTick0", rtmName)
%assign ss = SLibDeploymentRTMGet("StepSize0", rtmName)
%if SLibClockTickIsUnit32Pair(0)
%assign cth = SLibDeploymentRTMGet("ClockTickH0", rtmName)
if (!(%<ct>+1)) {
rtsiSetSolverStopTime(%<FcnRTMGetSolverInfo(rtmName)>, ...
((%<cth> + 1) * %<ss> * 4294967296.0));
} else {
rtsiSetSolverStopTime(%<FcnRTMGetSolverInfo(rtmName)>, ...
((%<ct> + 1) * %<ss> + %<cth> * %<ss> * 4294967296.0));
}
%else
rtsiSetSolverStopTime(%<FcnRTMGetSolverInfo(rtmName)>,((%<ct>+1)*%<ss>));
%endif
%closefile retBuf
%return retBuf
%endfunction
%function FcnGetTaskTime(ss, tid, rtmName) void
%assert (SLibIsERTCodeFormat())
%return RTMsGetTaskTimeForTIDGivenRTM(ss, rtmName, tid)
%endfunction
%function FcnDumpUpdateRateTransitionFlags(tid, rtmName)
%assert (!IsModelReferenceTarget() && SLibIsERTCodeFormat())
%openfile retBuf
%foreach idx = NumRuntimeExportedRates - tid - 1
%assign j = idx + tid + 1
%if SLibGetNeedRateInteraction(tid, j)
%assign cTick = SLibDeploymentRTMGet("TaskCounters", rtmName)
%assign shMat = SLibDeploymentRTMGet("PerTaskSampleHits", rtmName)
%assign limit = FcnComputeTaskTickLimit">FcnComputeTaskTickLimit(j)/FcnComputeTaskTickLimit">FcnComputeTaskTickLimit(tid)
%<SLibAddTIDtoAccessTIDList(...
System[NumSystems-1].Interface.RTMArgDef,::BlockFcn,"",tid)>
%assign period = ::CompiledModel.SampleTime[tid].PeriodAndOffset[0]
%assign offset = ::CompiledModel.SampleTime[tid].PeriodAndOffset[1]
%assign s_period = ::CompiledModel.SampleTime[j].PeriodAndOffset[0]
%assign s_offset = ::CompiledModel.SampleTime[j].PeriodAndOffset[1]
/* Update the flag to indicate when data transfers from
* Sample time: [%<period>s, %<offset>s] to Sample time: [%<s_period>s, %<s_offset>s] */
%if SLibModelHierarchyContainsNoninlinedSfcn() || GenerateGRTWrapper
%<SLibDeploymentRTMGet("PerTaskSampleHitsPtr", rtmName)>[%] = ...
(%<shMat>.%<SLibERTMultiRateTimingField(j,tid)> == 0);
%endif
%if HasModelReferenceBlocks() && ...
(SuppressMultiTaskScheduler || (UseTargetTaskScheduler() && !SLibSingleTasking()))
%<shMat>.b_%<SLibERTMultiRateTimingField(j,tid)> = ...
(%<shMat>.%<SLibERTMultiRateTimingField(j,tid)> == 0);
%endif
(%<shMat>.%<SLibERTMultiRateTimingField(j,tid)>)++;
if ((%<shMat>.%<SLibERTMultiRateTimingField(j,tid)>) > %) {
%<shMat>.%<SLibERTMultiRateTimingField(j,tid)> = 0;
}
%endif
%endforeach
%closefile retBuf
%return retBuf
%endfunction
%function FcnUpdateRateTransitionFlags(tid, skipMajorTimeCheck, rtmName)
%assert (SLibIsERTCodeFormat())
%openfile tmpBuf
%if !RootSystemIsSingleRate
%if FixedStepOpts.TID01EQ
%if ISEQUAL(tid, 0)
%<FcnDumpUpdateRateTransitionFlags(0, rtmName)>
%<FcnDumpUpdateRateTransitionFlags(1, rtmName)>
%elseif ISEQUAL(tid, 1)
%else
%<FcnDumpUpdateRateTransitionFlags(tid, rtmName)>
%endif
%else
%<FcnDumpUpdateRateTransitionFlags(tid, rtmName)>
%endif
%endif
%closefile tmpBuf
%openfile retBuf
%if !WHITE_SPACE(tmpBuf)
%if !skipMajorTimeCheck && (tid == 0) && (NumContStates > 0)
if (%<RTMIs("MajorTimeStep")>) {
%<tmpBuf>
}
%else
%<tmpBuf>
%endif
%endif
%closefile retBuf
%return retBuf
%endfunction
%function FcnGetTimingForTopOfOutputFcn(tid, rtmName, continuousOutput)
%assert (!UsingMalloc)
%assign needMajorTimeGuard = continuousOutput
%assign retBuf = ""
%openfile buf
%if continuousOutput
%<FcnERTSetSolverStopTime(rtmName)>
%endif
%<FcnUpdateRateTransitionFlags(tid, needMajorTimeGuard, rtmName)>
%closefile buf
%openfile retBuf
%if !WHITE_SPACE(buf)
%if needMajorTimeGuard
%assign rtmIsMajorTimeStep = FcnGenSpecialAccess(NumSystems-1, ...
"MajorTimeStep", "is", 0, [], "", rtmName)
if (%<rtmIsMajorTimeStep>) {
%endif
%<buf>
%if needMajorTimeGuard
} /* end MajorTimeStep */
%endif
%endif
%if needMajorTimeGuard
/* Update absolute time of base rate at minor time step */
%assign rtmIsMinorTimeStep = FcnGenSpecialAccess(NumSystems-1, ...
"MinorTimeStep", "is", 0, [], "", rtmName)
%assign tid = 0
if (%<rtmIsMinorTimeStep>) {
%<FcnGetTaskTime(System[NumSystems-1], tid, rtmName)> = rtsiGetT(%<FcnRTMGetSolverInfo(rtmName)>);
}
%endif
%closefile retBuf
%return retBuf
%endfunction
%function FcnRTMUpdateRealAbsoluteTimeForTID(tid, rtmName, continuousUpdate) void
%assert (!IsModelReferenceRTWTarget() && GenRTModel && !UsingMalloc)
%assign updateRealTimeFromSolverInfo = continuousUpdate
%assign offsetStr = FcnSampleTimeOffsetString(tid)
%if SLibClockTickIsUnit32Pair(tid)
%assign ct = SLibDeploymentRTMGet("ClockTick%<tid>", rtmName)
%assign cth = SLibDeploymentRTMGet("ClockTickH%<tid>", rtmName)
%assign ss = SLibDeploymentRTMGet("StepSize%<tid>", rtmName)
%assign tt = "%<FcnGetTaskTime(System[NumSystems-1], tid, rtmName)>"
%assign updStr = "if(!(++%<ct>)) {/n ++%<cth>; /n}"
%if PurelyIntegerCode
/* Integer time limited to single word timer. */
%assign updStr = "%<updStr> %<tt> = %<ct>;"
%elseif updateRealTimeFromSolverInfo
%assign updStr = "%<updStr> %<tt> = rtsiGetSolverStopTime(%<FcnRTMGetSolverInfo(rtmName)>);"
%else
%assign updStr = "%<updStr> %<tt> = %<ct> * %<ss> + %<cth> * %<ss> * 4294967296.0"
%assign updStr = updStr + offsetStr+";"
%endif
%else
%assign ct = SLibDeploymentRTMGet("ClockTick%<tid>", rtmName)
%assign ss = SLibDeploymentRTMGet("StepSize%<tid>", rtmName)
%assign tt = "%<FcnGetTaskTime(System[NumSystems-1], tid, rtmName)>"
%if PurelyIntegerCode
%assign updStr = "%<tt> = /n (++%<ct>);"
%elseif updateRealTimeFromSolverInfo
%assign updStr = "++%<ct>; /n %<tt> = rtsiGetSolverStopTime(%<FcnRTMGetSolverInfo(rtmName)>);"
%else
%assign updStr = "%<tt> = /n (++%<ct>) * %<ss>"
%assign updStr = updStr + offsetStr + ";"
%endif
%endif
%return updStr
%endfunction
%function FcnRTMUpdateIntegerAbsoluteTimeForTID(tid, rtmName) void
%assert (GenRTModel)
%assign updStr = ""
%if SLibClockTickIsUnit32Pair(tid)
%assign ct = SLibDeploymentRTMGet("ClockTick%<tid>", rtmName)
%assign cth = SLibDeploymentRTMGet("ClockTickH%<tid>", rtmName)
%if !ISEMPTY(ct)
%assign updStr = "%<ct>++;"
%assign updStr = "%<updStr>/n if (!%<ct>) {/n %<cth>++; /n}"
%endif
%else
%assign ct = SLibDeploymentRTMGet("ClockTick%<tid>", rtmName)
%if !ISEMPTY(ct)
%assign updStr = "%<ct>++;"
%endif
%endif
%return updStr
%endfunction
%function FcnRTMUpdateAbsoluteTimeForTID(tid, rtmName, continuousUpdate) void
%openfile tmpBuf
%<SLibGenAbsTimeComment(tid)>
%if SampleTime[tid].NeedFloatTime == "yes"
%<FcnRTMUpdateRealAbsoluteTimeForTID(tid, rtmName, continuousUpdate)>
%else
%<FcnRTMUpdateIntegerAbsoluteTimeForTID(tid, rtmName)>
%endif
%closefile tmpBuf
%return tmpBuf
%endfunction
%function LocFcnUpdateAbsoluteTimeNonRateGrouping(ssIdx, rtmName, continuousUpdate)
%assert (!IsModelReferenceForASimstructBasedTarget())
%assign absTimeDumped = TLC_FALSE
%openfile tmpBuf
%if SLibNeedAbsoluteTimeForTID(0)
/* Update absolute time for base rate */
%<FcnRTMUpdateAbsoluteTimeForTID(0, rtmName, continuousUpdate)>
%assign absTimeDumped = TLC_TRUE
%endif
%closefile tmpBuf
%if absTimeDumped
%assign arg = ::CompiledModel.System[ssIdx].Interface.RTMArgDef
%<SLibAccessArgHelper(arg,"","")>
%endif
%return tmpBuf
%endfunction
%function LocFcnUpdateAbsoluteTimeRateGrouping(ssIdx, subRateIdx, rtmName, ...
continuousUpdate) void
%assert (!IsModelReferenceForASimstructBasedTarget())
%assign tmpBuf = ""
%if SLibNeedAbsoluteTimeForTID(subRateIdx)
%openfile tmpBuf
%assert(SampleTime[subRateIdx].NeedAbsoluteTime == "yes")
/* Update absolute time */
%<FcnRTMUpdateAbsoluteTimeForTID(subRateIdx, rtmName, continuousUpdate)>
%closefile tmpBuf
%assign arg = ::CompiledModel.System[ssIdx].Interface.RTMArgDef
%<SLibAddTIDtoAccessTIDList(arg, ::BlockFcn, "",subRateIdx)>
%endif
%return tmpBuf
%endfunction
%function FcnGenUpdateAbsoluteTimeCode(rtmName, isPeriodicRateGrouping, tid, ...
continuousUpdate) void
%assign ::initBlockFcn = ::BlockFcn
%assign ::BlockFcn = "Update"
%openfile tmpBuf
%if isPeriodicRateGrouping || FixedStepOpts.TID01EQ
%assign System[NumSystems-1].CurrentTID = tid
%<LocFcnUpdateAbsoluteTimeRateGrouping(NumSystems-1, tid, rtmName, ...
continuousUpdate)>
%if FixedStepOpts.TID01EQ && (tid == 0)
%assign System[NumSystems-1].CurrentTID = 1
%<LocFcnUpdateAbsoluteTimeRateGrouping(NumSystems-1, 1, rtmName, ...
continuousUpdate)>
%endif
%assign System[NumSystems-1].CurrentTID = -1
%else
%<LocFcnUpdateAbsoluteTimeNonRateGrouping(NumSystems-1, rtmName, ...
continuousUpdate)>
%endif
%closefile tmpBuf
%assign ::BlockFcn = initBlockFcn
%return tmpBuf
%endfunction
%function FcnErtGenStopSimCode(rtmName)
%assign ::BlockFcn = "RootUpdate"
%assign rootSystem = System[NumSystems-1]
%assign isPeriodicRateGrouping = SLibIsMultiRateAndPeriodicRateGrouping(rootSystem)
%assign rootSystem.CurrentTID = 0
%openfile stopSimBuffer
%if !GenerateGRTWrapper
%if MatFileLogging
/* signal main to stop simulation */
%<FcnGenerateTidGuardOpenCode(0)>
%assign taskTime = (NumContStates > 0) ? ...
FcnGetTaskTime(System[NumSystems-1], FixedStepOpts.TID01EQ, rtmName) : ...
FcnGetTaskTime(System[NumSystems-1], 0, rtmName)
if ( (%<SLibDeploymentRTMGet("TFinal", rtmName)>!=-1) &&
!((%<SLibDeploymentRTMGet("TFinal", rtmName)>-%<taskTime>) > %<taskTime> * ...
%<LibGetMathConstant("EPSILON",tSS_DOUBLE)>)) {
%<RTMSetErrStat("/"Simulation finished/"")>;
}
%if NumChildSFunctions
if (%<RTMGetStopRequested()>) {
%<RTMSetErrStat("/"Simulation finished/"")>;
}
%endif
%<FcnGenerateTidGuardCloseCode(0)>
%endif
%assign stopTime = SLibERTGetStopTime()
%assign lifeSpanInSeconds = ::CompiledModel.ConfigSet.EvaledLifeSpan * 86400
%if stopTime > lifeSpanInSeconds
%assign warnTxt = "Stop time %<stopTime> (seconds) is out the range of "...
"Application life span %<::CompiledModel.ConfigSet.EvaledLifeSpan> (days). "...
"Generated code may fail to stop because timer can overflow before the stop time is reached. "...
"Consider choosing smaller 'Stop time' on Solver pane, or longer "...
"'Application life span' on Optimization pane."
%<LibReportWarning(warnTxt)>
%endif
%endif
%closefile stopSimBuffer
%assign rootSystem.CurrentTID = -1
%return stopSimBuffer
%endfunction
%function FcnGetTimingForBottomOfUpdateFcn(tid, skipMajorTimeCheck, taskName, ...
rtmName, continuousUpdate)
%assert (!IsModelReferenceTarget())
%if WHITE_SPACE(taskName)
%assign updateContStatesFcnName = "rt_ertODEUpdateContinuousStates"
%else
%assign updateContStatesFcnName = "%<taskName>_rt_ertODEUpdateContinuousStates"
%endif
%assign rtmIsMajorTimeStep = FcnGenSpecialAccess(NumSystems-1, ...
"MajorTimeStep", "is", 0, [], "", rtmName)
%assign needMajorTimeGuard = !skipMajorTimeCheck && continuousUpdate
%openfile buff
%if needMajorTimeGuard
if (%<rtmIsMajorTimeStep>) {
%endif
%if ISEQUAL(tid, 0) || ISEQUAL(tid, "")
%<FcnErtGenStopSimCode(rtmName)>
%endif
%if continuousUpdate
%assign reuseArgs = SLibModelFcnArgs("ODEUpdateContinuousStates",2,0)
%if !ISEQUAL(reuseArgs,"")
%assign reuseArgs = ", " + reuseArgs
%endif
%if !needMajorTimeGuard
if (%<rtmIsMajorTimeStep>) {
%<updateContStatesFcnName>(%<FcnRTMGetSolverInfo(rtmName)>%<reuseArgs>);
}
%else
%<updateContStatesFcnName>(%<FcnRTMGetSolverInfo(rtmName)>%<reuseArgs>);
%endif
%endif
%assert !LibAsynchronousTriggeredTID(tid)
%assign isPeriodicRateGrouping = SLibIsMultiRateAndPeriodicRateGrouping(System[NumSystems-1])
%assign tmpBuf = FcnGenUpdateAbsoluteTimeCode(rtmName, isPeriodicRateGrouping, ...
tid, continuousUpdate)
%if !WHITE_SPACE(tmpBuf)
%<tmpBuf>
%endif
%if needMajorTimeGuard
} /* end MajorTimeStep */
%endif
%closefile buff
%return buff
%endfunction
%function FcnDumpOneMoreMinorOutput(fcnName, rtmName, tid, tNumContStates)
%openfile tempBuf
%if ::CompiledModel.ModelBlocksUseContTimeOutputInconsistentWithStateAtMajorStep || ...
ISFIELD(::CompiledModel, "HasContTimeOutputInconsistentWithStateAtMajorStep")
%if (ISEQUAL(tid,0) || ISEQUAL(tid, "")) && (tNumContStates > 0)
/* ContTimeOutputInconsistentWithStateAtMajorStepFlag is set, need to run a minor output */
%assign rtmIsMajorTimeStep = FcnGenSpecialAccess(NumSystems-1, ...
"MajorTimeStep", "is", 0, [], "", rtmName)
%assign solverInfo = "%<FcnRTMGetSolverInfo(rtmName)>"
if (%<rtmIsMajorTimeStep>) {
if (rtsiGetContTimeOutputInconsistentWithStateAtMajorStep(%<solverInfo>)) {
rtsiSetSimTimeStep(%<solverInfo>, MINOR_TIME_STEP);
rtsiSetContTimeOutputInconsistentWithStateAtMajorStep(%<solverInfo>, %);
%<fcnName>();
rtsiSetSimTimeStep(%<solverInfo>, MAJOR_TIME_STEP);
}
}
%endif
%endif
%closefile tempBuf
%return tempBuf
%endfunction
%function FcnGenerateContinuousOutput(tid, task, entryPointIdx)
%assign rootSystem = System[NumSystems-1]
%assign fcnName = "%<task.FunctionName>_output"
%assign fcnReturns = "void"
%assign fcnParams = "void"
%assign rootSystem.CurrentTID = tid
%assign rootSystem.CurrentPID = task.PID
%assign rtmName = SLibDeploymentGetTasksRTMVarName(entryPointIdx)
%openfile tmpBuffer
%assign fcnAbstract = "Output for Task: %<task.FunctionName>"
%assign ::BlockFcn = "Output"
%assign timingCodeBuf = FcnGetTimingForTopOfOutputFcn(tid, rtmName, TLC_TRUE)
%assign rtmIsMajorTimeStep = FcnGenSpecialAccess(NumSystems-1, ...
"MajorTimeStep", "is", 0, [], "", rtmName)
%openfile fcnProtoType
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%if SLibNeedDumpRootSysPrototypeInPrivateHeader("Output", tid)
%<LibAddToSystemField(rootSystem, "SystemFcnPrototype","%<fcnProtoType>;")>
%endif
%assign empty = TLC_TRUE
%if !LibSystemFcnIsEmptyForTID(rootSystem,"Output")
%assign empty = TLC_FALSE
%endif
%openfile outputCode
%if empty && WHITE_SPACE(timingCodeBuf)
/* (no output code required) */
%else
%<SLibDumpLocalTidInSystem(rootSystem, "Output")>
%<LibGetSystemLocalVars(rootSystem,"Output", tid)>
%<LibGetSystemLocalVars(rootSystem, "OutputUpdate", tid)>
%if !WHITE_SPACE(timingCodeBuf)
%<timingCodeBuf>
%endif
%if !LibSystemFcnIsEmpty(rootSystem, "Output")
%openfile localVars
%<SLibGetFcnLocalVars(rootSystem, "Output", tid)>
%closefile localVars
%if !WHITE_SPACE(localVars)
{
%<localVars>
%endif
%<SLibGetBodyOutputFcnCache(rootSystem)>
%if !WHITE_SPACE(localVars)
}
%endif
%endif
%endif
%closefile outputCode
%if WHITE_SPACE(outputCode)
%assign outputCode = "/* (no output code required) */"
%endif
%openfile fcnContent
%<outputCode>
%closefile fcnContent
%addtorecord task OutputWrapperFcn fcnName
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertlib.tlc"; Type "Output"; ...
GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%<fcnProtoType> %<LibTaskComment(tid)>
{
%<fcnContent>
}
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%assign rootSystem.CurrentPID = -1
%return(tmpBuffer)
%endfunction
%function FcnGenerateContinuousUpdate(tid, task, entryPointIdx)
%assign rootSystem = System[NumSystems-1]
%assign fcnName = "%<task.FunctionName>_update"
%assign fcnReturns = "void"
%assign fcnParams = "void"
%assign rootSystem.CurrentTID = tid
%assign rootSystem.CurrentPID = task.PID
%assign rtmName = SLibDeploymentGetTasksRTMVarName(entryPointIdx)
%openfile tmpBuffer
%assign fcnAbstract = " Update for Task: %<task.FunctionName>"
%openfile fcnProtoType
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%assign empty = TLC_TRUE
%if !LibSystemFcnIsEmptyForTID(rootSystem,"Output")
%assign empty = TLC_FALSE
%endif
%if SLibNeedDumpRootSysPrototypeInPrivateHeader("Update", tid)
%<LibAddToSystemField(rootSystem, "SystemFcnPrototype","%<fcnProtoType>;")>
%endif
%openfile updateCode
%<SLibDumpLocalTidInSystem(rootSystem, "Update")>
%<LibGetSystemLocalVars(rootSystem,"Update", tid)>
%if !LibSystemFcnIsEmpty(rootSystem, "Update")
%openfile localVars
%<SLibGetFcnLocalVars(rootSystem, "Update", tid)>
%closefile localVars
%if !WHITE_SPACE(localVars)
{
%<localVars>
%endif
%<SLibGetBodyUpdateFcnCache(rootSystem)>
%if !WHITE_SPACE(localVars)
}
%endif
%endif
%<FcnDumpOneMoreMinorOutput(task.OutputWrapperFcn, rtmName, ...
tid, task.NumContStates)>
%<FcnGetTimingForBottomOfUpdateFcn(tid, TLC_TRUE, task.FunctionName, ...
rtmName, TLC_TRUE)>
%closefile updateCode
%if WHITE_SPACE(updateCode)
%assign updateCode = "/* (no update code required) */"
%endif
%openfile fcnContent
%<updateCode>
%closefile fcnContent
%if !WHITE_SPACE(fcnContent)
%addtorecord task UpdateWrapperFcn fcnName
%else
%addtorecord task UpdateWrapperFcn ""
%endif
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertlib.tlc"; ...
Type "Update"; GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%<fcnProtoType> %<LibTaskComment(tid)>
{
%<fcnContent>
}
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%assign rootSystem.CurrentPID = -1
%return tmpBuffer
%endfunction
%function FcnGenerateContinuousOutputUpdate(tid, task, entryPointIdx)
%assign tmpBlockFcn = ::BlockFcn
%assign rootSystem = System[NumSystems-1]
%assign ::BlockFcn = "OutputUpdate"
%assign fcnName = "%<task.FunctionName>_step"
%assign fcnReturns = "void"
%assign fcnParams = "void"
%assign rootSystem.CurrentTID = tid
%assign rootSystem.CurrentPID = task.PID
%assign rtmName = SLibDeploymentGetTasksRTMVarName(entryPointIdx)
%openfile tmpBuffer
%assign fcnAbstract = "Step for Task: %<task.FunctionName>"
%assign timingCodeBuf = FcnGetTimingForTopOfOutputFcn(tid, rtmName, TLC_TRUE)
%assign rtmIsMajorTimeStep = FcnGenSpecialAccess(NumSystems-1, ...
"MajorTimeStep", "is", 0, [], "", rtmName)
%openfile fcnProtoType
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%if SLibNeedDumpRootSysPrototypeInPrivateHeader("OutputUpdate",tid)
%<LibAddToSystemField(rootSystem, "SystemFcnPrototype","%<fcnProtoType>;")>
%endif
%openfile fcnContent
%<LibGetSystemLocalVars(rootSystem,"OutputUpdate", tid)>
%<LibGetSystemLocalVars(rootSystem,"Output", tid)>
%<LibGetSystemLocalVars(rootSystem,"Update", tid)>
%openfile outputUpdateCode
%if !WHITE_SPACE(timingCodeBuf)
%<timingCodeBuf>
%endif
%if !LibSystemFcnIsEmpty(rootSystem, "Output")
%openfile localVars
%<SLibGetFcnLocalVars(rootSystem, "OutputUpdate", tid)>
%<SLibGetFcnLocalVars(rootSystem, "Output", tid)>
%closefile localVars
%if !WHITE_SPACE(localVars)
{
%<localVars>
%endif
%<SLibGetBodyOutputFcnCache(rootSystem)>
%if !WHITE_SPACE(localVars)
}
%endif
%endif
%openfile updateCode
%if !LibSystemFcnIsEmpty(rootSystem, "Update")
%openfile localVars
%<SLibGetFcnLocalVars(rootSystem, "Update", tid)>
%closefile localVars
%if !WHITE_SPACE(localVars)
{
%<localVars>
%endif
%assign fcnInfo = LibGetFcnInfo(rootSystem, "Update", rootSystem.CurrentTID)
%<SLibGetBodyUpdateFcnCache(rootSystem)>
%if !WHITE_SPACE(localVars)
}
%endif
%endif
%<FcnDumpOneMoreMinorOutput(fcnName, rtmName, tid, task.NumContStates)>
%closefile updateCode
%if !WHITE_SPACE(updateCode)
if (%<rtmIsMajorTimeStep>) {
%<updateCode>
} /* end MajorTimeStep */
%endif
%<FcnGetTimingForBottomOfUpdateFcn(tid, TLC_FALSE,task.FunctionName, rtmName, ...
TLC_TRUE)>
%closefile outputUpdateCode
%if WHITE_SPACE(outputUpdateCode)
%assign outputUpdateCode = "/* (no output/update code required) */"
%endif
%<outputUpdateCode>
%closefile fcnContent
%addtorecord task OutputWrapperFcn fcnName
%addtorecord task UpdateWrapperFcn ""
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertlib.tlc"; ...
Type "Step"; GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%<fcnProtoType> %<LibTaskComment(tid)>
{
%<fcnContent>
}
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%assign rootSystem.CurrentPID = -1
%assign ::BlockFcn = tmpBlockFcn
%return(tmpBuffer)
%endfunction
%function FcnGenerateModelEntryPoint(fcnType)
%assert ((fcnType == "OutputUpdate") || (fcnType == "Output") || ...
(fcnType == "Update"))
%assign rootSystem = System[NumSystems-1]
%assign tmpBlockFcn = ::BlockFcn
%if ISEQUAL(fcnType, "OutputUpdate")
%assign topFcnName = SLibGenErtFunctionName("", "step")
%assign ::BlockFcn = "OutputUpdate"
%elseif ISEQUAL(fcnType, "Output")
%assign topFcnName = SLibGenErtFunctionName("", "output")
%assign ::BlockFcn = "Output"
%else
%assign topFcnName = SLibGenErtFunctionName("", "update")
%assign ::BlockFcn = "Update"
%endif
%assign topFcnReturns = "void"
%assign isSingleRate = LibIsSingleRateSystem(rootSystem)
%assign rootSystem.CurrentTID = ""
%openfile tmpBuffer
%assign topFcnParams = GetErtModelFcnArgs(fcnType, TLC_FALSE, "")
%createrecord fcnRec {Name topFcnName; Returns topFcnReturns; Params topFcnParams; ...
Abstract ""; Category "model"; ...
GeneratedBy "ertlib.tlc:SLibGenErt%<fcnType>Function"; ...
Type "%<fcnType>"; GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%if ISEQUAL(topFcnParams, "void")
%assert (isSingleRate)
%assign topFcnParams = "int " + ::CompiledModel.GlobalScope.tTID
%endif
%assign taskIdx = 0
%<topFcnReturns> %<topFcnName>(%<topFcnParams>) {
switch(%<::CompiledModel.GlobalScope.tTID>) {
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%openfile caseContent
%if !WHITE_SPACE(task.OutputWrapperFcn)
%if ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Output")
%if !GenerateClassInterface
%<task.OutputWrapperFcn>();
%else
%<::CPPObjectName>.%<task.OutputWrapperFcnCall>();
%endif
%endif
%if (ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Update")) && ...
!WHITE_SPACE(task.UpdateWrapperFcn)
%<task.UpdateWrapperFcn>();
%endif
%endif
%closefile caseContent
%if !WHITE_SPACE(caseContent)
case %<taskIdx> :
%<caseContent>
break;
%endif
%assign taskIdx = taskIdx + 1
%endforeach
%endforeach
default :
break;
}
}
%if !GenerateClassInterface
%assign prototypeBuf = "%<LibExternInFcnDecls()> %<topFcnReturns> %<topFcnName>(%<topFcnParams>);"
%<SLibCacheCodeToFile("mdl_extern_fcn_decl", prototypeBuf)>
%endif
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%return(tmpBuffer)
%endfunction
%function FcnGenerateDiscreteEntryPoint(tid, task, entryPointIdx, fcnType)
%assert ((fcnType == "OutputUpdate") || (fcnType == "Output") || ...
(fcnType == "Update"))
%assign rootSystem = System[NumSystems-1]
%assign tmpBlockFcn = ::BlockFcn
%if ISFIELD(task, "FunctionName")
%assign taskName = "%<task.FunctionName>"
%else
%assign taskName = "%<task.Name>"
%endif
%if !GenerateClassInterface
%if ISEQUAL(fcnType, "OutputUpdate")
%assign fcnName = "%<taskName>_step"
%assign ::BlockFcn = "OutputUpdate"
%elseif ISEQUAL(fcnType, "Output")
%assign fcnName = "%<taskName>_output"
%assign ::BlockFcn = "Output"
%else
%assign fcnName = "%<taskName>_update"
%assign ::BlockFcn = "Update"
%endif
%else
%assign classConfObj = FcnGetRTWCPPStepPrototypeRecord()
%if ISEQUAL(fcnType, "OutputUpdate")
%assign fcnCall = "%<taskName>_step"
%assign fcnName = "%<classConfObj.ModelClassName>::%<fcnCall>"
%assign ::BlockFcn = "OutputUpdate"
%else
%assign errTxt = "The fcnType cannot be %<fcnType> for C++ class interface"
%<LibReportFatalError(errTxt)>
%endif
%endif
%assign fcnParams = "void"
%assign fcnReturns = "void"
%assign rootSystem.CurrentTID = tid
%assign rootSystem.CurrentPID = task.PID
%assign rtmName = SLibDeploymentGetTasksRTMVarName(entryPointIdx)
%openfile tmpBuffer
%if ISFIELD(task, "FunctionName")
%assign fcnAbstract = "%<fcnType> for Task: %<taskName>"
%else
%assign fcnAbstract = "%<fcnType> for Trigger: %<taskName>"
%endif
%openfile fcnProtoType
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%if SLibNeedDumpRootSysPrototypeInPrivateHeader(fcnType,tid)
%<LibAddToSystemField(rootSystem, "SystemFcnPrototype","%<fcnProtoType>;")>
%endif
%openfile fcnContent
%if GenerateClassInterface
%assign backUpCPPObjectName = ::CPPObjectName
%assign ::CPPObjectName = "this"
%endif
%<LibGetSystemLocalVars(rootSystem, fcnType, tid)>
%if ISEQUAL(fcnType, "OutputUpdate")
%<LibGetSystemLocalVars(rootSystem,"Output",tid)>
%<LibGetSystemLocalVars(rootSystem,"Update",tid)>
%elseif ISEQUAL(fcnType, "Output")
%<LibGetSystemLocalVars(rootSystem, "OutputUpdate", tid)>
%endif
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%assign timingCodeBuf = FcnGetTimingForTopOfOutputFcn(tid, rtmName, TLC_FALSE)
%if !WHITE_SPACE(timingCodeBuf)
%<timingCodeBuf>
%endif
%if !LibSystemFcnIsEmpty(rootSystem, "Output")
%openfile localVars
%<SLibGetFcnLocalVars(rootSystem, fcnType, tid)>
%if ISEQUAL(fcnType, "OutputUpdate")
%<SLibGetFcnLocalVars(rootSystem, "Output", tid)>
%endif
%closefile localVars
%if !WHITE_SPACE(localVars)
{
%<localVars>
%endif
%<SLibGetBodyOutputFcnCache(rootSystem)>
%if !WHITE_SPACE(localVars)
}
%endif
%endif
%endif
%if ISEQUAL(fcnType, "Update") || ISEQUAL(fcnType, "OutputUpdate")
%if !LibSystemFcnIsEmpty(rootSystem, "Update")
%openfile localVars
%<SLibGetFcnLocalVars(rootSystem, fcnType, tid)>
%if ISEQUAL(fcnType, "OutputUpdate")
%<SLibGetFcnLocalVars(rootSystem, "Update", tid)>
%endif
%closefile localVars
%if !WHITE_SPACE(localVars)
{
%<localVars>
%endif
%<SLibGetBodyUpdateFcnCache(rootSystem)>
%if !WHITE_SPACE(localVars)
}
%endif
%endif
%<FcnGetTimingForBottomOfUpdateFcn(tid, TLC_FALSE, taskName, ...
rtmName, TLC_FALSE)>
%endif
%if GenerateClassInterface
%assign ::CPPObjectName = backUpCPPObjectName
%endif
%closefile fcnContent
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%addtorecord task OutputWrapperFcn fcnName
%if EXISTS(fcnCall)
%addtorecord task OutputWrapperFcnCall fcnCall
%endif
%if ISEQUAL(fcnType, "OutputUpdate")
%addtorecord task UpdateWrapperFcn ""
%endif
%elseif !WHITE_SPACE(fcnContent)
%addtorecord task UpdateWrapperFcn fcnName
%else
%addtorecord task UpdateWrapperFcn ""
%endif
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertlib.tlc"; ...
Type "Step"; GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%if ISEQUAL(tid, 0) && ISEQUAL(SolverType, "FixedStep") && FixedStepOpts.TID01EQ
%<fcnProtoType> %<LibTaskComment(1)>
%else
%<fcnProtoType> %<LibTaskComment(tid)>
%endif
{
%<fcnContent>
}
%if !ISFIELD(task, "FunctionName") && !GenerateClassInterface
%assign prototypeBuf = "%<LibExternInFcnDecls()>%<fcnProtoType>;"
%<SLibCacheCodeToFile("mdl_extern_fcn_decl", prototypeBuf)>
%endif
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%assign rootSystem.CurrentPID = -1
%assign ::BlockFcn = tmpBlockFcn
%return(tmpBuffer)
%endfunction
%function FcnGenerateDiscreteRateGroupEntryPoint(tid, task, fcnType)
%assert ((fcnType == "OutputUpdate") || (fcnType == "Output") || ...
(fcnType == "Update"))
%assign rootSystem = System[NumSystems-1]
%assign tmpBlockFcn = ::BlockFcn
%if ISEQUAL(fcnType, "OutputUpdate")
%assign fcnName = SLibGenErtFunctionName(tid, "step")
%assign ::BlockFcn = "OutputUpdate"
%elseif ISEQUAL(fcnType, "Output")
%assign fcnName = SLibGenErtFunctionName(tid, "output")
%assign ::BlockFcn = "Output"
%else
%assign fcnName = SLibGenErtFunctionName(tid, "update")
%assign ::BlockFcn = "Update"
%endif
%assign fcnReturns = "void"
%assign fcnParams = "void"
%assign rootSystem.CurrentTID = tid
%assign rootSystem.CurrentPID = task.PID
%assign rtmName = GetSimStructExpr(System[GetBaseSystemIdx()], ::tSimStruct)
%openfile tmpBuffer
%assign fcnAbstract = "%<fcnType> for TID: %<tid>"
%openfile fcnProtoType
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%openfile fcnContent
%assign localOutputVars = SLibGetFcnLocalVars(rootSystem, "Output", tid)
%assign localUpdateVars = SLibGetFcnLocalVars(rootSystem, "Update", tid)
%assign needBraces = !ISEMPTY(localOutputVars) && !ISEMPTY(localUpdateVars) && ...
ISEQUAL(fcnType, "OutputUpdate")
%<SLibDumpLocalTidInSystem(rootSystem, fcnType)>
%<LibGetSystemLocalVars(rootSystem, fcnType, tid)>
%if ISEQUAL(fcnType, "OutputUpdate")
%<LibGetSystemLocalVars(rootSystem,"Output",tid)>
%<LibGetSystemLocalVars(rootSystem,"Update",tid)>
%elseif ISEQUAL(fcnType, "Output")
%<LibGetSystemLocalVars(rootSystem, "OutputUpdate", tid)>
%endif
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%if !needBraces
%if ISEQUAL(fcnType, "OutputUpdate")
%<localOutputVars>
%<localUpdateVars>
%else
%<localOutputVars>
%endif
%endif
%<LibDumpSystemUserCode(rootSystem,"Output","Header")>
%assign timingCodeBuf = FcnGetTimingForTopOfOutputFcn(tid, rtmName, TLC_FALSE)
%if !WHITE_SPACE(timingCodeBuf)
%<timingCodeBuf>
%endif
%<LibDumpSystemUserCode(rootSystem,"Output","Body")>/
%if needBraces && !ISEMPTY(localOutputVars)
%<"{">
%<localOutputVars>
%endif
%<LibDumpSystemFcn(rootSystem,"Output%<tid>%<task.PID>")>/
%if needBraces && !ISEMPTY(localOutputVars)
%<"}">
%endif
%<LibDumpSystemUserCode(rootSystem,"Output","Trailer")>/
%endif
%if ISEQUAL(fcnType, "Update") || ISEQUAL(fcnType, "OutputUpdate")
%openfile updateCode
%if ISEQUAL(fcnType, "Update")
%<localUpdateVars>
%endif
%if !LibSystemUserCodeIsEmpty(rootSystem, "Update", "Header")
%<"{">
%<LibDumpSystemUserCode(rootSystem,"Update","Header")>/
%endif
%<LibDumpSystemUserCode(rootSystem,"Update","Body")>/
%if needBraces && !ISEMPTY(localUpdateVars)
%<"{">
%<localUpdateVars>
%endif
%<LibDumpSystemFcn(rootSystem,"Update%<tid>%<task.PID>")>/
%if needBraces && !ISEMPTY(localUpdateVars)
%<"}">
%endif
%<LibDumpSystemUserCode(rootSystem,"Update","Trailer")>/
%if !LibSystemUserCodeIsEmpty(rootSystem, "Update", "Header")
%<"}">
%endif
%closefile updateCode
%if !WHITE_SPACE(updateCode)
%<updateCode>
%endif
%<FcnGetTimingForBottomOfUpdateFcn(tid, TLC_TRUE, "", rtmName, TLC_FALSE)>
%endif
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%<FcnHandlesUnusedTIDArg(rootSystem, "Output")>
%else
%<FcnHandlesUnusedTIDArg(rootSystem, "Update")>
%endif
%closefile fcnContent
%if !WHITE_SPACE(fcnContent)
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%addtorecord task OutputWrapperFcn fcnName
%if ISEQUAL(fcnType, "OutputUpdate")
%addtorecord task UpdateWrapperFcn ""
%endif
%else
%addtorecord task UpdateWrapperFcn fcnName
%endif
%if SLibNeedDumpRootSysPrototypeInPrivateHeader(fcnType,tid)
%<LibAddToSystemField(rootSystem, "SystemFcnPrototype","%<fcnProtoType>;")>
%endif
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertlib.tlc"; ...
Type "Step"; GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%if ISEQUAL(tid, 0) && ISEQUAL(SolverType, "FixedStep") && FixedStepOpts.TID01EQ
%<fcnProtoType> %<LibTaskComment(1)>
%else
%<fcnProtoType> %<LibTaskComment(tid)>
%endif
{
%<fcnContent>
}
%else
%addtorecord task UpdateWrapperFcn ""
%addtorecord task OutputWrapperFcn ""
%endif
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%assign rootSystem.CurrentPID = -1
%assign ::BlockFcn = tmpBlockFcn
%return(tmpBuffer)
%endfunction
%function FcnGenerateContRateGroupEntryPoint(tid, task, fcnType)
%assert ((fcnType == "OutputUpdate") || (fcnType == "Output") || ...
(fcnType == "Update"))
%assign rootSystem = System[NumSystems-1]
%assign tmpBlockFcn = ::BlockFcn
%if ISEQUAL(fcnType, "OutputUpdate")
%assign fcnName = SLibGenErtFunctionName(tid, "step")
%assign ::BlockFcn = "OutputUpdate"
%elseif ISEQUAL(fcnType, "Output")
%assign fcnName = SLibGenErtFunctionName(tid, "output")
%assign ::BlockFcn = "Output"
%else
%assign fcnName = SLibGenErtFunctionName(tid, "update")
%assign ::BlockFcn = "Update"
%endif
%assign fcnReturns = "void"
%assign fcnParams = "void"
%assign rootSystem.CurrentTID = tid
%assign rootSystem.CurrentPID = task.PID
%assign rtmName = GetSimStructExpr(System[GetBaseSystemIdx()], ::tSimStruct)
%openfile tmpBuffer
%assign fcnAbstract = "%<fcnType> for TID: %<tid>"
%openfile fcnProtoType
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%if SLibNeedDumpRootSysPrototypeInPrivateHeader(fcnType,tid)
%<LibAddToSystemField(rootSystem, "SystemFcnPrototype","%<fcnProtoType>;")>
%endif
%openfile fcnContent
%assign localOutputVars = SLibGetFcnLocalVars(rootSystem, "Output", tid)
%assign localUpdateVars = SLibGetFcnLocalVars(rootSystem, "Update", tid)
%assign needBraces = !ISEMPTY(localOutputVars) && !ISEMPTY(localUpdateVars) && ...
ISEQUAL(fcnType, "OutputUpdate")
%<SLibDumpLocalTidInSystem(rootSystem, fcnType)>
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%<LibGetSystemLocalVars(rootSystem, "Output", tid)>
%if !needBraces
%if ISEQUAL(fcnType, "OutputUpdate")
%<localOutputVars>
%<localUpdateVars>
%else
%<localOutputVars>
%endif
%endif
%<LibDumpSystemUserCode(rootSystem,"Output","Header")>
%assign timingCodeBuf = FcnGetTimingForTopOfOutputFcn(tid, rtmName, TLC_TRUE)
%if !WHITE_SPACE(timingCodeBuf)
%<timingCodeBuf>
%endif
%<LibDumpSystemUserCode(rootSystem,"Output","Body")>/
%if needBraces && !ISEMPTY(localOutputVars)
%<"{">
%<localOutputVars>
%endif
%<LibDumpSystemFcn(rootSystem,"Output%<tid>%<task.PID>")>/
%if needBraces && !ISEMPTY(localOutputVars)
%<"}">
%endif
%<LibDumpSystemUserCode(rootSystem,"Output","Trailer")>/
%endif
%if ISEQUAL(fcnType, "Update") || ISEQUAL(fcnType, "OutputUpdate")
%openfile updateCode
%if ISEQUAL(fcnType, "Update")
%<LibGetSystemLocalVars(rootSystem,"Update",tid)>
%<localUpdateVars>
%endif
%if !LibSystemUserCodeIsEmpty(rootSystem, "Update", "Header")
%<"{">
%<LibDumpSystemUserCode(rootSystem,"Update","Header")>/
%endif
%<LibDumpSystemUserCode(rootSystem,"Update","Body")>/
%if needBraces && !ISEMPTY(localUpdateVars)
%<localUpdateVars>
%endif
%<LibDumpSystemFcn(rootSystem,"Update%<tid>%<task.PID>")>/
%if ISEQUAL(fcnType, "OutputUpdate")
%<FcnDumpOneMoreMinorOutput(fcnName, rtmName, tid, NumContStates)>
%elseif ISEQUAL(fcnType, "Update")
%assign outputFcnName = "rategroup_output%<tid>"
%<FcnDumpOneMoreMinorOutput(outputFcnName, rtmName, tid, NumContStates)>
%endif
%<LibDumpSystemUserCode(rootSystem,"Update","Trailer")>/
%if !LibSystemUserCodeIsEmpty(rootSystem, "Update", "Header")
%<"}">
%endif
%closefile updateCode
%if !WHITE_SPACE(updateCode)
if (%<RTMIs("MajorTimeStep")>) {
%<updateCode>
} /* end MajorTimeStep */
%endif
%<FcnGetTimingForBottomOfUpdateFcn(tid, TLC_TRUE, "", rtmName, TLC_TRUE)>
%endif
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%<FcnHandlesUnusedTIDArg(rootSystem, "Output")>
%else
%<FcnHandlesUnusedTIDArg(rootSystem, "Update")>
%endif
%closefile fcnContent
%if ISEQUAL(fcnType, "Output") || ISEQUAL(fcnType, "OutputUpdate")
%addtorecord task OutputWrapperFcn fcnName
%if ISEQUAL(fcnType, "OutputUpdate")
%addtorecord task UpdateWrapperFcn ""
%endif
%elseif !WHITE_SPACE(fcnContent)
%addtorecord task UpdateWrapperFcn fcnName
%else
%addtorecord task UpdateWrapperFcn ""
%endif
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertlib.tlc"; ...
Type "Step"; GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%if ISEQUAL(tid, 0) && ISEQUAL(SolverType, "FixedStep") && FixedStepOpts.TID01EQ
%<fcnProtoType> %<LibTaskComment(1)>
%else
%<fcnProtoType> %<LibTaskComment(tid)>
%endif
{
%<fcnContent>
}
%if ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Update")
%assign rootSystem.CurrentTID = tid
%<SLibGetBodyDerivativeFcnCache(rootSystem)>
%endif
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%assign rootSystem.CurrentPID = -1
%assign ::BlockFcn = tmpBlockFcn
%return(tmpBuffer)
%endfunction
%function FcnGenerateAsyncEntryPoint(tid, task)
%assign fcnType = "OutputUpdate"
%assign rootSystem = System[NumSystems-1]
%if ISFIELD(task, "FunctionName")
%if !GenerateClassInterface
%assign fcnName = "%<task.FunctionName>"
%else
%assign classConfObj = FcnGetRTWCPPStepPrototypeRecord()
%assign fcnCall = "%<task.FunctionName>"
%assign fcnName = "%<classConfObj.ModelClassName>::%<fcnCall>"
%endif
%else
%if !GenerateClassInterface
%assign fcnName = "%<task.Name>"
%else
%assign classConfObj = FcnGetRTWCPPStepPrototypeRecord()
%assign fcnCall = "%<task.Name>"
%assign fcnName = "%<classConfObj.ModelClassName>::%<fcnCall>"
%endif
%endif
%assign fcnReturns = "void"
%assign fcnParams = "void"
%assign rootSystem.CurrentTID = tid
%openfile fcnProtoType
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%openfile fcnContent
%<SLibDumpOutputUpdateCodeForAsyncTid(tid)>
%closefile fcnContent
%openfile tmpBuffer
%assign fcnAbstract = "%<fcnType> for Task:%<fcnName>"
%addtorecord task OutputWrapperFcn fcnName
%if EXISTS(fcnCall)
%addtorecord task OutputWrapperFcnCall fcnCall
%endif
%addtorecord task UpdateWrapperFcn ""
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertlib.tlc"; ...
Type "Step"; GeneratedFor FcnGeneratedFor(rootSystem)}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%<fcnProtoType> %<LibTaskComment(tid)>
{
%<fcnContent>
}
%if !GenerateClassInterface
%assign prototypeBuf = "%<LibExternInFcnDecls()> %<fcnReturns> %<fcnName>(%<fcnParams>);"
%<SLibCacheCodeToFile("mdl_extern_fcn_decl", prototypeBuf)>
%endif
%closefile tmpBuffer
%assign rootSystem.CurrentTID = -1
%return(tmpBuffer)
%endfunction
%function FcnAddEntryPointToCodeInfo(componentObj, fcnType, fcnName, tid, ...
fcnParams, fcnReturns) void
%assert ((fcnType == "OutputUpdate") || (fcnType == "Update"))
%assert ((fcnParams == "void") && (fcnReturns == "void"))
%openfile tmpBuff
tmpArgs = [];
tmpActualArgs = [];
tmpRet = coder.types.Argument.empty;
tmpActualReturn = RTW.DataInterface.empty;
%assert (SLibIsPeriodicRateGrouping() == TLC_TRUE)
%<fcnName>_Prototype = coder.types.Prototype;
%<fcnName>_Prototype.Arguments = tmpArgs;
%<fcnName>_Prototype.Return = tmpRet;
%assign ModelHeaderFile = LibGetMdlPubHdrBaseName()
%assign ModelSourceFile = LibGetMdlSrcBaseName()
%<fcnName>_Prototype.HeaderFile = ['%<ModelHeaderFile>', '.h'];
%<fcnName>_Prototype.SourceFile = ['%<ModelSourceFile>', '.%<::LangFileExt>'];
%<fcnName>_Interface = RTW.FunctionInterface;
%<fcnName>_Interface.Prototype = %<fcnName>_Prototype;
%<fcnName>_Interface.ActualArgs = tmpActualArgs;
%<fcnName>_Interface.ActualReturn = tmpActualReturn;
%assign taskID = (TYPE(tid) == "Number") ? tid : 0
%<fcnName>_Prototype.Name = '%<fcnName>';
%assign timeObj = SLibGetRTWTimingObject(taskID)
%<fcnName>_Interface.Timing = %<timeObj>;
%switch fcnType
%case "OutputUpdate"
%<componentObj>.OutputFunctions = [%<componentObj>.OutputFunctions, %<fcnName>_Interface];
%break
%case "Update"
%<componentObj>.UpdateFunctions = [%<componentObj>.UpdateFunctions, %<fcnName>_Interface];
%break
%default
%assign errTxt = "Parallel Deployment CodeInfo Error: Unknown fcnType: %<fcnType>"
%<LibReportFatalError(errTxt)>
%endswitch
%closefile tmpBuff
%return tmpBuff
%endfunction
%function SLibDeploymentEmitSolverFunctions(taskName, fcnType)
%assert (LibIsDeploymentDiagram())
%openfile tmpBuf
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%if !ISEQUAL(::CompiledModel.EventHandler[tgIdx].Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(::CompiledModel.EventHandler[tgIdx].NumTasks, 0)
%continue
%endif
%foreach taskIdx = ::CompiledModel.EventHandler[tgIdx].NumTasks
%if !ISEQUAL(::CompiledModel.EventHandler[tgIdx].Task[taskIdx].FunctionName, ...
taskName)
%continue
%endif
%assign task = ::CompiledModel.EventHandler[tgIdx].Task[taskIdx]
%assert !SLibDeploymentIsSynthesizedTask(tgIdx, taskIdx)
%assign hasFirstTidAllNot0 = TLC_TRUE
%foreach epIdx = task.NumEntryPointInfos
%if ISEQUAL(task.EntryPointInfo[epIdx].SampleTimeIndices[0], 0)
%assign hasFirstTidAllNot0 = TLC_FALSE
%break
%endif
%endforeach
%if hasFirstTidAllNot0
%continue
%endif
%assign currentSystem = System[NumSystems - 1]
%assign saveCurrentTID = currentSystem.CurrentTID
%assign saveCurrentPID = currentSystem.CurrentPID
%if !(currentSystem.HasCStatesArg)
%continue
%endif
%assert (SLibIsPeriodicRateGrouping() == TLC_TRUE)
%assign currentSystem.CurrentTID = 0
%assign functionName = "SLibGetBody%<fcnType>FcnCache"
%if !LibSystemFcnIsEmptyForTID(currentSystem, fcnType)
%assign code = %<functionName>(currentSystem)
%<code>
%endif
%assign currentSystem.CurrentTID = saveCurrentTID
%break
%endforeach
%endforeach
%closefile tmpBuf
%return tmpBuf
%endfunction
%function SLibDeploymentGetTimingBridgeName()
%assert (LibIsDeploymentDiagram())
%assign varName = "timingBridge"
%return varName
%endfunction
%function FcnDeclareTasksRTMVec() void
%assert (!IsModelReferenceTarget())
%assign numTasks = FcnGetNumPeriodicUserMappedEntities()
%if !::CompiledModel.EmptyRealTimeObject && (numTasks > 0)
%openfile tmpBuf
/* Tasks */
%assign definition = "%<::tSimStructType> %<SLibDeploymentGetTaskRTMVarName()>_[%<numTasks>];"
%<SLibApplyMemSecToDataDefn(definition, "MemSecDataInternal", "%<SLibDeploymentGetTaskRTMVarName()>_")>
%assign definition = "%<::tSimStructType> *%<SLibDeploymentGetTaskRTMVarName()>[%<numTasks>];"
%<SLibApplyMemSecToDataDefn(definition, "MemSecDataInternal", "%<SLibDeploymentGetTaskRTMVarName()>")>/
%closefile tmpBuf
%<SLibCacheCodeToFile("mdl_data_defn", tmpBuf)>
%endif
%endfunction
%function FcnDeclareTimingBridgeVec(numTimingBridge) void
%if numTimingBridge > 0
%openfile tmpBuf
/* Timing bridge */
rtTimingBridge %<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>];
%closefile tmpBuf
%<SLibCacheCodeToFile("mdl_data_defn", tmpBuf)>
%endif
%endfunction
%function FcnDeclareTasksContStatesVec() void
%openfile tmpBuf
/* Continuous states of tasks */
%assign definition = "%<::tContStateType> %<FcnGetTasksContStatesVarName()>;"
%<SLibApplyMemSecToDataDefn(definition, "MemSecDataInternal", "%<FcnGetTasksContStatesVarName()>")>
%closefile tmpBuf
%<SLibCacheCodeToFile("mdl_data_defn", tmpBuf)>
%endfunction
%function FcnDeclareTasksPeriodicContStatesVec() void
%assign pstateInd = FcnGetTasksPeriodicContStateIndicesVarName()
%assign pstateRng = FcnGetTasksPeriodicContStateRangesVarName()
%openfile tmpBuf
/* Periodic continuous states of tasks */
%assign defind = "%<::tPeriodicStateIndType> %<pstateInd>;"
%assign defrng = "%<::tPeriodicStateRngType> %<pstateRng>;"
%<SLibApplyMemSecToDataDefn(defind, "MemSecDataInternal", "%<pstateInd>")>/
%<SLibApplyMemSecToDataDefn(defrng, "MemSecDataInternal", "%<pstateRng>")>/
%closefile tmpBuf
%<SLibCacheCodeToFile("mdl_data_defn", tmpBuf)>
%endfunction
%function FcnDeclareTasksMassMatricesVec() void
%openfile tmpBuf
/* Mass matrices of tasks */
%assign numTasks = -1
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%assign numTasks = numTasks + 1
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%assign numTasks = numTasks + 1
%if task.NumContStates <= 0 || task.IsLinearlyImplicit == "no"
%continue
%endif
%assign definition = "%<::tMassMatrixGlobalType>_%<task.FunctionName> %<SLibDeploymentGetTasksMassMatricesVarName(numTasks)>;"
%<SLibApplyMemSecToDataDefn(definition, "MemSecDataInternal", "%<SLibDeploymentGetTasksMassMatricesVarName(numTasks)>")>
%endforeach
%endforeach
%closefile tmpBuf
%<SLibCacheCodeToFile("mdl_data_defn", tmpBuf)>
%endfunction
%function FcnDeclareSfcnInfoVec(numSfcnInfo) void
%openfile tmpBuf
%if numSfcnInfo > 0
/* Child s-functions */
RTWSfcnInfo %<SLibDeploymentGetTasksSfcnInfoVarName()>_[%<numSfcnInfo>];
RTWSfcnInfo *%<SLibDeploymentGetTasksSfcnInfoVarName()>[%<numSfcnInfo>];
%endif
%closefile tmpBuf
%<SLibCacheCodeToFile("mdl_data_defn", tmpBuf)>
%endfunction
%function FcnInitializeTasksStruct() void
%assert (!UsingMalloc)
%assign numTasks = FcnGetNumPeriodicUserMappedEntities()
%if ISEQUAL(numTasks, 0)
%return
%endif
%assign addr = IsMultiInstanceERTOrModelReference() ? "" : "&"
%openfile tmpBuf
int_T tIdx;
%if (NumContStates > 0) && SLibZeroMemory("CState")
/* initialize continuous states */
(void) %<LibGenMemFcnCall("memset", "(void *)%<addr>%<FcnGetTasksContStatesVarName()>", ...
"0", "sizeof(%<::tContStateType>)")>;
%if NumPeriodicContStates > 0
/* Initialize periodic continuous states */
(void) %<LibGenMemFcnCall("memset", "(void*)%<addr>%<FcnGetTasksPeriodicContStateIndicesVarName()>", ...
"0", "%<NumPeriodicContStates>*sizeof(int_T)")>;
(void) %<LibGenMemFcnCall("memset", "(void*)%<addr>%<FcnGetTasksPeriodicContStateRangesVarName()>", ...
"0", "%<2*NumPeriodicContStates>*sizeof(real_T)")>;
%endif
%endif
for(tIdx = 0; tIdx < %<numTasks>; tIdx++) {
%if !GenerateClassInterface
%<SLibDeploymentGetTaskRTMVarName">SLibDeploymentGetTaskRTMVarName()>[tIdx] = &%<SLibDeploymentGetTaskRTMVarName">SLibDeploymentGetTaskRTMVarName()>_[tIdx];
/* initialize real-time model */
(void) %<LibGenMemFcnCall("memset", "(void *) %<SLibDeploymentGetTaskRTMVarName()>[tIdx]", ...
"0", "sizeof(%<::tSimStructType>)")>;
%else
/* initialize real-time model */
(void) %<LibGenMemFcnCall("memset", "(void *)(&%<SLibDeploymentGetTaskRTMVarName()>[tIdx])", ...
"0", "sizeof(%<::tSimStructType>)")>;
%endif
%if SuppressMultiTaskScheduler && !GenerateSampleERTMain
%foreach i = NumRuntimeExportedRates
%if !GenerateClassInterface
%<SLibDeploymentGetTaskRTMVarName()>[tIdx]->Timing.TaskCounters.cLimit[%<i>] = %<FcnComputeTaskTickLimit(i)>;
%else
(&%<SLibDeploymentGetTaskRTMVarName()>[tIdx])->Timing.TaskCounters.cLimit[%<i>] = %<FcnComputeTaskTickLimit(i)>;
%endif
%endforeach
%endif
}
%if ModelIsLinearlyImplicit == "yes"
%assign nTasks = -1
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%assign nTasks = nTasks + 1
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%assign nTasks = nTasks + 1
%if task.NumContStates <= 0 || task.IsLinearlyImplicit == "no"
%continue
%endif
%openfile massMatrixBuf
%if GenerateGRTWrapper
%assign rtmName = SLibDeploymentGetTasksRTMVarName(nTasks)
%<FcnRTMSet("MassMatrixIr", "", "ir", rtmName)>;
%<FcnRTMSet("MassMatrixJc", "", "jc", rtmName)>;
%<FcnRTMSet("MassMatrixPr", "", "pr", rtmName)>;
%endif
%if SLibZeroMemory("MassMatrix")
(void) %<LibGenMemFcnCall("memset", "(void *)ir", "0", "%<task.MassMatrixNzMax>*sizeof(int_T)")>;
(void) %<LibGenMemFcnCall("memset", "(void *)jc", "0", "%*sizeof(int_T)")>;
(void) %<LibGenMemFcnCall("memset", "(void *)pr", "0", "%<task.MassMatrixNzMax>*sizeof(real_T)")>;
%endif
%closefile massMatrixBuf
%if !WHITE_SPACE(massMatrixBuf)
/* Mass matrix for %<task.FunctionName> */
{
int_T *ir = %<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.ir;
int_T *jc = %<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.jc;
real_T *pr = %<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.pr;
%<massMatrixBuf>/
}
%endif
%endforeach
%endforeach
%endif
%closefile tmpBuf
%<LibMdlRegCustomCode(tmpBuf, "declaration")>
%endfunction
%function SLibDeploymentGetTaskInfoForComponent(pid, stIdx)
%assert (LibIsDeploymentDiagram())
%assign rtmIdx = -1
%assign task = ""
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%assign isRateGroupTask = SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%if !isRateGroupTask
%assign rtmIdx = rtmIdx + 1
%endif
%assign taskTID = FcnGetTaskSampleTimeIndex(task)
%foreach epIdx = task.NumEntryPointInfos
%if ISEQUAL(taskTID, 0) && ISEQUAL(SolverType, "FixedStep") && ...
FixedStepOpts.TID01EQ && ISEQUAL(stIdx, 1) && ...
ISEQUAL(task.PID, pid)
%if isRateGroupTask
%createrecord taskInfo {RTMIdx -1; Task task; IsRateGroupTask TLC_TRUE}
%else
%createrecord taskInfo {RTMIdx rtmIdx; Task task; IsRateGroupTask TLC_FALSE}
%endif
%return taskInfo
%endif
%if ISEQUAL(task.PID, pid) && ISEQUAL(stIdx, taskTID)
%if isRateGroupTask
%createrecord taskInfo {RTMIdx -1; Task task; IsRateGroupTask TLC_TRUE}
%else
%createrecord taskInfo {RTMIdx rtmIdx; Task task; IsRateGroupTask TLC_FALSE}
%endif
%return taskInfo
%endif
%endforeach
%endforeach
%if ISEQUAL(tg.NumTasks, 0)
%assign rtmIdx = rtmIdx + 1
%assign task = tg
%assign taskTID = FcnGetTaskSampleTimeIndex(tg)
%foreach epIdx = task.NumEntryPointInfos
%if ISEQUAL(taskTID, 0) && ISEQUAL(SolverType, "FixedStep") && ...
FixedStepOpts.TID01EQ && ISEQUAL(stIdx, 1) && ...
ISEQUAL(task.PID, pid)
%createrecord taskInfo {RTMIdx rtmIdx; Task task; IsRateGroupTask TLC_FALSE}
%return taskInfo
%endif
%if ISEQUAL(task.PID, pid) && ISEQUAL(stIdx, taskTID)
%createrecord taskInfo {RTMIdx rtmIdx; Task task; IsRateGroupTask TLC_FALSE}
%return taskInfo
%endif
%endforeach
%endif
%endforeach
%assign rtmIdx = -1
%assign task = ""
%createrecord taskInfo {RTMIdx rtmIdx; Task task; IsRateGroupTask TLC_FALSE}
%return taskInfo
%endfunction
%function SLibDeploymentGetTaskIndexForBlock(blockIdx, stIdx)
%assert (LibIsDeploymentDiagram())
%assign rtmIdx = -1
%assign task = ""
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%assign isRateGroupTask = SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%if !isRateGroupTask
%assign rtmIdx = rtmIdx + 1
%endif
%assign taskTID = FcnGetTaskSampleTimeIndex(task)
%foreach epIdx = task.NumEntryPointInfos
%assign blkIdx = task.EntryPointInfo[epIdx].BlockIdx
%if ISEQUAL(blkIdx[2], blockIdx) && ISEQUAL(stIdx, taskTID)
%if isRateGroupTask
%return -1
%else
%return rtmIdx
%endif
%endif
%endforeach
%endforeach
%if ISEQUAL(tg.NumTasks, 0)
%assign rtmIdx = rtmIdx + 1
%assign task = tg
%assign taskTID = FcnGetTaskSampleTimeIndex(tg)
%foreach epIdx = task.NumEntryPointInfos
%assign blkIdx = task.EntryPointInfo[epIdx].BlockIdx
%if ISEQUAL(blkIdx[2], blockIdx) && ISEQUAL(stIdx, taskTID)
%return rtmIdx
%endif
%endforeach
%endif
%endforeach
%return -1
%endfunction
%function SLibDeploymentGetTaskIndexForComponent(compIdx, stIdx)
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(compIdx, stIdx)
%return taskInfo.RTMIdx
%endfunction
%function SLibDeploymentGetTaskNameForComponent(compIdx, stIdx)
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(compIdx, stIdx)
%assert(!ISEMPTY(taskInfo.Task))
%if ISFIELD(taskInfo.Task, "FunctionName")
%return taskInfo.Task.FunctionName
%else
%return taskInfo.Task.Name
%endif
%endfunction
%function SLibDeploymentIsValidAsyncSampleTimeIndexForComponent(pid, stIdx)
%assert (LibIsDeploymentDiagram())
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%assign taskTID = FcnGetTaskSampleTimeIndex(tg)
%if ISEQUAL(tg.PID, pid) && ISEQUAL(stIdx, taskTID)
%return TLC_TRUE
%endif
%else
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%assign taskTID = FcnGetTaskSampleTimeIndex(task)
%if ISEQUAL(task.PID, pid) && ISEQUAL(stIdx, taskTID)
%return TLC_TRUE
%endif
%endforeach
%endif
%endforeach
%return TLC_FALSE
%endfunction
%function FcnDumpModelInitializeSampleTimes(rtmName) Output
/* task periods */
%foreach tidIdx = NumRuntimeExportedRates
%assign period = SampleTime[tidIdx].PeriodAndOffset[0]
%assign fldIdx = "%<tidIdx>"
%assign initVal = "%<period>"
%<FcnRTMSet("SampleTime", fldIdx, initVal, rtmName)>;
%endforeach
/* task offsets */
%foreach tidIdx = NumRuntimeExportedRates
%assign offset = SampleTime[tidIdx].PeriodAndOffset[1]
%assign fldIdx = "%<tidIdx>"
%assign initVal = "%<offset>"
%<FcnRTMSet("OffsetTime", fldIdx, initVal, rtmName)>;
%endforeach
%endfunction
%function LocFcnDumpSolverInfoObjectCreation(bEmitReg, bEmitInit, rtmName) Output
%assert (GenRTModel && !UsingMalloc && SLibIsERTCodeFormat())
{
/* Setup solver object */
%assign stptr = "&%<SLibDeploymentRTMGet("SimTimeStep", rtmName)>"
%<FcnRTMSolverSet("SimTimeStepPtr", stptr, rtmName)>;
%assign tptr = "&%<SLibDeploymentRTMGet("TPtr", rtmName)>"
%<FcnRTMSolverSet("TPtr", tptr, rtmName)>;
%if RTMStepSizeForTIDIsReqFcn(0)
%assign sptr = "&%<SLibDeploymentRTMGet("StepSize0", rtmName)>"
%<FcnRTMSolverSet("StepSizePtr", sptr, rtmName)>;
%elseif RTMStepSizeIsReqFcn()
%assign sptr = "&%<SLibDeploymentRTMGet("StepSize", rtmName)>"
%<FcnRTMSolverSet("StepSizePtr", sptr, rtmName)>;
%endif
%if NumContStates > 0
%assign dxptr = "&%<SLibDeploymentRTMGet("dX", rtmName)>"
%<FcnRTMSolverSet("dXPtr", dxptr, rtmName)>;
%assign csptr = "(real_T **) &%<SLibDeploymentRTMGet("ContStates", rtmName)>"
%<FcnRTMSolverSet("ContStatesPtr", csptr, rtmName)>;
%assign ncsptr = "&%<SLibDeploymentRTMGet("NumContStates", rtmName)>"
%<FcnRTMSolverSet("NumContStatesPtr", ncsptr, rtmName)>;
%if NumPeriodicContStates > 0
%assign npsptr = "&%<SLibDeploymentRTMGet("NumPeriodicContStates", rtmName)>"
%<FcnRTMSolverSet("NumPeriodicContStatesPtr", npsptr, rtmName)>;
%assign psptr = "&%<SLibDeploymentRTMGet("PeriodicContStateIndices", rtmName)>"
%<FcnRTMSolverSet("PeriodicContStateIndicesPtr", psptr, rtmName)>;
%assign rsptr = "&%<SLibDeploymentRTMGet("PeriodicContStateRanges", rtmName)>"
%<FcnRTMSolverSet("PeriodicContStateRangesPtr", rsptr, rtmName)>;
%endif
%endif
%<FcnRTMSolverSet("ErrorStatusPtr", GetRTMErrorStatusPtr(), rtmName)>;
%<FcnRTMSolverSet("RTModelPtr", rtmName, rtmName)>;
}
%endfunction
%function LocFcnDumpMassMatrixSolverInfoObjectCreation() Output
%if ModelIsLinearlyImplicit == "yes"
%assign nTasks = -1
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%assign nTasks = nTasks + 1
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%assign nTasks = nTasks + 1
%if task.NumContStates <= 0 || task.IsLinearlyImplicit == "no"
%continue
%endif
%assign ir = "%<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.ir"
%assign jc = "%<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.jc"
%assign pr = "%<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.pr"
%assign rtmName = SLibDeploymentGetTasksRTMVarName(nTasks)
%<FcnRTMSolverSet("SolverMassMatrixIr", ir, rtmName)>;
%<FcnRTMSolverSet("SolverMassMatrixJc", jc, rtmName)>;
%<FcnRTMSolverSet("SolverMassMatrixPr", pr, rtmName)>;
%endforeach
%endforeach
%endif
%endfunction
%function LocFcnCreateAndInitializeSolverData(rtmName, bEmitReg, bEmitInit)
%assert (!UsingMalloc && !IsModelReferenceTarget() && !GenerateClassInterface)
%assign addr = IsMultiInstanceERTOrModelReference() ? "" : "&"
%assign solverInfo = "%<FcnRTMGetSolverInfo(rtmName)>"
%openfile buff
%if bEmitReg
%if LibIsContinuous(0)
%<LocFcnDumpSolverInfoObjectCreation(bEmitReg, bEmitInit, rtmName)>/
%endif
%endif
%if LibIsContinuous(0)
%if bEmitInit
%<FcnRTMSolverSet("SimTimeStep", "MAJOR_TIME_STEP", rtmName)>;
%<FcnRTMSolverSet("SolverOutputComputed", "false", rtmName)>;
%if NumContStates > 0
%if ISEQUAL(Solver, "ode1")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[0] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[0];
%elseif ISEQUAL(Solver, "ode2")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.y = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeY", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[0] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[0];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[1] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[1];
%elseif ISEQUAL(Solver, "ode3")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.y = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeY", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[0] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[0];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[1] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[1];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[2] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[2];
%elseif ISEQUAL(Solver, "ode4")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.y = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeY", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[0] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[0];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[1] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[1];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[2] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[2];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[3] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[3];
%elseif ISEQUAL(Solver, "ode5")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.y = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeY", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[0] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[0];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[1] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[1];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[2] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[2];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[3] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[3];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[4] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[4];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[5] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[5];
%elseif ISEQUAL(Solver, "ode8")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.deltaY= %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeDeltaY", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[0] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[0];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[1] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[1];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[2] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[2];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[3] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[3];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[4] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[4];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[5] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[5];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[6] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[6];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[7] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[7];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[8] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[8];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[9] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[9];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[10] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[10];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[11] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[11];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f[12] = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF", rtmName)>[12];
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.x0 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeX0", rtmName)>;
%elseif ISEQUAL(Solver, "ode14x")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.x0 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeX0", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f0 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF0", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.x1start = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeX1START", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f1 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF1", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.Delta = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeDELTA", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.E = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeE", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.fac = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeFAC", rtmName)>;
/* initialize */
{
int_T i;
real_T *f = %<SLibDeploymentRTMGet("IntgData", rtmName)>.fac;
for(i = 0; i < (int_T)(sizeof(%<SLibDeploymentRTMGet("OdeFAC", rtmName)>)/sizeof(real_T)); i++) {
f[i] = 1.5e-8;
}
}
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.DFDX = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeDFDX", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.W = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeW", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.pivots = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdePIVOTS", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.xtmp = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeXTMP", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.ztmp = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeZTMP", rtmName)>;
%if (ModelIsLinearlyImplicit == "yes")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.M = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeMASSMATRIX_M", rtmName)>;
%if (SLibModelMassMatrixType() != "constant")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.M1 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeMASSMATRIX_M1", rtmName)>;
%if (SLibModelMassMatrixType() == "statedep")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.xdot = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeXDOT", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.Edot = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeEDOT", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.fminusMxdot = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeFMXDOT", rtmName)>;
%endif
%endif
%endif
%<SLibDeploymentRTMGet("IntgData", rtmName)>.isFirstStep = %;
%<FcnRTMSolverSet("SolverExtrapolationOrder", "%<FixedStepOpts.ExtrapolationOrder>", rtmName)>;
%<FcnRTMSolverSet("SolverNumberNewtonIterations", "%<FixedStepOpts.NumberNewtonIterations>", rtmName)>;
%elseif ISEQUAL(Solver, "ode1be")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.x0 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeX0", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f0 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF0", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.f1 = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeF1", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.Delta = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeDELTA", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.fac = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeFAC", rtmName)>;
/* initialize */
{
int_T i;
real_T *f = %<SLibDeploymentRTMGet("IntgData", rtmName)>.fac;
for(i = 0; i < (int_T)(sizeof(%<SLibDeploymentRTMGet("OdeFAC", rtmName)>)/sizeof(real_T)); i++) {
f[i] = 1.5e-8;
}
}
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.DFDX = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeDFDX", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.W = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeW", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.pivots = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdePIVOTS", rtmName)>;
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.z = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeZ", rtmName)>;
%if (ModelIsLinearlyImplicit == "yes")
%<SLibDeploymentRTMGet">SLibDeploymentRTMGet("IntgData", rtmName)>.M = %<SLibDeploymentRTMGet">SLibDeploymentRTMGet("OdeMASSMATRIX_M", rtmName)>;
%endif
%<SLibDeploymentRTMGet("IntgData", rtmName)>.isFirstStep = %;
%<FcnRTMSolverSet("SolverNumberNewtonIterations", "%<FixedStepOpts.NumberNewtonIterations>", rtmName)>;
%endif
rtsiSetSolverData(%<solverInfo>, (void *)&%<SLibDeploymentRTMGet("IntgData", rtmName)>);
%endif
%endif
%endif
%if bEmitReg
rtsiSetSolverName(%<solverInfo>,"%<Solver>");
%if NumChildSFunctions
%<FcnRTMSet("RTWSolverInfoPtr", "", solverInfo, rtmName)>;
%endif
%endif
%closefile buff
%return buff
%endfunction
%function LocFcnInitializeMassMatrixVars() Output
%if (ModelIsLinearlyImplicit == "yes")
%assign nTasks = -1
%assign type = "(ssMatrixType)%<ModelMassMatrixType>"
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%assign nTasks = nTasks + 1
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%assign nTasks = nTasks + 1
%if task.NumContStates <= 0 || task.IsLinearlyImplicit == "no"
%continue
%endif
%assign nzmax = "%<task.MassMatrixNzMax>"
%assign ir = "%<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.ir"
%assign jc = "%<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.jc"
%assign pr = "%<SLibDeploymentGetTasksMassMatricesVarName(nTasks)>.pr"
%assign rtmName = SLibDeploymentGetTasksRTMVarName(nTasks)
%<FcnRTMSet("MassMatrixType", "",type, rtmName)>;
%<FcnRTMSet("MassMatrixNzMax", "", nzmax, rtmName)>;
%<FcnRTMSet("MassMatrixIr", "", ir, rtmName)>;
%<FcnRTMSet("MassMatrixJc", "", jc, rtmName)>;
%<FcnRTMSet("MassMatrixPr", "", pr, rtmName)>;
%<FcnRTMSolverSet("SolverMassMatrixType",type, rtmName)>;
%<FcnRTMSolverSet("SolverMassMatrixNzMax",nzmax, rtmName)>;
%endforeach
%endforeach
%endif
%endfunction
%function LocFcnCreateAndInitializeTimingData(rtmName, bEmitReg, bEmitInit)
%assert (!IsModelReferenceTarget())
%openfile buff
%if ExportFunctionsMode == 0
%if GenerateGRTWrapper || RTMNonInlinedSFcnsIsReqFcn()
/* Initialize timing info */
%if RTMModelPtrsForNonERTIsReqFcn() || SLibModelHierarchyContainsNoninlinedSfcn()
{
int_T *mdlTsMap = %<SLibDeploymentRTMGet("SampleTimeTaskIDArray", rtmName)>;
%if NumRuntimeExportedRates >= 1 && ...
NumRuntimeExportedRates < RollThreshold
%foreach sampIdx = NumRuntimeExportedRates
mdlTsMap[%<sampIdx>] = %<sampIdx>;
%endforeach
%elseif NumRuntimeExportedRates >= RollThreshold
int_T i;
for(i = 0; i < %<NumRuntimeExportedRates>; i++) {
mdlTsMap[i] = i;
}
%endif
%<FcnRTMSet("SampleTimeTaskIDPtr", "", "&mdlTsMap[0]", rtmName)>;
%<FcnRTMSet("SampleTimePtr", "", "&%<SLibDeploymentRTMGet("SampleTimeArray", rtmName)>[0]", rtmName)>;
%<FcnRTMSet("OffsetTimePtr", "", "&%<SLibDeploymentRTMGet("OffsetTimeArray", rtmName)>[0]", rtmName)>;
%<FcnDumpModelInitializeSampleTimes(rtmName)>/
}
%endif
%if RTMTimePtrIsReqFcn()
%<FcnRTMSet("TPtr", "", "&%<SLibDeploymentRTMGet("TaskTimeArray", rtmName)>[0]", rtmName)>;
%endif
%if SLibModelHierarchyContainsNoninlinedSfcn() || GenerateGRTWrapper
{
int_T *mdlSampleHits = %<SLibDeploymentRTMGet("SampleHitArray", rtmName)>;
%assert (SLibSingleTasking() == TLC_FALSE)
%if RTMChildSfunctionIsReqFcn()
int_T *mdlPerTaskSampleHits = %<SLibDeploymentRTMGet("PerTaskSampleHitsArray", rtmName)>;
%<FcnRTMSet("PerTaskSampleHitsPtr", "", "&mdlPerTaskSampleHits[0]", rtmName)>;
mdlSampleHits[0] = 1;
%endif
%<FcnRTMSet("SampleHitPtr", "", "&mdlSampleHits[0]", rtmName)>;
}
%endif
%elseif LibIsContinuous(0)
%assert RTMTimePtrIsReqFcn()
%assign val = "&%<SLibDeploymentRTMGet("TaskTimeArray", rtmName)>[0]"
%<FcnRTMSet("TPtr", "", val, rtmName)>;
%endif
%elseif LibIsContinuous(0)
%assert RTMTimePtrIsReqFcn()
%<FcnRTMSet("TPtr", "&%[0]")>;
%endif
%if bEmitReg || bEmitInit
%if StartTime != 0.0
%assign errTxt = "Start time must be 0.0 for the chosen target: %<StartTime>."
%<LibReportFatalError(errTxt)>
%endif
%if (SLibNeedAbsoluteTime() || MatFileLogging)
%if PurelyIntegerCode && MatFileLogging
%<LibReportError("Do not yet support integer-only MAT-file logging.")>
%elseif PurelyIntegerCode && !MatFileLogging
%else
%if RTMTFinalIsReqFcn()
%<FcnRTMSet("TFinal", "", "%<SLibERTGetStopTime()>", rtmName)>;
%endif
%foreach tid = NumSampleTimes
%if SampleTime[tid].NeedFloatTime == "yes" && !PurelyIntegerCode
%<SLibDeploymentRTMGet("StepSize%<tid>", rtmName)> = %;
%endif
%endforeach
%endif
%endif
%if RTMFirstInitCondFlagIsReqFcn()
%<FcnRTMSet("FirstInitCond", "", 1, rtmName)>;
%endif
%endif
%if bEmitInit
%if RTMNonInlinedSFcnsIsReqFcn() || GenerateGRTWrapper
%assign solverInfo = "%<FcnRTMGetSolverInfo(rtmName)>"
%<FcnRTMSet("RTWSolverInfoPtr", "", solverInfo, rtmName)>;
%<FcnRTMSet("StepSize", "", FixedStepOpts.FixedStep, rtmName)>;
%<FcnRTMSolverSet("FixedStepSize", FixedStepOpts.FixedStep, rtmName)>;
%assert(::CompiledModel.FixedStepOpts.SolverMode == "MultiTasking")
%<FcnRTMSolverSet("SolverMode", "SOLVER_MODE_MULTITASKING", rtmName)>;
%endif
%endif
%closefile buff
%return buff
%endfunction
%function FcnInitTaskMassMatrices() Output
%assign numTasks = -1
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%assign numTasks = numTasks + 1
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign numTasks = numTasks + 1
%assign task = tg.Task[tIdx]
%if task.NumContStates <= 0 || task.IsLinearlyImplicit == "no"
%continue
%endif
%<FcnCreateInitSystemMatrices(numTasks, task.NumContStates, task.MassMatrixJc, task.MassMatrixIr)>
%endforeach
%endforeach
%endfunction
%function FcnCreateInitSystemMatrices(tIdx, nx, jc, ir)
%assert (LibIsDeploymentDiagram() && ModelIsLinearlyImplicit == "yes")
%openfile buff
/* Root-level InitSystemMatrices */
{
%assign nnz = jc[nx]
static int_T taskMassMatrixIr[%<nnz>] = {/
%assign comma = ""
%foreach idx = nnz
%<comma>%/
%assign comma = ", "
%endforeach
};
%assign njc = nx+1
static int_T taskMassMatrixJc[%<njc>] = {/
%assign comma = ""
%foreach idx = njc
%<comma>%/
%assign comma = ", "
%endforeach
};
static real_T taskMassMatrixPr[%<nnz>] = {/
%assign comma = ""
%foreach idx = nnz
%<comma>1.0/
%assign comma = ", "
%endforeach
};
%assign copyAddr = "%<SLibDeploymentGetTasksMassMatricesVarName(tIdx)>.ir"
%assign copySize = "%<nnz>*sizeof(int_T)"
(void) %<LibGenMemFcnCall("memcpy", copyAddr, "taskMassMatrixIr", copySize)>;
%assign copyAddr = "%<SLibDeploymentGetTasksMassMatricesVarName(tIdx)>.jc"
%assign copySize = "%<njc>*sizeof(int_T)"
(void) %<LibGenMemFcnCall("memcpy", copyAddr, "taskMassMatrixJc", copySize)>;
%assign copyAddr = "%<SLibDeploymentGetTasksMassMatricesVarName(tIdx)>.pr"
%assign copySize = "%<nnz>*sizeof(real_T)"
(void) %<LibGenMemFcnCall("memcpy", copyAddr, "taskMassMatrixPr", copySize)>; }
%closefile buff
%return buff
%endfunction
%function FcnInitializeSolverAndTimingData() void
%assert !UsingMalloc
%assign bEmitReg = TLC_TRUE
%assign bEmitInit = TLC_TRUE
%if ISEQUAL(FcnGetNumPeriodicUserMappedEntities(), 0)
%return
%endif
%assign rtmName = "%<SLibDeploymentGetTaskRTMVarName()>[tIdx]"
%openfile solverDataBuf
%if (LibIsContinuous(0) || NumChildSFunctions)
%<LocFcnCreateAndInitializeSolverData(rtmName, bEmitReg, bEmitInit)>
%endif
%<LocFcnCreateAndInitializeTimingData(rtmName, bEmitReg, bEmitInit)>
%closefile solverDataBuf
%if !WHITE_SPACE(solverDataBuf)
%openfile tmpBuf
for (tIdx = 0; tIdx < %<FcnGetNumPeriodicUserMappedEntities()>; tIdx++) {
%<solverDataBuf>
}
%if LibIsContinuous(0) && ModelIsLinearlyImplicit == "yes"
%<LocFcnDumpMassMatrixSolverInfoObjectCreation()>
%<LocFcnInitializeMassMatrixVars()>
%<FcnInitTaskMassMatrices()>
%endif
%<FcnInitializeContinuousStates()>
%closefile tmpBuf
%<LibMdlRegCustomCode(tmpBuf, "declaration")>
%endif
%endfunction
%function FcnInitializeContinuousStates()
%assert (LibIsDeploymentDiagram())
%openfile buf
%assign addr = IsMultiInstanceERTOrModelReference() ? "" : "&"
%assign nTasks = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if GenerateGRTWrapper || isGRTMalloc
%assign contStateTypeInRTM = ""
%assign openBrace = ""
%assign closeBrace = ""
%else
%assign contStateTypeInRTM = "(%<::tContStateType> *)"
%assign openBrace = "("
%assign closeBrace = ")"
%endif
%if !ISEQUAL(tg.NumTasks, 0)
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign rtmName = SLibDeploymentGetTasksRTMVarName(nTasks)
%assign task = tg.Task[tIdx]
%if task.NumContStates > 0
%assign x = "%<contStateTypeInRTM>%<openBrace>(real_T *) %<addr>%<FcnGetTasksContStatesVarName()>" ...
+ " + %<task.ContStateStartIndex>%<closeBrace>"
%else
%assign x = "(NULL)"
%endif
%<FcnRTMSet("ContStates", "", x, rtmName)>;
%if (task.NumContStates > 0) && (task.NumPeriodicContStates > 0)
%assign poff = %<task.PeriodicContStateOffset>
%assign roff = 2*poff
%assign p = "%<addr>%<FcnGetTasksPeriodicContStateIndicesVarName()>"+"[%<poff>]"
%<FcnRTMSet("PeriodicContStateIndices", "", p, rtmName)>;
%assign r = "%<addr>%<FcnGetTasksPeriodicContStateRangesVarName()>"+"[%<roff>]"
%<FcnRTMSet("PeriodicContStateRanges", "", r, rtmName)>;
/* InitializeConditions for task-level periodic continuous states */
{
%assign bias = %<task.ContStateStartIndex>
%assign npcs = %<task.NumPeriodicContStates>
int_T taskPeriodicContStateIndices[%<npcs>] = {/
%assign comma = ""
%foreach idx = npcs
%<comma>%/
%assign comma = ", "
%endforeach
};
%assign npsr = 2*npcs
real_T taskPeriodicContStateRanges[%<npsr>] = {/
%assign comma = ""
%foreach idx = npsr
%<comma>%/
%assign comma = ", "
%endforeach
};
%assign destAddr = SLibDeploymentRTMGet("PeriodicContStateIndices", rtmName)
%assign copySize = "%<npcs>*sizeof(int_T)"
(void) %<LibGenMemFcnCall("memcpy", destAddr, "taskPeriodicContStateIndices", copySize)>;
%assign destAddr = SLibDeploymentRTMGet("PeriodicContStateRanges", rtmName)
%assign copySize = "%<npsr>*sizeof(real_T)"
(void) %<LibGenMemFcnCall("memcpy", destAddr, "taskPeriodicContStateRanges", copySize)>;
}
%endif
%assign nTasks = nTasks + 1
%endforeach
%else
%assign rtmName = SLibDeploymentGetTasksRTMVarName(nTasks)
%assign x = "(NULL)"
%<FcnRTMSet("ContStates", "", x, rtmName)>;
%assign nTasks = nTasks + 1
%endif
%endforeach
%closefile buf
%return buf
%endfunction
%function FcnInitializeSfcnInfo() void
%assert(!IsModelReferenceTarget())
%assign mdlRefBlks = ::CompiledModel.ModelReferenceBlocks
%assign sfcnInfoVar = SLibDeploymentGetTasksSfcnInfoVarName()
%assign numSfcnInfo = 0
%assign requiresRootSfcnRegistration = TLC_FALSE
%openfile tmpBuf
%foreach rowIdx = SIZE(mdlRefBlks,0)
%assign mdlRefInfo = mdlRefBlks[rowIdx]
%assign mSysIdx = mdlRefInfo[0]
%assign bIdx = mdlRefInfo[1]
%assign instIdx = mdlRefInfo[2]
%assign blk = System[mSysIdx].Block[bIdx]
%assign blockInterface = GetModelrefInterface(blk)
%if blockInterface.HasNonInlinedSfcn
%if !SLibDeploymentDiagramIsMapped(mSysIdx)
%assign requiresRootSfcnRegistration = TLC_TRUE
%continue
%endif
%assign sfcnInfo = "%<sfcnInfoVar>[%<numSfcnInfo>]"
%assign perTaskSampleHitsSize = ...
"(%<NumRuntimeExportedRates> * %<NumRuntimeExportedRates>)"
{ /* child S-Function registration */
static time_T *taskTimePtrs[%<NumSampleTimes>];
static int_T *perTaskSampleHitsPtrs[%<perTaskSampleHitsSize>];
%<sfcnInfo>= &%<sfcnInfoVar>_[%<numSfcnInfo>];
rtssSetErrorStatusPtr(%<sfcnInfo>, %<GetRTMErrorStatusPtr()>);
rtssSetNumRootSampTimesPtr(%<sfcnInfo>, &%<RTMGet("NumSampleTimes")>);
rtssSetTStartPtr(%<sfcnInfo>, &%<RTMGet("TStart")>);
%if RTMTFinalIsReqFcn()
rtssSetTFinalPtr(%<sfcnInfo>, &%<RTMGet("TFinal")>);
%endif
rtssSetTimeOfLastOutputPtr(%<sfcnInfo>, &%<RTMGet("TimeOfLastOutput")>);
rtssSetStepSizePtr(%<sfcnInfo>, &%<RTMGet("StepSize")>);
rtssSetStopRequestedPtr(%<sfcnInfo>, &%<RTMGetStopRequested()>);
rtssSetSimModePtr(%<sfcnInfo>, &%<RTMGet("SimMode")>);
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(SLibGetPIDFromBlock(blk, 0), 0)
%assign rtmIdx = taskInfo.RTMIdx
%if !ISEQUAL(rtmIdx, -1)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
rtssSetDerivCacheNeedsResetPtr(%<sfcnInfo>, ...
&%<SLibDeploymentRTMGet("DerivCacheNeedsReset", rtmName)>);
rtssSetZCCacheNeedsResetPtr(%<sfcnInfo>, ...
&%<SLibDeploymentRTMGet("ZCCacheNeedsReset", rtmName)>);
rtssSetContTimeOutputInconsistentWithStateAtMajorStepPtr(%<sfcnInfo>, ...
&%<SLibDeploymentRTMGet("ContTimeOutputInconsistentWithStateAtMajorStepFlag", rtmName)>);
rtssSetSolverInfoPtr(%<sfcnInfo>, ...
&%<SLibDeploymentRTMGet("RTWSolverInfoPtr", rtmName)>);
%elseif taskInfo.IsRateGroupTask
rtssSetDerivCacheNeedsResetPtr(%<sfcnInfo>, ...
&%<RTMGet("DerivCacheNeedsReset")>);
rtssSetZCCacheNeedsResetPtr(%<sfcnInfo>, ...
&%<RTMGet("ZCCacheNeedsReset")>);
rtssSetContTimeOutputInconsistentWithStateAtMajorStepPtr(%<sfcnInfo>, ...
&%<RTMGet("ContTimeOutputInconsistentWithStateAtMajorStepFlag")>);
rtssSetSolverInfoPtr(%<sfcnInfo>, &%<RTMGet("RTWSolverInfoPtr")>);
%else
rtssSetDerivCacheNeedsResetPtr(%<sfcnInfo>, ...
%<SLibGetNullDefinitionFromTfl()>);
rtssSetZCCacheNeedsResetPtr(%<sfcnInfo>, ...
%<SLibGetNullDefinitionFromTfl()>);
rtssSetContTimeOutputInconsistentWithStateAtMajorStepPtr(%<sfcnInfo>, ...
%<SLibGetNullDefinitionFromTfl()>);
rtssSetSolverInfoPtr(%<sfcnInfo>, %<SLibGetNullDefinitionFromTfl()>);
%endif
%foreach idx = NumSampleTimes
%assign pid = SLibGetPIDFromBlock(blk, idx)
%if SLibDeploymentIsValidAsyncSampleTimeIndexForComponent(pid, idx)
taskTimePtrs[%<idx>] = &(%<RTMGet("TPtr")>[%<idx>]);
%else
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(pid, idx)
%assign rtmIdx = taskInfo.RTMIdx
%if !ISEQUAL(rtmIdx, -1)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%if SampleTime[idx].NeedFloatTime == "yes"
taskTimePtrs[%<idx>] = &(%<FcnGetTaskTime(System[NumSystems-1], idx, rtmName)>);
%else
taskTimePtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%elseif taskInfo.IsRateGroupTask
taskTimePtrs[%<idx>] = &(%<RTMGet("TPtr")>[%<idx>]);
%else
taskTimePtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%endif
%endforeach
rtssSetTPtrPtr(%<sfcnInfo>, taskTimePtrs);
%foreach i = NumRuntimeExportedRates
%foreach j = NumRuntimeExportedRates
%if SLibGetNeedRateInteraction(i,j)
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(SLibGetPIDFromBlock(blk, i), i)
%assign rtmIdx = taskInfo.RTMIdx
%if !ISEQUAL(rtmIdx, -1)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%assign val = "%<SLibDeploymentRTMGet("PerTaskSampleHitsPtr", rtmName)>[%]"
perTaskSampleHitsPtrs[%<i>*%<NumRuntimeExportedRates> + %<j>] /
= &(%<val>);
%elseif taskInfo.IsRateGroupTask
%assign val = "%<RTMGet("PerTaskSampleHitsPtr")>[%]"
perTaskSampleHitsPtrs[%<i>*%<NumRuntimeExportedRates> + %<j>] /
= &(%<val>);
%else
perTaskSampleHitsPtrs[%<i>*%<NumRuntimeExportedRates> + %<j>] /
= %<SLibGetNullDefinitionFromTfl()>;
%endif
%endif
%endforeach
%endforeach
rtssSetPerTaskSampleHitsPtr(%<sfcnInfo>, perTaskSampleHitsPtrs);
rtssSetSampleHitsPtr(%<sfcnInfo>, &%<RTMGet("SampleHitPtr")>);
}
%assign numSfcnInfo = numSfcnInfo + 1
%endif
%endforeach
%if requiresRootSfcnRegistration
%<LibDumpSFunctionRegistration()>
%endif
%closefile tmpBuf
%<LibMdlRegCustomCode(tmpBuf, "declaration")>
%<FcnDeclareSfcnInfoVec(numSfcnInfo)>
%endfunction
%function SLibDeploymentCallModelrefBlockRegFcns(mdlRefBlks)
%assert (LibIsDeploymentDiagram() && !IsModelReferenceTarget() && GenRTModel ...
&& SLibIsERTCodeFormat())
%assign needClockTicks = TLC_FALSE
%assign needLongClockTicks = TLC_FALSE
%foreach idx = NumRuntimeExportedRates
%if ClockTickForTIDIsReqFcn(idx)
%assign needClockTicks = TLC_TRUE
%if LongClockTickForTIDIsReqFcn(idx)
%assign needLongClockTicks = TLC_TRUE
%break
%endif
%endif
%endforeach
%assign numTimingBridge = 0
%openfile modelrefBuffer
%assign baseSysIdx = GetBaseSystemIdx()
%if !ISEMPTY(mdlRefBlks)
%foreach rowIdx = SIZE(mdlRefBlks,0)
%assign mdlRefInfo = mdlRefBlks[rowIdx]
%assign mSysIdx = mdlRefInfo[0]
%assign bIdx = mdlRefInfo[1]
%assign instIdx = mdlRefInfo[2]
%assign blk = System[mSysIdx].Block[bIdx]
%assign blockInterface = GetModelrefInterface(blk)
%if blockInterface.NeedsGlobalTimingEngine
{
%if needClockTicks
static uint32_T *clockTickPtrs[%<NumSampleTimes>];
%if needLongClockTicks
static uint32_T *clockTickHPtrs[%<NumSampleTimes>];
%endif
%endif
%if RTMTimePtrIsReqFcn() || RTMTaskTimeIsReqFcnForTID(0)
static real_T *taskTimePtrs[%<NumSampleTimes>];
%endif
%if ::CompiledModel.SingleRate != "yes"
%if ERTPerTaskSampleHitsIsReqFcn()
%assign rateTransitionSize = ...
"(%<NumRuntimeExportedRates> * %<NumRuntimeExportedRates>)"
static boolean_T *rateTransitionPtrs[%<rateTransitionSize>];
%endif
%endif
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].nTasks = %<NumSampleTimes>;
%if needClockTicks
%foreach idx = NumSampleTimes
%assign recordName = "ClockTick%<idx>"
%assign pid = SLibGetPIDFromBlock(blk, idx)
%if ClockTickForTIDIsReqFcn(idx)
%if SLibDeploymentIsValidAsyncSampleTimeIndexForComponent(pid, idx)
clockTickPtrs[%<idx>] = &(%<SLibDeploymentRTMGet(recordName,...
GetSimStructExpr(System[GetBaseSystemIdx()], ::tSimStruct))>);
%else
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(pid, idx)
%assign rtmIdx = taskInfo.RTMIdx
%if !ISEQUAL(rtmIdx, -1)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
clockTickPtrs[%<idx>] = &(%<SLibDeploymentRTMGet(recordName, rtmName)>);
%elseif taskInfo.IsRateGroupTask
clockTickPtrs[%<idx>] = &(%<SLibDeploymentRTMGet(recordName,...
GetSimStructExpr(System[GetBaseSystemIdx()], ::tSimStruct))>);
%else
clockTickPtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%endif
%else
clockTickPtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%if needLongClockTicks
%assign recordName = "ClockTickH%<idx>"
%if LongClockTickForTIDIsReqFcn(idx)
%if SLibDeploymentIsValidAsyncSampleTimeIndexForComponent(pid, idx)
clockTickHPtrs[%<idx>] = &(%<SLibDeploymentRTMGet(recordName,...
GetSimStructExpr(System[GetBaseSystemIdx()],::tSimStruct))>);
%else
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(pid, idx)
%assign rtmIdx = taskInfo.RTMIdx
%if !ISEQUAL(rtmIdx, -1)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
clockTickHPtrs[%<idx>] = &(%<SLibDeploymentRTMGet(recordName, rtmName)>);
%elseif taskInfo.IsRateGroupTask
clockTickHPtrs[%<idx>] = &(%<SLibDeploymentRTMGet(recordName, ...
GetSimStructExpr(System[GetBaseSystemIdx()],::tSimStruct))>);
%else
clockTickHPtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%endif
%else
clockTickHPtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%endif
%endforeach
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].clockTick = clockTickPtrs;
%if needLongClockTicks
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].clockTickH = clockTickHPtrs;
%else
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].clockTickH = %<SLibGetNullDefinitionFromTfl()>;
%endif
%else
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].clockTick = %<SLibGetNullDefinitionFromTfl()>;
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].clockTickH = %<SLibGetNullDefinitionFromTfl()>;
%endif
%if ::CompiledModel.SingleRate != "yes"
%if ERTPerTaskSampleHitsIsReqFcn()
%assign shMat = RTMGet("PerTaskSampleHits")
%foreach i = NumRuntimeExportedRates
%foreach j = NumRuntimeExportedRates
%if SLibGetNeedRateInteraction(i,j)
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(SLibGetPIDFromBlock(blk, i), i)
%assign rtmIdx = taskInfo.RTMIdx
%if !ISEQUAL(rtmIdx, -1)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%if SuppressMultiTaskScheduler || (UseTargetTaskScheduler() && !SLibSingleTasking())
%assign val = "%<SLibDeploymentRTMGet("PerTaskSampleHits", rtmName)>."...
"b_%<SLibERTMultiRateTimingField(j,i)>"
%else
%assign val = "%<SLibDeploymentRTMGet("PerTaskSampleHits", rtmName)>."...
"%<SLibERTMultiRateTimingField(j,i)>"
%endif
rateTransitionPtrs[%<i>*%<NumRuntimeExportedRates> + %<j>] /
= &(%<val>);
%elseif taskInfo.IsRateGroupTask
%if SuppressMultiTaskScheduler || (UseTargetTaskScheduler() && !SLibSingleTasking())
%assign val = "%<SLibDeploymentRTMGet(...
"PerTaskSampleHits", GetSimStructExpr(System[GetBaseSystemIdx()],::tSimStruct))>."...
"b_%<SLibERTMultiRateTimingField(j,i)>"
%else
%assign val = "%<SLibDeploymentRTMGet(...
"PerTaskSampleHits", GetSimStructExpr(System[GetBaseSystemIdx()],::tSimStruct))>."...
"%<SLibERTMultiRateTimingField(j,i)>"
%endif
rateTransitionPtrs[%<i>*%<NumRuntimeExportedRates> + %<j>] /
= &(%<val>);
%else
rateTransitionPtrs[%<i>*%<NumRuntimeExportedRates> + %<j>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%endif
%endforeach
%endforeach
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].rateTransition = rateTransitionPtrs;
%endif
%endif
%if RTMTimePtrIsReqFcn() || RTMTaskTimeIsReqFcnForTID(0)
%foreach idx = NumSampleTimes
%assign pid = SLibGetPIDFromBlock(blk, idx)
%if SLibDeploymentIsValidAsyncSampleTimeIndexForComponent(pid, idx)
%if SampleTime[idx].NeedFloatTime == "yes"
taskTimePtrs[%<idx>] = &(%<FcnGetTaskTime(System[NumSystems-1], idx, ::tSimStruct)>);
%else
taskTimePtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%else
%assign taskInfo = SLibDeploymentGetTaskInfoForComponent(pid, idx)
%assign rtmIdx = taskInfo.RTMIdx
%if !ISEQUAL(rtmIdx, -1)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%if ISEQUAL(idx, 0)
taskTimePtrs[%<idx>] = &(%<SLibDeploymentRTMGet("T", rtmName)>);
%elseif SampleTime[idx].NeedFloatTime == "yes"
taskTimePtrs[%<idx>] = &(%<FcnGetTaskTime(System[NumSystems-1], idx, rtmName)>);
%else
taskTimePtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%elseif taskInfo.IsRateGroupTask
taskTimePtrs[%<idx>] = %<RTMsGetTaskTimeForTID(System[NumSystems-1], idx)>;
%else
taskTimePtrs[%<idx>] = %<SLibGetNullDefinitionFromTfl()>;
%endif
%endif
%endforeach
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].taskTime = taskTimePtrs;
%endif
%if RTMFirstInitCondFlagIsReqFcn()
%<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>].firstInitCond = &%<RTMIs("FirstInitCond")>;
%endif
}
%assign numTimingBridge = numTimingBridge + 1
%endif
%endforeach
%endif
%closefile modelrefBuffer
%if !GenerateClassInterface
%<FcnDeclareTimingBridgeVec(numTimingBridge)>
%endif
%return modelrefBuffer
%endfunction
%function FcnGenerateDiscreteOutputAndUpdate(taskTID, task, entryPointIdx)
%openfile tmpBuffer
%if (CombineOutputUpdateFcns == 1)
%<FcnGenerateDiscreteEntryPoint(taskTID, task, entryPointIdx, "OutputUpdate")>
%else
%<FcnGenerateDiscreteEntryPoint(taskTID, task, entryPointIdx, "Output")>
%assign buf = FcnGenerateDiscreteEntryPoint(taskTID, task, entryPointIdx, ...
"Update")
%if !WHITE_SPACE(buf)
%<buf>
%endif
%endif
%closefile tmpBuffer
%return(tmpBuffer)
%endfunction
%function FcnGenerateRateGroupOutputAndUpdate(task, taskTID)
%openfile tmpBuffer
%if ISEQUAL(taskTID, 0) && SLibDeploymentDiagramWithTopSolver()
%if (CombineOutputUpdateFcns == 1)
%<FcnGenerateContRateGroupEntryPoint(taskTID, task, "OutputUpdate")>
%else
%<FcnGenerateContRateGroupEntryPoint(taskTID, task, "Output")>
%assign buf = FcnGenerateContRateGroupEntryPoint(taskTID, task, "Update")
%if !WHITE_SPACE(buf)
%<buf>
%endif
%endif
%else
%if (CombineOutputUpdateFcns == 1)
%<FcnGenerateDiscreteRateGroupEntryPoint(taskTID, task, "OutputUpdate")>
%else
%<FcnGenerateDiscreteRateGroupEntryPoint(taskTID, task, "Output")>
%assign buf = FcnGenerateDiscreteRateGroupEntryPoint(taskTID, task, "Update")
%if !WHITE_SPACE(buf)
%<buf>
%endif
%endif
%endif
%closefile tmpBuffer
%return(tmpBuffer)
%endfunction
%function SLibDeploymentGenerateOutputAndUpdate() void
%assert (LibIsDeploymentDiagram())
%if UsingMalloc
%assign errTxt = "Parallel Deployment Error: malloc is not supported."
%<LibReportFatalError(errTxt)>
%endif
%if IsModelReferenceForASimstructBasedTarget()
%assign errTxt = "Parallel Deployment Error: SimStruct based targets are not supported."
%<LibReportFatalError(errTxt)>
%endif
%assign entryPointIdx = -1
%assign rootSystem = System[NumSystems-1]
%openfile tmpBuf
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if ISEQUAL(tg.NumTasks, 0) && ISEQUAL(tg.NumEntryPointInfos, 0)
%continue
%endif
%assign stateReductionFcnDefined = !ISEQUAL(NumPeriodicContStates, SLibDeploymentGetNumPeriodicContStates())
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%assign taskTID = FcnGetTaskSampleTimeIndex(task)
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%<FcnGenerateRateGroupOutputAndUpdate(task, taskTID)>
%continue
%endif
%if ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%assign entryPointIdx = entryPointIdx + 1
%endif
%if ISEQUAL(task.NumEntryPointInfos, 0)
%addtorecord task OutputWrapperFcn ""
%addtorecord task UpdateWrapperFcn ""
%continue
%endif
%assign requiresSolver = TLC_FALSE
%foreach epIdx = task.NumEntryPointInfos
%assign currentSystem = System[NumSystems - 1]
%if (currentSystem.HasCStatesArg == 1) && ISEQUAL(taskTID, 0) && task.NumContStates > 0
%assign requiresSolver = TLC_TRUE
%break
%endif
%endforeach
%if requiresSolver
%assign currentTid = !LibIsSingleRateSystem(rootSystem) && SLibIsPeriodicRateGrouping() ? 0 : ""
%assign rootSystem.CurrentTID = currentTid
%if (CombineOutputUpdateFcns == 1)
%<FcnGenerateContinuousOutputUpdate(currentTid, task, entryPointIdx)>
%else
%<FcnGenerateContinuousOutput(currentTid, task, entryPointIdx)>
%<FcnGenerateContinuousUpdate(currentTid, task, entryPointIdx)>
%endif
%assign rootSystem.CurrentTID = 0
%assign rootSystem.CurrentPID = task.PID
%<SLibDumpSolverCode(task, stateReductionFcnDefined)>
%assign stateReductionFcnDefined = stateReductionFcnDefined || (task.NumPeriodicContStates > 0)
%else
%if ISEQUAL(tg.Periodicity.Type, "AperiodicTrigger")
%<FcnGenerateAsyncEntryPoint(taskTID, task)>
%else
%<FcnGenerateDiscreteOutputAndUpdate(taskTID, task, entryPointIdx)>
%endif
%endif
%endforeach
%if !ISEQUAL(tg.NumEntryPointInfos, 0)
%assign tid = FcnGetTaskSampleTimeIndex(tg)
%if ISEQUAL(tg.Periodicity.Type, "AperiodicTrigger")
%foreach epIdx = tg.NumEntryPointInfos
%<FcnGenerateAsyncEntryPoint(tid, tg)>
%endforeach
%else
%assign entryPointIdx = entryPointIdx + 1
%<FcnGenerateDiscreteOutputAndUpdate(tid, tg, entryPointIdx)>
%endif
%endif
%endforeach
%if GenerateGRTWrapper
%assign genLocalMain = 1
%elseif (GenerateSampleERTMain || RateBasedStepFcn ) && ...
(!SLibGenerateNativeThreads())
%assign genLocalMain = 0
%else
%assign genLocalMain = 1
%endif
%if ISEQUAL(genLocalMain, 1)
%if !GenerateGRTWrapper && (CombineOutputUpdateFcns == 1)
%<FcnGenerateModelEntryPoint("OutputUpdate")>
%else
%<FcnGenerateModelEntryPoint("Output")>
%<FcnGenerateModelEntryPoint("Update")>
%endif
%endif
%closefile tmpBuf
%if !GenerateClassInterface
%<FcnDeclareTasksRTMVec()>
%endif
%if NumContStates > 0
%<FcnDeclareTasksContStatesVec()>
%if NumPeriodicContStates > 0
%<FcnDeclareTasksPeriodicContStatesVec()>
%endif
%endif
%if ModelIsLinearlyImplicit == "yes"
%<FcnDeclareTasksMassMatricesVec()>
%endif
%<FcnInitializeTasksStruct()>
%<FcnInitializeSolverAndTimingData()>
%if SLibModelHierarchyContainsNoninlinedSfcn()
%<FcnInitializeSfcnInfo()>
%endif
%<FcnGenerateAdvanceTaskCountersFcn()>
%return (tmpBuf)
%endfunction
%function SLibDeploymentGenerateCodeInfo(componentObj) void
%assert (LibIsDeploymentDiagram())
%openfile tmpBuff
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%assign tid = FcnGetTaskSampleTimeIndex(task)
%if !WHITE_SPACE(task.OutputWrapperFcn)
%assign fcnName = task.OutputWrapperFcn
%assign fcnParams = "void"
%assign fcnReturns = "void"
%<FcnAddEntryPointToCodeInfo(componentObj, "OutputUpdate", fcnName, tid, ...
fcnParams, fcnReturns)>;
%if !WHITE_SPACE(task.UpdateWrapperFcn)
%assign fcnName = task.UpdateWrapperFcn
%<FcnAddEntryPointToCodeInfo(componentObj, "Update", fcnName, tid, ...
fcnParams, fcnReturns)>;
%endif
%endif
%endforeach
%if !ISEQUAL(tg.NumEntryPointInfos, 0)
%assign tid = FcnGetTaskSampleTimeIndex(tg)
%if !WHITE_SPACE(tg.OutputWrapperFcn)
%assign fcnName = tg.OutputWrapperFcn
%assign fcnParams = "void"
%assign fcnReturns = "void"
%<FcnAddEntryPointToCodeInfo(componentObj, "OutputUpdate", fcnName, tid, ...
fcnParams, fcnReturns)>;
%if !WHITE_SPACE(tg.UpdateWrapperFcn)
%assign fcnName = tg.UpdateWrapperFcn
%<FcnAddEntryPointToCodeInfo(componentObj, "Update", fcnName, tid, ...
fcnParams, fcnReturns)>;
%endif
%endif
%endif
%endforeach
%closefile tmpBuff
%return tmpBuff
%endfunction
%function FcnGenerateAdvanceTaskCountersFcn() void
%assert (LibIsDeploymentDiagram())
%openfile tmpBuf
%assign fcnName = SLibDeploymentSchedulerName()
%if !GenerateClassInterface
%assign fcnParams = "void"
%else
%assign fcnParams = "%<::tSimStructType> & %<::tSimStruct>"
%endif
%assign fcnReturns = "void"
%openfile schedulerCode
%if !RootSystemIsSingleRate && (!SuppressMultiTaskScheduler || ...
SLibGenerateNativeThreads())
%assign ::NeedScheduler = %<FcnScheduleSubRates()>
%endif
%closefile schedulerCode
%openfile fcnAbstract
This function updates active task counters and model execution time.
%closefile fcnAbstract
%openfile fcnProtoType
%createrecord fcnRec {Name fcnName; Returns fcnReturns; Params fcnParams; ...
Abstract fcnAbstract; Category "model"; GeneratedBy "ertmdlreftiming.tlc";...
Type "Schedule"}
%<SLibDumpFunctionBanner(fcnRec)>
%undef fcnRec
%<fcnReturns> %<fcnName>(%<fcnParams>)/
%closefile fcnProtoType
%<fcnProtoType>
{
%if !WHITE_SPACE(schedulerCode)
%<schedulerCode>
%endif
/* Update absolute time for base rate */
%<FcnRTMUpdateAbsoluteTimeForTID(0, ...
GetSimStructExpr(System[GetBaseSystemIdx()], ::tSimStruct), TLC_FALSE)>
%if !IsModelReferenceTarget()
%<FcnUpdateAsyncTaskTimers()>
%endif
}
%closefile tmpBuf
%assign prototypeBuf = "%<LibExternInFcnDecls()> %<fcnReturns> %<fcnName>(%<fcnParams>);"
%if !GenerateClassInterface
%<SLibCacheCodeToFile("mdl_extern_fcn_decl", prototypeBuf)>
%else
%<SLibCacheCodeToFile("baseMdl_fcn_prototype", prototypeBuf)>
%endif
%<SLibCacheCodeToFile("baseMdl_fcn_defn", tmpBuf)>
%endfunction
%function SLibDeploymentGenerateGRTMain() void
%assert (LibIsDeploymentDiagram())
%openfile banner
/*
* %<Name>.%<LangFileExt>
*
%<SLibCommonHeaderInfo()>/
*/
%closefile banner
%<SLibCacheCodeToFile("mainSrc_ban", banner)>
%openfile tmpBuf
%<SLibCreateMainForGRTWrapper()>
%closefile tmpBuf
%return (tmpBuf)
%endfunction
%function SLibDeploymentCallGRTEntryPoints(tid, fcnType) void
%assert (LibIsDeploymentDiagram())
%assert ((fcnType == "Update") || (fcnType == "Output") || ...
(fcnType == "OutputUpdate"))
%assign taskIdx = 0
%openfile tmpBuf
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%assign taskTID = FcnGetTaskSampleTimeIndex(task)
%if ISEQUAL(tid, taskTID) || ...
(ISEQUAL(tid, "") && LibIsSingleRateSystem(rootSystem))
%if ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Output")
MdlOutputs(%<taskIdx>);
%endif
%if ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Update")
MdlUpdate(%<taskIdx>);
%endif
%endif
%assign taskIdx = taskIdx + 1
%endforeach
%endforeach
%if !SuppressMultiTaskScheduler && ...
(tid == 0) && ...
(ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Update"))
%<SLibDeploymentSchedulerName()>();
%endif
%closefile tmpBuf
%return (tmpBuf)
%endfunction
%function SLibDeploymentCallERTEntryPoints(tid) void
%assert (LibIsDeploymentDiagram())
%openfile tmpBuff
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%assign taskTID = FcnGetTaskSampleTimeIndex(task)
%if ISEQUAL(tid, taskTID) || ...
(ISEQUAL(tid, "") && LibIsSingleRateSystem(rootSystem))
%if !WHITE_SPACE(task.OutputWrapperFcn)
%<task.OutputWrapperFcn>();
%if !WHITE_SPACE(task.UpdateWrapperFcn)
%<task.UpdateWrapperFcn>();
%endif
%endif
%endif
%endforeach
%endforeach
%if !SuppressMultiTaskScheduler
%<SLibDeploymentSchedulerName()>();
%endif
%closefile tmpBuff
%return tmpBuff
%endfunction
%function SLibDeploymentGRTCustomizeRtOneStep(indexVar, fcnType) void
%assert (LibIsDeploymentDiagram())
%assert ((fcnType == "Update") || (fcnType == "Output") || ...
(fcnType == "OutputUpdate"))
%assign nTids = SLibDeploymentGetNumPeriodicTasks()
%assign varName = FcnGetSampleTimeIndexVarName()
%openfile tmpBuf
{
int_T k;
for (k = 0; k < %<nTids>; k++) {
if (%<varName>[k] == %<indexVar>) {
%if ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Output")
MdlOutputs(k);
%endif
%if ISEQUAL(fcnType, "OutputUpdate") || ISEQUAL(fcnType, "Update")
MdlUpdate(k);
%endif
}
}
}
%closefile tmpBuf
%return (tmpBuf)
%endfunction
%function SLibDeploymentDeclareTasksSampleTimeIndex() void
%assert (LibIsDeploymentDiagram())
%assign initStr = ""
%assign comma = ""
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%if ISEQUAL(tg.NumTasks, 0)
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%if !ISEQUAL(task.NumEntryPointInfos, 0)
%assign taskTID = FcnGetTaskSampleTimeIndex(task)
%if !ISEQUAL(taskTID, "")
%assign initStr = initStr +"%<comma>%<taskTID>"
%assign comma = ","
%endif
%endif
%endforeach
%endforeach
%assign varName = FcnGetSampleTimeIndexVarName()
%openfile tmpBuf
int_T %<varName>[%<SLibDeploymentGetNumPeriodicTasks()>] = {%<initStr>};
%closefile tmpBuf
%return tmpBuf
%endfunction
%function SLibDeploymentBeautifyGRTMain() void
%assert (LibIsDeploymentDiagram())
%openfile tmpBuf
%assign dirName = "%<::CompiledModel.Name>_grt_rtw"
%if ::GRTInterface==TLC_FALSE
%assign fileName = "rt_main.c"
%else
%assign fileName = "classic_main.c"
%endif
%assign name = FEVAL("fullfile", dirName, fileName)
%matlab c_beautifier(name)
%closefile tmpBuf
%return (tmpBuf)
%endfunction
%function SLibDeploymentDeclareEntryPoints()
%assert LibIsDeploymentDiagram() && GenerateClassInterface
%openfile tmpDecl
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%if ISEQUAL(tg.Periodicity.Type, "AperiodicTrigger")
%assign decl = "void %<task.FunctionName>(void);/n"
%else
%assign decl = "void %<task.FunctionName>_step(void);/n"
%endif
/* model step function */
%<decl>
%endforeach
%foreach epIdx = tg.NumEntryPointInfos
%if ISEQUAL(tg.Periodicity.Type, "AperiodicTrigger")
%assign decl = "void %<tg.Name>(void);/n"
%else
%assign decl = "void %<tg.Name>_step(void);/n"
%endif
/* model step function */
%<decl>
%endforeach
%endforeach
%closefile tmpDecl
%return tmpDecl
%endfunction
%function SLibDeploymentAddClassPrivateData() void
%assert LibIsDeploymentDiagram() && GenerateClassInterface
%assign declRec = ::CompiledModel.CPPEncapsulationRecord
%assign numTimingBridge = 0
%assign mdlRefBlks = ISFIELD(::CompiledModel,"ModelReferenceBlocks") ? ...
::CompiledModel.ModelReferenceBlocks : []
%if !ISEMPTY(mdlRefBlks)
%foreach rowIdx = SIZE(mdlRefBlks,0)
%assign mdlRefInfo = mdlRefBlks[rowIdx]
%assign mSysIdx = mdlRefInfo[0]
%assign bIdx = mdlRefInfo[1]
%assign blk = System[mSysIdx].Block[bIdx]
%assign blockInterface = GetModelrefInterface(blk)
%if blockInterface.NeedsGlobalTimingEngine
%assign numTimingBridge = numTimingBridge + 1
%endif
%endforeach
%endif
%if numTimingBridge > 0
%assign declaration = ...
"rtTimingBridge %<SLibDeploymentGetTimingBridgeName()>[%<numTimingBridge>]; /n"
%assign declRec.PrivateData = declRec.PrivateData + "/* Timing bridge */"
%assign declRec.PrivateData = declRec.PrivateData + declaration
%endif
%assign numTasks = FcnGetNumPeriodicUserMappedEntities()
%if numTasks > 0
%assign declaration = "%<::tSimStructType> %<SLibDeploymentGetTaskRTMVarName()>[%<numTasks>];/n"
%assign declRec.PrivateData = declRec.PrivateData + "/* Real-Time Model for Tasks */"
%assign declRec.PrivateData = declRec.PrivateData + declaration
%endif
%endfunction
%function SLibDeploymentGetContStatesStruct(sysIdx, forceDerivFromRTM) void
%assign tid = System[sysIdx].HasCStatesArg ? 0 : 1
%if forceDerivFromRTM
%assert EXISTS(::GlobalCurrentPID)
%assign taskIdx = SLibDeploymentGetTaskIndexForComponent(::GlobalCurrentPID, tid)
%endif
%assign varName = ""
%if forceDerivFromRTM
%assign varName = SLibDeploymentGetTasksRTMVarName(taskIdx)
%else
%assign varName = "%<FcnGetTasksContStatesVarName()>"
%endif
%if ::CompiledModel.HasSimStructVars == 1
%assign retStr = SLibDeploymentRTMGet("ContStates", varName)
%assign retStr = "((%<::tContStateType> *) %<retStr>)"
%else
%assign retStr = varName
%endif
%return retStr
%endfunction
%function SLibDeploymentGetContStatesDisabledStruct(sysIdx, forceDerivFromRTM) void
%assign errTxt = "Parallel Deployment Error: variable-step solver is not supported."
%<LibReportFatalError(errTxt)>
%endfunction
%function SLibDeploymentGetContStatesDerivativeStruct(sysIdx, forceDerivFromRTM) void
%if ::CompiledModel.HasSimStructVars == 1 || forceDerivFromRTM
%assign tid = System[sysIdx].HasCStatesArg ? 0 : 1
%assign taskIdx = SLibDeploymentGetTaskIndexForComponent(::GlobalCurrentPID, tid)
%assert (taskIdx >= 0)
%assign varName = SLibDeploymentGetTasksRTMVarName(taskIdx)
%assign xdotName = SLibDeploymentGetTaskNameForComponent(::GlobalCurrentPID, tid)
%return "((%<::tXdotType>_%<xdotName> *) %<SLibDeploymentRTMGet("dX", varName)>)"
%else
%return ::tXdot
%endif
%endfunction
%function SLibDeploymentGetSystemCStatesDeriv(sysIdx)
%assert (LibIsDeploymentDiagram())
%assert (sysIdx == NumSystems-1)
%assign retval = ["", 0]
%assign cstates = ""
%assign numContStates = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger") || ISEQUAL(tg.NumTasks, 0)
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%if task.NumContStates <= 0
%continue
%endif
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign identifier = "%<::tXdotType>_%<task.FunctionName>"
%openfile comment
/* State derivatives for %<task.FunctionName> */
%closefile comment
%openfile taskCStates
%<comment>/
%<GetHideChildDefineSymbol("ifndef")>/
typedef struct {
%foreach epIdx = task.NumEntryPointInfos
%assign compIdx = task.EntryPointInfo[task.BlockContStateOrder[epIdx]].BlockIdx
%if compIdx[1] >= 0
%assign taskCStatesDerivBuff = SLibGetSystemCStatesDeriv(compIdx[1])
%else
%assign taskCStatesDerivBuff = SLibGetSystemCSDerivForBlock(NumSystems - 1, compIdx[2])
%endif
%if taskCStatesDerivBuff[1] > 0
%
%endif
%endforeach
} %<identifier>;
%<GetHideChildDefineSymbol("endif")>/
%closefile taskCStates
%assign cstates = "%<cstates> %<taskCStates>"
%assign numContStates = numContStates + task.NumContStates
%endforeach
%endforeach
%if !SLibDeploymentDiagramWithTopSolver()
%if numContStates > 0
%assign System[sysIdx].HasCStatesDerivArg = 1
%endif
%if LibGetFieldSet(System[sysIdx], "HasCStatesDerivArg") == 0
%<LibSetFieldSet(System[sysIdx], "HasCStatesDerivArg")>
%endif
%endif
%if numContStates > 0
%assign retval[0] = "%<cstates>"
%assign retval[1] = %<numContStates>
%endif
%return retval
%endfunction
%function SLibDeploymentGetSystemMassMatrix(sysIdx)
%assert (LibIsDeploymentDiagram())
%assign retval = ["", 0]
%assign taskMassMatrixBuff = ""
%assign numTasksWithMassMatrices = 0
%if (::CompiledModel.ModelIsLinearlyImplicit == "yes")
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger") || ISEQUAL(tg.NumTasks, 0)
%continue
%endif
%openfile taskMassMatrixDef
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%if task.NumContStates == 0 || task.IsLinearlyImplicit == "no"
%continue
%endif
%assign identifier = "%<::tMassMatrixGlobalType>_%<task.FunctionName>"
%openfile comment
/* Mass Matrix for %<task.FunctionName> */
%closefile comment
%<comment>/
%<GetHideChildDefineSymbol("ifndef")>/
typedef struct {
int_T ir[%<task.MassMatrixNzMax>];
int_T jc[%];
real_T pr[%<task.MassMatrixNzMax>];
} %<identifier>;
%<GetHideChildDefineSymbol("endif")>/
%endforeach
%closefile taskMassMatrixDef
%assign taskMassMatrixBuff = "%<taskMassMatrixBuff> %<taskMassMatrixDef>"
%assign numTasksWithMassMatrices = numTasksWithMassMatrices + 1
%endforeach
%endif
%assert (SLibDeploymentDiagramWithTopSolver() || (LibGetFieldSet(System[sysIdx], "HasMassMatrixGlobalArg") == 0))
%if numTasksWithMassMatrices > 0
%assign System[sysIdx].HasMassMatrixGlobalArg = 1
%endif
%<LibSetFieldSet(System[sysIdx], "HasMassMatrixGlobalArg")>
%if numTasksWithMassMatrices > 0
%assign retval[0] = "%<taskMassMatrixBuff>"
%assign retval[1] = %<numTasksWithMassMatrices>
%endif
%return retval
%endfunction
%function FcnFindBlockFromSystem(system, grSysIdx, blockIdx) void
%with system
%foreach bIdx = NumBlocks
%if Block[bIdx].Type == "SubSystem"
%assign childSystem = System[Block[bIdx].BlockIdx[1]]
%assign block = FcnFindBlockFromSystem(childSystem, grSysIdx, blockIdx)
%if !ISEMPTY(block)
%return block
%endif
%endif
%assign grSrc = Block[bIdx].GrSrc
%if ISEQUAL(grSrc[0], grSysIdx) && ISEQUAL(grSrc[1], blockIdx)
%return Block[bIdx]
%endif
%endforeach
%endwith
%return ""
%endfunction
%function SLibDeploymentGetSystemMassMatrixPr(grSysIdx, blockIdx, prOffset, isSubsys)
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger") || ISEQUAL(tg.NumTasks, 0)
%continue
%endif
%foreach tIdx = tg.NumTasks
%assign task = tg.Task[tIdx]
%if task.NumContStates <= 0
%continue
%endif
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%foreach epIdx = task.NumEntryPointInfos
%assign compIdx = task.EntryPointInfo[epIdx].BlockIdx
%assign sysIdx = (compIdx[1] < 0 || isSubsys) ? compIdx[0] : compIdx[1]
%assign block = System[sysIdx].Type == "root" ? ...
System[sysIdx].Block[compIdx[2]] : ...
FcnFindBlockFromSystem(System[sysIdx], grSysIdx, blockIdx)
%if ISEMPTY(block) || ...
block.GrSrc[0] != grSysIdx || ...
block.GrSrc[1] != blockIdx
%continue
%endif
%assign contStartIdx = isSubsys ? ...
block.SubsystemParamSettings.SystemContStates[1] : block.ContStates[2]
%assign blkcstateIdx = contStartIdx - task.ContStateStartIndex
%return task.MassMatrixJc[blkcstateIdx]
%endforeach
%endforeach
%endforeach
%return prOffset
%endfunction
%function SLibDeploymentGetNumContStates() void
%assign nTaskContStates = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%assign nTaskContStates = nTaskContStates+task.NumContStates
%endforeach
%endforeach
%return nTaskContStates
%endfunction
%function SLibDeploymentGetNumPeriodicContStates() void
%assign nTaskPeriodicContStates = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%if task.NumContStates > 0
%assign nTaskPeriodicContStates = nTaskPeriodicContStates+task.NumPeriodicContStates
%continue
%endif
%endforeach
%endforeach
%return nTaskPeriodicContStates
%endfunction
%function SLibDeploymentGetMassMatrixNzMax() void
%assign massMatrixNzMax = 0
%foreach tgIdx = ::CompiledModel.NumEventHandlers
%assign tg = ::CompiledModel.EventHandler[tgIdx]
%if !ISEQUAL(tg.Periodicity.Type, "PeriodicTrigger")
%continue
%endif
%foreach tIdx = tg.NumTasks
%if SLibDeploymentIsSynthesizedTask(tgIdx, tIdx)
%continue
%endif
%assign task = tg.Task[tIdx]
%if (task.NumContStates == 0) || (task.IsLinearlyImplicit == "no")
%continue
%endif
%assign massMatrixNzMax = massMatrixNzMax+task.MassMatrixNzMax
%endforeach
%endforeach
%return massMatrixNzMax
%endfunction
%function SLibDeploymentDiagramWithTopSolver() void
%assign nTaskContStates = SLibDeploymentGetNumContStates()
%return !ISEQUAL(nTaskContStates, NumContStates)
%endfunction
%function SLibDeploymentIsSampleHit(tid, compIdx) void
%assert (LibIsDeploymentDiagram())
%assign rtmIdx = SLibDeploymentGetTaskIndexForComponent(::GlobalCurrentPID, tid)
%assert ((rtmIdx >= 0) || ((rtmIdx == -1) && ((compIdx == NumSystems-1) || SLibDeploymentDiagramWithTopSolver())))
%if (rtmIdx >= 0)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%assign rtmIsMajorTimeStep = FcnGenSpecialAccess(NumSystems-1, ...
"MajorTimeStep", "is", 0, [], "", rtmName)
%else
%if ((tid == 0) && SLibDeploymentDiagramWithTopSolver())
%assign tid = 1
%endif
%assign rtmIsMajorTimeStep = LibIsSampleHit(tid)
%endif
%return rtmIsMajorTimeStep
%endfunction
%function SLibDeploymentGenerateRTMGetMacro(tid, compIdx, field) void
%assert (LibIsDeploymentDiagram())
%assign rtmIdx = SLibDeploymentGetTaskIndexForComponent(::GlobalCurrentPID, tid)
%assert ((rtmIdx >= 0) || ((rtmIdx == -1) && ((compIdx == NumSystems-1) || SLibDeploymentDiagramWithTopSolver())))
%if (rtmIdx >= 0)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%assign rtmAccess = SLibDeploymentRTMGet(field, rtmName)
%else
%assign rtmAccess = RTMGet(field)
%endif
%return rtmAccess
%endfunction
%function SLibDeploymentRTMSolverIs(tid, compIdx, field) void
%assert (LibIsDeploymentDiagram())
%assign rtmIdx = SLibDeploymentGetTaskIndexForComponent(::GlobalCurrentPID, tid)
%assert ((rtmIdx >= 0) || ((rtmIdx == -1) && ((compIdx == NumSystems-1) || SLibDeploymentDiagramWithTopSolver())))
%if (rtmIdx >= 0)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%assign rts = FcnRTMGetSolverInfo(rtmName)
%else
%assign rts = RTMGetSolverInfo()
%endif
%assign rtmAccess = "rtsiIsSolver%<field>(%<rts>)"
%return rtmAccess
%endfunction
%function SLibDeploymentGenerateRTMGetTMacro(tid, compIdx) void
%assert (LibIsDeploymentDiagram())
%assign rtmIdx = SLibDeploymentGetTaskIndexForComponent(::GlobalCurrentPID, tid)
%assert ((rtmIdx >= 0) || ((rtmIdx == -1) && ((compIdx == NumSystems-1) || SLibDeploymentDiagramWithTopSolver())))
%if (rtmIdx >= 0)
%assign rtmName = SLibDeploymentGetTasksRTMVarName(rtmIdx)
%assign rtmAccess = FcnGetTaskTime(System[NumSystems-1], tid, rtmName)
%else
%assign rtmAccess = RTMsGetTaskTimeForTID(System[NumSystems-1], tid)
%endif
%return rtmAccess
%endfunction
%function SLibDeploymentEmitCallTaskFunction(taskNum, tgNum) void
%assert (LibIsDeploymentDiagram() && SLibIsERTCodeFormat())
%if (GenerateSampleERTMain || RateBasedStepFcn) && (!SLibGenerateNativeThreads())
%assign errTxt = "Parallel Deployment Error: No model wrapper function"
%<LibReportFatalError(errTxt)>
%endif
%assign tIdx = 0
%foreach tgIdx = tgNum - 1
%assign tIdx = tIdx + ::CompiledModel.EventHandler[tgIdx].NumTasks
%endforeach
%assign tIdx = tIdx + taskNum
%openfile tmpBuf
%if SLibIsERTTarget()
%assign stepFcnName = SLibGenErtFunctionName("", "step")
%<stepFcnName>(%<tIdx>);
%else
MdlOutputs(%<tIdx>);
MdlUpdate(%<tIdx>);
%endif
%closefile tmpBuf
%return tmpBuf
%endfunction
%function SLibDeploymentGetAperiodicEventHandler(aehIdx)
%assign nAEH = -1
%assign nTaskGroups = LibDeploymentGetNumTaskGroups()
%assign retVal = ""
%foreach tgIdx = nTaskGroups
%assign tg = LibDeploymentGetTaskGroup(tgIdx)
%if ISEQUAL(tg.Periodicity.Type, "AperiodicTrigger")
%assign nAEH = nAEH + 1
%if ISEQUAL(nAEH, aehIdx)
%assign retVal = tg
%break
%endif
%endif
%endforeach
%return retVal
%endfunction
%function SLibDeploymentGetLocalVars(fcnType) void
%openfile localVars
%foreach sysIdx = NumSystems-1
%assign currentSystem = System[sysIdx]
%if ISEQUAL(fcnType, "Start") && SLibDeploymentDiagramIsMapped(sysIdx)
%<FcnDeclareAccessedLocalVariables(currentSystem)>
%endif
%endforeach
%closefile localVars
%return localVars
%endfunction
%include "paralleldeploymentlib.tlc"