Refreshing Webcams

Help each other out

Refreshing Webcams

Postby scottw on Tue Apr 25, 2006 12:57 pm

I just started messing with adding some webcams to my Xlobby and need some help having them refresh.

I made a database with the url's to the webcams after following Jowaldo's skin (thanks!!). I have a page with the thumbnail view of all the cams which runs the "load http covers" command, and then clicking on a cam takes you to a details page with a bigger image of the cam, this is what I need help with. Each time the webcam_details page loads it runs the following event:

Wait: 20000 (wait for the new image to be loaded on the webserver)
load http covers: webcams (refresh the image)
goto screen: webcam_refresh (I got this from Jowaldo's, I just says to wait while the images refresh)
goto screen: webcam_details

I wanted this process to repeat/update so that is why I set it to run on the page load.

This process works great but I cannot get it to stop refreshing since it re-runs the event each time the webcam_details page loads, which is what I want. I just need a way to stop it.

Hope that makes sense and is not to confusing
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Postby jowaldo on Tue Apr 25, 2006 4:21 pm

So basically, you have it constantly refreshing, and you just want a way to break that loop?

I'm trying to think of a way to do that, but nothing is coming to me right now ;)
jowaldo
 
Posts: 903
Joined: Wed May 21, 2003 7:17 pm

Postby scottw on Tue Apr 25, 2006 4:33 pm

Yes, thanks for simplifying it for me.


I want it to update every 20 seconds constantly only while I am on that page and need to know how to break the loop.

Let me know if you come up with anything.
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Postby ingalls on Tue Apr 25, 2006 6:32 pm

Yes, I think it should be a feature request for steven:

you make something lite an event with the refresh action, then a wait, the a repeat that will loop back to the refresh, then wait and so on
ingalls
 
Posts: 193
Joined: Wed May 12, 2004 7:46 pm

Postby dalanik on Tue Apr 25, 2006 6:49 pm

Why don't you just use XScript plugin and write yourself a script to loop? I do that for my "now playing" screens and I then exit by setting a variable on buttonclick in XLobby (while checking the variable value in the script every second)....

D.
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Postby scottw on Tue Apr 25, 2006 7:08 pm

Thanks dalanik,

I looked at Xscript but at first glance it looked like it would loop all the time but doing what you say may work for me.

Is there ary way you could get into more detail for me, if not I understand?


ingalls,
That's exactly what I am trying to do.
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Postby dalanik on Tue Apr 25, 2006 8:32 pm

Sure, I'll post you a simplified version of my "cycle" script, hold on... :-)
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Postby dalanik on Tue Apr 25, 2006 8:44 pm

OK, I didn't test this, but it should be something like this:

' ---------------------------------------------------------------------------------

Module Script

Public Sub Main()
Dim ac as Integer
Dim sexit as String

Do While( 1 = 1 ) ' *** loop indefinitely
For ac = 1 To 20 ' *** waits 10 seconds
Wait( 0.5 )' *** but monitors exitkiosk variable
sexit = Xlobby.GetXlobbyVar("variable>exitkiosk")

if( sexit = "1" ) Then
Exit Do ' *** if exitkiosk var set to 1, exit
End if
Next
' *** insert code for webcam update HERE :-)
Loop

Xlobby.ExecCommand("xlobby", "goto screen", "main") ' *** return to menu
End Sub


Public Sub Wait( Tm as Double )
Dim finish As Double

finish = Microsoft.VisualBasic.DateAndTime.Timer + Tm

Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
' *** wait
Loop
End sub

End Module

' ---------------------------------------------------------------------------------

Then in XLobby, just create button on that screen that sets variable exitkiosk to 1.... (good idea to set it to 0 on page load) :-)


maybe there is a simpler way, but I just adapted this from my existing nowplaying cycle script... :-) Well, you get the idea.
D.
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Postby jowaldo on Tue Apr 25, 2006 9:10 pm

thanks dalanik

that does sound like the best way to do it.
jowaldo
 
Posts: 903
Joined: Wed May 21, 2003 7:17 pm

Postby scottw on Wed Apr 26, 2006 1:07 am

dalanik wrote:OK, I didn't test this, but it should be something like this:

' ---------------------------------------------------------------------------------

Module Script

Public Sub Main()
Dim ac as Integer
Dim sexit as String

Do While( 1 = 1 ) ' *** loop indefinitely
For ac = 1 To 20 ' *** waits 10 seconds
Wait( 0.5 )' *** but monitors exitkiosk variable
sexit = Xlobby.GetXlobbyVar("variable>exitkiosk")

if( sexit = "1" ) Then
Exit Do ' *** if exitkiosk var set to 1, exit
End if
Next
' *** insert code for webcam update HERE :-)
Loop

Xlobby.ExecCommand("xlobby", "goto screen", "main") ' *** return to menu
End Sub


Public Sub Wait( Tm as Double )
Dim finish As Double

finish = Microsoft.VisualBasic.DateAndTime.Timer + Tm

Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
' *** wait
Loop
End sub

End Module

' ---------------------------------------------------------------------------------

Then in XLobby, just create button on that screen that sets variable exitkiosk to 1.... (good idea to set it to 0 on page load) :-)


maybe there is a simpler way, but I just adapted this from my existing nowplaying cycle script... :-) Well, you get the idea.
D.


Thanks so much for taking time out to post that. I will probably get into it Thursday sometime.

Thanks again.
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Postby scottw on Thu Apr 27, 2006 12:47 pm

dalanik,

This worked good but I have a few questions/problems.

First here is the script that I changed, I just added the 3 lines for my webcam update for now and my main page to menu from Main:

' ---------------------------------------------------------------------------------

Module Script

Public Sub Main()
Dim ac as Integer
Dim sexit as String

Do While( 1 = 1 ) ' *** loop indefinitely
For ac = 1 To 20 ' *** waits 10 seconds
Wait( 0.5 )' *** but monitors exitkiosk variable
sexit = Xlobby.GetXlobbyVar("variable>exitkiosk")

if( sexit = "1" ) Then
Exit Do ' *** if exitkiosk var set to 1, exit
End if
Next
Xlobby.ExecCommand("category", "load http covers", "webcams")
Xlobby.ExecCommand("xlobby", "goto screen", "webcamsrefresh")
Xlobby.ExecCommand("xlobby", "goto screen", "webcams_details")

Loop

Xlobby.ExecCommand("xlobby", "goto screen", "menu") ' *** return to menu
End Sub


Public Sub Wait( Tm as Double )
Dim finish As Double

finish = Microsoft.VisualBasic.DateAndTime.Timer + Tm

Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
' *** wait
Loop
End sub

End Module

' ---------------------------------------------------------------------------------

Clicking the button to go into the webcams_details page has the following events:

goto screen: webcams_details
variable set: Category Name = webcams Variable= exitkiosk Value = 0
Command: Plugin = XScript Command = ExecScript Variables = webcams.txt (your script)

It works fine to this point :D

Now for testing I added a button on the webcams_details page to stop the process:

variable set: Category Name = webcams Variable= exitkiosk Value = 1

but this does not work, it still refreshes and does not goto the menu page (which is what I think it is supposed to do)

1) Am I doing the "variable set" correctly?
2) How can I increase the wait to 20sec.?
3) When I launch the script it seems to take alot of cpu power, about 50% of my 3ghz and 100% of my 1.8ghz, is that normal?

Once I get this working I can see alot more uses for a script like this :D

Thanks so much for your help and time!!!!
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Postby scottw on Thu Apr 27, 2006 1:05 pm

OK I found the answer to question 1 and why the process would not stop.

I changed:
sexit = Xlobby.GetXlobbyVar("variable>exitkiosk")

to:
sexit = Xlobby.GetXlobbyVar("category>webcams>exitkiosk")

and the process stops and takes me back my main page.

This ROCKS!!!!!

If you have time for the other 2 questions I would appreciate it.

Thanks,
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Postby dalanik on Thu Apr 27, 2006 1:22 pm

Increasing the time is easy; in line:

For ac = 1 To 20 ' *** waits 10 seconds

just change 20 to whatever you wish (in seconds * 2), that is 20 seconds would be 40, 50 seconds 100, etc.

As far as CPU is concerned, I didn't notice that since I use it for "nowplaying" screens, and they have only 1 button (exit!) :-) so when they cycle, I don't do anything in XLobby. I can check. On second thought, on these screens I also run XVis and MPC videos, and I didn;t notice they stutter....

Try using

System.Threading.Thread.Sleep(500)

instead of

Wait( 0.5 )

or try increasing 0.5 to 1 (it should check for variable every second instead twice a second) - but then in for remeber that it's not 2x seconds :-)


D.
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Postby scottw on Thu Apr 27, 2006 1:45 pm

Total Awesome!!!!!

The seconds increase worked, thanks.

The System.Threading.Thread.Sleep(500) fixed the cpu problem as well. Just increasing the Wait to 1 had the same effects but using this one works great.



This is so cool, thanks alot.
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland