ngoodman Posted November 10, 2010 Share Posted November 10, 2010 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 More sharing options...
AzeoTech Posted November 14, 2010 Share Posted November 14, 2010 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 More sharing options...
ngoodman Posted November 15, 2010 Author Share Posted November 15, 2010 have also found that lwp-download runs like a batch file. to use it in a batch file you have to use the CALL command and this also works in this application .... correct directory and it all works thanks Link to comment Share on other sites More sharing options...
AzeoTech Posted November 15, 2010 Share Posted November 15, 2010 Right. I didn't think about the possibility that it was a .bat file. ShellExecute() works similar to the script in a batch file (since that's what a batch file is, a bunch of shellexecute's essentially), so to run a batch file you have to use call. Link to comment Share on other sites More sharing options...
ngoodman Posted November 23, 2010 Author Share Posted November 23, 2010 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 Link to comment Share on other sites More sharing options...
AzeoTech Posted November 23, 2010 Share Posted November 23, 2010 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 More sharing options...
AzeoTech Posted November 23, 2010 Share Posted November 23, 2010 Also, do you find delayUpdate() is required? Link to comment Share on other sites More sharing options...
ngoodman Posted November 24, 2010 Author Share Posted November 24, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.