LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Diagram inside For Loop

I created a fairly involved for-loop with a flat sequence inside of it.  The sequence had about four events that occured, and since it was kind of ugly, I thought I'd try the State Diagram Toolkit to replace the majority of the code.  When I selected state diagram from the pallete, I was outside my for-loop.  I drew up the various states/transitions, then realized that all this code needed to be inside the for-loop, but LV won't let me place state diagram-generated code inside the for-loop.  I select everything related to the state diagram, but when I drag into the for-loop, only the comments come inside.  I even tried generating a new for-loop and placing the state code inside.  No luck. Any thoughts?
0 Kudos
Message 1 of 4
(2,910 Views)

If you try to create a new 'for'Loop around your State diagram Structure, 'I guess' it should be possible ( go to functuions tools, select a for Loop and draw it around/encapsulate your state diagram)

Sorry I do not have LabVIEW installed on my system currently,so could not try it

Hence the statement 'I guess"Smiley Wink

0 Kudos
Message 2 of 4
(2,882 Views)
Hello mrbean,

the stat diagram toolkit creates a structure looking like the while loop. You can transform it into a normal while loop by disconnecting it from the state diagram toolkit, but then you can't use the toolkit anymore. Do you have that much code that rebuilding from scratch is a lot of work? Or you could build your state diagram inside a subvi.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 3 of 4
(2,876 Views)

"Any thoughts?"

Yes but not any that will help.

1) Just modify your SD so that the exit loops back to the start while there are still things to do. Forget the outer For loop.

2) THe observations you reported are correct. When I first discovered these limitiations I said "That sucks!". Since then I have learned a bit and have grown to love the SDE.

The SDE is JUST (note: "just" is a four letter word around here Smiley Surprised ) a LV application that ofers a very limited GUI consisting of a picture control that then scripts (see LAVA Scripting Forum for info on scripting) your SD for you. SCripting LV code is no easy task. My experiments with scripting has shown that I have to keep a database of the contents of the LV diagram my code is developing to keep track of what is where. Well it turns out that the structure of a LV diagram is a lot like the structure of a FP in that you start with a "root" object either the FP or the BD. THe BD then has structures on it, like seq's loops etc with unlited nesting possible.

Now the SD created by the SDE is really just a fancy while loop with an case structure and code to support the driving enum. In order for you to be able to edit the SD the SDE needs to know what is htere already so it can show the diagram. It "KNOWS" by looking at its internal DB (I believe is stored inside of VI along with the enum.ctl) of the SD. To keep the DB updated, the SDE must be used to manipulate the SD.

Stop rambling and guessing and get to the point!

Moving the SD is just not supported by the SDE so it can not be done. To do so would require the SDE be able to "look" at the diagram, and repeat all of its work in the new location in the diagram.

BTW: Thank you for trying out and asking about the SDE. the more talking we do on this subject, the sooner the SDE will be updated.

My SDE wishlist (partial)

Add comments to diagram from SDE screen.

Add data structures to SD (shift registers) from SDE screen.

Add "un-do".

Select multiple objects on SDE screen and move or allign.

Select multiple objects on SDE screen and do "create sub-State-Diagram".

Allow watching more than one SDE in execution highlighting at the same time.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 4
(2,854 Views)