when I generate code from a state diagram in C++, activities in states and transitions are automatically related to the class the state diagram belongs to.
For example the activity doSomething(); gets ctxt.doSomething(); in the C++ code.
When I define a guard for a transition, it is just taken literally into the code. So I have to write ctxt.testCondition() in the diagram to get functioning code.
Thanks for replying. I cannot fin any demo project in this post nor my email. Would you mind to attach your demo project (or send it to lilian@visual-paradigm.com )? Thanks in advance!
Thanks for sending the project file and generated code to my email address. But I can find the code in your code file “TestClass_sm.cpp” (please refer to attached image).
that’s what I tried to explain: the activity is called as ctxt.doSomething(), but the guard is called without the ctxt in front. Since there is no method isConditionTrue() in the TestClassFSM the compiler refuses to compile this code.
The only way around this seems to be to write ctxt.isConditionTrue() in the model, which introduces implementation details from the state machine compiler into the model.
Thanks for replying and I’m sorry for my misunderstanding. I’ve forwarded the issue to our engineers to follow-up. If there is any feedback, I’ll come back to you immediately.
Despite it usually starts with ctxt, but it’s not necessary. If we generate ctxt, users cannot remove it from the code. Please add validate code if you need.