LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

24 hour textfile

Solved!
Go to solution

Please probe the contents of the shift register. By what you are saying, I'm understanding that you are storing the Date String in the shift register instead of time string. Also, please initialize the shift register with an empty string before initially running in the string.

 

OK, I'm sorry, I understood the VI incorrectly. 

Firstly, initialize the shift register with either a proper time stamp, or a null string.

Then secondly,  you need to stop the inner loop (the stop 2 button) so that it comes to the outer loop. If you do that for a couple of times, it comes up after a minute and again pops up the "Save As" dialog for me. 

 

Please let me know if I'm doing something wrong.

Message Edited by NitinD on 08-27-2009 12:16 PM
Message 21 of 31
(1,434 Views)

Hi nitin,

 

Is there a way to allow both while loop to continue running? the inner while loop should keep looping and capture any data that might be coming in. if the inner while loop is stopped, any data that is coming in will not be captured in the textfile.

 

 

I have another question. If the data comes in at exactly 00:00:00 which i can't possibly rule out, do you think the data will be logged in the previous textfile or will it be in the new textfile?

0 Kudos
Message 22 of 31
(1,423 Views)

Please remove the outer loop, and use Dennis' code in the place where you're writing the log into the file. Instead of creating the file outside the loop, create/open the file inside the loop.

 

i.e. the place where you are currently writing the string into the file, instead of just writing the string into the file, do an Open, write and close in case the string is same as shift register esle in the other case, Create, write and close the file. 

 

Hope this helps you.

Message 23 of 31
(1,416 Views)

Hi labviewproject,

 

Some things bothers me about you code Smiley Sad

First you open the file and keep it open the whole time. If something happens with mains power you will loose all your data since the file is never closed. I think you better capture data for let say one hour in an array, then save the array to file in a Open-Save-Close file sequence. That could be one sub-Vi that is well tested so you don't have to bother if it will work or not at midnight.

Second, is this the whole porgram or is this just the "capture" and "save" part of it? If this is the whole, you could keep it this way with some modifications. If not you beter consider the use of a state machien architecture. You have some well defined states so that would be an ideal case study 🙂

Third, what is the Numeric control for? You save only if it's equal to 1.

 

I think we miss the whole picture to help you in a good way.

Message 24 of 31
(1,398 Views)

Hi guys,

 

@Nitin: I tried to visualize what you have given. I'm not very sure if this is what u meant.

 

New Picture (9).jpg

 

This was what i had interpreted from what you have wrote.

 

@Alain: The data that is captured will be inserted into the database. I have a gui design that will be integrated with my program. I have tried integrating using the gui design & it works. but the program that was used, which is in my 1st post, does not recreate a textfile at 00:00:00. Do you want to see the gui design so that you can better understand how my textfile should work? I have just read up on the state machine that you have stated & i would have to design a new application. Would it take a long time to think of a design, as i have only 2 more weeks to finish up this & inserting the data into the database. The input control of 1 is to be used as a comparison. When the led in the gui design lights up, it will send the data to my textfile, logging down what is happening & where is the event at.

0 Kudos
Message 25 of 31
(1,380 Views)

New Picture (9).jpg

 

Sorry.Just notice that the picture is small.

0 Kudos
Message 26 of 31
(1,374 Views)
Please check this VI... Let me know if I've got something wrong... Hope it helps...
Message 27 of 31
(1,364 Views)

2 weeks is still a lot of time Smiley Very Happy

This could be your roadmap 

  1. First define small well defined steps that does only one thing.
  2. Make for some, or all of those steps a sub vi that you can test independent of the rest. That way you're sure that all of your subs does what you want.
  3. Then download the Open G State machine toolkit. With this you get a whole framework that works. There's a small video available that shows you how the whole thing is set up. Don't forget to watch it 🙂
  4. Add the states as required. In each state call the sub vi's you made previously.
  5. Job done Smiley Happy

Let's give it a trial

State: Idle | Purpose: software has nothing to do 🙂 | Put here an event structure to handle all user controls

State: Create a file | Purpose: Create one file | Called: each day at 00:00:xx, use Denis code somewhere at the start of this thread to check actual time. | Return value: reference to the file, error cluster

State: Save data | Purpose: same some data to the actual file (open file - store data - close file) | Called: as yu said "When the led in the gui design lights up" | Return value : Data saved, error cluster

State: ............ I can't think of other states since I don't know the whole application

 

 

According to the name "midnight textfile" one could think this vi is for creating a file at midnight but than what does the "save" thing in this vi?

What is the clear button for in this vi?

What is the "Not yet logged?" stuff for?

Because you don't have a good archticture you need all those flags to control your code

Message 28 of 31
(1,358 Views)

Hi Nitin,

 

Thanks alot for modifying the vi.When i used the highlight execution to see how the vi goes, i found that the vi does not recreate the textfile when the time changes. It will only prompt the user to change when the control changes to 1. If the vi could compare the time & create a new textfile when it detects a change in time, it would be considered done for me. could you tell me why the recreation of my textfile does not appear when the current time is different from the shift register? 

 

@Alain: The 'save' in my vi is to prompt user to save their textfile name & location. This is used because for my simulation, a prompt is easier to see as i know when the vi will recreate a textfile. The clear button in my vi is to clear the log that would appear in my gui design. It would be abit messy if the log is not clear in the gui design. the not yet logged is to check if there is an input of data. I will try to see if i could think of a design for the state machine within these 2 weeks.  Thanks.

0 Kudos
Message 29 of 31
(1,350 Views)
try it with dates, it will work... the problem with time is that OS doesn't allow the time tag... if instead you just had another counter that you could append to the file, you'll find that files will be created automatically... here, in your VI you are putting up a dialog to the user, take that off, and determine the file name automatically...
Message 30 of 31
(1,331 Views)