www.gusucode.com > ecoder 案例源码程序 matlab代码 > ecoder/TraceGeneratedCodeToBlocksExample.m
%% Trace Generated Code to Blocks % Navigate and trace between generated code and its source model for % validation. %% Open Example Model % Open the example |rtwdemo_hyperlinks|. model='rtwdemo_hyperlinks'; open_system(model) %% Code to Model Navigation % Navigate from the code to the model. % % # Open the *Code Generation > Report* pane of the Configuration Parameters % dialog box. % # Verify the following parameters are selected: *Create code generation % report* and *Open report automatically*. % # Switch to the *All Parameters* tab and verify parameter *Code-to-model* % is selected. % # In the model editor window, press *Ctrl+B* to generate code. When code % generation is complete, the software displays a code generation report % with hyperlinks. % # In the generated report, click the |rtwdemo_hyperlinks.c| link to see % the code with embedded hyperlinks. % # Click links in the code to trace generated code segments to the % highlighted elements in the model. For example, if you click the % hyperlink |<Root>/Sum|, the Sum block in the model is % highlighted. % %% Model to Code Navigation % Navigate from the model to the code. % % # Open the *Code Generation > Report* pane of the Configuration % Parameters dialog box. % # Verify the following parameters are selected: *Create code generation % report* and *Open report automatically*. % # Switch to the *All Parameters* tab and verify parameter *Model-to-code* is % selected. % # In the model editor window, press *Ctrl+B* to generate code. When code % generation is complete, the software displays a code generation report % with hyperlinks. % # In the model window, right-click any block and select *Code Generation % > Navigate to Code*. The software highlights the generated code for this % block in the code generation report. % # Inspect the highlighted lines in the code generation report. The total % number of highlighted lines is displayed next to each source file name in % the left pane of the report. Use the *Previous* and *Next* buttons to % navigate through the highlighted lines. % % Note: *Model-to-code* navigation also works for Stateflow objects and % *MATLAB* functions. % % Note: The report displays a diagnostic message if there is no code to % highlight for the selected block (for example, if you select a virtual % block). %% Traceability Report % Generate and inspect the *Traceability Report*. % % # Open the *Code Generation > Report* of the Configuration Parameters % dialog box. % # Verify the following parameters are selected: *Create code generation % report* and *Open report automatically*. % # Switch to the *All Parameters* tab and find the traceability report % parameters using keyword |GenerateTraceReport|. Verify all the listed % parameters are selected. % # In the model editor window, press *Ctrl+B* to generate code. When code % generation is complete, the software displays a code generation report % with hyperlinks. % # To see a report of the untraceable (not in the generated code) and % traceable blocks in your model, on the left pane of the generated report % click *Traceability Report*. % # In the *Traceability Report*, inspect the *Eliminited / Virtual Blocks* % and *Traceable Blocks* lists. For example, the *Scope* block is an % untraceable block. It is listed under *Eliminated / Virtual Blocks* % because the code generator does not create code for this block. % % Copyright 2007-2015 The MathWorks, Inc.