Sample Time Functions

LibAsynchronousTriggeredTID(tid)

Returns whether this TID corresponds to a asynchronous triggered rate.

See LibAsynchronousTriggeredTID in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibBlockSampleTime(block)

Returns the block's sample time. The returned value depends on the sample time classification of the block, as shown in the following table.

Block ClassificationReturned Value

Discrete

The actual sample time of a block (real > 0)

Continuous

0.0

Triggered

-1.0

Constant

-2.0

See LibBlockSampleTime in matlabroot/rtw/c/tlc/lib/blocklib.tlc.

LibGetClockTick(tid)

Returns integer task time (current clock tick of the task timer). The resolution of the timer can be obtained from LibGetClockTickStepSize(tid). The data type ID of the timer can be obtained from LibGetClockTickDataTypeId(tid).

See LibGetClockTick in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetClockTickDataTypeId(tid)

Returns clock tick data type ID.

See LibGetClockTickDataTypeId in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetClockTickHigh(tid)

Returns high-order word of the integer task time. LibGetClockTickHigh is used when uint32 pairs are used to store absolute time. The resolution of a clock tick can be obtained from LibGetClockTickStepSize(tid).

See LibGetClockTickHigh in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetClockTickStepSize(tid)

Returns clock tick step size, which is the resolution of the integer task time. LibGetClockTickStepSize cannot be used if the task does not have a timer.

See LibGetClockTickStepSize in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetElapseTime(system)

Returns time elapsed since the last time the subsystem started to execute.

See LibGetElapseTime in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetElapseTimeCounter(system)

Returns an integer elapsed time. This is the number of clock ticks elapsed since the last time the system started. To get real-world elapsed time, this integer elapsed time must be multiplied by the applicable resolution.

You can obtain the resolution by calling LibGetElapseTimeResolution(system). You can obtain the data type ID of the integer elapsed time counter by calling LibGetElapseTimeCounterDTypeId(system).

See LibGetElapseTimeCounter in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetElapseTimeCounterDTypeId(system)

Returns the date type ID of the integer elapsed time returned by LibGetElapseTimeCounter.

See LibGetElapseTimeCounterDTypeId in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetElapseTimeResolution(system)

Returns the resolution of the elapsed time returned by LibGetElapseTimeCounter.

See LibGetElapseTimeResolution in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetGlobalTIDFromLocalSFcnTID(sfcnTID)

Returns the model task identifier (sample time index) corresponding to the specified local S-function task identifier or port sample time. LibGetGlobalTIDFromLocalSFcnTID allows you to use one function to determine a global TID, independent of port- or block-based sample times.

The input argument to LibGetGlobalTIDFromLocalSFcnTID should be one of the following:

Examples

Multirate block.  

%assign globalTID = LibGetGlobalTIDFromLocalSFcnTID(2)

or

%assign globalTID = 
LibGetGlobalTIDFromLocalSFcnTID("InputPortIdx4") 
%assign period = 
CompiledModel.SampleTime[globalTID].PeriodAndOffset[0]
%assign offset = 
CompiledModel.SampleTime[globalTID].PeriodAndOffset[1]

Inherited sample time block.  

%switch (LibGetSFcnTIDType(0)) 
  %case "discrete" 
  %case "continuous" 
    %assign globalTID = LibGetGlobalTIDFromLocalSFcnTID(2) 
    %assign period = ... 
      CompiledModel.SampleTime[globalTID].PeriodAndOffset[0] 
    %assign offset = ... 
      CompiledModel.SampleTime[globalTID].PeriodAndOffset[1] 
    %breaksw 
  %case "triggered" 
    %assign period = -1 
    %assign offset = -1 
    %breaksw 
  %case "constant" 
    %assign period = rtInf 
    %assign offset = 0 
    %breaksw 
  %default 
    %<LibBlockReportFatalError([],"Unknown tid type")> 
%endswitch

See LibGetGlobalTIDFromLocalSFcnTID in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetNumSFcnSampleTimes(block)

Returns the number of S-function sample times for a block.

See LibGetNumSFcnSampleTimes in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetSFcnTIDType(sfcnTID)

Returns the type of the specified S-function task identifier (sfcnTID). Possible values are:

"continuous" — The specified sfcnTID is continuous.

"discrete" — The specified sfcnTID is discrete.

"triggered" — The specified sfcnTID is triggered.

"constant" — The specified sfcnTID is constant.

The format of sfcnTID must be the same as for LibIsSFcnSampleHit.

See LibGetNumSFcnSamplTimes in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetTaskTime(tid)

Returns a string to access the absolute time of the task, which is a floating-point number. However, if you have configured the model for integer-only code generation (by deselecting Support floating-point numbers), the string represents an integer equal to the number of base rate ticks (the absolute time divided by the base sample time) rather than the absolute time.

LibGetTaskTime is the TLC version of the SimStruct macro: "ssGetTaskTime(S,tid)".

See LibGetTaskTime in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibGetTaskTimeFromTID(block)

Returns a string to access the absolute time of the task associated with the block.

If the code format is not Embedded-C, LibGetTaskTimeFromTID returns the string "RTMGet("T")" if the block is constant or the system is single rate, and "RTMGetTaskTimeForTID(tid)" otherwise.

If the code format is Embedded-C, LibGetTaskTimeFromTID returns "RTMGetTaskTimeForTID(tid)".

If the block is constant or the system is single rate, this is the TLC version of the SimStruct macro: "ssGetT(S)" and "ssGetTaskTime(S, tid)" otherwise.

In both cases, S is the name of the SimStruct.

See LibGetTaskTime in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibIsContinuous(TID)

Returns 1 if the specified task identifier (TID) is continuous, 0 otherwise. Note that task identifiers equal to "triggered" or "constant" are not continuous.

See LibIsContinuous in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibIsDiscrete(TID)

Returns 1 if the specified task identifier (TID) is discrete, 0 otherwise. Note that task identifiers equal to "triggered" or "constant" are not discrete.

See LibIsDiscrete in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibIsSFcnSampleHit(sfcnTID)

Returns 1 if a sample hit occurs for the specified local S-function task identifier (TID), 0 otherwise.

The input argument to LibIsSFcnSampleHit should be one of the following:

Examples

See LibIsSFcnSampleHit in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibIsSFcnSingleRate(block)

LibIsSFcnSingleRate returns a Boolean value (1 or 0) indicating whether the S-function is single rate (one sample time) or multirate (multiple sample times).

See LibIsSFcnSingleRate in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibIsSFcnSpecialSampleHit(sfcnSTI, sfcnTID)

Returns the Simulink® macro to promote a slow task (sfcnSTI) into a faster task (sfcnTID).

This advanced function is specifically intended for use in rate transition blocks. LibIsSFcnSpecialSampleHit determines the global TID from the S-function TID

The input arguments to LibIsSFcnSpecialSampleHit are

The format of sfcnSTI and sfcnTID must follow that of the argument to LibIsSFcnSampleHit.

Examples

See LibIsSFcnSpecialSampleHit in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibIsSingleRateModel()

Returns true if model is single rate, and false otherwise.

See LibIsSingleRateModel in matlabroot/rtw/c/tlc/mw/codetemplatelib.tlc.

LibIsZOHContinuous(TID)

Returns 1 if the specified task identifier (TID) is zero order hold (ZOH) continuous, 0 otherwise. A TID equal to triggered or constant is not ZOH continuous.

See LibIsZOHContinuous in matlabroot/rtw/c/tlc/lib/utillib.tlc.

LibNumAsynchronousSampleTimes()

Returns the number of discrete sample times in the model.

See LibNumAsynchronousSampleTimes in matlabroot/rtw/c/tlc/mw/codetemplatelib.tlc.

LibNumDiscreteSampleTimes()

Returns the number of discrete sample times in the model.

See LibNumDiscreteSampleTimes in matlabroot/rtw/c/tlc/mw/codetemplatelib.tlc.

LibPortBasedSampleTimeBlockIsTriggered(block)

Determines whether the port-based S-function block is triggered.

See LibPortBasedSampleTimeBlockIsTriggered in matlabroot/rtw/c/tlc/lib/blocklib.tlc.

LibSetVarNextHitTime(block, tNext)

Generates code to set the next variable hit time. Blocks with variable sample time must call LibSetVarNextHitTime in their output functions.

See LibSetVarNextHitTime in matlabroot/rtw/c/tlc/lib/blocklib.tlc.

LibTriggeredTID(tid)

Returns whether this TID corresponds to a triggered rate.

See LibTriggeredTID in matlabroot/rtw/c/tlc/lib/utillib.tlc.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS