LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Test struct stuck

Hi all

    It's a status machine demo ,when I drop down "OK"button,program stuck and tick timer no respond and how to both run testing code and drop down menu set parameter,how to optimized  to better.It's appreciated your prompt,thanks!!

0 Kudos
Message 1 of 10
(3,327 Views)

Your attached VI, unfortunately, had all of the Controls set to "stay invisible".  You also managed to hide all of the Wires and functions on the Block Diagram that you attached.  So without seeing (and being able to closely inspect, and ultimately run) your code, all we can say is "something is wrong with your code" (though, who knows, you might have a bad PC, or a bad installation of LabVIEW ...).

 

Why don't you try again by replying to this message and attaching your VI (or VIs) so we can see what you did?

 

Bob Schor

0 Kudos
Message 2 of 10
(3,299 Views)

Thank you for replying,I want to make a test instruct with status machine instruct,when I scanning bar-code and focus return,start testing with custom instruct polling out and tick timer,in both drop down"Static->Set Parameter",will stuck it,how to optimized and try other way to best,thanks!

 

 

0 Kudos
Message 3 of 10
(3,293 Views)

Before GerdW or others note that we Forum users always ask for WinZip for compression, here is the Original Poster's VI as a .zip file (I haven't even looked at it, yet ...).

 

Bob Schor

0 Kudos
Message 4 of 10
(3,291 Views)

OK, I've now had a chance to look at the submitted code.  There is one Control (whose name I don't know, as it appears to be named in Chinese, and seems to be an Enum consisting of something like a State Machine's "States", also in Chinese) that I renamed to "Control", and did a manual "Replace" in the Main VI and one sub-VI where it was used, which cleaned up all the Broken Arrows.  But, of course, I don't know what the States mean, so am forced to "guess" What the Original Poster intended.

 

Some Forum readers of my Replies may have noticed I occasionally Rant and Rave about the distinction between What we want our LabVIEW code to accomplish and How we use the code to accomplish it.  I'm sure that there's some good Computer Science terminology for this "What" vs "How" dichotomy, but I coined it when a colleague showed me a Block Diagram that spread across two large-ish monitors and said "Help me get this to run".  I said "What does it do?", and he proceded to try to explain the Mess of Spaghetti before us.  I said "No, don't tell me how it does it -- just in 2 sentences, tell me what you are trying to do ...".  He said "Well I open some files, extract some data from each, and use these data to do such-and-such".  OK, that might be 3 VIs: Open Files, Extract Data, Analyze Data.  Our Humongous VI just became much smaller.  Each sub-VI was (largely) independent, did a simple Task (for those into SOLID, this is the "S", "Single Responsibility").  Pretty soon, we had a dozen sub-VIs in place of one Mess, and the Problem in the code became obvious and easily solved.

 

So get out pencil and paper (or Keyboard and Browser to the Forum) and describe "what" you want to do.  You seem to be using Menus as your "Organizing Principles".  I remember encountering Menus in my first major LabVIEW project (already-developed code I was tasked with "improving" and "maintaining") that used Menus.  I never understood the Menu system (and, more important, could not figure out "What" was being done, nor "Why").  I abandoned all the Menus and went to a structure similar to the Queued Message Handler, and the code (almost) re-wrote itself.

 

Bob Schor

0 Kudos
Message 5 of 10
(3,285 Views)

@Bob_Schor wrote:

... always ask for WinZip for compression,


I don't think anybody asks for winzip. Winzip is commercial software that nobody needs. Any newer windows version has "compressed folders" built in. Just select all your files and folders, then "right-click...send to ...compressed (zipped) folder".

 

 

altenbach_0-1588525461071.png

 

And if you need additional functionality, such a rar support and more, the free and open source 7zip is a great choice. Not sure why anyone would pay $30+ for winzip to clutter their computer with it. 😉

Message 6 of 10
(3,268 Views)

You are making some glaring beginner mistakes, such as placing lengthy loops inside event cases. Your event locks the front panel until it completes, that means once OK is pressed, the VI becomes unresponsive until that event is done. This entire thing is inside out. You might use the outer loop to anchor your state machine (e.g. using the timeout case) or you could place it in a separate loop, retaining the loop with the event structure for UI handling.

 

Some other problems:

  • blatant overuse of stacked sequences. None are needed. To set the keyfocus before the loop starts and clear the control, just use the following. No sequence needed. The other string you clear is an indicator, so set the VI to "vi properties...execution...clear indicators when called". No code needed.:
  • altenbach_0-1588527323383.png

     

  • Your upper/lower, etc. belong in a shift register. No need for local variables.
  • Your "modify parameters" subVI makes absolutely no sense. You can configure the VI top open the front panel when called and close afterwards. No need for all these methods.
  • Writing the value of a local variable to itself does nothing at all! (cancel case).
  • Your num3,4 are never invisible, so why do you need to make the visible with every call?
  • Your loop spins millions of times per second wasting CPU, burning power, and heating your room. There is no need for that.
  • ...

Since I don't understand the rest of your code, I won't look further but I recommend to do a few tutorials and look at examples.

0 Kudos
Message 7 of 10
(3,262 Views)

Thanks a lot.I have changed to English version ,product testing require as below:

 

1)when scanning bar code starting run and tick count on.

2)drop-down"static->set parameter"change upper or lower limited in both run test item.

 

in other words,when run the test item and tick count on,in both drop down menu change parameter will not stuck.

 

0 Kudos
Message 8 of 10
(3,237 Views)

It is still a total mess: Your event still has a lengthy loop inside an event frame.

 

 

0 Kudos
Message 9 of 10
(3,228 Views)

I think that is mess in indeed,I desired to that function as mention,how to optimized it with present struct,thanks.

0 Kudos
Message 10 of 10
(3,213 Views)