11-02-2021 04:58 AM
I have two while loops. First while loop contains event structure to handle events and second while loop is data aquisition/recorded loop. How the DATA (recorded) data can be reset to 0 from CLEAR DATA button pressed?
If I use code bellow, the DATA is not reset...
11-02-2021 06:42 AM
You need to act on the data carried by the shift register in the acquisition loop.
Here are two examples, one with an event structure, the other without. There may be other small variations, though.
11-02-2021 06:55 AM
@AndrazS wrote:
I have two while loops. First while loop contains event structure to handle events and second while loop is data aquisition/recorded loop. How the DATA (recorded) data can be reset to 0 from CLEAR DATA button pressed?
If I use code bellow, the DATA is not reset...
The reason your code doesn't work is that even though you are resetting the DATA indicator to empty, the data still (also) exists on the shift register and thus gets repopulated in its entirety next loop.
You're like 75% of the way to a producer/consumer queued state machine so why not just make it such.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
11-02-2021 06:59 AM
@AndrazS wrote:
I have two while loops. First while loop contains event structure to handle events and second while loop is data aquisition/recorded loop. How the DATA (recorded) data can be reset to 0 from CLEAR DATA button pressed?
If I use code bellow, the DATA is not reset...
You are correct that this code does not Reset the data. Remember, the data is in the wire, not the indicator. You might temporarily change the indicator, but it will change back within 100 ms.
The suggestions that pincpanter gave work for this simple example - you really only need one loop. If you really need two loops then one common way is to set up a queue to send messages from the UI loop to the data acquisition loop. Search for information on queued message handlers to learn more about how this might work for your application. Channel wires can also be used.
11-02-2021 07:30 AM
Help -> Find Examples -> Queued message handler
11-02-2021 03:07 PM - edited 11-02-2021 03:08 PM
Assuming there is not much more to all this, just do everything in one loop. I like the case output tunnels that "use default if unwired", eliminating a lot of extra wires. (the shaded tunnel immediately shows that the other case is empty!)
Here's how it could look like (feel free to position the array indicator, case structure, and built array to your liking ;)):