LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine enum decision

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.)

0 Kudos
Message 11 of 17
(734 Views)

good idea, thanks!

0 Kudos
Message 12 of 17
(733 Views)

Hi gregoryj,

 

       what change did you make in this attached pic?? I thought you are replaceing the array with queues.

 

       Thanks so much!!!!

0 Kudos
Message 13 of 17
(733 Views)

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.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 14 of 17
(718 Views)

@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.

0 Kudos
Message 15 of 17
(716 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 17
(708 Views)

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.

 

 

0 Kudos
Message 17 of 17
(702 Views)