LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure to Save configuration data on save button control is happening only once

Solved!
Go to solution

Hello,

I am trying to save configurations using save button and an event structure. Data (config write) on  front panel should get updated in the config file every time user hits save button but somehow it is happening only once. Can anyone please help me with this?
I am attaching the vi for your reference.

Thank you.

0 Kudos
Message 1 of 4
(892 Views)

Hi Nectar,

 

On the simplest level, your Event Structure is only working once because the loop it is in (on top) is stopping after it runs.

You've connected "N == N?" to the Stop condition.

 

Usually, you might add a specific button to stop the VI, and have a separate event case for that button.

Often we also put the buttons that trigger an Event case inside the case (this isn't required, but it can be used to 'reset' "latching" buttons).

 

You also have the same problem in the bottom loop (N==N -> stop) but there is an outer loop in that case, so it isn't as obvious.

 

As a separate consideration, if you're not using the Timeout case on the Event Structure, you can delete it (and you then don't wire a constant to the top left of the Event Structure).


GCentral
0 Kudos
Message 2 of 4
(889 Views)
Solution
Accepted by topic author Nectar_techabhi

Here's a rewritten version showing some of the changes I mentioned (no timeout, use the Stop button Value Change event for the top loop (although the button remains in the bottom loop), remove the N==N? checks, remove the inner While loop at the bottom.

 

I also changed the For loop inputs to be "Indexing", which means that one value will be taken from each array each time. This does the same thing as your original code, but without the Index Array nodes being required.

The only time you might want to use Index Array instead is if the array lengths (you have two per For loop) might be different - with Indexing Tunnels, the For loop will run once for each element in the shortest array - with Index Array and a larger value connected (than the number of elements) you get the default value instead (for the data type of the array).

This can be important sometimes.

 

I also added a "Wait (ms)" to the bottom loop to reduce your CPU usage - you might have noticed that your version was using high CPU or Disk activity, this one should be less (but still behave at almost the same noticeable speed).

 

cbutcher_0-1647672104455.png

 


GCentral
0 Kudos
Message 3 of 4
(886 Views)

Thank you for your solution. It worked 👍😀

0 Kudos
Message 4 of 4
(824 Views)