12-24-2012 08:32 PM
Only the first three values after P is shown. I can see only 10 as output. I need it to update as 10 then 11 then 12 and so on as the data comes in. How do I do that?
12-24-2012 11:47 PM - edited 12-24-2012 11:50 PM
It sounds like perhaps you are not indexing the array of output values, there should be three elements. The code in the snippet looks fine.
And to defend the honor of Scan from String, Mark misspoke slightly as I quote from the LV Help:
"A space in format string matches any amount of white space, such as spaces, tabs, linefeeds, and form feeds."
12-26-2012 08:44 PM
Here is the problem. The file data is anexample of how the data I get looks like. When I try a simple splitstring I do get the desired data but the output displays only now and then. meaning it skips most of the data in between. The kishortcp should work but it keeps saying that the input string is not of the expected order. This is because the number of bytes I read doesnot end exactly at the end of the pattern we want. I am not sure what to do. Kindly help
12-26-2012 10:20 PM
You are not processing the data correctly. In your one example you are reading new data every iteration of the loop and your are effectively overwriting the data which was not processed in the prior iteration. IN the other example you are only reading one sample from the string. Did you look at the code that I posted earlier? I suggest you use one loop to read data and another to process it. You will need to either split the string so you remove the data you already processed from it or keep track of the index into the string for the point you need to process next. When you receive new data you simply concatenate it with the data you have not processed yet.
12-27-2012 01:48 PM
I based my code entirely on yours. I am grateful for your help. So you suggest that I read the data in a seperate loop, split it when P occurs using splt string and then send it to the processing loop?
12-27-2012 05:45 PM
I can see it now. Everytime i read the data from tcp I overwrite the data I read from the last loop. But how do I solve this? I tried writing to a xml file but it keeps overwriting it. Please help
12-27-2012 09:46 PM
I finally tried what you said and it is working but the delay is a lot between me receiveing the data and the processing side displaying the output in clusters. Is there a way to solve this?
12-28-2012 10:13 AM
What do you consider to be a lot of delay?
One thing in the first loop is that you open the file but never close it. More commonly the file is opened outside the loop then the writes recur within the loop and the file is closed after the loop ends. Repeatedly opening the file without ever closing it could create problems with your references. The open process is probably slow. Although you are not writing large quantities of data as the file grows, maybe it has to reallocate space for the files.That process may also be slow.
In your read file loop it appears that you read the entire file each time even though the data hasn't changed from the previous read. If you keep track of the read file position in a shift register or feedback node, then you would only read the data that has been appended. I'm not sure that would be faster but it seems like it would worth trying. There is nothing in the second loop which knows whether the first loop has written new data to the file. You might consider checking file size and comparing it with the previous file size before reading to avoid reading the same data again. you could also check the File/Directory Info function to get the modification time date information.
Nothing to do with speed but using constants for the file paths means that you have to change constants two places anytime you want to change the file path. Move the constant outside both loops and just use one.
Lynn
12-28-2012 11:17 AM
@kishorgenius wrote:
I finally tried what you said and it is working but the delay is a lot between me receiveing the data and the processing side displaying the output in clusters. Is there a way to solve this?
That is the general idea but I wouldn't use a file to transfer data between two loops. I would use a queue to pass the data. Queues will be much more efficient. You will also need to keep track of where you are in the data buffer in terms of processing it. It would be easiest to remove the data from the buffer once it is processed that way your processing will always take place at the start of the buffer. If you process all the data then you simply wait for more.
12-28-2012 05:43 PM
The problem i am facing with queue is I receive no data outside the loop. Hence I am made to do the reading and processing in the same loop. Is there a way out?