Create and Organize Block Artifacts
After creating a new blockset or importing your existing blocksets, you can start adding artifacts. In Blockset Designer, there are different artifacts associated with different blocks:
Subsystem blocks — You can add test and documentation.
MATLAB System blocks — You can add test using the Blockset Designer working area. To document your blocks, add comments in the System object™ code.
S-function and S-function Builder Blocks — You can build S-functions, add test and documentation.
Follow the status of your artifacts by checking the icons in the working area.
No files are specified for the artifact. To resolve, click Create or select an artifact from Browse.
The artifact files have been updated but has not been run yet. To resolve, click Run in the toolstrip for the desired artifact.
No action needed for the shown status of this block. For example, you do not need to build a MATLAB System or a Subsystem block, and on the status table, Build column shows this icon.
Build operation of the selected S-function block encountered an error. To resolve, check the S-function build report from the top right of the Build working area, or check your S-function code to resolve issues. See S-Function Related Artifacts for more details.
Add Tests to Blocks
To ensure that your custom blocks run seamlessly, you can add a test to your blocks. Blockset Designer gives you the capability to create a test harness automatically, or using you can bring in your own test suite.
To create a test model and a test suite automatically using Blockset Designer, click Create. Your test model opens automatically, investigate this model and verify that it matches your testing needs. Note that you can only create one test using Blockset Designer, but you can add many tests using test suite. To write your test, open the MATLAB® unit test file. This file is just a template for you create your test. If you are going to use the test harness the Blockset Designer created for you, make sure to uncomment the model file.
To bring in your own tests, browse and select your test model and click Apply. To bring your own test suite, browse to your test suite and click Apply.
To recreate a harness model, delete the contents of the Harness model and Test Suite and click Apply. Then, the Create button reappears.
Check Blocks Using Model Advisor
Use Model Advisor functionalities to do further checks on your blocks. To use Model Advisor, you must have a test harness model for your block. Access it from Check, select Model Advisor.You can create a test model automatically using the steps above, or you can browse and select your own harness model.
To learn more about Model Advisor checks, see Check Your Model Using the Model Advisor.
Run S-Function Checks
Use S-function Checks to analyze the quality of your S-functions. To use S-function checks, you must have a test harness model for your block. To run these checks, from Check, select Run S-Function Checks in Simulink® toolstrip. The checks generate an S-function check report for your S-function. To learn more about S-function checks, see Check S-Functions Using S-Function Analyzer APIs.
Document the Blocks
The Blockset Designer enables creating documentation for your custom blocks. To create documentation automatically, click Create in the Document part of the working area.
This creates a Live Editor file for you to write your documentation. After you complete your block documentation, save the Live Editor file. To produce an HTML file for your documentation, from the Simulink toolstrip, confirm that the Document check box is selected, and click Run.
S-Function Related Artifacts
In the steps above, you already learned how to create a new S-function block. Here you learn how to build an S-function in a Blockset Designer project.
Build S-Function Blocks
If you create your S-function as a new block:
Check the working area and observe that S-Function File and S-Function Build Script fields are already populated for your S-function.
To open the S-function code template, click Open next to the S-Function File. Write the code for your S-function and save your code. Close the MATLAB Editor.
To learn more about writing S-functions, see Implement C/C++ S-Functions. If you prefer to create a S-function automatically, see S-Function Builder.
Return to the Blockset Designer working area.
From the Blockset Designer toolstrip, confirm the Build check box is selected and click Run .
During the run, your S-function files are added to the project. A build report for your S-function that contains your S-function build status is generated. If you face any issues during build, check this report. You can reopen this report by clicking on the timestamp in the top right corner of Build section.
Return to the working area and observe that after build operation, an S-function MEX File is generated for this S-function block.
Build S-Function Builder Blocks
After creating an S-function Builder block, the S-Function Builder dialog window automatically opens from the library model. Write your code in the panes of the S-function Builder dialog window.
Click Build on the top-right of the S-function Builder dialog window. This will build your S-function, create all S-function artifacts, and communicate with the Blockset Designer.
Click Close to return to
Blockset Designerworking area.
When you are finished adding and building Blockset Designer artifacts, you are ready to publish your project as a toolbox and share. For more information, see Publish the Created Blockset.
S-Function | S-Function Builder | MATLAB System | Subsystem