SageTV Community  

Go Back   SageTV Community > SageTV Products > SageTV Software
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Software Discussion related to the SageTV application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the SageTV software application should be posted here. (Check the descriptions of the other forums; all hardware related questions go in the Hardware Support forum, etc. And, post in the customizations forum instead if any customizations are active.)

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-03-2004, 06:16 AM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
Suspend and resume with SageTV

Quick Link: download SageWake 1.2.4.1

download SageWake 2.2 beta


I've been looking all over these forums for information about using Windows power management and SageTV simultaneously, allowing the PC to go into low power states (standby or hibernate) when Sage doesn't have anything to record and the PC is left idle. The best solution I've found seems to be Jman's little Java tool the parses the SageTV schedule dump. But it doesn't seem to me to be a very elegant solution.

Obviously, the best solution would be to have a setting in SageTV for "Wake PC when Sage wants to record." This would be so amazingly simple for the developers to implement, I'm really amazed it hasn't been done yet. There's no need for Windows Task Scheduler jobs or the AT command or any of that nonsense. It would be as simple as setting a Waitable Timer object, which is a standard Windows synchronization object, and setting the fResume parameter to TRUE. This waitable timer object would be created when Sage is loaded, and would be reset with SetWaitableTimer every time the scheduler thread wakes up to determine the next program to be recorded. So simple! This would take care of everything. The system could standby/hibernate when there's no disk activity, and the waitable timer object would bring it back to life a couple minutes before Sage wants to start recording.

I'm thinking about coding this myself, albeit in a bit less elegant way since I can't modify SageTV. I'd have to use the schedule dump text file like Jman, but I wouldn't do a recurring task in the Task Scheduler to parse it: polling is wasteful. The Windows API lets you register to receive change notifications for any object in the filesystem. I'd just have my tool run in the background, register a change notification on Sage's schedule dump file, and sit in an efficient wait state until that notification is signalled. When that occurs, it would parse the file, find the next show to be recorded, reset its waitable timer object and go back into the wait state on the file.

Of course, if this behavior were integrated into SageTV, I wouldn't have to code anything.

Last edited by mwhitlock; 01-22-2006 at 08:36 PM.
Reply With Quote
  #2  
Old 03-03-2004, 09:53 AM
falchulk falchulk is offline
Sage Icon
 
Join Date: Sep 2003
Posts: 1,150
Have you read that huge Power Management thread?? It's not as easy as it sounds. I like you foolishly stated that at first as well. Jmans app works great for me. Why do you want it to be elegant? I want it to be invisible, which it is on my system. You would never know its running. Narflex stated he will be including this in V2 eventually. He even said he may use jamns code to do so.
Reply With Quote
  #3  
Old 03-03-2004, 12:18 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
SageWake

Not as easy as it sounds? I've already written my little tool. It's a single 5.5-KB Win32 executable with no external dependencies, just good old-fashioned Win32 APIs. I just tested it out and it works. It monitors the SageTV schedule dump file and when it sees a change, it parses the file, finds the next scheduled record time (it scans the whole file so multiple tuners are not a problem), and resets its waitable timer object for that time minus a user configurable number of seconds (defaults to 60 seconds). Additionally, you can tell it you don't want it to wake the computer for manual recordings, intelligent recordings, and/or favorite recordings. I'm including a more thorough description of the available options in a text file inside the Zip file I'm attaching to this post.

EDIT: See below for new version.

Last edited by mwhitlock; 03-04-2004 at 12:20 PM.
Reply With Quote
  #4  
Old 03-03-2004, 02:02 PM
falchulk falchulk is offline
Sage Icon
 
Join Date: Sep 2003
Posts: 1,150
Nice job. It provides the same functionality as jmans app.
Reply With Quote
  #5  
Old 03-03-2004, 03:05 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
The difference is that my app uses a change notification to know when to rescan the schedule file, whereas Jman's checks it every x minutes. Checking the file repeatedly like that means the system won't standby on its own due to the disk activity.

Also, I'm not seeing where Jman's wakeup lets you tell it you don't want to wake for intelligent recordings or manual recordings or favorites. Seems it's hard-coded to wake for favorites and manuals. I myself make use of intelligent recording to record a lot of shows that I do like to watch, so ignoring intelligent recordings is not good for me.


...Not to mention the overhead of coding in Java. Can you tell I'm a no-nonsense C/C++ programmer who really doesn't like Java? I'm so biased.

Last edited by mwhitlock; 03-03-2004 at 03:48 PM.
Reply With Quote
  #6  
Old 03-03-2004, 04:06 PM
jptaz's Avatar
jptaz jptaz is offline
Sage Fanatic
 
Join Date: May 2003
Location: Detroit Michigan
Posts: 991
Can you either provide the source or add an option to close SageTV and all SageRecorder Instances and then start them back up?

Here is the issue that Jman never resolved.

After the system resumes the Actisys IR Blaster no longer functions and will not function again until SageTV and/or SageRecorder is stopped and then started again. Also the original code only worked for 1 capture card, Does your code scan the entire file for the earliest recording? In a multiple tuner system, such as mine, each tuner's schedule for the next 3 days is listed after each other. Also in my system I have SageTV and 3 Instances of SageRecorder since I have 2 Actisys IR Blasters and a USB UIRT for conmtrolling 3 cable TV Boxes. So in an ideal world the program would read an ini file for settings like close all SageTV abd SaageRecorder instances as well as a list of paths to the instances to restart. I do a lot of C++ programming so I could very easily modify your existing program to do these things and for that matter rewrite it myself, but I would rather not duplicate the work if you are will to share your code.

Thanks,
John
__________________
SageTV 6.6, 100Mb LAN
Living Room: WinXP Pro SP2, AMD XP3200+, 1GB, 1.3TB 3ware 9500S12 RAID5, GigaByte GA7N400Pro2, 2xVBOX USB2 HD Tuner<-Antennna, 1xHDHR<-Antennna , HD100 to HDMI Splitter 1080i->32" 4:3 HDTV or 1080i->92" 1080P LCD Projector
Kitchen: WinXP Home SP2, Celeron 2.0Ghz, 512MB, 40GB, Saphire ATI MB, ATI9200->19"LCD
2 BedRooms: MediaMVP
Reply With Quote
  #7  
Old 03-03-2004, 07:46 PM
OPTIMO OPTIMO is offline
Sage User
 
Join Date: Feb 2004
Location: The Venice of America
Posts: 18
Send a message via AIM to OPTIMO
Thanks for the tool. I'll be testing it out tonight/tomorrow.
Reply With Quote
  #8  
Old 03-04-2004, 07:55 AM
bisbjerg bisbjerg is offline
Sage User
 
Join Date: Nov 2003
Location: Denmark
Posts: 71
Cool,
I'm currently using JMan's tool in conjunction with FireDaemon, and as falchulk stated, it works!
Anyway, IŽll give your tool a try.
Would it be possible to include some log-info on the activity? Something in XML would be very nice...
__________________
We've all heard that a million monkeys on a million keyboards would eventually come up with the entire works of Shakespeare - thanks to the Internet, we now know this isn't true....
Reply With Quote
  #9  
Old 03-04-2004, 09:30 AM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
Quote:
Originally posted by jptaz
Can you either provide the source or add an option to close SageTV and all SageRecorder Instances and then start them back up?

Here is the issue that Jman never resolved.

After the system resumes the Actisys IR Blaster no longer functions and will not function again until SageTV and/or SageRecorder is stopped and then started again. Also the original code only worked for 1 capture card, Does your code scan the entire file for the earliest recording? In a multiple tuner system, such as mine, each tuner's schedule for the next 3 days is listed after each other. Also in my system I have SageTV and 3 Instances of SageRecorder since I have 2 Actisys IR Blasters and a USB UIRT for conmtrolling 3 cable TV Boxes. So in an ideal world the program would read an ini file for settings like close all SageTV abd SaageRecorder instances as well as a list of paths to the instances to restart. I do a lot of C++ programming so I could very easily modify your existing program to do these things and for that matter rewrite it myself, but I would rather not duplicate the work if you are will to share your code.

Thanks,
John
John, my code does scan the entire file and picks the earliest program found, so it will be friendly to multiple-tuner systems. I can easily add an option for restarting instances of SageTV and SageRecorder. I'm working on it right now.

Quote:
Originally posted by bisbjerg
Cool,
I'm currently using JMan's tool in conjunction with FireDaemon, and as falchulk stated, it works!
Anyway, IŽll give your tool a try.
Would it be possible to include some log-info on the activity? Something in XML would be very nice...
I could add an optional log output. XML, you say? No problem. Sounds cool.
Reply With Quote
  #10  
Old 03-04-2004, 12:01 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
SageWake 1.1

Alright, I've finished SageWake 1.1. I squashed a couple of bugs, added an option to output a log file in XML format, and added the feature to prevent the system from going into standby while there is a recording going on.

Last edited by mwhitlock; 03-04-2004 at 05:44 PM.
Reply With Quote
  #11  
Old 03-04-2004, 04:55 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
SageWake 1.1.1

Tweaked a couple of things. Now it won't go into "allow system to go to sleep" mode at all if there's another recording immediately following the last one. Also it reports the scheduled wakeup time in the local timezone, since UTC was kind of confusing and inconsistent with the other times shown. Lastly, I cut down on the amount of reparsing of the schedule file it has to do. It seems that Sage likes to output its schedule file over and over even if it hasn't changed anything. SageWake now runs a lightweight checksum on the schedule file and if its contents haven't changed, it doesn't bother parsing it again.

Last edited by mwhitlock; 03-04-2004 at 07:13 PM.
Reply With Quote
  #12  
Old 03-04-2004, 07:13 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
SageWake 1.1.2

Fixed another little glitch where it wouldn't allow the system to sleep after a recording if there were another recording scheduled later (which is nearly always the case).

Last edited by mwhitlock; 03-07-2004 at 06:03 PM.
Reply With Quote
  #13  
Old 03-05-2004, 12:41 PM
falchulk falchulk is offline
Sage Icon
 
Join Date: Sep 2003
Posts: 1,150
mwhitlock, am I correct in assuming that you do not want to make this source code available?
Reply With Quote
  #14  
Old 03-05-2004, 01:45 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
I tried it and it works great, too bad my Revo doesn't ever return from S3.
Reply With Quote
  #15  
Old 03-05-2004, 04:50 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
Umm, I could make the source available, but no one would be able to use it. I don't code in a very mainstream way: I don't use the C/C++ runtime libraries but rather my own homegrown application framework. I basically use the C/C++ grammar as a shorthand for the underlying assembly. That's the main reason my programs come out so small. I won't release my personal framework source files, as I have a certain amount of selfish pride in them. However, I would release my code for SageWake itself, but none of you would be able to compile it without rewriting a substantial portion of it and porting it over to the standard (and IMO unnecessarily bloated) libraries. You could all at least see how it works anyway.
Reply With Quote
  #16  
Old 03-07-2004, 10:00 AM
Scriber Scriber is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: AZ
Posts: 210
Thumbs up

Sweet, thanks mwhitlock!

I'm new to Sage and it took me a missed show or 2 to figure out that there was no recording while sleeping.

This is very simple and works great. IMO, this needs a sticky or something for others to use (along with plugins etc) if this type of feature is not integrated into Sage.

Suggestion - have the default locaton for the txt file be the default Sage install directory.
Reply With Quote
  #17  
Old 03-07-2004, 12:09 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
If you put SageWake.exe in the same folder as the schedule file and call the schedule file schedule.txt, you don't need to specify --schedfile on the command line. ;-)
Reply With Quote
  #18  
Old 03-07-2004, 06:03 PM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
SageWake 1.1.3

  • Less textual data in XML log, more XML entities
  • Log system suspend and resume power events
EDIT: See below for latest version.

Last edited by mwhitlock; 03-13-2004 at 05:49 PM.
Reply With Quote
  #19  
Old 03-08-2004, 02:02 AM
bisbjerg bisbjerg is offline
Sage User
 
Join Date: Nov 2003
Location: Denmark
Posts: 71
Very nice going.
I might provide a frontend to the log, for easy browsing...
__________________
We've all heard that a million monkeys on a million keyboards would eventually come up with the entire works of Shakespeare - thanks to the Internet, we now know this isn't true....
Reply With Quote
  #20  
Old 03-08-2004, 05:22 AM
mwhitlock's Avatar
mwhitlock mwhitlock is offline
Sage Advanced User
 
Join Date: Jan 2004
Location: Gainesville, FL
Posts: 125
Send a message via AIM to mwhitlock
Oooo, a frontend. Okay, I will try very hard to keep my XML format consistent from here on out. Are you going to put some cool statistics in it? Maybe like duty cycle of PC (what percentage of time is spent in the 'on' state as opposed to low-power states) and average number of suspend/resume cycles per day. Perhaps you would like me to add an option to SageWake to append to the log with each new instance rather than starting over.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 12:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.