I am using Rhapsody in C 7.6.1
When I generate code for a statechart, i see that the statechart is implemented using switch case. This is absolutely fine.
At the end of switch case, there is a "default:" case, for which no code is generated.
Where should i mention the code in statechart so that it is generated in the "default:" case of the generated code?
Pinned topic Code for default: in a statechart
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-02-14T11:10:08Z at 2013-02-14T11:10:08Z by shanz9903
Yevo 270002F6T8285 Posts
Re: Code for default: in a statechart2013-02-12T11:43:11ZThis is the accepted answer. This is the accepted answer.You should not. The default case is used to meet coding standards like MISRA. Also, if ,e.g., statechart receives an event, which it doesn't process, then the defaut case is used to ignore it. Probably, more situations are possible, when Default (empty) case is needed.
SystemAdmin 110000D4XK1305 Posts
Re: Code for default: in a statechart2013-02-13T08:42:38ZThis is the accepted answer. This is the accepted answer.
- Yevo 270002F6T8
ok but consider this scenario.
Say I have a statechart with say 5 states named state_1, state_2, ... ,state_5.
Depending on a certain input i go to one of these states. Now if I get an invalid input, then I want my system to go to say state_2.
This can only be done by default: case right? How else can i do it? So i need to generate code for default:
shanz9903 270003S6R4315 Posts
Re: Code for default: in a statechart2013-02-14T11:10:08ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
Then the event can trigger a transition into state_2 from the superstate - ie: irrespective of the status in the inner states.