LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continue upon error

Solved!
Go to solution

Hi All,

 

New to labview and have had a dig through the forums but couldn't find a relevant solution. I have two VIs (LV-2017), one in the lab continuously collecting data and writing a CSV file onto a network drive (every 2 mins). The other in the office, displaying the data by graphing the data from the network drive (reading every 10 mins). Each file is named in the format 'name_dd_mm_yyyy', so there is a new file created as the date changes and this is appended to throughout the day. This works fairly well except over the stroke of midnight where, based on the write and read intervals, occationally the read.vi looks for a file that the write.vi has not created yet. This, of course, causes an error and stops the read.vi from continuing.

 

What I'm thinking I need to do is either, somehow delay the read.vi to look for a file dated 10 mins in the past so there will always be a file when read.vi looks for it OR somehow enter some way of ignoring the 'no file found' error. I do not have the slightest clue how to do either. I'm using the 'Format Date/Time String' block to write the file name and append it to a path constant. Are there any tried and tested solutions that are used to handle this kind of thing?

 

Thanks in advance.

LV-2017
0 Kudos
Message 1 of 6
(2,652 Views)
Solution
Accepted by topic author Potticary

Hi Potticary,

 

there is NO errorhandling in your VI!

All those file functions support errorIO wires - USE them!

 

Hint: you can connect an error wire directly with the selector of a case structure and it will automatically present two cases of "error" and "no error"…

check.png

Best regards,
GerdW


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

One thing you don't mention is how long the program runs.  You do mention that it writes a new file every 2 minutes, or 60 * 24 / 2 = 720 files a day.

 

I have a colleague who, as you are doing, likes to put TimeStamp information in the name of the File.  I hate that -- it makes the file somewhat "human-hostile", as there is a lot of verbiage for a human looking at a bunch of filename and trying to figure out if one is missing.  The scheme I prefer is to have a (unique) Experiment Name (say, Bob3), a serial "Series" name (such as -001, -002, -003) to allow me to collect series of Experiments starting on different days, and a serial "Run" name (maybe also -001, -002, -003) to allow me to identify the different 2-minute files.  Much easier to see Bob3-002-002, Bob3-002-004, Bob3-002-005 etc. and know they are all from the same Bob3-002 series and run -003 is missing (it's especially easy when they are in a single column, which is easily alphabetized).  If you want a TimeStamp, the initial File has it, and you could (if necessary) include it as a datum inside the file.

 

If you decided you needed to take data for a week, simply use a 4-digit run number (e.g. Bob3-002-1234) which will suffice for about two weeks.  Six digits will get you a year's worth of sequential files.  And no need to fuss with interpreting TimeStamps and Times (you only need to measure the 2 minutes with reasonable accuracy).

 

Bob Schor

0 Kudos
Message 3 of 6
(2,605 Views)

Actually, Bob, it's one file per day.  It's just written to every two minutes.  In which case, using the date is not so bad, but it would be better if it was written in yyyymmdd format, which is much easier to parse.

0 Kudos
Message 4 of 6
(2,595 Views)

hank you for the clarification.  It also suggests the following extremely simple algorithm -- every time you need to write a file, create its filename in the form of YYYYMMDD.<whatever>.  By using a VIG (see below), you can detect whether or not the Date (= Filename) has changed, and set a New File? flag for further processing.  If the File is new, you'll want to Create it, write to it, and close it.  Otherwise, you'll want to Open it (for reading and writing), go to the end of the file, and write.

Daily File Name.png

Bob Schor

 

P.S. -- Note I made the file name YYYYMMDD -- if you want it to be YYYYMMDD.dat, just change the format string to %Y%m%d.dat.

Message 5 of 6
(2,575 Views)

Thanks All.

 

I used GerdW's solution and it worked a charm.

 

 

LV-2017
0 Kudos
Message 6 of 6
(2,562 Views)