4/16/13 - "Harmony Ultimate" hybrid touchscreen and "Harmony Smart Control" models join the ranks.
4/15/13 - Convenient $150 hard buttoned remote for use with Apple iPhone or iPad-based control systems.
1/24/13 - Disappointing Q3 earnings due to flagging global PC market to blame.
12/31/12 - Our thanks to everyone who has helped make Remote Central a great community for the past year!
12/25/12 - Got a new remote? Want a new remote? Explore Remote Central's resources!
|
|
 |
|
The following page was printed from RemoteCentral.com:
| Topic: | Actions and sleep This thread has 24 replies. Displaying posts 1 through 15. |
|
| Post 1 made on Tuesday June 19, 2012 at 06:16 |
Hi!
I'm trying to find a manageable way to either executeActions() or scheduleActions(), and also put the remote to sleep for a while.
In pseudo code this is what I want to do in a pronto script:
if preprocessor is off { switch it on sleep for 2 sec }
..do the rest of the script.
The reason for the sleep is that my preprocessor uses 12V triggers to a couple of PS Audio Power Plant Premieres which powers the whole system, so to be sure that everything has entered standby I want the script/remote to sleep for 2 seconds.
However, if I try to use executeActions() it throws the famous error: ProntoScript error: Busy playing actions Offending activity script: (untagged) Offending line #14: " CF.widget("POWER_ON", "DEVICE_PREPRO_TRANSPORT", "DEVICE_PREPRO").executeActions();"
And if I uses scheduleActions() instead it will do things in an incorrect order, i.e. it will schedule the power on for later, then go to sleep, then schedule all other power ons in the script and after this execute the whole batch. The problem here is that it doesn't allow the 2 second grace period needed for everything to enter standby before they can accept commands like power on.
I guess I could wrap all this in a scheduleAfter() but it would mean a lot of duplicated code and make the script grow.
Are there any smarter ways to accomplish this? If the preprocessor is already on then just move on in the script, if it is off it needs a power on and then everything should sleep for 2 sec before continuing.
|
|
| OP | Post 2 made on Tuesday June 19, 2012 at 06:22 |
This is the current snippet of the script, using scheduleActions():
// PreProcessor Power On // If PreProcessor is off, everything else is also off // Power on the PreProcessor and then wait for 2 sec for everything to enter standby if (System.getGlobal("powerStatus.PREPRO") != "ON") { System.print("Powering On PreProcessor"); System.setGlobal("powerStatus.PREPRO", "ON"); CF.widget("POWER_ON", "DEVICE_PREPRO_TRANSPORT", "DEVICE_PREPRO").scheduleActions(); System.delay(2000); // Sleep for 2 sec }
|
|
| OP | Post 3 made on Tuesday June 19, 2012 at 08:39 |
The same issue applies when shutting down the system. If the HTPC or projector is on I want to send power off to them, then sleep for an appropriate amount of time and lastly send power off to the preprocessor.
|
|
| OP | Post 4 made on Sunday June 24, 2012 at 13:00 |
No suggestions here yet? :)
|
|
| Post 5 made on Sunday June 24, 2012 at 18:42 |
Guy Palmer Active Member |
Joined: Posts: | June 2008 639 |
|
|
Why not put the delay into the actionlist itself?
|
|
| Post 6 made on Sunday June 24, 2012 at 21:21 |
Lowpro Select Member |
Joined: Posts: | March 2004 1,803 |
|
|
I would suggest the same. Simply use ProntoScript to conditionally run one of two actionlists, one actionlist which includes the delay action and another which doesn't.
Last edited by Lowpro on June 24, 2012 23:06.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
| OP | Post 7 made on Monday June 25, 2012 at 01:06 |
I'm not sure I understand, should I put the delay on the buttons for power on/off respectively and not when entering an activity or shutting down?
|
|
| Post 8 made on Monday June 25, 2012 at 01:30 |
alpha Long Time Member |
Joined: Posts: | September 2003 208 |
|
|
Create a New Hidden Button ("SPECIAL_OFF") that is only accessible through Prontoscript. Hide It Under a graphic or on a hidden page.
Add a Power Off action. (projector) Add a 2 second Delay Action. (sleep) Add a Power Off action. (preprocessor)
CF.widget("SPECIAL_OFF", "DEVICE_PREPRO_TRANSPORT", "DEVICE_PREPRO").scheduleActions();
|
Project Boredom 2 is here. [Link: mediafire.com]------------------------ Check Version 1 & 2 out in the files section. |
|
| OP | Post 9 made on Monday June 25, 2012 at 01:36 |
Wouldn't this behave in the same way as my original problem?
|
|
| Post 10 made on Monday June 25, 2012 at 07:19 |
Guy Palmer Active Member |
Joined: Posts: | June 2008 639 |
|
|
On June 25, 2012 at 01:36, urskog said...
Wouldn't this behave in the same way as my original problem? It all depends on exactly what your problem is. You can put delays into either actionlists (as per the examples above) or into scripts (via simple loops that compare times). You can invoke actionlists in either blocking (i.e. via executeActions()) or non-blocking (i.e. scheduleActions()) manners. All this means that you have complete flexibility, I think. From my reading of your original post, you want the script to only resume X seconds after the first actionlist is invoked. Putting a delay at the end of the first actionalist and invoking it using executeActions() will achieve this.
|
|
| Post 11 made on Monday June 25, 2012 at 09:22 |
Lowpro Select Member |
Joined: Posts: | March 2004 1,803 |
|
|
On June 19, 2012 at 06:16, urskog said...
If the preprocessor is already on then just move on in the script, if it is off it needs a power on and then everything should sleep for 2 sec before continuing. Based on your description above the easiest way to accomplish what you want is to only use ProntoScript to conditionally determine which actionlist you want to execute. The actionlist itself would contain all actions you want executed from start to finish, including any delay actions along the way. In the below example I have you tracking the power state of your preprocessor using a System Global. The button you'd press to power on your system would contain the below ProntoScript only. if(System.getGlobal ("Preprocessor")=="On") {CF.widget("SystemOn","Page (PS Name)","Activity (PS Name)").executeActions();} else {System.setGlobal ("Preprocessor","On"); CF.widget("SystemOn (Ext)","Page (PS Name)","Activity (PS Name)").executeActions();}This is a simple if/else statement which states, if the preprocessor is already powered on execute the actionlist contained on the button with the ProntoScript name, "SystemOn". If the preprocessor is not already powered on first update the SystemGlobal as you are about to power on the preprocessor, then execute the actionlist contained on the button with the ProntoScript name, "SystemOn (Ext)". The actionlist on the button with the ProntoScript name, "SystemOn" would contain all actions you want executed to power on your system from start to finish, minus the delay action as it is not needed if the preprocessor is already powered on. The actionlist on the button with the ProntoScript name, "SystemOn (Ext)" would contain the same exact actionlist items, but would also include a delay action for 2 seconds after sending the power on command to the preprocessor. All that being said, there is actually an even simplier approach. All we are talking about here is 2 seconds. As such, who cares if the preprocessor is powered on already. Include the 2 second delay action each and every time. It would act as a fail-safe. It's just 2 seconds after all. In this case we're just talking about a button with an actionlist. No ProntoScript required. Now if you do need to execute ProntoScript prior to the actionlist running such as for updating System Globals and so forth you certainly can. Just make the last line of ProntoScript your executeActions statement invoking the particular actionlist to be run which could be contained on the same button if you want.
Last edited by Lowpro on June 25, 2012 09:41.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
| OP | Post 12 made on Monday June 25, 2012 at 09:58 |
Great! I'll try this approach as soon as I can but it sounds promising :) Thanks a lot to everyone who posted in the thread.
I agree that 2 seconds isn't a lot but when powering off it might be significantly higher, probably 60-90 seconds if the projector was on and needs a cooldown. Of course I could always wait this amount of time before powering off the system but my inner nerd wanted everything nice and pretty :)
|
|
| Post 13 made on Monday June 25, 2012 at 10:21 |
Lowpro Select Member |
Joined: Posts: | March 2004 1,803 |
|
|
On June 25, 2012 at 09:58, urskog said...
Great! I'll try this approach as soon as I can but it sounds promising :) Thanks a lot to everyone who posted in the thread.
I agree that 2 seconds isn't a lot but when powering off it might be significantly higher, probably 60-90 seconds if the projector was on and needs a cooldown. Of course I could always wait this amount of time before powering off the system but my inner nerd wanted everything nice and pretty :) No need to wait the 60-90 seconds before powering off your system. For the actionlist that powers off your system just ensure 90 seconds has past after powering off the projector, but before the actionlist actually ends by inserting the needed delay action. While the actionlist is running you could even have an informational page displayed on the remote stating to please wait while the system is being powered off.
Last edited by Lowpro on June 25, 2012 10:32.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
| OP | Post 14 made on Monday June 25, 2012 at 10:27 |
On June 25, 2012 at 10:21, Lowpro said...
No need to wait the 60-90 seconds before powering off your system. For the actionlist that powers off your system just ensure 90 seconds has past after powering off the projector, but before the actionlist actually ends by inserting the needed delay action. Yea I was planning something along the lines of a timer that starts counting down in the background when the projector powers down and then I will wait for the remaining amount of time before power off the prepro, thus making it dynamic between 0-90 seconds. Haven't studied up on the specifics of such a timer yet thou but I assume that it would be possible.
|
|
| Post 15 made on Monday June 25, 2012 at 10:36 |
Lowpro Select Member |
Joined: Posts: | March 2004 1,803 |
|
|
Everything can be done with a simple actionlist. Simply add delay actions where needed along the way. The actionlist would first power off the projector, then everything else except the preprocessor. You would then have a 90 second delay action to account for the time the projector needs to cool down. The last item in the actionlist would be the command to power off the preprocessor.
Last edited by Lowpro on June 25, 2012 10:47.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
 |
Before you can reply to a message... |
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now. |
Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.
|
|