 iman_h
		
			iman_h
		
		
		
		
		
		
		
		
	
			04-17-2017 10:54 AM
Hi all,
I've made a program to send and receive data. The program works in two modes:
1- One shot, in which the user clicks a button and one batch of data is then acquired.
2- Continuous mode, in which the program transmits data continuously every 250 ms.
I attached a snippet of a similar program. (The main one is very untidy and complicated.) The event structure handles the user interaction and the parallel while is performing the data transmission.
The program works fine but I wonder if there is a better way to do this. Could somebody help?
Thanks.
Solved! Go to Solution.
 altenbach
		
			altenbach
		
		
		 
		
		
		
		
		
	
			04-17-2017 11:00 AM - edited 04-17-2017 11:03 AM
@iman_h wrote:
The program works fine ...
No it does not. For example, your "stop" button only gets read once when the program starts, so the loops will either continue forever of both stop after one iteration. Basic dataflow constipation. Also look at your case structure on the right. What you think would happen if you would just wire the button to the global, omitting the case structure entirely?
All you need is one loop. You can use the timeout event. You don't need any local or global variables or coercion dots.
 altenbach
		
			altenbach
		
		
		 
		
		
		
		
		
	
			04-17-2017 11:19 AM
Try something like this ...
04-17-2017 11:31 AM
Thanks!