LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI Stops Working After Event Structure Is Activated

Hi everyone! I’m not sure if I’ve set up the event structure in my program correctly. The Deal button works as expected it deals two cards each to the dealer and the player. However, after I click Hit or Stand, it announces the winner, but then nothing else happens. The game doesn’t respond to any more clicks, and I have to stop and rerun the program to play again. Any ideas on what might be causing this or how I can fix it? I’d really appreciate any help!

0 Kudos
Message 1 of 5
(220 Views)

By default, an event case locks the panel until the event completes, so if you have inner interactive code, you are not doing it right. Similarly, if the event structure is not in the dataflow and gets triggered, the panel will lock up forever because the event can never complete.

 

Start with saving your toplevel VI for previous (e.g. 2019) so more can look at your code (I cannot,  because In only have LabVIEW 2020). Saving for previous will drag along all dependencies and create a new folder. Zip that up and attach it.

 

0 Kudos
Message 2 of 5
(193 Views)

This should be saved for the 2019 version. But Im guessing that is the problem because the event structure is within a case structure.

0 Kudos
Message 3 of 5
(181 Views)

All you need is a simple state machine. Keep he various arrays in shifter registers and update as needed depending on case. You don't need any local variables at all.

 

There is way (way!) too much complicated code, for example the SUM(SubVI) could use a lookup array instead of a case structure with 53(!) cases differing only in a constant. Just use the player card to index into an array of values!

Similarly, in "Finals", just use the integer to index into an array of strings. No structures needed.

 

Instead of appending two elements to an empty array using "insert into array", just use built array.

 

You don't even really need an event structure, just pace the toplevel loop reasonably and call an empty case if nothing needs to be done.

0 Kudos
Message 4 of 5
(162 Views)

I like the idea of the project. You have some fundamental misunderstanding of program flow. A structure can't finish until all components are finished and WHILE performing the HIT event you stop to wait for a Hit 2 button press. A press that can't happen since the front panel is locked, as Altenbach wrote.

You'll wait for a very long time ...

 

This could all be handled in the Event structure or in a State Machine. Imagine, e.g. that Hit only updates the players cards, then Disable and grey out the HIT button? The players can only press HIT 2 and that even will pull those cards and reenable HIT. 

 

If you need a bunch of extra functionality you can add some User events for e.g. Evaluation and the initial draw that shouldn't be outside. But then we're basically back to a State Machine implemented in an Event structure. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(119 Views)