| Simulink Reference | ![]() |
Get runtime information about a Level-2 M-file S-function block.
Description
This class allows a Level-2 M-file S-function or other M program to obtain information from Simulink and provide information to Simulink about a Level-2 M-file S-function block. Simulink creates an instance of this class for each Level-2 M-file S-function block in a model. Simulink passes the object to the callback methods of Level-2 M-file S-functions when it updates or simulates a model, allowing the callback methods to get and provide block-related information to Simulink. See Writing Level-2 M-file S-functions for more information.
You can also use instances of this class in M-file programs to obtain information about Level-2 M-file S-function blocks during a a simulation. See Accessing Block Data During Simulation for more information.
Parent Class
Derived Classes
Property Summary
| Name |
Description |
|
Specifies which of the S-function's dialog parameters are tunable. |
|
Time of the next sample hit for variable sample time S-functions. |
Method Summary
| Name |
Description |
|
Register this block's dialog parameters as runtime parameters. |
|
Update this block's runtime parameters. |
|
Determine whether the current simulation stage is the constant sample time stage. |
|
Determine whether the current simulation time step is a major time step. |
|
Determine whether the current simulation time is one at which a task handled by this block is active. |
|
Determine whether the current simulation time is one at which multiple tasks handled by this block are active. |
|
Register a callback method for this block. |
|
Register fixed-point data type with binary point-only scaling. |
|
Register fixed-point data type with [Slope Bias] scaling specified in terms of fractional slope, fixed exponent, and bias. |
|
Register data type with [Slope Bias] scaling. |
|
Specify whether to use this block's TLC file to generate the simulation target for the model that uses it. |
|
Set compiled attributes of this block's ports to default values. |
|
Set precompiled attributes of this block's ports to be inherited. |
|
Specify whether block is a viewer. |
|
Write custom parameter info to RTW file. |
Properties
DialogPrmsTunable
Description: Specifies whether a dialog parameter of the S-function is tunable. Tunable parameters are registered as run-time parameters when you call the AutoRegRuntimePrms method. Note that SimOnlyTunable parameters are not registered as run-time parameters.
NextTimeHit
Description: Time of the next sample hit for variable sample-time S-functions.
Methods
AutoRegRuntimePrms
Purpose.: Register a block's tunable dialog parameters as runtime parameters.
Description: Register this block's tunable dialog parameters as runtime parameters.
AutoUpdateRuntimePrms
Purpose.: Update a block's runtime parameters.
Description: Automatically update the values of the run-time parameters during a call to mdlProcessParameters.
IsDoingConstantOutput
Purpose.: Determine whether this is in the constant sample time stage of a simulation.
Syntax: bVal = IsDoingConstantOutput;
Description: Returns true if this is the ~constant sample time stage of a simulation, i.e., the stage at the beginning of a simulation where Simulink computes the values of block outputs that cannot change during the simulation (see Constant Sample Time). Use this method in the mdlOutputs method of an S-function with port-based sample times to avoid unnecessarily computing the outputs of ports that have constant sample time, i.e., ['inf', 0], i.e.,
function Outputs(block) . . if block.IsDoingConstantOutput ts = block.OutputPort(1).SampleTime; if ts(1) == Inf %% Compute port's output. end end . . %% end of Outputs
See Specifying Port-Based Sample Times for more information.
IsMajorTimeStep
Purpose.: Determine whether current time step is a major or a minor time step.
Syntax: bVal = IsMajorTimeStep;
Description: Returns true if the current time step is a major time step; false, if it is a minor time step. This method can be called only from mdlOutputs and mdlUpdate.
IsSampleHit
Purpose.: Determine whether the current simulation time is one at which a task handled by this block is active.
Syntax: bVal = IsSampleHit(stIdx);
Description: Use in Outputs or Update block methods when the M-file S-function has multiple sample times to determine whether a sample hit has occurred at stIdx. (Similar to ssIsSampleHit for C-Mex S-functions).
IsSpecialSampleHit
Purpose.: Determine whether the current simulation time is one at which multiple tasks implemented by this block are active.
Syntax: bVal = IsSpecialSampleHit(stIdx1,stIdx1);
Description: Use in Outputs or Update block methods to ensure the validity of data shared by multiple tasks running at different rates. Returns true if a sample hit has occurred at stIdx1 and a sample hit has also occurred at stIdx2 in the same time step. (Similar to ssIsSpecialSampleHit for C-Mex S-functions)
RegBlockMethod
Purpose: Register a block callback method.
Syntax: RegBlockMethod(methName, methHandle);
Description: Registers the block callback method specified by methName and methHandle. Use this method in a Level-2 M-file S-function to specify the block callback methods that the S-function implements.
RegisterDataTypeFxpBinaryPoint
Purpose: Register fixed-point data type with binary point-only scaling.
Syntax: dtID = RegisterDataTypeFxpBinaryPoint(isSigned, wordLength, fractionalSlope, fixedExponent, bias, obeyDataTypeOverride);
true indicates that the Data Type Override setting for the subsystem is to be obeyed. Depending on the value of Data Type Override, the resulting data type could be True Doubles, True Singles, ScaledDouble, or the fixed-point data type specified by the other arguments of the function.
false indicates that the Data Type Override setting is to be ignored.
Description: This method registers a fixed-point data type with Simulink and returns a data type ID. The data type ID can be used to specify the data types of input and output ports, run-time parameters, and DWork states. It can also be used with all the standard data type access methods defined for instances of this class, such as DatatypeSize.
Use this function if you want to register a fixed-point data type with binary point-only scaling. Alternatively, you can use one of the other fixed-point registration functions:
RegisterDataTypeFxpFSlopeFixExpBias to register a data type with [Slope Bias] scaling by specifying the word length, fractional slope, fixed exponent, and bias.
RegisterDataTypeFxpSlopeBias to register a data type with [Slope Bias] scaling.
If the registered data type is not one of the Simulink built-in data types, a Simulink Fixed Point license is checked out.
RegisterDataTypeFxpFSlopeFixExpBias
Purpose: Register fixed-point data type with [Slope Bias] scaling specified in terms of fractional slope, fixed exponent, and bias
Syntax: dtID = RegisterDataTypeFxpFSlopeFixExpBias(isSigned, wordLength, fractionalSlope, fixedExponent, bias, obeyDataTypeOverride);
true indicates that the Data Type Override setting for the subsystem is to be obeyed. Depending on the value of Data Type Override, the resulting data type could be True Doubles, True Singles, ScaledDouble, or the fixed-point data type specified by the other arguments of the function.
false indicates that the Data Type Override setting is to be ignored.
Description: This method registers a fixed-point data type with Simulink and returns a data type ID. The data type ID can be used to specify the data types of input and output ports, run-time parameters, and DWork states.It can also be used with all the standard data type access methods defined for instances of this class, such as DatatypeSize.
Use this function if you want to register a fixed-point data type by specifying the word length, fractional slope, fixed exponent, and bias. Alternatively, you can use one of the other fixed-point registration functions:
RegisterDataTypeFxpBinaryPoint to register a data type with binary point-only scaling.
RegisterDataTypeFxpSlopeBias to register a data type with [Slope Bias] scaling.
If the registered data type is not one of the Simulink built-in data types, a Simulink Fixed Point license is checked out.
RegisterDataTypeFxpSlopeBias
Purpose: Register data type with [Slope Bias] scaling.
Syntax: dtID = RegisterDataTypeFxpSlopeBias(isSigned, wordLength, totalSlope, bias, obeyDataTypeOverride);
true indicates that the Data Type Override setting for the subsystem is to be obeyed. Depending on the value of Data Type Override, the resulting data type could be True Doubles, True Singles, ScaledDouble, or the fixed-point data type specified by the other arguments of the function.
false indicates that the Data Type Override setting is to be ignored.
Description: This method registers a fixed-point data type with Simulink and returns a data type ID. The data type ID can be used to specify the data types of input and output ports, run-time parameters, and DWork states. It can also be used with all the standard data type access methods defined for instances of this class, such as DatatypeSize.
Use this function if you want to register a fixed-point data type with [Slope Bias] scaling. Alternatively, you can use one of the other fixed-point registration functions:
RegisterDataTypeFxpBinaryPoint to register a data type with binary point-only scaling.
RegisterDataTypeFxpFSlopeFixExpBias to register a data type by specifying the word length, fractional slope, fixed exponent, and bias
If the registered data type is not one of the Simulink built-in data types, a Simulink Fixed Point license is checked out.
SetAccelRunOnTLC
Purpose: Specify whether to use block's TLC file to generate code for the Simulink accelerator.
Syntax: SetAccelRunOnTLC(bVal);
Description: Specify if the block should use its TLC file to generate code that runs with the accelerator. If this option is 'false', the block runs in interpreted mode
SetPreCompPortInfoToDefaults
Purpose: Set compiled attributes of this block to default values.
Syntax: SetPreCompPortInfoToDefaults;
Description: Initialize the compiled information (dimensions, datatype, complexity, and sampling mode) of this block's ports to have default attributes (double, real, sample-based scalars)
SetPreCompPortInfoToDynamic
Purpose: Set compiled attributes of this block to be inherited.
Syntax: SetPreCompPortInfoToDefaults;
Description: Initialize the compiled information (dimensions, datatype, complexity, and sampling mode) of the block's ports to be inherited.
SetSimViewingDevice
Purpose: Specify whether this block is a viewer.
Syntax: SetSimViewingDevice(bVal);
Description: Specify if the block is a viewer/scope. If this flag is specified, the block will be used only during simulation and automatically stubbed out in generated code.
WriteRTWParam
Purpose: Write a custom parameter to the RTW information file used for code generation.
Syntax: WriteRTWParam(pType, pName, pVal)
Description: Use in the mdlRTW method of the M-file S-function to write out custom parameters. These parameters are generally settings used to determine how code should be generated in the TLC file for the S-function.
| Simulink.ModelWorkspace | Simulink.NumericType | ![]() |
© 1994-2005 The MathWorks, Inc.