11-27-2011 04:13 PM
Hi all,
I want to implement a functionality - which in a shortcut - will open file as it arrive. I get an image file from a source, this files are simple, small bitmaps named with date and time. I need to open this files as soon as they arrive, one after one. I know how frequently this file appears, but I have no idea how to
I would be very grateful for help with this issue.
regards,
Marcin
11-27-2011 05:55 PM
How are you monitoring to know when it arrives? That is the first problem you need to solve. The only method I know of is to consistently poll the directory and looking at the list of files and comparing them to the previous list.
The second thing is to use the new file to open it. There are lots of examples for handling files and the graphics and sound palette has VI's for opening and reading bitmap files.
11-27-2011 09:40 PM
@Ravens Fan wrote:
How are you monitoring to know when it arrives? That is the first problem you need to solve. The only method I know of is to consistently poll the directory and looking at the list of files and comparing them to the previous list.
As a possible alternative to polling, check out this nifty example that uses .NET calls to trigger an event when a directory is changed (files added, deleted, modified or renamed).
11-30-2011 05:31 AM
Czesc Marcin :),
how do you actually send/recieve the file - e.g. what's the source of the picture?
11-30-2011 05:36 AM
Hi,
Image are sent over ethernet, but it is not a typical TCP/IP. I use a special application for reading images and saving to disk, to a specified folder. data and a time of image acquisition is a image filename.
regards,
Marcin Kowalski
11-30-2011 07:39 AM
Hi,
I was just asking to see, if we could get some sort of trigger signal together with the incoming images.
Since this is in software, I'd try either of the methods mentioned by Ravens Fan and nathand- the .NET solution sounds like an elegant solution.
As far as the bitmap part is concerned, you can use functions like Read BMP File VI and Draw Flattened Pixmap VI .
Please ask further question if something is not clear.
11-30-2011 09:07 AM - edited 11-30-2011 09:09 AM
@Ravens Fan wrote:
How are you monitoring to know when it arrives? That is the first problem you need to solve. The only method I know of is to consistently poll the directory and looking at the list of files and comparing them to the previous list.
The second thing is to use the new file to open it. There are lots of examples for handling files and the graphics and sound palette has VI's for opening and reading bitmap files.
I have used the polling method in the past. The thing to be aware of is that you might detect and try to read the file before it has been completely written. The way I got around that was to first create file.bmp.lock, write file.bmp, then delete file.bmp.lock. My polling will see that file.bmp exists then check if file.bmp.lock exists. If so it ignores file.bmp. There are probably file properties you could read to see if something else has it open.
If using Windows the .NET file watcher works very well although I am unsure if you will have the same problem of trying to read a file that has not been completely written. I am guessing (hoping) that the trigger occurs after the file has been completely written.
11-30-2011 02:08 PM
It looks I understand how this works and hopefully I will cope with this task. Unfortunately I won't check that before the weekend. Thanks for all replies.
regards,
Marcin
12-06-2011 06:32 AM
Hi,
Finally I tried The directory watcher. It looks good, but I don't know how to use this files to trigger open image (bmp open) function. Any ideas?
regards,
Marcin
12-06-2011 07:55 AM
I would do it similar to this one:
https://decibel.ni.com/content/docs/DOC-8962
When you receive an image, add to the queue. So basically you will have two while loops as in the link above, the top while loop (producer loop) will be the directory monitoring loop and the bottom one (consumer loop) will be your bmp file functions (for example http://zone.ni.com/reference/en-XX/help/371361H-01/lvpict/read_bmp_file/ as mentioned above)
Hope this helps.
regards,
aCe