LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

action engine/array question

Solved!
Go to solution

Hi, I'm trying to implement an Action Engine in a project I'm working on.  One of the actions is for it to act as a global variable of an array.  I stripped away all the other functions except the ones giving me trouble.  I am able to initialize the array, and write to the array, but when I try to read the values back from the AE it gives me an array with nothing in it.  I've tried using the AE to write and read in series and parallel, but I get the same result. 

 

This seems like the most basic and simple implementation of an AE and I don't know what my issue is here.  Anyone see anything?

 

Thanks,

 

gintree

 

Simple AE.pngAE Test - Series.pngAE Test - Parallel.png 

0 Kudos
Message 1 of 5
(2,804 Views)
Solution
Accepted by topic author gintree78

Hi, Gintree. 

 

When I first looked at your post and the code that I could see, I thought I saw the problem in the Parallel version ("Which comes first, the Read or the Write"), but then I actually downloaded the code and tried it and found a Surprise + the Problem (so thank you for posting the Code -- without it, we would have no clue).

 

The problem is that you are Too Clever.  The Action Engine only needs 2 States, Write and Read (it will be naturally initialized with an empty Array).  As it stands, it can accept an I32 array of any size (which is a Good Thing, I think).

 

But that's not the problem.  When you first coded it, you probably did "New VI", then wrote the code.  And it would have worked!  But then you made it a Pre-allocated Reentrant VI, and disabled Debugging (so you couldn't easily see the problem happening before your eyes).  Action Engines depend on preserving "State", so if you call it three times and it is reentrant, you'll have three separate VIs, one of which you Initialize, one of which you Write, and one of which you Read.  In particular, the one you Read will come up with an empty Array, which is its Default State!

 

Try simply removing Reentrancy and see how it runs.  I also recommend removing the unnecessary Initialize State, and leaving just Read and Write.

 

Bob Schor

Message 2 of 5
(2,787 Views)

THANK YOU SO MUCH!!! I kinda remember messing around with reentrancy when I first implemented this on an older version, but completely forgot.  

0 Kudos
Message 3 of 5
(2,782 Views)

I have to state that if all you have is a "Set" and a "Get" state to your AE, you might as well use a Global Variable.  They are faster and simpler.

A Look At Race Conditions

Are Global Variables Truly Evil?


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 4 of 5
(2,778 Views)

Agreed crossrulz, however this is just a stripped down version of my AE so I could highlight this issue I was having.  I actually do perform some actions in other states besides just storing data.

 

Thanks,

 

gintree

0 Kudos
Message 5 of 5
(2,774 Views)