LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My First Nugget - Directory Changed Event

Hi all,

 

 

I admire your great job Steve! Considering your VIs I wonder if it is possible to use this project to trigger image reading function. Can you give me some clues how to do it?

 

regards,

Marcin

0 Kudos
Message 11 of 25
(1,935 Views)

I assume you have something collecting images and placing them in some directory. The <Dir Event> in the event structure will fire whenever a file is created in the specified directory. That event case is where you would start your image reading function. Your actual image reading function is probably going to take some time so it should go in another loop. Use a queue to send notification from the user event to that loop.

 

After you have processed the image you should delete it or move it to another directory so that you only see the files that are new and have not yet been processed. The example fires an event any time that a file is created, deleted, changed or renamed. You could change it to only fire when the file is created. Notice the Reg Event Callback with a bunch of wires going into it. There are four sections with three wires each. Delete all three wires from the deleted, changed and renamed sections then resize so that only the three wires for the created section are showing.

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


0 Kudos
Message 12 of 25
(1,926 Views)

Yes, I want to open images placed in one specified directory. The name of image is date and time and I want to open a file as fast as it arrives.

 

I don't know if I understand you properly - do I need to use a Generate Event Function to trigger a read_bmp_file.vi?

0 Kudos
Message 13 of 25
(1,912 Views)

@bikekowal wrote:

Yes, I want to open images placed in one specified directory. The name of image is date and time and I want to open a file as fast as it arrives.

 

I don't know if I understand you properly - do I need to use a Generate Event Function to trigger a read_bmp_file.vi?


The callback VI will generate the user event.  Your code to read the file needs to be placed inside the event structure, in the event case for the user event that is generated when a new file is added to the directory.

0 Kudos
Message 14 of 25
(1,898 Views)

Hi Steve,

 

I based my code on the FileSystemWatcher Functions to develop a little application, unfortunately when I build the installer to run it on a non-Labview machine runing XP and wich have the .NetFramework 4.0. The app does not start and provide the following error:" the vi is not executable. the full development version of labview is required to fix the errors"

 

The application works fine under Windows7 on a non-Labview machine, works obviously fine on a development machine under windows 7 too, but I had no chance making it work on two different XP sp3 non-LabView Machine with .NetFramework 4.0.

 

After some investigation, removing the .Net references within my VIs, I concluded that for some reason the .Net implementation of this function in LabView is not compatible with some XP components.

 

Am I right? Or what is the reason?

Do you think there is a workaround?

 

Thanks a lot.

 

 

0 Kudos
Message 15 of 25
(1,690 Views)

This is a Question for Steve or anyone else that would know the answer.

How can I use this approach to monitor 1  Excel file (called Testfile) instead of a directory. The file will be updating every few milli seconds with different data thats being overwritten. Any time Testfile has new data I need to be notified. 

 

0 Kudos
Message 16 of 25
(1,647 Views)

Hi *E*,

 

If you place the Excel file you want to monitor in a directory by itself, you can use Steve's code with few alterations.  Simply add your notification action inside the event structure found in 'Dir Watch.vi'.  That event structure executes whenever a change is detected in the files contained within the selected folder.  I tested it out and a simple 'save' operation in excel triggers a whole bunch of file changes in a row (10ish?), so be prepared for that.

0 Kudos
Message 17 of 25
(1,588 Views)

Thank you!

0 Kudos
Message 18 of 25
(1,582 Views)

Glorious! How have I not seen this? I'm glad someone posted a thank you which bumped it. I have written a loop to run in parallel that gets a directory listing when software starts and gets a listing from then on every one second, compares the different files to determine if something is new. 

 

We often do this to handle when new files are FTPd from RT to the Host PC, and then the host PC will move them to network storage. 

0 Kudos
Message 19 of 25
(1,570 Views)

Any ideas on how to do this on a real-time target?  As far as I know they don't support .NET?  Would I just have to create a VI that polls the dir contents with some frequency and compares the results for differences?

 

0 Kudos
Message 20 of 25
(1,472 Views)