02-05-2016 12:50 PM
You mention, "There is huge amounts of duplicate code that can be consolidated into one. (e.g. many case structure only differ by a diagram constant. Correclty written that program would comfortably fit on a single screen." How would I consolidate the code into one?
02-08-2016 11:07 AM
Hi djnbae,
As for getting started with state machines, LabVIEW comes with many examples that can help you getting started. The state machine example can be access from Help -> Find examples… -> search for “State Machine Fundamentals.”
Case structures don’t have to take Boolean values as inputs. Sometimes, it is better to give an integer input for many different cases. Think of it as the “if…else if… else” conditional statement.
Here are a few links on the things I talked about:
State Machine: http://www.ni.com/tutorial/7595/en/
Case Structure: http://www.ni.com/white-paper/7592/en/
Core 1 Training: http://sine.ni.com/tacs/app/overview/p/ap/of/lang/en/pg/1/sn/n24:12725/id/1582/
Like mentioned in the thread, I do recommend LabVIEW training like Core 1 and 2. Both teach best programming practices in LabVIEW and design patterns.
02-08-2016 12:06 PM
Hi RenKylo2,
Thank you for your comments. I have taken Core 1 online and am in the process of taking Core 2 online. I think I understand what you are saying about case structures, however don't understand where a state machine would fit in. Could you please suggest where or how I should use a state machine?
02-09-2016 09:58 AM
Hi djnbae,
Glad I was able to help.
State machines are very useful when you are trying to break the sequence of process flows. Say we have process A, B, C and D, which they run in the alphabetical order. However, there are also scenarios when we want to run C before B due to various reasons, such as user inputs. That is something like a flat sequence structure cannot achieve. It is also possible that we want to add another process, say B1, in between B and C. By using state machines, it makes adding another process easier.
State machines are great, but you don’t have to use them. If your application does not have the distinguishable processes or states, feel free to leave them out.