Interactive Message - Gear change
vinicius oliveira 4 years ago in IQANdesign • updated 4 years ago • 4
I'm trying to implement gear change using buttons (D, R and N). When the user press the button, it will ask for confirmation to prevent miss click, if "Yes" it will send CAN message and active gear, if "No" do nothing.
I implemented this latch to hold the value of D, R and N gear (if true or false after interactive message).
But the thing is, I want to keep only one gear active at a time, for example D=True,R=False and N=False. How I can manage to turn off other variables inside Qcode?
Customer support service by UserEcho
You could try using a state machine to ensure you only have one gear condition active at the same time.
As Nick mention, State machines are powerful in this type of function. Its a good and easy way to have correct selection through out the program. The tricky part is the nature of IMSG. It will hold the last action even if the popup is hidden from screen. To reset the value a Hiding must be activated in the IMSG. I made a small example for you, you can see that I'm using Positive and Negative flanks to trigger on Gear change and resetting IMSG channels.
And I always say, if the expression is simple then keep it as Object List!
Consider using a finite state machine. Also it's worth exploring if you need in-between states ('D to N' or 'N to R'). They might make it easier to link to messages. The button triggers the in-between state. Depending on the output of the IMSG, you go to the next or the previous state.
What I like about the FSM is that you cannot create a situation where you are in multiple states at the same time, something you really want to prevent here.
Hope this helps ;)
Thanks so much for the tips.
I did use Finite State Machine and I solved the problem. I'm not sure if it's the best approach, but for now is good.