Main Content

slreportgen.report.CFunction Class

Namespace: slreportgen.report

C Function block reporter

Since R2021b

Description

Use an object of the slreportgen.report.CFunction class to report on a C Function block.

By default, a CFunction object reports:

  • A table that includes the Description parameter and any custom mask parameters

  • A table that lists the contents of the Symbols parameter

  • Sections for the C code defined by the Output Code, Start Code, and Terminate Code parameters

Use the object properties to exclude or modify the reported information.

Note

To use a CFunction reporter in a report, you must create the report using the slreportgen.report.Report class.

The slreportgen.report.CFunction class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

rptr = slreportgen.report.CFunction creates a CFunction object with default property values. You must specify the C Function block to report by setting the Object property. Use other properties to specify report options.

rptr = slreportgen.report.CFunction(cFunctionBlock) specifies the C Function block to report and sets the Object property to cFunctionBlock.

example

rptr = slreportgen.report.CFunction(Name=Value) sets properties using name-value arguments. For example, rptr = slreportgen.report.CFunction(Object="slrgex_cfunction/C Function") sets the Object property to "slrgex_cfunction/C Function". You can specify multiple name-value arguments.

Properties

expand all

Simulink C Function block to report, specified as one of these values:

  • A string scalar or character vector that contains the path of a C Function block

  • A handle to a C Function block

  • An slreportgen.finder.BlockResult object that represents the block

Note

If you use a finder to find C Function blocks and add the results directly to a report, the blocks are reported using slreportgen.report.CFunction reporters, instead of slreportgen.report.SimulinkObjectProperties reporters.

Whether to include a table of block parameters, specified as true or false. If this property is true, the reporter generates a table that includes the Description parameter and any custom mask parameters, by default. The Output Code, Start Code, Terminate Code, and Symbols parameters are not included in this table because they are reported in separate sections. Use the ObjectPropertiesReporter property of this reporter to specify the parameters that the table includes or to customize the table format. If the parameters are empty, the reporter does not generate a table.

Data Types: logical

Whether to include a table of the symbols used by the C Function block, specified as true or false.

Data Types: logical

Whether to include the C code used to compute the outputs of the C Function block, specified as true or false.

Data Types: logical

Whether to include the C code used to compute the state of the C Function block at the start of the simulation, specified as true or false.

Data Types: logical

Whether to include the C code that the C Function block executes when it terminates, specified as true or false.

Data Types: logical

Whether to include initialization C code that executes whenever the C Function block is enabled, specified as true or false. If this property is true, the reporter includes the condition initialization code in the report. If the C Function block does not define condition initialization code, nothing is added to the report.

Data Types: logical

Formatter for the C Function block properties table, specified as an slreportgen.report.SimulinkObjectProperties object. The default value of this property is an empty slreportgen.report.SimulinkObjectProperties object. You can customize the appearance of the block properties table by modifying the properties of the default object or by replacing it with another SimulinkObjectProperties object. You can specify the properties to display in this table by using the Properties property of the SimulinkObjectProperties object. If Properties is empty, the reporter automatically determines which properties to display based on the C Function block parameters.

Formatter for the table of symbols used by the C Function block, specified as an mlreportgen.report.BaseTable object. The default value of this property is an empty BaseTable object with the StyleName property set to "CFunctionSymbolsTable". You can customize the appearance of the table of symbols by modifying the properties of the default object or by replacing it with another BaseTable object. Any content added to the title property of the BaseTable object appears before the default generated table title in the report.

Paragraph formatter for the titles of the output, start, and terminate code sections of the report, specified as an mlreportgen.dom.Paragraph object. The default value of this property is an empty Paragraph object with the StyleName property set to "CFunctionCodeTitle". You can customize the appearance of the code section titles by modifying the properties of the default object or by replacing it with another Paragraph object. Any content added to the Paragraph object in this property appears before the code titles in the report.

Formatter for the C code in the output, start and terminate code sections of the report, specified as an mlreportgen.dom.Preformatted object. The default value of this property is an empty Preformatted object with StyleName set to "CFunctionCode". You can customize the appearance of the C code by modifying the properties of the default object or by replacing it with another Preformatted object. Any content added to the Preformatted object in this property appears before the formatted code in the report.

Since R2024a

Type of C code to include, specified as "both", "simulation", or "code generation". This property applies only if a C Function block is configured to use different C code in generated code than it uses for simulation. Otherwise this property is ignored.

  • "both" (default) — Include C code used during simulation and C code used in generated code.

  • "simulation" — Include only C code used during simulation.

  • "code generation" — Include only C code used in generated code.

Data Types: char | string

Source of the template for this reporter, specified in one of these ways:

  • Character vector or string scalar that specifies the path of the file that contains the template for this reporter

  • Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter

The specified template must be the same type as the report to which you append this report. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of the template for this reporter, specified as a character vector or string scalar. The template for this reporter must be in the template library of the template specified by the TemplateSrc property of this reporter.

Data Types: char | string

Hyperlink target for this reporter, specified as a character vector or string scalar that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A character vector or string scalar value converts to a LinkTarget object. The link target immediately precedes the content of this reporter in the output report.

Methods

expand all

Examples

collapse all

This example generates a report that includes information about a C Function block used in a model.

Import the Report API packages so that you do not have to use long, fully qualified class names.

import mlreportgen.report.*
import slreportgen.report.*

Create a report.

rpt = slreportgen.report.Report("output","pdf");

Load a model that has a C Function block.

model_name = "slrgex_cfunction";
cFcnObj = "slrgex_cfunction/C Function";
load_system(model_name);

Create a chapter reporter.

chapter = Chapter(cFcnObj);

Create a C Function block reporter. By default, the reporter includes the Output Code, Start Code, Terminate Code, and Symbols parameters, as well as any other block parameters in the report. The Terminate Code parameter of the C Function block in this example is empty.

rptr = CFunction(cFcnObj);

Add the C Function reporter to the chapter and chapter to the report.

append(chapter,rptr);
append(rpt,chapter);

Close and view the report.

close(rpt);
close_system(model_name);
rptview(rpt);

Here is the C Function block information in the report:

Version History

Introduced in R2021b

expand all