R12.1 Project Publication-2025Dec23

Control Logic Blocks

You can use the following different logic blocks to control which actions are executed to diagnose the intented issue.

If-then

If-then logic is used to perform different actions based on whether a condition is true or false. If the condition is not met, it can be combined with Else or ElseIf to execute alternative actions.

Example: You can use If-then logic to check whether the ASA failover status is changed.

  1. In an intent, click Add If-then to add this logic block, and set the condition as If failover_state (Current) Dose not equal to failover_state (Last).
  2. Add an action called Diagnosis Message and define its content.
  3. Execute this intent. If the specified condition is true, the content of the defined message will be output.

Loop

Loop logic allows you to repeatedly execute the included logic blocks or actions until a specific condition is met.

Example: Loop an ADT that defines an ACL compliance rule to check whether the current device's ACL configuration matches the rule.

  1. Define ACL compliance rules in the ADT 'ACL_Compliance_Rule'.
  2. Use loop logic to iterate through multiple devices.
  3. Automatically check whether each device's ACL complies with the defined rules.

Switch-case

NI also supports the switch-case logic, which can serve as a simplified version of ‘if-then-else’, and offer a more concise expression, better performance, and a reduced likelihood of errors.

When you need to execute different code blocks based on multiple possible values of a single variable, switch-case logic can make the code simpler and more readable.
A screenshot of a computer

Description automatically generated

For the ‘switch-case’ statement:

  • The variable type of the ‘switch-case’ can only be int, float, or string.
  • It can contain multiple case branches, 0 or 1 default branch. If there is a default branch, it can only be placed at the end.
  • ‘Case’ can only be followed by a constant, and its type must be consistent with the switch variable type. It cannot be a variable or an expression.
  • All cases will be analyzed in turn to find the matching ones. If a case branch matches, the diagnosis logic in this branch will be executed. If no case branches match, the diagnosis logic in the default branch will be executed.

See also: