> I usually do the following:
> All profiles that could potentially conflict start the same task, called "Event Handling", which then checks for active profiles (%PACTIVE) and acts accordingly.
> Using the IF/ELSE IF statements, and adding some time counter to avoid repetitive calls, it's easy to make it prioritize actions (actions further up in the IF list will have a higher priority than those down).
That is how I handle it As well and it seems to work great. Dave fisher has a slightly different approach you might want to check out in the link below. You will notice in my example I set variables for my toggles but I have since switched to %PACTIVE as it is a far better approach.
Rich....
Always helps to include the link... :)
One of these days i will figure out how to make those links renamed into a cool one word link......
Rich...
Yes, you definitely need to think of all the states and transitions so that you don't get stranded...but I've done lots of firmware development where this is common practice. Also, some of my transitions are set up this way:
* state = car + BT not connected -> new state = left car
* state changed = left car + location work -> new state = work
This way, the "left car" state can still have meaningful settings and transitions, and I can do power wasting location operations, knowing that they will only run once.
Also, it's easy to do stuff like state = car + last state = work + time 1600-1800 -> navigate to home so I can see traffic.
> I've already implemented my state transitions, and the next step will be to change all of my profiles which actually change settings to make use of the new state.
>
> Any thoughts?
The one problem I found with letting different profiles change settings with multiple tasks was as baudi mentioned when they try to run at the same time. If one task is in the middle of changing settings and another profile becomes active then you need to anticipate this and try to control it with priorities or wait untill , and it just gets very complicated. Everything got much less complex when i had only one task allowed to change settings.
Because profiles become active instantly when there contexts are met no matter what task is running when my settings task is flowing through the logic steps, using the %PACTVE it can make choices based on what contexts are met at that exact point in time and not rely on a task to set a variable that could be interrupted by another task with a higher priority. (I hope that makes sense)
The way I control the settings task is simply when a profile becomes active like 'Home' it will first do a wait until %TRUN not match 'settings ' to make sure it waits its turn then a perform task 'settings' and pass the profile name 'Home' through %par1 so 'settings' knows which profile would like to change the settings.
I could be totally missing the bigger picture of the way your state variables will work and would be very interested in how it works out, please let us know....
Just thought I would add my two cents... Rich....
I don't mind at all, but let me get together some screen shots and profile exports for you.