We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Best method of swapping sketches on a timer
Page Index Toggle Pages: 1
Best method of swapping sketches on a timer? (Read 904 times)
Best method of swapping sketches on a timer?
May 13th, 2009, 9:18am
 
Hi guys,

I have made some little programs that I will be using for a small exhibition that will run throughout the day.
I want to rotate through my programs (about 5 of them) every minute or so for display on a dedicated monitor.

So program 1 plays for 1 minute, stops, and then program 2 plays etc.

What is the best way to do this? I can have a linux or windows OS.

At the moment I'm thinking of making a batch file or shell script to loop them, rather than spending ages to rewrite all my sketches into classes and run one giant program.

Has anyone done anything similiar or got any suggestions?
Re: Best method of swapping sketches on a timer?
Reply #1 - May 13th, 2009, 10:26am
 
I know there was a thread about this topic, only thing i could find was this post, but there is another one i cant find atm:

http://processing.org/discourse/yabb2/num_1221068842.html
Re: Best method of swapping sketches on a timer?
Reply #2 - May 14th, 2009, 2:13am
 
I had a quick play with Mother and it seems more like a VJing program where you operate it in real time and it mixes sketches together.

I'm looking to have a dedicated box "locked away" inside a display unit that will just loop different sketches with zero user input, ie power it on and it starts running the programs.

Was thinking maybe a batch file to start program 1, wait 1min, shut it and start program 2 etc. repeated indefinitely until power down.
Re: Best method of swapping sketches on a timer?
Reply #3 - May 14th, 2009, 3:00am
 
A batch file like this seems to work ok, but flashes to the desktop when killing the task and starting another.

Code:
@echo off
:TOP
Start /d"S:\path to file1" program1.exe
CALL WAIT 60
Taskkill /im javaw.exe /f
Start /d"S:\path to file2" program2.exe
CALL WAIT 60
Taskkill /im javaw.exe /f
GOTO TOP


with the wait.bat ping hack implemented from malektips.com/dos0017.html

Code:
@ping 127.0.0.1 -n 2 -w 1000 > nul
@ping 127.0.0.1 -n %1% -w 1000> nul
Re: Best method of swapping sketches on a timer?
Reply #4 - May 14th, 2009, 3:05am
 
You should have a look at Field http ://openendedgroup.com/field/wiki/
http ://vimeo.com/3034647 (with processing)
Re: Best method of swapping sketches on a timer?
Reply #5 - May 14th, 2009, 4:47am
 
Field looks great, especially for the timeline feature. Unfortunately I don't have a mac and can't afford to buy one just for this as it is Mac OSX only
Re: Best method of swapping sketches on a timer?
Reply #6 - May 14th, 2009, 5:12am
 
I shown such concept in Re: Sequencing, display update, and functions, re-used it in Re: searching arraylist and pushed it even farther in Re: getting a better random number! Smiley
Re: Best method of swapping sketches on a timer?
Reply #7 - May 14th, 2009, 6:13am
 
Yeah PhiLho, I think I saw that before whihle searching, and is what I meant when I said I could rewrite each of my current independant sketches into classes, and then run it from a master void draw.

That will take a bit of time, especially to bugfix the inevitable problems I will come accross when moving programs into classes.

I might be able to borrow a mac to try Field, otherwise I think I'll stick with bat files or shell scripts to open/close my sketches on a timer.
Re: Best method of swapping sketches on a timer?
Reply #8 - May 14th, 2009, 6:33am
 
PhiLho mentioned the thread i talked about but couldnt find... Smiley
Re: Best method of swapping sketches on a timer?
Reply #9 - May 14th, 2009, 9:21am
 
This may not be the best (or easiest), but should work.

Assuming you have memory for it, you could embed PApplets onto a JFrame (or other container).

Then have some kind of switching scheme. Somthing like:
Code:
if (stopWatch > switchTime) {
currentpapplet.noLoop();//stop the animation

currentApplet = pappletList[nextPapplet];

currentApplet.setVisible(true);//Since PApplet extends Applet

//all others, hide
for (...)
if (nextPapplet != i)
pappletList[i].setVisible(false);

currentApplet.loop();

}
Page Index Toggle Pages: 1