%if EXISTS("_BLOCK_SETUP_LIB_") == 0
%assign _BLOCK_SETUP_LIB_ = 1
%function BlockSetupAndCompatibilityCheck() void
%with ::CompiledModel
%foreach sysIdx = ::CompiledModel.NumSystems
%assign ::system = ::CompiledModel.System[sysIdx]
%with ::system
%if ISFIELD(::system, "Block")
%addtorecord ::system NumTotalBlocks SIZE(system.Block,1)
%else
%addtorecord ::system NumTotalBlocks 0
%endif
%foreach blkIdx = ::system.NumBlocks
%assign ::block = ::system.Block[blkIdx]
%with ::block
%if ::block.Type != "Opaque"
%foreach idx = ::block.NumRWorkDefines
%assign work = ::block.RWorkDefine[idx]
%if !ISFIELD(::block,"%<work.Name>")
%assign %<work.Name> = work
%assign ::block = ::block + %<work.Name>
%endif
%endforeach
%foreach idx = ::block.NumIWorkDefines
%assign work = ::block.IWorkDefine[idx]
%assign %<work.Name> = work
%assign ::block = ::block + %<work.Name>
%endforeach
%foreach idx = ::block.NumPWorkDefines
%assign work = ::block.PWorkDefine[idx]
%if !ISFIELD(::block,"%<work.Name>")
%assign %<work.Name> = work
%assign ::block = ::block + %<work.Name>
%endif
%endforeach
%foreach idx = ::block.NumDWork
%assign work = ::block.DWork[idx]
%assign %<work.Name> = work
%assign ::block = ::block + %<work.Name>
%endforeach
%endif
%addtorecord ::block BlkSysIdx system.SystemIdx
%assign ::CurrentSFcnBlockName = ""
%if ::block.Type == "S-Function"
%if LibSystemIsReusedLibraryFcn(::system)
%assign ::CurrentSFcnBlockName = ::block.ParamSettings.FunctionName
%endif
%endif
%assign _globalVar = SLibBlockTypeSetupName(sysIdx, blkIdx)
%if !EXISTS("::%<_globalVar>")
%if SLibIsMainCodeGenPhase()
%assign blkTypeInit = ...
CGMODEL_ACCESS("FileRepository.initializeBlockType",_globalVar)
%endif
%<GENERATE(::block, "BlockTypeSetup", ::system)>/
%assign ::%<_globalVar> = 1
%else
%if SLibIsMainCodeGenPhase()
%assign vcond = SLibGetBlockVariantCondition(::block)
%assign updateCond = ...
CGMODEL_ACCESS("FileRepository.updateHeaderConditionBasedOnType", ...
_globalVar, vcond)
%endif
%endif
%assign ::CurrentSFcnBlockName = ""
%assign ::BlockFcn = "BlockInstanceSetup"
%<GENERATE(::block, "BlockInstanceSetup", ::system)>/
%assign ::BlockFcn = "Unknown"
%if ::block.UseTLC
%if SLibBlockIsExpressionCompliant(::block)
%foreach opIdx = ::block.NumDataOutputPorts
%if LibBlockOutputSignalWidth(opIdx) > 1
%foreach ipIdx = ::block.NumDataInputPorts
%if LibBlockInputSignalWidth(ipIdx) == 1 && ...
!SLibBlockInputSignalAllowScalarExpandedExpr(::block, ipIdx)
%<SLibSetBlockInputSignalIsNotExpr(::block, ipIdx)>
%endif
%endforeach
%endif
%endforeach
%else
%foreach ipIdx = ::block.NumDataInputPorts
%<SLibSetBlockInputSignalIsNotExpr(::block, ipIdx)>
%endforeach
%<SLibSetBlockOutputSignalsAreNotExpr(::block)>
%endif
%endif
%endwith
%endforeach
%if EXISTS("EmptySubsysInfo")
%with EmptySubsysInfo
%foreach idx = NumRTWdatas
%assign temp = RTWdata[idx]
%if ISFIELD(temp,"IncludePath")
%addincludepath temp.IncludePath
%endif
%if ISFIELD(temp,"TLCFile")
%if FILE_EXISTS(GENERATE_FILENAME(temp.TLCFile))
%<GENERATE_TYPE(temp, "ProcessRTWdata", temp.TLCFile, system)>
%else
%if system.Type != "root"
%assign sysName = LibUnmangledPathName(system.Name)
%else
%assign sysName = ::CompiledModel.Name
%endif
%openfile errTxt
Cannot locate TLC file %<temp.TLCFile>.tlc
A block specified RTWData without a corresponding TLC file. /
RTWData must include the TLC file name. For example,
data.Foo = '1';
data.TLCFile = 'foofile';
set_param(gcb, 'RTWData', data);
RTWData {
Foo "1"
TLCFile "foofile"
}
The specified TLC file either does not exist, or is not on the TLC /
path, or is incorrect.
The block was located in system: %<sysName>
%closefile errTxt
%<LibReportError(errTxt)>
%endif
%endif
%endforeach
%endwith
%endif
%endwith
%endforeach
%endwith
%undef ::system, ::block, param, bo, work, temp
%endfunction
%function SLibSetupSharedGlobalVariables() void
%if !EXISTS("::Accelerator")
%assign ::Accelerator = 0
%endif
%endfunction
%endif