LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read config file at the same time

Hi All,

 

I and have a reentrant vi, reading a config file, my question is:

 

it is possible to cause problem if we read the same config file at the same time? 

 

and what is reason behind it?

 

also attached my code

read config.png

 

 

0 Kudos
Message 1 of 5
(3,125 Views)

The sub-VI that you attached to read the Config file is not re-entrant, so if two re-entrant routines call this sub-VI at the same time, the (single) sub-VI will run, open the Config file, read it, close the file, and exit, at which time the second calling VI's call will cause this sub-VI to run again and repeat the actions.  No problem.

 

 

Bob Schor

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

Does a snippet include VI properties?  I'd be a bit surprised if it did.  If so, Bob is right.

 

If not, I suspect it goes to the default and you have taken the time to set it re-entrant on your end.  I'm not aware of any issues with multiple reads taking place.  Problems show up when you try to edit that file while it's open elsewhere. 

 

If you're worried, the execution time of that VI is minimal.  Set it to non-reentrant and the worst case scenario is the second place trying to read it is delayed by that minimal amount.

0 Kudos
Message 3 of 5
(3,095 Views)

@natasftw wrote:

Does a snippet include VI properties?  I'd be a bit surprised if it did.  If so, Bob is right.

 

 


And if it doesn't include VI Properties, Bob is Wrong!  It never occurred to me, I'm sorry to say, to test this, but saving a "Clone" (a VI with Pre-Allocated, Re-entrant Execution set) as a Snippet and pasting it into a blank VI returns Non-Reentrant.

 

Sorry about that.  But I agree that this particular VI does not need to be (and possibly shouldn't be) reentrant.

 

Bob Schor

 

P.S. -- if the Config file is big, and you want to really speed things up, read the entire file in once, save all the settings in a Big Cluster, then simply index them out of the Cluster.  I've done something similar to this with a LabVIEW RT routine -- I don't have a Configuration File, per se, but I'm getting "trial settings" from the columns of an Excel Worksheet, one row per trial and about 160 columns of specs.

 

Bob Schor

0 Kudos
Message 4 of 5
(3,083 Views)

What I would do is open the config file reference and pass it into your reentrant VI.  Then everybody has the same reference and can get the data without opening multiple references to the same file.

 

The above solution is assuming all of the reentrant calls are in the same location (like with a parallel FOR loop or Asynchround Call By Reference in a FOR loop).  If that is not an option, then I would probably resort to either using an Action Engine for the config file (the AE keeps the reference for the config file and everybody can use it to get the desired data) or just read the file at the start and save all of the data in a Current Value Table (CVT, very useful library) or global variable(s).


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 5 of 5
(3,024 Views)