Msrivas Posted September 23, 2013 Share Posted September 23, 2013 private curenttime=GetTime(ChannelA[0]) private time =2 while (GetTime(ChannelA[0])<currenttime + time) ? "hello" endwhile What is wrong with the above code? I am using U6 to stream data into Daqfactory and I want the stream over a period of 2 seconds. Link to comment Share on other sites More sharing options...
AzeoTech Posted September 23, 2013 Share Posted September 23, 2013 Several things: 1) you have a while() loop with a delay(), which will run at full speed. 2) you have ? inside this super fast while loop which will dump a whole lot of stuff to the command / alert window, probably bogging down DAQFactory 3) you are basing the end time on the time of ChannelA. If ChannelA doesn't get any new values with a time stamp past two seconds from now, the while() loop will go forever. I'd recommend using systime() instead. But, if all you want to do is stream for 2 seconds, just do: // .. script to start stream delay(2) // .. script to end stream Link to comment Share on other sites More sharing options...
Msrivas Posted September 23, 2013 Author Share Posted September 23, 2013 Actually I am streaming continuously. I want to capture a 2 second window of data at 1000 times per second. The ? was just a debugging mechanism. My input stream is continuous and I have a feeling that execution never gets inside the loop. Link to comment Share on other sites More sharing options...
AzeoTech Posted September 23, 2013 Share Posted September 23, 2013 If the history is big enough, you can easily capture 2 seconds just by subsetting by time. Something like this: global capturedData = channelA[systime(), systime()-2] That will capture 2 seconds worth of data starting at the instant the code is run, and going back two seconds. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.