IP cam


Recommended Posts

Hi

I am building a remote monitor and alarm for a remote part of the factory to integrate a lone worker alarm and a remote ip cam.

I have found a bit of perl code to load the camera data into a file this on its own works fine

the plan is to refresh this file and display as a symbol - this works fine from a file

the question is how do I call the perl code to refresh image from within daq factory?

this is my sample code

// capture new picture //

// delete old picture

File.Delete("c:\image.jpg"):

// get new picture

system.ShellExecute("lwp-download http://192.168.8.44/jpg/image.jpg ")

delay(1) // allow time for image to load

// display picture

component.test.loadjpeg("c:\image.jpg")

I think it may be a syntax thing as the "lwp-download" works from a command line

regards

Nigel

Link to comment
Share on other sites

Two possibilities:

1) lwp-download is located in the wrong directory. Try fully specifying the path in the shellexecute() call.

2) lwp-download is associated to the perl executor and its either not found, or shellexecute() isn't picking up the association. In that case, specify the executor as well.

I would imagine its probably #1.

Link to comment
Share on other sites

have found a far more elegant way of grabbing the frame. it uses a dos utility called wget and the program just calls this routine when a frame is needed very simple very reliable.

sequence is below

// capture new picture //


ignore("all")	 // we dont want this sequenceto stop
delay(5)		 // delay to allow network connection 
while(1)
   delay(2)		  //  between pic delay
   getpic=1
   system.DelayUpdate()  // stop screen update
   File.Delete("c:\image.jpg"): // delete old picture

   // get new picture
   system.ShellExecute("wget.exe","open","http://192.168.8.44/jpg/image.jpg","c:\","hide")
   delay(1) // allow time for image to load

   // display picture
   component.test.loadjpeg("c:\image.jpg")
   system.ResumeUpdate()
   getpic=0
endwhile

wget is open source as well (and free) and is available from www.gnu.org/software/wget/

attached is screendump showing image set into top left of screen with controls around

hope this is of interest and help to someone else - I never cease to amaze at the power and versatility of daqfactory - brilliant....

Nigel

post-7149-1290513883_thumb.jpg

Link to comment
Share on other sites

Wow, very nice! Thanks for sharing that. I know a lot of people that will be interested, and we'll probably mention it in our next newsletter.

BTW: I recommend using try/catch instead of ignore("all"), even if its just:

try
   // your code
catch()
endcatch

However, I would put ? strLastError inside the catch(). So your script looks something like:

// code
while(1)
   delay(2)
   try
	  // more code
   catch()
	  ? strLastError
   endcatch
endwhile

Note that the delay(2) needs to be outside the try/catch to keep the loop paced correctly even if there is an error.

The reason I recommend this, beyond good form, is that doing ? strLastErrror will at least cause any errors to print in the command / alert window. The sequence will keep running, but you'll actually know something is wrong and what it is.

Link to comment
Share on other sites

Thanks for that

will change error handling as suggested.

I found the image did not always change smoothly from old to new and flashed a red cross for perhaps 1/4 of a second. so used the delayupdate() command to allow time for the image to load. Its pretty much transparent to a user just a slight delay when clicking on a button.

regards

Nigel

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.