LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure Help

Hello Everyone,

 

I need some help with the attached VI (created in 8.6.1).  I am building a VI that will take data from WSN nodes and save them to files.  I am just using this VI to try and debug my file building and naming.  You can see the naming convention in the attached VI.  I will be taking data points every six seconds and would like to have the data fill down in text files with naming corresponding to the date they are being recorded.  I cannot figure out what to wire for the case structure so that the files will build in the correct way (i.e.  correct file name, with multiple lines of data).

 

I appreciate any help that people can give. 

 

Thanks 

0 Kudos
Message 1 of 12
(3,664 Views)

You need to test for the date outside the loop, and run the code to create a new file if the date has changed. In other words, Get Date/Time should be outside, and it should compare the date to the last date where a file was created. If you're on a new day, create a new file. 

 

Aside: You should not use string operations to create paths. Use the Build Path and Strip Path functions. Also, I am assuming that in your "real" VI you don't have the paths hard-coded like that. For instance, the path you provided would work under XP, but would not, for example, work under Windows 7. 

0 Kudos
Message 2 of 12
(3,648 Views)
What is the easiest way to have it check for a new day.  Do I compare the path to a Date/Time String.
0 Kudos
Message 3 of 12
(3,632 Views)

Use the Date and Time functions to read the current time and convert it to a time record. The cluster you get will allow you to get the day of the year (Julean date) which you can use in your application. Keep this value in a shift register and create a new file when this value changes.

 

Day of Year.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 12
(3,599 Views)

First of all, you need to add a date to your filename.  I suggest using "%m_%d_%Y".  Separate the date from the time with a space in your filename creation.  Now when wanting to compare the filename with today's date, get today's date with Format Date String, get the file date by extracting the date part, and compare the strings.

 

Date.png

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 12
(3,591 Views)

Here is what I have right now.  It appears to all be working except for one detail.  I think it has to do with someones advice from above about looking for the date outside of the loop (which i could not figure out how to do successfully).  When i create my data files with this vi, the last point in the data file really belongs on the data file a day ahead (ex. the last two points of file 04/05/10 would have 11:59:55 PM and 12:00:01 AM instead of 12:00:01 AM being in file 4/06/10 ).  Anyway, the file i have attached seems to work...mostly.  But i do think there is a cleaner way to successfully perform my task.  Any advice would be helpful.

 

0 Kudos
Message 6 of 12
(3,579 Views)

I wouldn't use the "Value has changed" vi.  It is a lot of VI there for what is a simple comparison operation.

 

Initialize your shift register with a value such as 0 or -1.  Do the comparison ahead of the case structure with the current time's day of year to the value in the shift register.  You get that carry over because you feed the day of year into the shift register at the end, so the day changes in one iteration, but doesn't get looked at until the next iteration.

0 Kudos
Message 7 of 12
(3,573 Views)
I must be really dense today.  I can't get it to work.
0 Kudos
Message 8 of 12
(3,566 Views)

lockesmith wrote:

Here is what I have right now.  It appears to all be working except for one detail.  I think it has to do with someones advice from above about looking for the date outside of the loop (which i could not figure out how to do successfully). 


Sorry. I meant to say "outside the case structure in the loop". 

 

Try something like this:

 

 

0 Kudos
Message 9 of 12
(3,556 Views)
Nevermind, I think I got it.
0 Kudos
Message 10 of 12
(3,554 Views)