SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-26-2007, 01:51 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Calling SetRecordingTimes()

Writing a plugin that will automatically modify recording times for live events (i.e. sports) so that games that run long will automatically record until they're over.

All was going well until it was time to call the SetRecordingTimes() API call. According to the API docs, this call returns true on success or an error message on failure, so here's a code fragment of how I'm calling it:
Code:
if(mon.isOver()) // End the recording now
{
	try
	{
		apiResult = sage.SageTV.api("SetRecordingTimes", new Object[] {airing, getScheduleStartTime(), now.getTime()});
		if((Boolean)apiResult == true)
		{
			retVal = RecordingExtenderResult.STOPPED;
			scheduleEndTime = now.getTime();
		}
	}
	catch(ClassCastException e) // Call must have returned a string (error)
	{
		if(apiResult != null)
			SageRecordingExtender.logger.logln(apiResult.toString());
		retVal = RecordingExtenderResult.FAILED_STOPPED;
	}
}
The call to SetRecordingTimes is stopping the recording as expected, but it's also dropping into the catch block. I've starred long enough at the API docs, is there something obvious I'm missing here?

Help appreciated.
Reply With Quote
  #2  
Old 03-26-2007, 02:53 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
If you got an error message back from the API call, what does that message say? If you didn't get a message back, what did you get? What's your evidence for assuming that it dropped into the catch block (since it doesn't look like you're printing out the exception)?

What I generally do in such cases is to do a bunch of experimentation with Expression Evaluator to make sure I understand how the API works and what it returns in various cases. If it really returns a Boolean in some cases and a String in others (as the API docs seem to imply), then I'd be inclined to use instanceof instead of a cast exception to discriminate. But I suppose that's a matter of taste.

As a side note, if you're going to be doing a lot of SageTV API calls from Java, you may find the API wrappers in my Tools package handy.
__________________
-- Greg
Reply With Quote
  #3  
Old 03-26-2007, 03:06 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
A quick test in Expression Evaluator seems to indicate that SetRecordingTimes() returns neither a Boolean nor a String, but a sage.e$e (whatever that is). This is the same result type returned by Watch(), and I have to admit I've always been somewhat baffled about what it is and how to use it. The error-handling code surrounding calls to Watch() in the standard STV obviously works, but minor variations on that code do not seem to work as I would have expected.

Maybe Andy or somebody else in the know will chime in with more specific info.
__________________
-- Greg
Reply With Quote
  #4  
Old 03-26-2007, 03:26 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
It's dropping into the catch block because the method that the above chunk is from is returning my FAILED_STOPPED enum value plus it's writing to the logfile I created [SageRecordingExtender.log.logln()], but it's not writing anything useful.

Code:
==========
Mon Mar 26 15:24:08 EDT 2007

Currently recording 'Seinfeld' until Mon Mar 26 15:30:00 EDT 2007
        Monitor: sage.e$e@17777a1
ERROR: Attempt to stop recording failed!
The bold value is the toString() value of the object the API call is returning. Clearly not a Boolean nor a String value, but, as I say, the call is indeed stopping the recording as expected, so it seems as though the call is successful, but not returning a value in accordance with the API docs. Removing the checks on the API call makes everything play nice, but blindly calling something like SetRecordingTimes() without checking the result seems rather foolish to me.

I'm not able to play with anything in Studio as I'm still using the trial version while I experiment to see if Sage will be able to do what I want.
Reply With Quote
  #5  
Old 03-26-2007, 04:02 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by GKusnick View Post
As a side note, if you're going to be doing a lot of SageTV API calls from Java, you may find the API wrappers in my Tools package handy.
While waiting for more info from someone on this issue, I took a quick look at your tools package. This is beautiful!! While I wait for more replies on this issue, I'm going and removing my own wrapper in favour of yours. My wrapper was only partial in that I only loaded what I needed for what I was doing, but was finding that I needed to go back and add to it. Your package solves that problem. Excellent piece of work!

Now I just need to know what a sage.e$e is and how to interpret it.
Reply With Quote
  #6  
Old 03-26-2007, 05:57 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
Apparently it's "a localized error message"

I don't see anywhere obvious where the default STV does anything with that "localized error message".
Reply With Quote
  #7  
Old 03-26-2007, 07:10 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by stanger89 View Post
I don't see anywhere obvious where the default STV does anything with that "localized error message".
Right, in the three existing calls to SetRecordingTimes() it just drops the result on the floor. However there are numerous calls to Watch() where it checks the result and displays it in a popup dialog if != true. What I don't quite understand is how it does that comparison, or converts the result to a string for display, since neither .equals() nor .toString() seems to do anything useful. This may be another case where there's special magic built into the widget interpreter to make these objects play nice with Studio code, but unfortunately not with Java code.
__________________
-- Greg
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
SageMC 6.31 and calling an external application CanadianEh SageMC Custom Interface 6 01-23-2007 06:09 PM
D11 linkup hardware and cabling options - calling all D11 owners IncredibleHat Hardware Support 7 01-14-2007 02:45 AM
Recording drive question (calling all hard drive experts!) Kirby Hardware Support 4 07-17-2006 12:01 PM
Calling all MT users, Demedius plus Channel Order! rsagetv99 SageTV EPG Service 16 04-12-2006 10:58 AM
Calling Girder experts! soulprops77 General Discussion 3 12-09-2005 05:10 PM


All times are GMT -6. The time now is 06:10 PM.


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