11-01-2016 06:15 AM - edited 11-01-2016 06:33 AM
I am trying to create a vi which represents the insertion of data into a database from 38 generators. Each generator has 22 variables.
As there will be 836 variables in the code, I am looking for ways to collect the variables to make the code more readable. I created a sub-vi containing 22 control variables for a generator. I plan to use this vi as the case for all 38 generators so I changed the settings to a preallocated clone re entrant vi to allow multiple executions in parallel.
When I insert the sub-vi into the main VI the the variables show up as a sink rather than source? But they are set as controls in the sub-vi. How do I make this work? Is it possible to collect the variables in this way or is it better to use a cluster?
Solved! Go to Solution.
11-01-2016 06:47 AM
Look at a functional global variable or action engine.
You may also want to look at Current Value Table you can find here Current Value Table (CVT) which is intended for situations such as yours.
11-01-2016 07:40 AM
Well, your code certainly isn't readable (by us) now. If you post your code (as a VI -- no pictures, please), we can comment on its readability and make suggestions appropriate to your level of expertise.
Bob Schor
11-01-2016 09:37 AM - edited 11-01-2016 09:40 AM
Hi Bob,
Attached is my current vi. I clustered 22 variables for each generator (38 in total) and in case use a sub-vi which formats the values into a string ready to insert into the database. I am working with PostgreSQL 9.6.
I'm sure there's a better way of doing it, but this is all I've come up with so far.
Thanks for your time.
Lisa
11-01-2016 09:39 AM
Thanks I will look into it!
11-01-2016 11:37 AM
Make an Array of generators and loop it in parallell, it'll clean up the code a lot.
/Y
11-01-2016 11:54 AM
Thanks for your suggestion. When you say make an array of the generators, list the values for all 38 generators in the array to begin with? or to convert from the cluster? I'd like to have controls so i can change the values and know what variable they refer to. Also with the loop- if it's in parallel this would require 38 separate loops?
11-01-2016 11:57 AM
Thanks for your suggestion. When you say make an array of the generators, list the values for all 38 generators in the array to begin with? or to convert from the cluster? I'd like to have controls so i can change the values and know what variable they refer to. Also if in parallel, would this require 38 separate loops?
Lisa
11-01-2016 12:27 PM
Thank you for posting your code. I agree with Yamaeda that an array of Clusters would be much simpler. I also think I see where the Control/Indicator confusion might arise.
So some basic questions.
Bob Schor
11-02-2016 04:37 AM - edited 11-02-2016 05:04 AM
Bob thank you so much for your detailed help.
Thanks again, your assistance is much appreciated!
Lisa