12-04-2024 12:12 PM - edited 12-04-2024 12:13 PM
Hi,
I am not sure what am I missing. I wish to create an FGV that has multiple states (Initialize file, Write, Read Close OR Open, Read, Close). I can initialize a file as expected and it also creates a reference number and an actual file on the disk. But it errors out when attempting to write, read or close file.
Only time it works is if I do it all in one go, in linear manner.
Edit: Try this sequence Init>Run, Write>Run or Init>Run then Close>Run.
Please see the attached VI.I would appreciate if someone could point out my mistake. LabVIEW 2019 is used.
Solved! Go to Solution.
12-04-2024 03:24 PM
In your VI, you write nothing to the file, you had an empty array added to the shift register. I also got rid of the open state because you already open the file in the int state; in addtion it used the orginal file path, not the one that you checked. See if the attached gives you some clues, as it works for me.
12-04-2024 03:26 PM - edited 12-04-2024 03:36 PM
Thank you mcduff!
I will double check that.
Can you please save it for previous version 2019? I do not have LabVIEW 21.
Edit: Strange about no values in the array. Since I set some values as default and that is how I could verify that the linear approach worked and the other one with shift registers did not. I left open case for future to directly open a selected file, sorry about the confusion on that.
Curious to try your modified VI.
12-04-2024 03:43 PM - edited 12-04-2024 03:44 PM
EDIT: I made a pseudo state machine of your loop for testing, you can change back to a FGV.
12-04-2024 04:11 PM - edited 12-04-2024 04:23 PM
Hi mcduff,
I see what what you pointed out in the "Open" case. Apologies for that, I was skipping over that case when testing but it added confusion. I left it delete untouched now too this time after your modification.
What you gave me works. I changed it to an FGV and it gave error 2501. It is almost seeming like the moment VI stops, something goes wrong with the reference. If I probe reference wire, I can still see the correct reference number created by the first run (init), up until it goes into Write TDMS Vi in the second run (Write) but right after that it becomes 0.
What I did:
1) Select enum to init and run the VI (no error)
2) Select enum to Write and run the VI (Error -2501).
Can you please check one more time to see if this issue gets re-created for you?
12-04-2024 04:25 PM - edited 12-04-2024 04:31 PM
Because you are stopping and starting the VI some of the shift registers are going to default values.
Try the attached and see if it works for you. The FGV should keep its values while active, once it stops all bets are off.
EDIT: Your reference is the problem, LabVIEW closes open references when a VI finishes, so the value doesn't stay on the wire.
12-04-2024 04:39 PM
I believe I understand it now. If have a main VI in which this FGV is called (Ran and Stopped but still in the memory), the references will stay alive as long as the main, caller VI is running.
For some reason this is the first time I am experiencing something like this. Typically, for me values stayed alive even if the FGV was called on its own. But that may have mostly been for simple value (strings, number etc) and not the references. I mostly called those reference based FGVs while their main VI was running but never realized it.
This hurts my brain a little. But thank you so much for patiently bringing me to this point.
12-04-2024 04:50 PM
I think you got it. References can go bad if the Top-Caller goes idle.
12-05-2024 04:29 AM
12-05-2024 09:16 AM
@rolfk wrote:
@mcduff wrote:
I think you got it. References can go bad if the Top-Caller goes idle.
Actually CAN is a little weak in this context. It WILL get closed anytime the top level VI, in whose hierarchy that reference was created, goes idle.
True. But I thought if I used stronger language someone would chime in with a static reference example. 🙂