03-07-2014 06:20 AM
Dear Norbert,
Give me some sample example.
I think we can use Statemachine without case structure. what you think?
http://www.ni.com/white-paper/7595/en/
BR,
Guru
03-07-2014 06:22 AM
03-07-2014 06:54 AM
Dear GerdW,
I think we can create statemachine also without case str. Please correct me if my undestanding is wrong.
BR,
Guru
03-07-2014 06:57 AM
03-07-2014 07:00 AM
@Munna232 wrote:
[...]Please correct me if my undestanding is wrong.
BR,
Guru
Guru,
please stand corrected.
You are mistaken with your assumption, that case structure only "selects between return value options". Gerd already pointed out that you select for functions you execute or skip.
Your code has no chance of skipping code execution, so it will always execute all code. This will waste performance in the best case, in the worst case it will kill your whole computer, maybe even damaging peripherals.
Excluding specific pieces of code dynamically is an essential part of every programming language. Without that option, most of todays applications would not exist.
There is, on the other hand, a technique of implementing state machines without case structures:
Dynamic calling VIs using VI server.
This approach, however, is heavily convoluted, wastes performance at a great deal and is way more complex than case structures.
Norbert
03-07-2014 07:46 AM
Dear Norbert,
Thank you so much for your valuable Information.
Yes, I will agree with you're point,
.................................................
Your code has no chance of skipping code execution, so it will always execute all code.
..................................................
Just I'm trying to get the information how much possibilities are there with LabVIEW for these kind of approaches.
For you're information, In simulink we are not using Switch case. Instead of this we are using Multiport Switch (like Se
lector). We never faced any issues.
BR,
Guru
03-07-2014 07:47 AM
03-07-2014 07:56 AM
Guru,
Although it is possible to code using any imaginable approach, does not make it the "right way". There is more to writing software than "making it work". Heck, anyone, given enough time can write something that will execute. Just as 1000 monkeys hitting a keyboard will write meaningful words... But do the words or (if you can call them ) sentences make any sense? Do they convey what the monkeys are thinking? I doubt it.
Writing software needs to be done in a manner that when yourself or someone else reads that code in the future, or needs to scale or maintain the code, that it is possible to do so.
Often, when dealing with badly written code, it takes more time to decypher the actual intent, or to modify code which is not scalable; than to write the code from scratch.
03-07-2014 08:00 AM
03-07-2014 08:03 AM
Dear GerdW,
I don't know relation b/w Simulink and LabVIEW VIs.Infact I don't know how they implemented simulink blocks in MATLAB.
Just we are using Slector kind of SW in Simulink block instead of Switch cases.
BR,
Guru