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 09-02-2006, 12:10 AM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Custom STV - Access to Placeshifter

I have a quick question about the placeshifter code. I will be living in Germany for the next two years and I have successfully set up a DVB-S card for free to air channels. I also left a server computer at my parents to record cable from the US. Currently I download the shows through a script with PCanywhere.
I downloaded the placeshifter trial and I believe the quality will work for most things I want to do (only a 27" SDTV). My question is, if I purchase the placeshifter license, will I be able to create a custom STV for Sage on my HTPC that will still do the regular HTPC functions for the DVB-S card and local recordings, but that will be able to access the US computer through the placeshifter client without leaving the UI.

I guess my main question is, will it be as easy as editing the sage stv, or is there a lot more involved.

thanks
Josh
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #2  
Old 09-02-2006, 12:51 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
If I'm understanding the question right, the answer is no. The Placeshifter client is not just an STV skin for the regular SageTV application. It's a completely separate piece of software. So you can't just click a menu item in SageTV running locally and suddenly be in Placeshifter mode talking to a server on the other side of the world without ever leaving the Sage UI. You would have to quit the local UI and start up a placeshifter client instead.

However it wouldn't be hard to customize your local STV to automate that process of switching back and forth between clients. For instance you could write some code in Studio to launch a batch file or script just before quitting. The script would then wait a few seconds before firing up the Placeshifter client, wait in the background for Placeshifter to exit, and then relaunch the regular SageTV UI. Or something along those lines.

This would be a good argument for running your local SageTV in service mode, so that closing the UI doesn't interfere with local recording.
__________________
-- Greg
Reply With Quote
  #3  
Old 09-02-2006, 02:56 AM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Quote:
Originally Posted by GKusnick
However it wouldn't be hard to customize your local STV to automate that process of switching back and forth between clients. For instance you could write some code in Studio to launch a batch file or script just before quitting. The script would then wait a few seconds before firing up the Placeshifter client, wait in the background for Placeshifter to exit, and then relaunch the regular SageTV UI. Or something along those lines.

This would be a good argument for running your local SageTV in service mode, so that closing the UI doesn't interfere with local recording.
Thanks. It's unfortunate that the two programs can't be incorporated for seamless switching. But I think this will work. I was just looking for a way to incorporate it into the menus of my normal SageTV. I will work on making a special menu item to open placeshifter, which will follow your recommendations. I am not new to programming, I have been programming visual basic, matlab, and other enginnering applications for years, I am just starting to branch into Sage and automation. I know the process for batch files, is there some reference I can read on how I might run a script that has delays and has some type of listener for closing the program?

One other question, Is there a way to skip over the "Connect Screen" in placeshifter, so I can have it automatically hook up to the same server with the same settings each time? That way the script would take me right to the login screen.

thanks
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #4  
Old 09-02-2006, 05:36 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
Quote:
Originally Posted by kuch68
Thanks. It's unfortunate that the two programs can't be incorporated for seamless switching. But I think this will work. I was just looking for a way to incorporate it into the menus of my normal SageTV.
My customisable menus plugin allow you to easily add a new menu item which can sleep Sage; execute placeshifter, and then auto-unsleep Sage when placeshifter exits
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #5  
Old 09-02-2006, 07:04 AM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Quote:
Originally Posted by nielm
My customisable menus plugin allow you to easily add a new menu item which can sleep Sage; execute placeshifter, and then auto-unsleep Sage when placeshifter exits
nielm,
Thanks for the info. I should have checked back earlier. I already worked out most of the details on my own. I have no problem launching it now from the STV modifications I made. I do see one difference. Does your customizable menus contain special instructions/code that allow the waitforexit argument? Because I can run the code to execute the placeshifter program, but my SageTv server never goes to sleep. Is there additional code I can add either to the ActionWidget properties or the xml file that would mimic your waitforexit=0?

thanks
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #6  
Old 09-02-2006, 09:19 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
How are you with Java

The ExecuteProcess() returns a java.lang.Process object.

The Process java object has a waitFor() function, so you could do (untested):
Code:
 (action) +- SageCommand("Power Off")
 (action) +- p=ExecuteProcess("SageTVPlaceshifter.exe",null,null,true)
 (action)    +- (action) Fork()
 (action)       +- java_lang_Process_waitFor(p)
 (action)          +- SageCommand("Power On")
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #7  
Old 09-02-2006, 10:16 AM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Quote:
Originally Posted by nielm
How are you with Java

The ExecuteProcess() returns a java.lang.Process object.

The Process java object has a waitFor() function, so you could do (untested):
Code:
 (action) +- SageCommand("Power Off")
 (action) +- p=ExecuteProcess("SageTVPlaceshifter.exe",null,null,true)
 (action)    +- (action) Fork()
 (action)       +- java_lang_Process_waitFor(p)
 (action)          +- SageCommand("Power On")
Well, if it is any indication I just downloaded the JDK package today. So I guess that would make me an absolute beginner. But, I am not intimidated by programming so my next stop will be amazon.com to pick up a shiny new java how to....

thanks for your help.
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #8  
Old 09-02-2006, 11:28 AM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Nevermind, I still need to learn JAVA but your code helped greatly.

I need to make one change though to make it work the way I wanted. The SageCommand("Power Off") need to be the first child of the ExecuteProcess widget. Then it worked perfectly.

I am almost there, one more question for ya...

I want to be able to start and stop placeshifter in full screen mode after logging in. Now the starting in full screen mode might not be feasible, but I imaging there could be an internal SageCommand to completely shut down the application (similar to selecting the x in the top of the window when not in full screen mode). I tried "Exit" and "Close", but these didn't do anything.

Or is this another hurdle to be accomplished by JAVA?

thanks
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #9  
Old 09-02-2006, 12:00 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
There's no SageCommand() string for Exit, but there is an Exit() function in the API. SageTV API docs, if you haven't found them yet, are here.

Also click here for Java 1.4 API docs, and here for online Java tutorials. I was able to learn everything I needed to know about Java from these, without spending any money on how-to books. (Note, though, that the tutorials are geared toward later versions of Java than the one that installs with Sage.)
__________________
-- Greg
Reply With Quote
  #10  
Old 09-02-2006, 12:06 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by kuch68
I know the process for batch files, is there some reference I can read on how I might run a script that has delays and has some type of listener for closing the program?
Windows includes a scripting facility that can execute scripts written in JScript, VBScript, and other third-party scripting languages such as Perl and Python. For many purposes this is a better approach than writing batch files (although you may have to train your virus scanner not to panic when it sees a VBScript trying to execute). Windows script docs are here.
__________________
-- Greg
Reply With Quote
  #11  
Old 09-02-2006, 12:31 PM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
and I also have an ExitSage plugin (which needs my dynamic menus)...
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki

Last edited by nielm; 09-02-2006 at 12:38 PM.
Reply With Quote
  #12  
Old 09-03-2006, 01:03 AM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Quote:
Originally Posted by nielm
and I also have an ExitSage plugin (which needs my dynamic menus)...
nielm + GKusnick,

Thanks for all your help. It is working perfectly as of last night. These little exercises have certainly peaked my interest. I am definitely going to devote some time reading through the links you passed along.

Maybe one day I'll be able to create some cool imports and customizations.
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #13  
Old 09-06-2006, 01:42 PM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
nielm + GKusnick,

One more question for you. The links you were provided were great and I have totally immersed myself. The JavaBeans program was a huge help for debugging my first coding efforts. I am not doing anything in particular, but was just trying to create a parsing program to test importing data into sage.

My lack of knowlege deals with the executable part of java from within Sage. I have a program no that works great to open a urlstream to a weather website, and pull out temperature information. Though I have only figured out how to make it work by creating the "public static void main" class and call the class constructers from within the program.

Is there anywhere out there that details the method for running the stand alone jar files (whether in sage or not) and calling specific methods?

I didn't mean to turn this into a Java thread. I am going to get a Java book anyways since it seems like there is so much you can do with it.

thanks
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #14  
Old 09-06-2006, 01:58 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
I'm not entirely sure I understand the question. P. 137 of the Studio manual describes how to call your Java code from Studio's widget language, if that's what you're asking. You can instantiate arbitrary Java objects and call their methods, using a somewhat klunky syntax.

If you're asking how to run Java code in a separate thread in the background while SageTV executes, there are two ways to do that. You can the Studio API to Fork() a new thread in your widget code, and then call into Java from there. Or you can specify a list of runnable Java classes in the load_at_startup_runnable_classes property in your .properties file to be loaded and started when Sage starts.

If you're asking how to write a standalone Java app that can be run from the Windows command prompt or whatever, the Hello World tutorial should cover that.
__________________
-- Greg

Last edited by GKusnick; 09-06-2006 at 02:01 PM.
Reply With Quote
  #15  
Old 09-07-2006, 01:31 PM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Sorry, now that I look at my post it is kind of confusing. My main question is where and how to access my code once it is written. It looks like to me that all applications are distributed in .jar files for sage to access.

Say I have a Java001.jar package with a class querySomething and methods getInfo() and sendInfo(). Can I just compile the jar file and stick it in sage and access the specific methods via

Java001_querySomething_getinfo()

Also, when you make something run using the java command from the command line you are using a .java file and subsequent class file, but it looks like you need a main class which then starts your code process as soon as you load it from the java command.

Is this needed for sage as well?

I seem to be doing great at the programming and running things in JavaBeans, I just can't understand the sage interface.

thanks
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #16  
Old 09-07-2006, 04:35 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
The name of your JAR file is not really relevant for calling your code from Sage. What matters is the package declaration at the top of your file. So if your code looks like this:

Code:
package some.package.name;

class querySomething
    {
    public void getInfo()
        {
        }
    }
then in Studio you want to write something like this:

Code:
+ var = new_some_package_name_querySomething();
+ some_package_name_querySomething_getInfo(var);
If you don't have a package statement at the top of your file, you should put one there. Pick a package name that's not likely to conflict with anybody else's. Then all you need to do is drop your JAR file into the SageTV\JARs folder and the above code sample should work.

This is assuming you want the getInfo() code to run synchronously in the UI thread, i.e. the UI will be paused and you'll see the spinning Sage icon on screen while your code is thinking. If that's good enough, then you're done.
__________________
-- Greg
Reply With Quote
  #17  
Old 09-08-2006, 01:16 PM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Exactly the information I was looking for!

I have been trying a couple things without much luck so maybe under your careful eye you can point out my error. I made a simple class that should return a string when the method is called. Here is the code

package jbk.projects;

public class reportWeather {
public String weatherLocation;

public String returnName() {
weatherLocation = "Stuttgart";
return weatherLocation;
} }

All I wanted to do was place the name "Stuttgart" in a menu selection to make sure the communication between SageTV and my java code was working before I tackled bigger things. Here is the sage hierarchy:

Menu
+ Menu Panel
+ Item(Name = "Weather")
+ Action(jbk_projects_reportWeather_returnName(newWeath))
+ Text (untitiled)
+ Hook (BeforeMenuLoad)
+ Action(newWeath = new_jbk_projects_reportWeather())

I tried a couple different variations on this theme (like using aVarName = jbk_projects_reportWeather_returnName(newWeather)), with the JAR file compile (through NetBeans) and placed in the SageTV Jars folder. Nothing seems to rename the Item widget.

This is tougher than I thought. Kudos to those that can create reliable efficient programs to run in sage.

thanks
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
Reply With Quote
  #18  
Old 09-08-2006, 02:18 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Arrow

Quote:
Originally Posted by kuch68
Menu
+ Menu Panel
+ Item(Name = "Weather")
+ Action(jbk_projects_reportWeather_returnName(newWeath))
+ Text (untitiled)
+ Hook (BeforeMenuLoad)
+ Action(newWeath = new_jbk_projects_reportWeather())

I tried a couple different variations on this theme (like using aVarName = jbk_projects_reportWeather_returnName(newWeather)), with the JAR file compile (through NetBeans) and placed in the SageTV Jars folder. Nothing seems to rename the Item widget.

thanks
The problem is that the newWeath object you create in the hook will not exist any more (nor will it be visible) when the text widget gets evaluated, so the returnName() method will always be called with null. Define an attribute for the panel, and assign the object to this attribute, this will ensure that the object will be accessible from all child widgets of the panel.

And a tip: code fragments in a post are easier to read if you enclose them in "[code]" tags :

Code:
 
package jbk.projects;

public class reportWeather {

   public String weatherLocation;

   public String returnName() {
      weatherLocation = "Stuttgart";
      return weatherLocation;
   } 
}
Dirk
Reply With Quote
  #19  
Old 09-08-2006, 02:52 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by flachbar
Define an attribute for the panel, and assign the object to this attribute, this will ensure that the object will be accessible from all child widgets of the panel.
It's not clear from the posted code whether the BeforeMenuLoad hook is a child of the panel or of the menu. My intuition (I could be wrong) is that for proper hook operation it needs to be a direct child of the menu, in which case the attribute should be a child of the menu as well (not of the panel) so that its scope includes both the hook and the panel code.

Also, call me old-fashioned, but I like to arrange the widgets in the order they actually execute (i.e. declaration before initialization before use). It makes no difference to the widget evaluator, but I think it makes the logic easier to follow for the human reader.

Code:
Menu
+ Attribute newWeath
+ Hook (BeforeMenuLoad)
  + Action(newWeath = new_jbk_projects_reportWeather())
+ Menu Panel
  + Item(Name = "Weather")
    + Action(jbk_projects_reportWeather_returnName(newWeath))
      + Text (untitiled)
__________________
-- Greg
Reply With Quote
  #20  
Old 09-09-2006, 01:57 AM
kuch68 kuch68 is offline
Sage User
 
Join Date: Feb 2006
Location: Koblenz, Germany
Posts: 28
Thumbs down

Gkunsik,
I did have the beforeMenuLoaded hook under the correct tree, sorry for the confusion as I spaced the text out but didn't realize that it would be compressed back down without HTML formatting.
flachbar,
That did the trick, my java programming and sageTV are now talking to each other and generally playing nice.

I have run into one more formatting question. Once I create the new instance in sage, and I want to reference the new instance but pass along a string argument, how is that written in the action widget?

I have tried:
Code:
+ Panel (SubMenu)
     + Action (jbk_projects_reportWeather_getLocator(newWeath, "Stuttgart")
           + Text (Untilted)

Where the java code is

public String getLocator(String newLocation){    
     ....
     return ...;
}
thanks
__________________
Server and Media Center - Intel Core Duo 2x2.50 Ghz, Asus P5N7a-VM (Onboard HDMI and Optical Audio), 2GB Ram, Hauppauge HVR-1300, SageTV Beta v7.0.9, nVidia PureVideo decoder
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 04:20 PM.


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