LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append to file dilemma

What I'm trying to do is to append to a file which has the daily running record in it. I only want to have one updated record to the file, the record is being updated while the program is running. Because the program is very often being aborted instead of shutting down properly, I can not do the save to file in the end of the run. I don't what to have a big list of record either. I only want to have one updated record attached to the existing file. I couldn't figure out a way to do it, anyone can think of a way to do it?
 
Thanks in advance,
 
Guangde
0 Kudos
Message 1 of 6
(2,479 Views)


@guangdew1 wrote:
Because the program is very often being aborted instead of shutting down properly,


Well that's not good, is there any way to get the users to change their behavior?Smiley Mad
 
What exactly is your problem?  Is it being aborted before it gets to the point outside of a loop where the log gets written?  Without knowing how your program is structured (what happens first, what loops are occurring, what happens last) it could be difficult to answer your question.
 
If it is a daily log, just open w/append, write to the file, then close.  If this happens within a loop, use a shift register to store some value as to when it is last written and use a case structure wrapped around those functions so that they only execute in the event that 24 hours have passed since the last logging.  Or that it is after 5pm and it is a different day then the last logging.  Something like that.

Message Edited by Ravens Fan on 06-06-2007 11:55 PM

Message 2 of 6
(2,470 Views)
Well the first thing to do is not let the user abort the VI. You can do this in the VI properties by turning off the ability to close the window. In addition, you can turn off the menubar so they can't select Exit.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 6
(2,463 Views)
Thank you for your response. The problem here is not that we don't know how to shut it down or someone mess with it. We have parallel running loops which reads in data from RS232 port. Some times if the port couldn't read in data, it will not run. Then we can not get out of the main loop, we don't have the choice but to abort it. This is my main concern. I hope I have made my problem clear and people can suggest me some solutions for it.
 
Best regards,
 
Guangde
0 Kudos
Message 4 of 6
(2,452 Views)

Thank you for your response. I haven't written the program yet, I know about this potentiel problem and think about how to get around it. If the program can always been shut down properly, then I can save (append) the final data out side of the while loop. Because of the potentiel problem, I'm thinking whether we can write it inside the while loop, so it will be updated every cycle. This way, no matter when and how the program is shut donw, we always have the most updated data. The problem is how we can make it work.

Best regards,

Guangde

0 Kudos
Message 5 of 6
(2,451 Views)
Hi Guangde,

once I had the same problem of a RS232 getting stucked in an endless loop without having the possibility to stop the subvi (the serial read operation didn't terminate, no timeout error, just stucked...)

I made up this solution:
The serial read vi is setting a 'watchdog' flag (global variable) every time it reads a new value. This global gets checked (and resetted) by a 2nd vi. When the watchdog flag isn't set for a period of time you can assume the RS232 part is broken again. Do your file write operation and exit Labview/your program in correct order!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(2,444 Views)