Jump to content

new project - need advice on best method to achieve objective


jimmyo

Recommended Posts

Hi everyone & thanks in advance for any help / advice / comments you can provide.  I have a motorized camera connected to my webserver.  The camera motor is controlled via camera.exe with various parameters (eg camera.exe up moves the camera up, etc).

 

I have set up a remote control on a webpage that uses exec("camera.exe up"); when someone presses the 'up' button.  So far so good and it works fine.

 

What I would now like to do is allow any one user to control the remote for, say, 5 minutes.  ie if the remote is not being used and a web surfer comes to my website they can press a button on the remote and they then can control it for 5 minutes.  If during that time someone else surfs to the page they can't control it until the remote is released after five minutes.

 

I'm having problems in two areas:

 

First is how to store on the server that the remote is either available or not.  eg is there a 'system' variable that can be called by a php script everytime it gets run no matter who has pressed a button that results in the script being called?  So if user #1 on computer #1 shows up, presses a button, the 'system' variable gets set to 'date() + 5 minutes' so that when user #2 shows up and presses a button, the php script first checks the variable and compares it to the current time sees that it is in use and hence doesn't exec() the camera movement.  Is there such a thing as a permanent system variable that can be created and accessed by each instance of the script? The only idea I have here is to create a file and store the time in text format ... but it seems very inefficient to have to read/write to disk for this.

 

Second issue I don't know how to deal with is when a user does have the remote but surfs away from my server.  If someone does that is there a way to have a script run that would set my 'in use' variable to 'no longer in use'.  eg maybe when a session terminates, automatically run a php script?

 

Thanks again for any suggestions anyone has.

 

Jim

 

 

Hi everyone & thanks in advance for any help / advice / comments you can provide.  I have a motorized camera connected to my webserver.  The camera motor is controlled via camera.exe with various parameters (eg camera.exe up moves the camera up, etc).

 

I have set up a remote control on a webpage that uses exec("camera.exe up"); when someone presses the 'up' button.  So far so good and it works fine.

 

What I would now like to do is allow any one user to control the remote for, say, 5 minutes.  ie if the remote is not being used and a web surfer comes to my website they can press a button on the remote and they then can control it for 5 minutes.  If during that time someone else surfs to the page they can't control it until the remote is released after five minutes.

 

I'm having problems in two areas:

 

First is how to store on the server that the remote is either available or not.  eg is there a 'system' variable that can be called by a php script everytime it gets run no matter who has pressed a button that results in the script being called?  So if user #1 on computer #1 shows up, presses a button, the 'system' variable gets set to 'date() + 5 minutes' so that when user #2 shows up and presses a button, the php script first checks the variable and compares it to the current time sees that it is in use and hence doesn't exec() the camera movement.  Is there such a thing as a permanent system variable that can be created and accessed by each instance of the script? The only idea I have here is to create a file and store the time in text format ... but it seems very inefficient to have to read/write to disk for this.

 

Second issue I don't know how to deal with is when a user does have the remote but surfs away from my server.  If someone does that is there a way to have a script run that would set my 'in use' variable to 'no longer in use'.  eg maybe when a session terminates, automatically run a php script?

 

Thanks again for any suggestions anyone has.

 

Jim

 

 

 

 

This sounds like a very COOL project.

 

It really is the same thing as a message board forum. You should have a DB that tracks EVERY click the user makes as if they were scouring a web forum. Until the user stops doing anything for 5 minutes, he then gets disconnected(goes offline) and someone else can then take control....

 

I assume you're only letting "registered" users play with your camera?

 

 

Thanks and you are partially right.  However the problem is that because this is a camera it is quite normal for someone to point the camera where they want and then just sit there and watch so having no clicks for an extended period of time is normal.  Also I wasn't planning to restrict access - it's merely a view of a lake with some hills and I want people to be able to pan up, down and around.

1) Use database to check whether camera is in use or not. When some one starts camers, Update status as in use and record start time in DB.

 

2) You can use Javascript to meaure 5 mins after camera has started and send the user to some other page after 5 mins which will update the status as not in use in DB and start time as 00-00-00 00:00:00

- in case some browsers dont have JS enabled, you can run a cron job ( scheduled task ) in PHP every min and check if the start time in database is more than 5 mins old. if it is , then find and kill process for camera.exe using exec();

 

hth

Thanks and you are partially right.  However the problem is that because this is a camera it is quite normal for someone to point the camera where they want and then just sit there and watch so having no clicks for an extended period of time is normal.  Also I wasn't planning to restrict access - it's merely a view of a lake with some hills and I want people to be able to pan up, down and around.

 

I understand, if you ever go to NFL.com and watch a live game, they will have a popup after about 30 minutes asking you to hit OK to continue. If you don't do anything you get logged off...

 

At the end of the day, you just have to prompt the user after 5 minutes because:

 

1) It's not fair if someone is waiting to play with the camera, how long do they have to wait then?

it should be 5 minutes, and a pop up to either continue or discontinue.

 

2) if you make the session too long, you'll get one guy hogging up the camera forever...

 

600 is in seconds.

 

$_SESSION['expires_by'] = time() + 600;

 

 

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.