08-27-2009 01:38 AM - edited 08-27-2009 01:46 AM
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.
08-27-2009 02:20 AM
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?
08-27-2009 02:59 AM
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.
08-27-2009 05:17 AM
Hi labviewproject,
Some things bothers me about you code
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.
08-27-2009 08:36 PM
Hi guys,
@Nitin: I tried to visualize what you have given. I'm not very sure if this is what u meant.
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.
08-27-2009 08:49 PM
Sorry.Just notice that the picture is small.
08-27-2009 11:59 PM
08-28-2009 12:48 AM
2 weeks is still a lot of time
This could be your roadmap
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
08-28-2009 04:33 AM
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.
08-29-2009 05:31 AM