Implementing Analysis Modules
- Updated2025-07-23
- 3 minute(s) read
The sequence analyzer passes an AnalysisContext object to the analysis module. After calling a VI, the sequence analyzer checks the Error Out cluster output and reports an Internal Error analysis message if the status indicates that an error occurred. After calling a .NET method, the sequence reports an Internal Error analysis message if the method returns False. After calling a DLL function, the sequence analyzer checks the return value and reports an Internal Error analysis message if the bool value is False or if the int value is not 0. The Analysis Results pane in the TestStand Sequence Editor and the Messages tab in the stand-alone sequence analyzer application include the error message the analysis module returns for the most recent analysis of the current project.
Analysis modules use the AnalysisContext properties and methods to analyze individual objects. The sequence analyzer does not maintain or recognize any relationships between analysis modules and rules. The sequence analyzer calls all analysis modules regardless of which rules are disabled, but the sequence analyzer discards messages reported for disabled rules. To improve performance when a rule is disabled, ensure that an analysis module first checks if the rule is enabled before performing any analysis. Pass the rule ID to the AnalysisContext.GetRuleConfiguration method to get the RuleConfiguration for the rule and check the RuleConfiguration.Enabled property. Pass the rule ID to the AnalysisContext.NewMessage method to create a new message for the rule, and call the AnalysisContext.ReportMessage method to report the message to the sequence analyzer. Use the AnalysisContext.File and AnalysisContext.Object properties to get the analyzed file and object.
The sequence analyzer calls an analysis module only for the kinds of objects you specify in the Edit Analysis Module dialog box. Each time the sequence analyzer makes a transition between analyzing one type of object to analyzing a different type of object, it calls analysis modules configured to be called for that type of transition. If you specify analysis transitions in the Edit Analysis Module dialog box, the sequence analyzer calls the analysis module at those transitions. Use the AnalysisContext.Transition property to determine which transition is in effect.
Use the AnalysisContext.GetRuleAnalysisData method to get an empty PropertyObject container to which you add subproperties to store data associated with a rule during the current analysis session. You must use the GetRuleAnalysisDataOption_Lock option if the analysis module modifies the data.
If you use global variables during analysis, use the following techniques to help ensure data integrity:
- Use locks to protect access to the global data by preventing the sequence analyzer from calling analysis modules from multiple threads at the same time.
- Use the AnalysisContext.AnalysisId property to get a unique identifier for the current analysis session that you can use to index into a global table to avoid interference between simultaneous analysis sessions.
- Use the AnalysisTransition_BeforeSystem and AnalysisTransition_AfterSystem transitions to initialize and clean up global data.
When you stop the analysis before it completes, the sequence analyzer waits for the currently executing analysis module to complete. If the sequence analyzer has called any analysis modules for any Before analysis transitions, the sequence analyzer calls the same analysis modules for the corresponding After analysis transitions. Analysis modules generally should not report messages after you stop analysis. If the analysis module reports messages during the After analysis transitions, check the AnalysisContext.StopRequested property to determine whether users stopped the analysis so you can avoid reporting the messages.
Use the AnalysisContext.Utilities property to access the AnalysisUtilities methods, which perform common types of checks, such as validating expressions, paths, and remote hosts, or enabling automatic property checking. The built-in analysis modules perform some of these checks on all instances of certain types, such as validating expressions and paths. To disable the built-in checking for subproperties of certain objects for a custom rule, set the AnalysisUtilities.AutomaticPropertyCheckingEnabled property to False in the custom analysis module the sequence analyzer calls for those objects. For instance, to disable automatic checking of subproperties of a step type that you implemented, set the AnalysisUtilities.AutomaticPropertyCheckingEnabled property to False in the custom analysis module the sequence analyzer calls for instances of the custom step type.