03-03-2018 06:17 PM - edited 03-03-2018 06:20 PM
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
Solved! Go to Solution.
03-03-2018 06:56 PM
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
03-03-2018 07:07 PM
THANK YOU SO MUCH!!! I kinda remember messing around with reentrancy when I first implemented this on an older version, but completely forgot.
03-03-2018 07:11 PM
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.
Are Global Variables Truly Evil?
03-03-2018 07:16 PM
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