01-31-2022 07:57 AM
Hi Everyone,
I have external software which is continuously being logging data to Notepad(.log) text file.
The software buffers data 4 minutes. Therefore, I will need to wait 4 minutes before the first write operation and be able to see data on the text file.
I am trying to read that data from the same file in real time every 4 minutes. However, LabVIEW doesn't read the file unless I stop software from logging data, even though I can manually open the file and see the data logged for the past 4 minutes while the software is logging data for the next 4 minutes.
Here is the overall program code and offline .log file.
I would like to get some help please. Thank you.
o
01-31-2022 10:13 AM
@LaAb wrote:
LabVIEW doesn't read the file unless I stop software from logging data, even though I can manually open the file and see the data logged for the past 4 minutes while the software is logging data for the next 4 minutes.
This is probably because if a program has a file open for writing (read/write) then a second program tries to open the file (read/write mode) it causes a file sharing violation.
BTW: This has been true since DOS.
Two suggestions:
01-31-2022 10:13 AM
@LaAb wrote:
...LabVIEW doesn't read the file unless I stop software from logging data, even though I can manually open the file and see the data logged for the past 4 minutes while the software is logging data for the next 4 minutes.
I don't have LabVIEW 2020 (only 2018 at the moment), so I cannot see your code. However, it sounds like a common file permissions error. Try to open the file as read-only access to avoid Windows thinking you want to modify the file. This may avoid the locking behavior.
If editing the log program is possible, I would recommend opening and closing the file reference every 4 minutes as opposed to holding the reference open forever.
01-31-2022 02:05 PM
Thank you for replying.
I'm new to LabVIEW so I hope you forgive me for asking silly questions and making stupid mistakes.
I have used this code but still can't read the file.
I can edit the log programme on the software to log data on schedule, for instance log data for every minute continuously till I press stop logging on the software and it will be saved us time sequence.
02-02-2022 07:58 AM
Any reason why you don't just use the Read from Text File primitive to do all that? If you are not reading a partial file, you don't need all that complexity.
The Read from Text File function already opens a file as read-only.
02-04-2022 06:29 AM
The file is ready to be read once the software buffer is full.
I have solved it this why (see attached pic). However, can't get the graph working. The Y-axis appears fine but the X-axis 0. I want to the reflect the X-axis of the file. Is there a way you can help on that.
Thank you
02-04-2022 06:54 AM - edited 02-04-2022 06:56 AM
Hi Lab,
@LaAb wrote:
The file is ready to be read once the software buffer is full.
I have solved it this why (see attached pic). However, can't get the graph working. The Y-axis appears fine but the X-axis 0. I want to the reflect the X-axis of the file. Is there a way you can help on that.
So the graph is not working, but you "solved" the problem? 😄
So many questions for such small code…
02-04-2022 07:35 AM
Thank you for your feedback GerdW.
Before won't be able to read the file when the software buffer is full so I was referring to that when I say I solved the problem.
There might be a simpler way to do it but I'm new to LabVIEW.
There is a path wired so I select a file(.log) while the software is logging data. Once the buffer of the software is full then the data appears on .log file.
The buffer takes 206 seconds to be full and time interval is 0.2s.
i will attach the code, If you can help me to make it more simpler and to get the graph represents .log file, that would be appreciated.
Thank you.
02-04-2022 09:51 AM - edited 02-04-2022 09:52 AM
Hi LaAb,
@LaAb wrote:
i will attach the code, If you can help me to make it more simpler and to get the graph represents .log file, that would be appreciated.
See this:
@LaAb wrote:
There is a path wired so I select a file(.log) while the software is logging data. Once the buffer of the software is full then the data appears on .log file.
The buffer takes 206 seconds to be full and time interval is 0.2s.
There is no "buffer" in your VI!? What exactly are you talking about?
Why do you check the filesize every 1s when your "other software" takes 206s to "make its buffer full"?
What is that "time interval is 0.2s" coming from?
Why do you try to read the file incrementally when that "other software" writes "once the buffer is full then the data appears on log file"?
@LaAb wrote:
Thank you for your feedback GerdW.
Nice to get a "thank you", but you didn't take any of my suggestions!?
What should be displayed in the graph?
Which spreadsheet file do you want to load - there still is no filepath wired!?
(Why do you use ReadSpreadsheetFile function when you already collect log file content in this "Data" wire/indicator!?
Please explain in simple words what you really want to achieve…
02-07-2022 08:11 AM
Hi GerdW,
I have used your code and it is much simpler but still XY Graph is not displaying anything.
The software is a third party and its hardware have a buffer. The software reads sensor data directly and the software allows me to log data of the sensor in real time.
However, The softeware is not compatible with Modbus/TCP connection as a result, to get a real time data from software I had to implement this code.
I was checking it every seconds because when I press stop logging data on the software side, I want the LabView side to read the new file. However, with your code, still working fine except XY Graph.
It should display the log file
You are right, there is no need for ReadSpreadsheetFile function. I was just experimenting.
I want to display the data (.log) above as it is, in any form of graph as soon as the LabView reads it.
Thank you.