Using History with Submachines does not work
Real-Time Event Frameworks based on active objects & state machines
Brought to you by:
quantum-leaps
I'm trying to create a History in QM that points to a submachine. While QM allows that just fine (see image attached), it's when I compile that things go pear-shaped.
The submachine is called "bluetooth_2_0" and is of type "bluetooth". The error message I get is this:
error: cannot convert 'const AOUi::AOUi::SM_bluetooth*' to 'const QP::QMState*' in assignment
I circumvented the problem by slightly changing the source file:
// state history attributes
hist_app = &bluetooth_2_0_s.super; // <<<--- was &bluetooth_2_0_s;
This way, it will compile. Naturally, this change will be lost when we rebuild the source from withing QM.
It does seem to work, though. Not sure if what I'm doing was ever intended, but since QM allows it, I assumed it would work. Hence this report.
Happy to provide more details.
Anonymous
Hi Sander,
Thank you for reporting. I was able to reproduce the compilation problem.
I'm not sure how to prioritize this bug. This seems to be a little esoteric use of history and sub-machine states.
The change to add
.superin the initialization of the history attribute seems to be working (both compiling and running the app). Are you sure that it does not work for you?The bug will be assigned to the next QM release.
--MMS
Last edit: Quantum Leaps 2022-12-13
Thanks for your response! I agree with you it is rather esoteric. :)
The change to add
.superto the initialisation of the history attribute did work indeed, but it is overwritten when the model is regenerated. Unless I missed something? (Maybe my explanation wasn't as clear as I'd hoped.)Thanks again,
Sander
Yes, I agree. QM generates incorrect code in this special case, so yes, any manual changes in the generated code will be obviously overwritten.
But at least it is clear how to fix the bug (by adding
.superin case of a sub-machine state). The code without.superis for regular states.--MMS
Fixed in QM 5.2.4 and QP/C/C++ 7.2.0. (Both are needed for the fix).
--MMS