10-23-2018 12:38 PM
There's some strange things going on there.
First they initialize an array of 10 "idle"'s, then they proceed to "insert" another "Idle" at the beginning.
When they need to add another state, they are again "insert" at the beginning of the array. It would be much simpler if they just used Build Array. But then they wind up using delete from array that takes the item at the beginning of the array. So they are basically only working with the top item of the array. It is more of a stack arrangement rather than a queue arrangement, but I don't see enough code to know whether they ever get to the 2nd, 3rd, 4th, .... items in the array.
Using Queues are easier in that LabVIEW can do more of the work in queuing up the stats and keeping them in order. Arrays require you to manage that manipulation yourself. However arrays will allow you to more easily manipulate the array deleting middle, elements, or rearranging. But if your architecture requires you to do all of that, you probably have too complicated of a logic flow going on and should consider rewriting your code.
With queues or arrays, you need to keep an eye out for situations where you might build up a queue with extra states that you might never get to. (Dequeue one item, but enqueue 2 new things, you may never get through all your actions.)
10-23-2018 12:41 PM
good idea, thanks!
10-23-2018 12:42 PM
Hi gregoryj,
what change did you make in this attached pic?? I thought you are replaceing the array with queues.
Thanks so much!!!!
10-23-2018 01:52 PM
IMHO - if you're having trouble understanding an example, it is saying that maybe that approach isn't right for you. I think you should code to your strengths, not someone else's. If you've developed good LabVIEW practices, your code will stand up to NI scrutiny. 🙂
10-23-2018 01:54 PM
@idjuven1 wrote:
Hi gregoryj,
what change did you make in this attached pic?? I thought you are replaceing the array with queues.
Thanks so much!!!!
No, I didn't make any changes. Just wanted to post a picture, in case someone didn't want to open up the .zip file or is looking on their phone. But posting at least the code is the right thing to do, because when people only post pictures it often doesn't tell enough to get accurate help.
10-23-2018 02:20 PM
@RavensFan wrote: First they initialize an array of 10 "idle"'s, then they proceed to "insert" another "Idle" at the beginning.
Insert Into Array defaults to adding an element at the end of the array. So it is actually behaving like a queue, just a lot less efficient and more confusing.
10-23-2018 02:45 PM
This is like deja vu. I think I had a recent thread where I made the same mistake.
Because the index input is unwired, and defaults to 0 if you right click and create a constant, I assume it inserts the element at index 0.
Which is one of the reasons it is that much more confusing.