2009-03-05, 12:42 AM
Hi all..
I want to share my experiences and my setup for managing the power of my HTPC..
Here it goes:
What I want is:
1. Machine should hibernate if no remote activity is registered for a set period of time (say 1 hour)
2. If machine is working either recording a show or transcoding something then machine should not hibernate.
Notice how (2) doesn't mean any activity of remote/keyboard/mouse. And also, if we go by CPU activity, recording a show doesn't mean a lot of CPU activity (between 10-25%)
Windows integrated power management doesn't work because as soon as CPU usage jumps over 10%, it restarts its standby/hibernation/shutdown timer. Therefore, (2) would be accomplished, because recording and of course also transcoding would keep machine from hibernating. However not No. 1 because simply watching TV (withouth recording, and without sending any control remote commands means over 10% CPU)
Solution: TOff. I found out this utility which is much more powerful than windows power management. It has a simple activity timer and regardless of CPU it executes the desired "OFF" command (in my case soft hibernation) when no keyboard/mouse activity is recorded.
## Problem #1
This led to the following problem. TOff didn't care I was controlling PVRX2 with the remote control changing channels, visiting menu guide, whatever.
I'm using HIP, so there lied the problem. I was using only POST commands to send commands to PVRX2. Of course, those aren't keyboard commands, those are some kinda underground between programs commands. So I changed from POST commands to keystrokes and problem solved
## Problem #2
Now, how to prevent TOff from hibernating the computer when GBPVR is recording. What I did was I created a recordingstatus.bat file. What it does: It sets two GBPVR "stages" one is RECORDING and the other is AFTER-RECORDING. We recognize stage by the recordingstatus argument. When GBPVR starts recording the word "Recording" is passed as part of the command line argument to the recordingstatus batchfile. When it finishes, the word "Sleeping" is passed as part of the command line argument. Therefore, we detect which of those two words was received and: If on RECORDING stage, the TOff command is closed by the /closeall flag. If on AFTER-RECORDING stage, call the Toff batchfile and start the hibernation timer again.
## Problem #3
At last, how to keep program from hibernating when transcoding a recording. When GBPVR sends a movie to be transcoded, recordingstatus still receives "Sleeping" as part of the command line argument. So our current setup so far has TOff running and with no activity, it would hibernate no matter what after the timer rouns out. Solution?? Easy and within the same TOff. It has a configurable CPU level for considering CPU activity as timer resetting. I set this to 70% (ffmpeg runs over 80% almost constantly) so it is set.
## Problem #4
After hibernating, TOff closes and then when resuming there's no TOff back, so we don't have power management. Toff includes an appealing option called "Every time". This appears to work and it does work. When returning from hibernation, Toff starts again with the same settings. "Every time" means that TOff is run with the same settings every time a user logs on, just like when you return from hibernation. Problem arises when you get to the RECORDING stage of recordingstatus batchfile, it sends a /closeall signal to TOff to close the running TOff. When this happens, TOff has to know if you want TOff to start again upon another user logon or not. That means a dialog box which eliminates the automation objective. Therefore, the "Every time" option is out of question.
Solution: I use the wake.cmd file. In that file, I first send a /closeall signal to TOff (in the case that the hibernation was manual and therefore TOff wasn't closed automatically) and then call again the TOff batchfile to start the timer again.
## Manual hibernation
I didnd't spend too much time thinking about this. For me it was simple. I set the power button on the HTPC to do nothing. So when you press it, it just doesn't do anything. And I mapped the power button from the remote control to the execution of a bat file: tryhiber.bat.
If you look at the recordingstatus batchfile, you'll see that when arriving to the RECORDING stage I create c:\pvrwrkng file so that when I get "Sleeping" as command line and that file exists, it goes to AFTER-RECORDING stage.
This tryhiber.bat simple sees if the file c:\pvrwrkng exists. If it does, it doesn't hibernate. If it doesn't exist, then it goes to hibernate with a TOff command. This TOff command doesn't mess with an already running TOff command.
There are a lot of uncovered corners here:
- When transcoding it hibernates (shouldn't matter, since hibernation should return back to the point where the ffmpeg process left)
- Going to the start menu to hibernate and hibernating isn't stopped
- If you don't have the remote, you can't hibernate (doesn't matter too much to me, it hibernates after an hour automatically)
- I don't know what happens when you try to hibernate from the system submenu in pvrx2
I'm attaching Recordingstatus.bat, wake.cmd, tryhiber.bat, toff.bat and the hip file. Of course, you have to check for paths. The files are extremely short though.
About the hip file, check my other post for some clarification, it's pretty much standard with very few tweaks. Keeping it in its own post for easy finding.
Mede
I want to share my experiences and my setup for managing the power of my HTPC..
Here it goes:
What I want is:
1. Machine should hibernate if no remote activity is registered for a set period of time (say 1 hour)
2. If machine is working either recording a show or transcoding something then machine should not hibernate.
Notice how (2) doesn't mean any activity of remote/keyboard/mouse. And also, if we go by CPU activity, recording a show doesn't mean a lot of CPU activity (between 10-25%)
Windows integrated power management doesn't work because as soon as CPU usage jumps over 10%, it restarts its standby/hibernation/shutdown timer. Therefore, (2) would be accomplished, because recording and of course also transcoding would keep machine from hibernating. However not No. 1 because simply watching TV (withouth recording, and without sending any control remote commands means over 10% CPU)
Solution: TOff. I found out this utility which is much more powerful than windows power management. It has a simple activity timer and regardless of CPU it executes the desired "OFF" command (in my case soft hibernation) when no keyboard/mouse activity is recorded.
## Problem #1
This led to the following problem. TOff didn't care I was controlling PVRX2 with the remote control changing channels, visiting menu guide, whatever.
I'm using HIP, so there lied the problem. I was using only POST commands to send commands to PVRX2. Of course, those aren't keyboard commands, those are some kinda underground between programs commands. So I changed from POST commands to keystrokes and problem solved
## Problem #2
Now, how to prevent TOff from hibernating the computer when GBPVR is recording. What I did was I created a recordingstatus.bat file. What it does: It sets two GBPVR "stages" one is RECORDING and the other is AFTER-RECORDING. We recognize stage by the recordingstatus argument. When GBPVR starts recording the word "Recording" is passed as part of the command line argument to the recordingstatus batchfile. When it finishes, the word "Sleeping" is passed as part of the command line argument. Therefore, we detect which of those two words was received and: If on RECORDING stage, the TOff command is closed by the /closeall flag. If on AFTER-RECORDING stage, call the Toff batchfile and start the hibernation timer again.
## Problem #3
At last, how to keep program from hibernating when transcoding a recording. When GBPVR sends a movie to be transcoded, recordingstatus still receives "Sleeping" as part of the command line argument. So our current setup so far has TOff running and with no activity, it would hibernate no matter what after the timer rouns out. Solution?? Easy and within the same TOff. It has a configurable CPU level for considering CPU activity as timer resetting. I set this to 70% (ffmpeg runs over 80% almost constantly) so it is set.
## Problem #4
After hibernating, TOff closes and then when resuming there's no TOff back, so we don't have power management. Toff includes an appealing option called "Every time". This appears to work and it does work. When returning from hibernation, Toff starts again with the same settings. "Every time" means that TOff is run with the same settings every time a user logs on, just like when you return from hibernation. Problem arises when you get to the RECORDING stage of recordingstatus batchfile, it sends a /closeall signal to TOff to close the running TOff. When this happens, TOff has to know if you want TOff to start again upon another user logon or not. That means a dialog box which eliminates the automation objective. Therefore, the "Every time" option is out of question.
Solution: I use the wake.cmd file. In that file, I first send a /closeall signal to TOff (in the case that the hibernation was manual and therefore TOff wasn't closed automatically) and then call again the TOff batchfile to start the timer again.
## Manual hibernation
I didnd't spend too much time thinking about this. For me it was simple. I set the power button on the HTPC to do nothing. So when you press it, it just doesn't do anything. And I mapped the power button from the remote control to the execution of a bat file: tryhiber.bat.
If you look at the recordingstatus batchfile, you'll see that when arriving to the RECORDING stage I create c:\pvrwrkng file so that when I get "Sleeping" as command line and that file exists, it goes to AFTER-RECORDING stage.
This tryhiber.bat simple sees if the file c:\pvrwrkng exists. If it does, it doesn't hibernate. If it doesn't exist, then it goes to hibernate with a TOff command. This TOff command doesn't mess with an already running TOff command.
There are a lot of uncovered corners here:
- When transcoding it hibernates (shouldn't matter, since hibernation should return back to the point where the ffmpeg process left)
- Going to the start menu to hibernate and hibernating isn't stopped
- If you don't have the remote, you can't hibernate (doesn't matter too much to me, it hibernates after an hour automatically)
- I don't know what happens when you try to hibernate from the system submenu in pvrx2
I'm attaching Recordingstatus.bat, wake.cmd, tryhiber.bat, toff.bat and the hip file. Of course, you have to check for paths. The files are extremely short though.
About the hip file, check my other post for some clarification, it's pretty much standard with very few tweaks. Keeping it in its own post for easy finding.
Mede