12-12-2024 01:51 AM
Hi all
when vi abort due to power cut or someone abort it actually saves the data into the log file.
Example:
I have Vi outside the while loop I am saving the data to file when this while loop completes.
what if someone aborted it, it should have the data in a log file.
Solved! Go to Solution.
12-12-2024 02:02 AM
Hi Basavaraj,
@Basavaraj093 wrote:
Example:
I have Vi outside the while loop I am saving the data to file when this while loop completes.
what if someone aborted it, it should have the data in a log file.
Simple solution: write the data to your log file "inside the loop" instead of "after the loop"…
@Basavaraj093 wrote:
when vi abort due to power cut … it actually saves the data into the log file.
Simple solution: place a UPS next to your computer and react on the "active" signal of this UPS…
@Basavaraj093 wrote:
when vi abort due to … someone abort it actually saves the data into the log file.
Simple solution: create an EXE from your VI and prohibit the "aborting" of this EXE…
12-12-2024 09:52 AM
@Basavaraj093 wrote:
Hi all
when vi abort due to power cut or someone abort it actually saves the data into the log file.
Example:
I have Vi outside the while loop I am saving the data to file when this while loop completes.
what if someone aborted it, it should have the data in a log file.
The only way someone can "abort" a loop is if you are running your program from the LabVIEW development environment. You should NOT be doing that. You should be building executables and running them.
A properly written program could have an "abort" button that would exit the loop and save your data. Using events like "Panel Closed" in an executable can also trigger your program to save the data when someone closes the window.
12-12-2024 11:34 AM - edited 12-12-2024 11:37 AM
@Basavaraj093 wrote:
when vi abort due to power cut ....
As an additional note, if the power is cut, you might lose the last log entries due to disk caching unless you flush. Of course using that lowers performance.
Another possibility is a computer crash due to some other running process or faulty driver (... or even a bug in your own code!) and an UPS won't help there.
All other scenarios need to be handled in code as has been explained already.
12-12-2024 01:45 PM
Of course, there is a case of hard drive corruption due to power loss (it may happen), then these precautions are useless if hard drive cannot be recovered.
12-13-2024 04:01 AM
Its working fine but it also makes it run slow,
for example, if you want to stop loop at exact 30min using elapsed time, it stops loop when time is elapsed, but it also skips some seconds during logging data into the excel.
12-13-2024 04:13 AM - edited 12-13-2024 04:15 AM
Hi Basavaraj,
@Basavaraj093 wrote:
Its working fine but it also makes it run slow,
for example, if you want to stop loop at exact 30min using elapsed time, it stops loop when time is elapsed, but it also skips some seconds during logging data into the excel.
Yes. This is by (your) code design!
12-13-2024 09:37 AM
@Basavaraj093 wrote:
Its working fine but it also makes it run slow,
for example, if you want to stop loop at exact 30min using elapsed time, it stops loop when time is elapsed, but it also skips some seconds during logging data into the excel.
"Make it run slow" and "exactly" are very poorly defined terms. You probably know the loop rate and the program can stop according to the number of iterations instead of elapsed time.
Typically, the acquisition time is important. The time for saving is not part of the experiment and is irrelevant. In order to efficiently save, you need to use an efficient file format (e.g.open the file once, keep it open while appending data, and only close it at the end). Most high level file IO will open/close the file around each write, which is significantly more expensive. In addition, the saving can be done in a parallel loop where more jitter is acceptable.
12-14-2024 04:12 AM
As you said i tried but I am getting to many readings in log file, I want every minute reading. But here i am getting to many.
12-14-2024 10:01 AM
Your spin your loop every 10ms but only look at integer seconds so the remainder will be zero ~100 times (at 0, 10, 20, 30, 40... 990ms, unless the saving takes more than 10ms).