Hint: Use square brackets for transition conditions [OK]
Common Mistakes:
Using parentheses instead of square brackets
Confusing braces or angle brackets with correct syntax
Omitting brackets entirely
3. Consider this Stateflow transition: [speed > 10] / count = count + 1; What happens when speed is 12 and count is 3?
medium
A. Transition does not occur and count stays 3
B. Transition occurs and count becomes 4
C. Transition occurs but count stays 3
D. Syntax error due to missing semicolon
Solution
Step 1: Check transition condition
Condition is speed > 10. Given speed = 12, condition is true, so transition occurs.
Step 2: Apply transition action
Action increments count by 1: count = 3 + 1 = 4.
Final Answer:
Transition occurs and count becomes 4 -> Option B
Quick Check:
Condition true + action increments count = 4 [OK]
Hint: Check condition first, then apply action on transition [OK]
Common Mistakes:
Ignoring the action and leaving count unchanged
Assuming transition does not occur when condition is true
Thinking semicolon causes syntax error in Stateflow
4. You wrote this transition in Stateflow: [temp > 50] count = count + 1; but the action does not execute. What is the error?
medium
A. Missing slash '/' before the action
B. Condition syntax is wrong
C. Count variable is not initialized
D. Semicolon should be outside brackets
Solution
Step 1: Review transition syntax
Transition actions must follow a slash '/' after the condition, e.g., [condition] / action.
Step 2: Identify missing slash
The given transition lacks '/', so action is not recognized or executed.
Final Answer:
Missing slash '/' before the action -> Option A
Quick Check:
Action requires '/' separator [OK]
Hint: Always put '/' before actions in transitions [OK]
Common Mistakes:
Forgetting the slash '/' before actions
Assuming condition syntax error without checking slash
Thinking variable initialization affects action execution here
5. You want a transition that only happens when pressure > 100 and increments alarmCount only once per transition. Which transition syntax is correct?
hard
A. [pressure > 100] alarmCount = alarmCount + 1;
B. / [pressure > 100] alarmCount = alarmCount + 1;
C. [pressure > 100] / alarmCount = alarmCount + 1;
D. [pressure > 100] / alarmCount += 1
Solution
Step 1: Confirm correct transition condition and action format
Condition must be in square brackets, followed by a slash '/', then the action ending with a semicolon.
Step 2: Evaluate each option
[pressure > 100] / alarmCount = alarmCount + 1; matches correct syntax: [condition] / action;. [pressure > 100] alarmCount = alarmCount + 1; misses '/', C has '/' before condition, D uses '+=' which is not standard in Stateflow.