10-03-2022 03:16 AM
Thank you all for the replies. Your questions also helped me formulate my problem a bit better.
Basically the "Home position", "Remove Sample" and "Load Sample" are all commands that contain several "Move Stepper" commands. These commands, together with "Set temperature" will be used during actual operation of the machine. The "Move Stepper" commands are usually only used to calibrate it and ideally would never be used together with high priority commands. So the actual priority order would be Home position, Remove Sample, Load Sample, Set Temperature and then priority for Move stepper commands doesn't really matter.
The priority comes in only once per cycle, eg.: if machine is busy executing a command and user selects several commands during that time, they should be executed in order of priority. So the whole queue doesn't need to be ordered, only one cycle of commands.
For Example if user selects Move Stepper 2, Load Sample and Home position commands (in that order):
User Ordered by priority Queue
Move Stepper 2 Home position Home position
Load Sample Load Sample Remove Sample
Home Position Move Stepper 2 Home position
Set temperature
New Queue
Home position
Remove Sample
Home position
Set temperature
Home Position
Load Sample
Move Stepper 2
Again, ideally only one command would be in the queue at a time, but i'm trying to do a bit of safety if several commands do end up in the queue.
@altenbach wrote:There are some basic convolutions aready visible in the above code. For example you can replace the index array with autoindexing and remove the 8 on N.
Can you explain how the commands are triggered? Are these controls (LEDs are typically indicators)?
How many levels of "priorities" are there? What if there are several high priority commands?
All you probably need is enqueue at the front for certain commands.
I left the 8 on N and disabled autoindexing so i knew which command came at the dequeue. The VI i provided was just a quick demonstration of my problem, so the LEDs as controls were just an error on my part.