11-19-2008 05:55 AM
Hello.
I am running a program that reads dataloggers every second and displays a plot on screen.
What i want, is that when i press a button, program ask for a filename and starts to log data to file and continues doing that as long as button is pressed.
When i press the button again the program asks the filename again, so i can choose a new file to write.
I have included a simplified version of my program that works by asking filename at start.
How do i change the program that it starts a new file every time the button is pressed again.
Solved! Go to Solution.
11-19-2008 09:03 AM
Hi Kai Patjas,
you should use two or more loops in parallel. One with an event structure to select the path. One to record your data and maybe one to write the data to the selected file. You can use queues to send the data from loop to loop. The loop which write your data to the file could be with a statemachine.
Hope it helps.
Mike
11-19-2008 09:08 AM
Hi,
So do you want to hold the botton down, or switch it? so you click it, the data starts logging and then you click it again to stop it...the next time to click the button it asks for a file name and so on...?
It's not a very 'pretty' solution but you could just use a simple case statement that checks a value, so your flow would be something like:
button clicked->ask for filename->change value of 'check' to 1->record data............->button click->stop logging data >change value of 'check' to 0.
So in the True case you would have the data logging bit with the part that asks for a filename inside a case statement that has a 'if Check = 0' entry and changes it to 1 and on the false case you would change the value of Check back to 0.
See attached, like i said it's not pretty but it will work to allow you to carry on developing...
Easy,
Darren.
11-20-2008 01:39 AM - edited 11-20-2008 01:40 AM
Hi Darren.
I forgot to say, that i use LV8.0, so i couldn't get your file open.
I tried something according your suggestion and got this kind of solution.
It works as i want, but is there a better solution for transferring refnum to different cases.
Now i use local variable.
-Kai
11-20-2008 02:38 AM
Kai,
I have changed the example I gave you to LV8.0 but I have never used the 'save for previous version...' option before so I'm not sure if it will work.
I have combined the start and stop record into one button (just change the text to whatever you need) and I have used the 'value' property to pass the filepath between the cases. The filepath can be formatted like you have in your version, just remember to use the convert string to filepath function.
Just in case it doesn't work on your LV version I have attached a screen shot of the block diagram.
Hope this helps, let me know if you have any more problems with this.
Easy.
Darren.
11-20-2008 05:04 AM
Darren,
Thanks, The example is working nicely.
The only problem is, that it uses "write to spreadsheet file" and because i need to write strings at the beginning of the log file (like channel names and other measurement info) i can't get it to work in my project.
Im using "write to text file" and having problems where to put "close file" and how to transfer refnum to it.
-Kai
11-20-2008 05:25 AM
Kai,
If you right click on the 'write to spreadsheet file' icon, you can then go to 'select type' and there you can change it to accept strings.
I may be wrong but I believe this is the same as using the 'write to text file' you are currently using, just without the whole refnum issues.
Hope this helps,
Easy.
Darren.
11-20-2008 06:24 AM
Darren,
Hmm. i can't find 'select type' anywhere. Could it be because of the 8.0 version.
I think it's time to update to newest version.
11-20-2008 09:39 AM
Kai,
I have looked in the release notes for V8.5 and there is no mention of it, although I guess it couls also have been introduced in 8.2!
If you wire a string to the 1D input, does it not change automatically?
Like you say, maybe it's time to upgrade...there are quite a few good changes made in 8.5 and 8.6 so it would be worth it.
Easy.