Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
ProntoScript and power tracking question
This thread has 10 replies. Displaying all posts.
Post 1 made on Saturday July 24, 2010 at 00:22
micro
Long Time Member
Joined:
Posts:
December 2004
25
I am trying to write my first power tracking into my 9400 and looking for some help. I have looked at a number of posts on doing it but all of them only have PS for all activities.

I have 2 devices TV and Receiver which have discrete for ON/OFF, however my PVR doesn't.

I have an activity button (Watch TV)which when pressed calls the 2 functions to power on the TV and Receiver. My question is how do I now add the PS after the first two functions to check the status and turn on the PVR?

As far as I can tell it's either you use PS or you don't. How do you use both?

Thanks

Micro.
Post 2 made on Saturday July 24, 2010 at 07:41
buzz
Super Member
Joined:
Posts:
May 2003
4,384
micro,

For each button, there are two action lists -- IR and ProntoScript. It is your choice which list will be executed when the button is pressed. ecuteActions() and scheduleActions() offer methods of invoking a button's IR list. Check out these functions in the Developers guide.
Post 3 made on Saturday July 24, 2010 at 12:38
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,003
It is executeActions vs ecuteActions
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 4 made on Saturday July 24, 2010 at 16:27
micro
Long Time Member
Joined:
Posts:
December 2004
25
Thanks for pointing me in the right direction.
Post 5 made on Saturday July 24, 2010 at 16:57
juiter
Long Time Member
Joined:
Posts:
July 2009
10
I have something to add. In PEP2, there is no way to direct send out IR codes using ProntoScript. But you can put an action list in a button which stays in a hide page and assign it with "ProntoScript Name" (both button,page,activity). Then you can use CF.widget(sWidget, sPage, sActivity).executeActions() or CF.widget(sWidget, sPage, sActivity).scheduleActions(). The sWidget,sPage,sActivity stands for the ProntoScript Name of the button,page and activity where the hide button stays.

The different between executeActions() and scheduleActions() is that the former will cause action conflict when you write the executeActions function in a Page Script or an Activity Script. Because in Pronto, only one action can be executed at the same time. So in Page Script and Activity Script, the page jump action haven't finished so you cannot do another action during this time, unless you make a function and use scheduleAfter function to schedule the action.

If you have only one device that doesn't have a discrete power on/off function. I have some better advice for you. First of all, use a varialbe to store the status of the power status of the PVR, use System.setGlobal() if needed. Make two action list in two buttons or two macros in macro lists(new firmware supported). Assign them with prontoscript name. Then before you call any IR actions, read the variable first and get the power status of the PVR. If it is on, then execute macro NO.1 in which doesn't contain a PVR power toggle action. If it is off, then execute macro No.2 in which contains a PVR power toggle action. That you can put your PVR toggle action anywhere in those two action lists.

Here is another solution for you. Use some current sensor to detect if your PVR is working,then add power sensor action in the power toggle action in the action list. That you must add some kind of sensor equipments.
...
Post 6 made on Saturday July 24, 2010 at 19:13
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
You don't need to put IR stuff on a button an a hidden page. You can put your IR stuff on a macro in the "macros activity" and then exec the actions of the macro.

juiter sorry to point it out this way, but you idea of power tracking is not a good one in my opinion. If in any case the on and off states get switched (like something prevents the pvr to get the ir code right, someone powers it off on the device/with a remote), and then you have an erroneous working system. A more casual problem: your TSU battery dies when the system is in operation. When the tsu is rebooted it will not work as it should any more. If you can do it true power sensing is the best solution.

If you have any electronic skills you can oe the device and find a power sense point (like the power supply lines of the USB whis is usually powered with the device, hdd power pins etc.)
Post 7 made on Saturday July 24, 2010 at 19:45
juiter
Long Time Member
Joined:
Posts:
July 2009
10
to: BluPhenix

Thanks for your advice.

I have mentioned the macro activity in my last post. :)

And I know that the exception that might cause by using variable to store status. That's just a cheap solution. I mentioned the current sensor solution which is more reliable in the end. It is not very easy for every person to oe a device.

Hope better solution will be brought up.

On July 24, 2010 at 19:13, BluPhenix said...
You don't need to put IR stuff on a button an a hidden page. You can put your IR stuff on a macro in the "macros activity" and then exec the actions of the macro.

juiter sorry to point it out this way, but you idea of power tracking is not a good one in my opinion. If in any case the on and off states get switched (like something prevents the pvr to get the ir code right, someone powers it off on the device/with a remote), and then you have an erroneous working system. A more casual problem: your TSU battery dies when the system is in operation. When the tsu is rebooted it will not work as it should any more. If you can do it true power sensing is the best solution.

If you have any electronic skills you can oe the device and find a power sense point (like the power supply lines of the USB whis is usually powered with the device, hdd power pins etc.)
...
Post 8 made on Saturday July 24, 2010 at 20:42
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,003
Have you seen these 2 threads as well? If you have not seen these, a look at the titles may provide you assistance with future searches.

[Link: remotecentral.com]

[Link: remotecentral.com]
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 9 made on Saturday July 24, 2010 at 23:59
micro
Long Time Member
Joined:
Posts:
December 2004
25
Thanks for the great advice.
Please keep in mind that this is my first time writing PS so it may not the best way of doing things but it helps me learn.

I have the following lines of code for my activity watch cable(turn on the receiver, tv, pvr and set the input in the receiver, tv and go to the pvr page) I have gotten up to work except for my last two CF calls.

Am I missing something?

CF.widget("REC_ON","Devices","Control_Power").executeActions();
System.delay(1000);
CF.widget("TV_ON","Devices","Control_Power").executeActions();
System.delay(1000);
if (System.getGlobal("PVRPOW") == "Off")
{
System.setGlobal("PVRPOW", "On");
CF.widget("PVR_TOGGLE","Devices","Control_Power").executeActions();
}
System.delay(1000);
CF.widget("RecCable","RecPage1","Receiver").executeActions();
System.delay(1000);
System.delay(1000);
CF.widget("TVCable","TVPage1","TV").executeActions();
System.delay(1000);
CF.page("PVRPage1","PVR").executeActions();
Post 10 made on Sunday July 25, 2010 at 01:22
buzz
Super Member
Joined:
Posts:
May 2003
4,384
micro,

OK for a first shot. Make sure that all of your referenced activities, pages, and buttons have ProntoScript names.

All of those delays would drive me crazy. Usually, the only delays that are required are between a device ON and the first command to that device. Some devices don't need any delay, but I've seen some TV's that need 11 seconds. (Yes, that is eleven seconds!) An 11 second delay would drive me to stomping on something. For that TV I used a page timer loop to send an Input Select command to the TV after a while. The user did not blame my program for being slow, because they were obviously waiting for the TV, but since I used a non blocking technique, the user could select cable channels while waiting for the TV.

I did track the TV power. If the TV was ON, I did not bother to throw that 11 second delay into the mix.

You might want to look into scheduleAfter()

A technique you can use to tune the delays (if you actually need them) is to add a setup page to the home activity. You can use PageDown to get to the page. Enable the scroll wheel here and use it to increment or decrement a delay global variable. Display the current value of the variable in a panel or button. Once you are satisfied with the delay, you can hard code it into your program. Reference this delay as appropriate in other parts of the program:

var delayTuning = System.getGlobal("delayTime");

...

System.delay( delayTuning );

...

System.delay( delayTuning );

...

Now you can tune the delay without needing to constantly download another version. (But, I don't recommend using that blocking wait in any case)


---

All of this is complicated as you first start out, but before long you'll have your own little bag of tricks that will make things easier.
Post 11 made on Sunday July 25, 2010 at 01:26
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,003
Pages do not have actions, only buttons so, therefore, you cannot simply do:

CF.page("PVRPage1","PVR").executeActions();

You need to put the code in the page into a function and call it from button script. If the code above is executing as a page script, then you need to put the code from 2nd page into a function at the activity level.

You should also realize that System.delay() is a blocking call and should be avoided if possible.

To schedule something to happen in the future, use something like:

CF.activity().scheduleActions(1000,function(){CF.widget('RecCable',...).executeActions();});

Which will execute the widget actions in around 1 second.

May I also suggest you become Level 1 Certified for Pronto's (click ProntoScript icon on top-right of Philips' site) such that you can download and review scripts supplied by Philips and others that will help you on the quest to become an asynchronous/event-driven (not using System.delay() or GUI.updateScreen()) programmer.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Jump to


Protected Feature 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.

Hosting Services by ipHouse