07-22-2014 04:38 PM
murchak wrote:Is putting all the constant controls in one cluster an incorrect use of a cluster?
I could be shot here for what I am about so say. This sounds like a good use case for a Global Variable
...yes, I already feel the guns cocked and loaded, pointed at me, with fingers starting to pull the triggers...
Here me out here. Global Variables are excellent ways to hold CONSTANTS that you will need everywhere in your code. Notice that capitalized word. CONSTANTS. This means that you are not changing the values. They are set. But you can just get the value by calling the global. It is quick and very efficient. What I like to do with my globals is read the settings from a configuration file as soon as the program starts and put those values in the global. From then on out, they are constants.
And for those who are still about to finish squeezing that trigger: Constant = no race condition
07-22-2014 04:55 PM
Thanks. Below is the code architecture that I have:
A few questions:
1. Just for the learning purpose, I put my "format the table" state as State 2 which is where I format the entries of the tabe (for example, negative values would show as red). Do I feed
the output of State 1 (table) into State 2 via a shift register?
2. If my Cluster of properties is constant, does it make sense to keep it ouside of the While Loop, like I have shown below?
3. Finally, I have been learning about State Machines and everyone would argue in favor or using it. But if the purpose of the code is to execute all 4 states, irrespective of the outcome
in the previous states (no decision), why would State Machine be good to use aside from keeping the BD compact and maybe code readability?
To make my point lucid, my code must create the table, format it, then make different plots. Period. This task must be done whenever the user runs the code and select data files.
In this case, what is special about using State Machines? Not arguing against it, but merely trying to understand its usefullness here.
4. Finally, anything you would change about the diagram below?
07-22-2014 05:01 PM
A Global would require a code change, Why not Just use a file for constants? If the file is in xml or a csv format the constant value could be changed with notepad or any simple text editor. I think you should use clusters but the data in the cluster should relate to each To be logically grouped. Do not have one big cluster so there is only wire in your block diagram.. This could slow your program because labview would not be able to parallel process data but would follow the wire path through your code through each sub vi.
07-22-2014 05:05 PM
Good, we are getting to the crux of the problem. So if I put my constants (color boxes, color arrays, etc.) I would then have to convert those quantities to
some kind of string representation. Then everytime I use the file, I have to open it and convert back to color type, and so on. Wouldn't that really add more code
to my already bulky BD?
07-22-2014 05:17 PM
07-22-2014 05:19 PM
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-22-2014 05:21 PM
murchak wrote:
:
1. Just for the learning purpose, I put my "format the table" state as State 2 which is where I format the entries of the tabe (for example, negative values would show as red). Do I feed
the output of State 1 (table) into State 2 via a shift register?
2. If my Cluster of properties is constant, does it make sense to keep it ouside of the While Loop, like I have shown below?
3. Finally, I have been learning about State Machines and everyone would argue in favor or using it. But if the purpose of the code is to execute all 4 states, irrespective of the outcome
in the previous states (no decision), why would State Machine be good to use aside from keeping the BD compact and maybe code readability?
2. Yep.
1 & 3. I've been known to make a VI for each step of what you have in your state machine and then just sequence the VIs. Yes, this work quite well. That is until something gets changed and you have to reorganize your sequence. That is when you will be happy you have a state machine. It is a lot easier to just change the case you go to or an array constant (FOR loops work well in this instance) than to have to delete wires move VIs around and rewire. And anything that can be passed from one state to the next should be put in a shift register.
07-22-2014 05:23 PM
This is what I was reading when you mentioned ini file:
http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/creating_configuration_files/
Seems like more work just to read a color constant. My aim is to make the code simpler. I'll continue reading to better understand it.
07-22-2014 05:28 PM
There are no free lunches with a computer. It does exactly what you tell it to do.your Program initialization does not have to be bulky. Use a sub vi to initialize your clusters at start up. At shutdown a sub vi to save those clusters when you close your program. Evan a simple program should have 3 parts - Startup/Initialize , Logic Execution/Error Handler and Exit/Shutdown.
07-22-2014 05:31 PM