SageTV Community

SageTV Community (http://forums.sagetv.com/forums/index.php)
-   SageTV Studio (http://forums.sagetv.com/forums/forumdisplay.php?f=34)
-   -   HOWTO: Integrate VB or C# .NET Components Using the SageTV Studio (http://forums.sagetv.com/forums/showthread.php?t=14013)

Narflex 11-10-2005 10:57 AM

HOWTO: Integrate VB or C# .NET Components Using the SageTV Studio
 
I wrote up an article on how to Integrate VB or C# .NET Components into SageTV using the Studio.

Thanks to deria for providing the VB example source for this.

I'm sure many of you will find this useful...and the example can be done using all FREELY available compilers.

Enjoy! Comments are welcome. :)

http://www.sagetv.com/IntegrateVBDot...udio_Curr.html

This example also shows how you would integrate C or C++ code since that's the bridge used to tie in the VB/C# code.

So now we've shown you how to do Java, C, C++, VB and C# integrations. :dance: Let's see what y'all can do. :thumb:

insomniac 11-11-2005 10:44 PM

wow..no comments on this yet!??! I cannot wait till i get some free time to start screwing around with all kinds of hair brain ideas ;)

thx for the recent dump of information!

I.

deria 11-13-2005 12:23 PM

Quote:

Originally Posted by insomniac
wow..no comments on this yet!??!
I.

I did my commenting (which was all entirely positive) in private. :) Seriously, Sage really went above and beyond when it came to implementing this example. I was very, very, very impressed both with their response (ie: that they were interested in doing it) and with their effectiveness (they made it happen very quickly and in an easy to implement way).

I've pretty much finished porting my disk monitor to Sage TV (the example uses the code for the disk monitor). It is slow going, but that is because there is just so much information to absorb. The actual porting is not that difficult. The only real difficulty is learning how to work within the studio environment -- its a very complex and powerful environment, and it takes a little getting used to. I think that would be true of any complex environment though.

I'm still not too sure how I'm going to actually release the plugin when its finished. I know what files I need to distribute, but creating an STVI doesn't sound particularly easy at all. I'm hoping that if I stick with the standard STV and don't make any references to it other than using the MainMenuTheme that I can then just export the tree where all my stuff is (the main display and the configuration popups) and then import it again in another STV. I'll have to play around with it.

I've also been playing around with STV editing in general as a learning tool, which is kind of fun. It gives you a feeling of empowerment. I wanted SageMC 169 to display hours left and GB left on the recordings screen, so I added that. I wanted it to go directly to the show details of whatever I'm watching when I press stop instead of bringing up that "x is stopped" popup, so I changed that. The recording details screen doesn't show which tuner recorded the show or the file size of the recording, so I added that (but I added it in the wrong part of the menu, so it looks dumb right this second). It's really kind of a blast to be able to do this type of thing so easily.

Anyway, off to finish that module.

jreichen 12-05-2005 08:36 PM

JNI.NET
 
I ran across JNI.NET today and am posting the link in case anybody is interested.

http://caffeine.berlios.de/site/deve...net-guide.html

jeffld 12-22-2005 02:36 AM

It is API's like this that attract those who are interested in the journey more than the destination.

I haven't explored this yet, but I think that the fact that it exists is fantastic.

I think more and more companies will be making API's available for their products and will notice that the effort is definitely worth while.

Check out this API for the Roomba Vacuum Robot

Bohica 03-13-2006 11:51 AM

Questions about the example...
 
Hi all,

I am going through this example trying to implement some native code I have written, and am a bit confused about a couple of points. I have not gotten to the STV example to look at what was done with it -- but am focusing now on modifiying my existing .net source ala the examples. Then I will move on to making the Java code, creating the c++ wrapper DLL -- if you will -- and then onto the sage environment. Correct steps??

The question I have is that the example provides a little base code for sending messages from java through to the .net code, but does not really ever demonstrate this correct? I see the definitions for the two functions, and trace them through to the .net VB sample -- where they return existing values. I have this working in my own code now. The sample for the sending messages into the queue -- or for triggering events are never used correct? Am I missing those examples by not pouring over the STV sample? Or does this example not really send messages or receive events. I will want to do both with my application... are there other examples by someone that does utilize the queue infrastructure and trigger events back to the sage level? Am I just lost?

nielm 03-14-2006 03:32 AM

There are no built-in queuing/event mechanisms other than the predefined hooks and listeners for predefined events.

However, you could create your own event/queuing system in the native code, and provide JNI functions such as:

my_jni_queue_class_AddEventToQueue(q,msg)
event=my_jni_queue_class_WaitForNextEvent(q,timeout)

These functions can then be called from the STV -- eg Fork a thread, then loop calling event=my_jni_queue_class_WaitForNextEvent(q,timeout), handling the event accordingly.

For a trivial example, the Sage IMDB code reads several IMDB web pages in the background, and triggers the STV to refresh the results page when more data is available... (search for 'net_sf_sageplugins_sageimdb_DbObject_waitUpdates')

Bohica 03-14-2006 09:57 AM

Much thanks! I will take a look...

beelzerob 05-21-2006 11:43 PM

Linking errors with listed example....
 
I went through the example of building a .NET java DLL, and have some linking errors that the example doesn't talk about. Specifically:

c:\Documents and Settings\Rob\My Documents\Visual Studio Projects\SystemMonitorJNI\SystemMonitorJNI.cpp(20): fatal error C1191: 'mscorlib.dll' can only be imported at global scope
C:\Program Files\Microsoft Visual Studio .NET\Vc7\include\stdio.h(191): error C2624: '(HANDLE,DWORD,LPVOID)DllMain::_iobuf' : local classes cannot be used to declare 'extern' variables

Any help would be appreciated...I may just have a configuration error, although I followed the steps in the tutorial.

Also, I'd like to make sure this isn't all a pointless effort, so here is my goal:

I'm trying to write a driver for the CQC home automation software. This driver will allow a user to query the EPG, find out what is next to record or is already recording, what shows have been recorded, and will allow the user to choose a show to watch (on the Sage host computer, not as in "client"). So in other words, I'm going to want a lot of info, and have a little bit of control.

Is the java plugin the route I would want to take to do this? I have lots of C++ experience, but no java....so it's a little slow goin. Just want to make sure I'm not heading the wrong way.

Thanks for any help.

mogrinz 05-22-2006 10:34 AM

Has anyone looked into using JNBridge or J-Integra to generate the cross-platform calls? We use those tools at my work to let the Java and C# groups share code, and they do all the heavy-lifting for you. You set your classpath, push a button, and get a C# class w/ no effort.

IVB 05-23-2006 02:08 PM

beelzerob - any progress on this? Wondering how it's going.

beelzerob 05-24-2006 08:48 AM

Quote:

Originally Posted by IVB
beelzerob - any progress on this? Wondering how it's going.

:bang:

I'd like to get to a simple "Hello world" type of java plugin to work, to get my feet wet. But I can't even seem to compile the example they gave, so it's a tad frustrating.

My next goal is going to be to try and use the free compilers they mention instead....since no one here seems to know what problem it is I'm experiencing. Maybe there's just too much obsfucation with Visual Studio .NET. :confused:

IVB 05-28-2006 01:26 AM

any help that anyone can provide beelzerob on how to integrate SageTV with CQC would be greatly appreciated. I personally know of 3-5 professional installers that would LOVE to include SageTV as part of their custom designed Home Automation/Home Theater automation solution, but that means much tighter integration than just kicking off SageTV from within CQC. They're waiting on this driver to get done before formally approaching anyone here about it.

Thanks,
- Vivek

beelzerob 05-28-2006 01:48 AM

Well, for now I've forsaken anything Visual .NET related, and am embracing java wholeheartedly. I'm well versed in C++, so it seems pretty familiar. Enough anyway....hopefully the learning will go fast.

What I really need is some good examples of hooking up plugins into Sage, and communicating via ports, and all that. I understand that Neilm's webserver code is considered the standard for this, and I keep reading that it's freely available...but I have yet to be able to find out how to get ahold of a copy for myself. That would be the biggest help.

UFGrayMatter 01-24-2007 12:06 AM

digging up an old thread - just wondering if Sage has some sort of .NET interop, so I can play around w/ the API from within VS C#?

Thanks,
Ryan

cowboyway 08-16-2009 08:15 PM

Delphi?
 
Anyone use these methods with Delphi to do the same? I'm using version 6.

jsonnabend 08-17-2009 08:30 AM

Good to hear someone else is still on D6. I'll be curious to hear if anyone answers. I hadn't even thought of doing any Sage stuff in Delphi, but it's my most proficient language.

- Jeff

owilsky 09-17-2009 11:41 AM

I also would like to know if it is possible to call certain functions from the SageTV API from within a C# program.

Slugger 09-18-2009 11:33 AM

Quote:

Originally Posted by owilsky (Post 381027)
I also would like to know if it is possible to call certain functions from the SageTV API from within a C# program.

Sort of, if you install the remote APIs plugin and call your API calls in C# via that then you could, but there is no way to directly call the Sage API outside of a Java program running in an active SageTV embedded JVM process.

stanger89 09-18-2009 01:16 PM

Well I guess that brings up the question, what do you really want to do? As you may have noticed, the Sage API is really designed for writing code to be called from inside Sage, not so much for external apps to call into Sage from the outside.

Quote:

Originally Posted by Slugger (Post 381261)
...there is no way to directly call the Sage API outside of a Java program running in an active SageTV embedded JVM process.

Not directly, but with a JNI wrapper, you should be able to call into Sage from any language code.


All times are GMT -6. The time now is 07:47 AM.

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