LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

open file as it arrive

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

0 Kudos
Message 1 of 10
(3,140 Views)

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.

0 Kudos
Message 2 of 10
(3,133 Views)

@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).

Message 3 of 10
(3,122 Views)

Czesc Marcin :),

 

how do you actually send/recieve the file - e.g. what's the source of the picture?

Best regards,
Jano
0 Kudos
Message 4 of 10
(3,082 Views)

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

0 Kudos
Message 5 of 10
(3,077 Views)

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.

Best regards,
Jano
0 Kudos
Message 6 of 10
(3,064 Views)

@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.

=====================
LabVIEW 2012


0 Kudos
Message 7 of 10
(3,055 Views)

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

0 Kudos
Message 8 of 10
(3,043 Views)

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

0 Kudos
Message 9 of 10
(3,001 Views)

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


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 10 of 10
(2,994 Views)