Wrapper for C# plugin development!
-
- HouseBot Special Member
- Posts: 409
- Joined: Tue Jul 13, 2004 9:13 am
- Location: Tigard, OR
Wrapper for C# plugin development!
A while back I was able to make contact with Peter (the guy who wrote the old VB6 wrapper). It's a long story but the short version is that a few days later he sent me the beginnings of a newly-written C# wrapper for HouseBot! (he did it for the challenge ). After a few rounds of revisions I started writing plugins.
That was about four months ago. In the interim I've written four plugins using the wrapper and they are working quite well. I suspect there are issues I haven't run into yet but if anyone is interested I'm happy to post the files needed to use it (I have permission from Peter).
It’s conceptually similar to vbWrapper.
1) Copy HBDotNetBridge.dll into the \housebot\plugins\devices folder
2) Copy HBDotNet.dll into the \housebot folder (!)
3) Create a new C# class library and add a reference to HBDotNet
4) Derive a class from HBDeviceBase (applying the proper attributes)
5) Build your project and put the resulting dll in \housebot\plugins\devices
I'm willing to share the source for the plugins I've written (although it's not the cleanest code ). Additionally I can probably help with some of the "teething" issues regarding developing with the wrapper.
-- Dave
That was about four months ago. In the interim I've written four plugins using the wrapper and they are working quite well. I suspect there are issues I haven't run into yet but if anyone is interested I'm happy to post the files needed to use it (I have permission from Peter).
It’s conceptually similar to vbWrapper.
1) Copy HBDotNetBridge.dll into the \housebot\plugins\devices folder
2) Copy HBDotNet.dll into the \housebot folder (!)
3) Create a new C# class library and add a reference to HBDotNet
4) Derive a class from HBDeviceBase (applying the proper attributes)
5) Build your project and put the resulting dll in \housebot\plugins\devices
I'm willing to share the source for the plugins I've written (although it's not the cleanest code ). Additionally I can probably help with some of the "teething" issues regarding developing with the wrapper.
-- Dave
Re: Wrapper for C# plugin development!
Please share everything you have, including your samples!!!
I had just started on something very similar, but this will be awesome (and much better than what I could have scraped together).
Thanks, and extend my(our) thanks to Peter as well!
Terry
I had just started on something very similar, but this will be awesome (and much better than what I could have scraped together).
Thanks, and extend my(our) thanks to Peter as well!
Terry
Re: Wrapper for C# plugin development!
Ooooo....this sounds good. I, too, am interested in anything you've got.
Is he willing to provide the VB6 wrapper as well?
Osler
Is he willing to provide the VB6 wrapper as well?
Osler
-
- HouseBot Special Member
- Posts: 409
- Joined: Tue Jul 13, 2004 9:13 am
- Location: Tigard, OR
Re: Wrapper for C# plugin development!
I'll post the C# stuff later today (probably around 16:30 Pacific time). I'll ask him about the VB6 wrapper when I get a chance.
-- Dave
-- Dave
-
- HouseBot Special Member
- Posts: 409
- Joined: Tue Jul 13, 2004 9:13 am
- Location: Tigard, OR
Re: Wrapper for C# plugin development!
Here are the files I promised. Install the HBDotNet files per the instructions in the first post in this thread. The EnergyMonitor project is for this whole house energy monitor I recently purchased.
Both plugins should compile and allow you to create the devices. Neither will start though unless you have the associated software/hardware. The two plugin ZIP files contain the Visual Studio 2005 solutions.
The TheaterTek ZIP file actually contains two related plugins and includes code that accesses a separate Access database. Some of the code is specific to my file structure at home though so again it won't work directly on other computers.
The source should give you a good idea of what's possible though. Somewhere I think I have a good "Hello World" plugin. I'll dig around a bit and if I can find it I'll post it as well. Let me know how it goes.
-- Dave
Both plugins should compile and allow you to create the devices. Neither will start though unless you have the associated software/hardware. The two plugin ZIP files contain the Visual Studio 2005 solutions.
The TheaterTek ZIP file actually contains two related plugins and includes code that accesses a separate Access database. Some of the code is specific to my file structure at home though so again it won't work directly on other computers.
The source should give you a good idea of what's possible though. Somewhere I think I have a good "Hello World" plugin. I'll dig around a bit and if I can find it I'll post it as well. Let me know how it goes.
-- Dave
- Attachments
-
- TheaterTekHB.zip
- (35.81 KiB) Downloaded 1649 times
-
- EnergyMonitorHB.zip
- (11.75 KiB) Downloaded 1652 times
-
- HBDotNet.zip
- (30.15 KiB) Downloaded 1567 times
-
- HouseBot Special Member
- Posts: 409
- Joined: Tue Jul 13, 2004 9:13 am
- Location: Tigard, OR
Re: Wrapper for C# plugin development!
See the attached file for a very basic device written using the wrapper. This should compile and work on any HB installation.
-- Dave
-- Dave
- Attachments
-
- HBDotNet device.zip
- (5.28 KiB) Downloaded 1740 times
Re: Wrapper for C# plugin development!
Good stuff...this is a great excuse to get off my a** and learn C#.
The VB wrapper would still be nice to have, though. I am an old hobbyist with much more interest than I have time at the moment.
Osler
The VB wrapper would still be nice to have, though. I am an old hobbyist with much more interest than I have time at the moment.
Osler
Re: Wrapper for C# plugin development!
Osler,
You may not have to learn C#. The beauty of the .NET world is that you can develop in VB.NET or C# and it get compiled into the same binary. While VB.NET is substantially different that VB6 in several places, it shouldn't be quite the jump the VB6 -->C# would be. I don't do a lot with VB.NET but I'll take one of the examples and convert it to see how well it works. I think there are even some web-apps online that will convert smaller stuff for you.
Dave, will this work with the free Express editions of C# or do we nee full-blown Visual Studio? Also, what version of the framework needs to be loaded (3.5 maybe)? My HB server runs very thin and I'd rather not load all of them up.
Thanks again,
Terry
BTW: Somebody should mention this thread over on Cocoontech, I know a big turn-off for some is the requirement to learn c++ to develop plugins for HB. This could help bring in some fresh meat, err, new enthusiasts.
You may not have to learn C#. The beauty of the .NET world is that you can develop in VB.NET or C# and it get compiled into the same binary. While VB.NET is substantially different that VB6 in several places, it shouldn't be quite the jump the VB6 -->C# would be. I don't do a lot with VB.NET but I'll take one of the examples and convert it to see how well it works. I think there are even some web-apps online that will convert smaller stuff for you.
Dave, will this work with the free Express editions of C# or do we nee full-blown Visual Studio? Also, what version of the framework needs to be loaded (3.5 maybe)? My HB server runs very thin and I'd rather not load all of them up.
Thanks again,
Terry
BTW: Somebody should mention this thread over on Cocoontech, I know a big turn-off for some is the requirement to learn c++ to develop plugins for HB. This could help bring in some fresh meat, err, new enthusiasts.
Re: Wrapper for C# plugin development!
Attached is an example device written in VB.NET. I used the 2008 Express Edition and the 3.5 .NET framework. It is a copy of Dave's "HBDotNet device" but rewritten for VB. I used a C# to VB converter here: http://www.developerfusion.com/tools/co ... arp-to-vb/
Most everything converted except for the thread stuff which needed a little tweaking to get VB to create the thread.
Enjoy,
Terry
Most everything converted except for the thread stuff which needed a little tweaking to get VB to create the thread.
Enjoy,
Terry
- Attachments
-
- HBDotNet VBDevice.zip
- HB.NET VB Example Device
- (54.38 KiB) Downloaded 1708 times
Re: Wrapper for C# plugin development!
This is great!!! I have only dabbled in .NET and only when absolutely required. I think I can transition to VB.NET easier than C#. Thank you for the conversion and the heads up.
Osler
Osler
-
- Member
- Posts: 81
- Joined: Thu Sep 01, 2005 7:56 am
- Location: UK
Re: Wrapper for C# plugin development!
Excellent work Dave. Been hoping for this for a long time!
As I know c# I now have no excuss now to write some plugins
First job is to write a plugin for this:
http://www.currentcost.com/product-cc128.html
I'll post it once it's ready.
As I know c# I now have no excuss now to write some plugins
First job is to write a plugin for this:
http://www.currentcost.com/product-cc128.html
I'll post it once it's ready.
Last edited by allanstevens on Wed Mar 04, 2009 1:17 pm, edited 1 time in total.
-
- HouseBot Special Member
- Posts: 409
- Joined: Tue Jul 13, 2004 9:13 am
- Location: Tigard, OR
Re: Wrapper for C# plugin development!
FYI - I've already written a plugin for a similar device (http://www.brultech.com/HomeEnergy/homemodels.html). I've been running the plugin for a month or so and it's working well. I'm even generating graphs using RRD and displaying them on a software remote.
-
- HouseBot Guru Extraordinaire
- Posts: 1121
- Joined: Tue Sep 28, 2004 7:49 am
- Location: The Netherlands
Re: Wrapper for C# plugin development!
Dave,dlmorgan999 wrote:See the attached file for a very basic device written using the wrapper. This should compile and work on any HB installation.
-- Dave
I took this example and compiled it and did all of the other stuff you mentioned in previous posts, but something is wrong with the code. I find the Clock device after adding it, but it produces an error like "Encountered an improper argument".
I also looked at your other examples and combined a few parts to get something to work. It has something to do with creating the properties:
[HBProperty("Current Time", ePropertyType.ptTime, "")]
Properties.Add(new HBProperty("Energy Monitor COM Port", "Energy Monitor COM Port", true, "COM4", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptAlpha, "Enter the COM port used to communicate with the ECM-1220 (i.e. COM4)"));
The first one produces an error and the second one doesn't give me anything. Obviously I started fresh everytime so I deleted the registered properties from the property manager. Which was a pain actually since the protection flag is set. I had to delete the properties using MS Access.
So in short: Does your example device work correctly in your setup?
I get no errors on the compile and the other dll's are put in the right directories.
I would very much like to get this to work since I am running into some restrictions using vbscript.
Richard
Re: Wrapper for C# plugin development!
Ok, I've been playing with this in vb.net and I am able to create a device with associated properties and populate said properties. I think I am having some issues with late binding using CreateObject due to my lack of knowledge with regard to references in .NET. I should be able to resolve this.
This is the format that I have found to work for property creation. The extended version doesn't appear to be supported in HBDotNet.dll posted above. There also doesn't appear to be a method for property value population at device creation via the wizard. Not a huge deal, though. Just requires documentation or not putting the device out there for public consumption.
I am working on converting my Yahoo Weather script to a device. When it's done I will post the source as a starting point for others. Right now I am simply having issues moving from VB6 to vb.NET. I have to say it is quite cool to have HB creating my own personal devices. Very nice!
Osler
Richard:Richard Naninck wrote:
<HBProperty("Current Time", ePropertyType.ptTime, "")> _
This is the format that I have found to work for property creation. The extended version doesn't appear to be supported in HBDotNet.dll posted above. There also doesn't appear to be a method for property value population at device creation via the wizard. Not a huge deal, though. Just requires documentation or not putting the device out there for public consumption.
I am working on converting my Yahoo Weather script to a device. When it's done I will post the source as a starting point for others. Right now I am simply having issues moving from VB6 to vb.NET. I have to say it is quite cool to have HB creating my own personal devices. Very nice!
Osler
-
- HouseBot Special Member
- Posts: 409
- Joined: Tue Jul 13, 2004 9:13 am
- Location: Tigard, OR
Re: Wrapper for C# plugin development!
I'm sorry I haven't been able to be more active on this. I'm pretty busy at work right now and when I get home I'm not spending much time working on HB - just using and enjoying it .
When I was first testing the wrapper we discovered some issues with properties. I don't remember exactly what they were any more but I now use a different method for creating them. Here is a code snippet that shows how I do it (including use of the wizard - see the last three properties):
This code along with the following to create property values exists in the OnRegisterProperties method.
I'm on a long weekend and I may have a bit more time to respond to things so feel free to ask other questions if you have any.
-- Dave
When I was first testing the wrapper we discovered some issues with properties. I don't remember exactly what they were any more but I now use a different method for creating them. Here is a code snippet that shows how I do it (including use of the wizard - see the last three properties):
Code: Select all
Properties.Add(new HBProperty("TheaterTek Title", "TheaterTek Title", true, "", eIOType.ioInputOnly, true, true, true, false, ePropertyType.ptAlpha, ""));
Properties.Add(new HBProperty("TheaterTek Time", "TheaterTek Time", false, "", eIOType.ioInputOnly, true, true, true, false, ePropertyType.ptAlpha, ""));
Properties.Add(new HBProperty("A/V Status", "Status", false, "", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptAlpha, ""));
Properties.Add(new HBProperty("TheaterTek Chapter", "TheaterTek Chapter", false, "", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptNumeric, ""));
Properties.Add(new HBProperty("TheaterTek Chapter Count", "TheaterTek Chapter Count", false, "", eIOType.ioInputOnly, true, true, true, false, ePropertyType.ptNumeric, ""));
Properties.Add(new HBProperty("TheaterTek Command", "TheaterTek Command", false, "", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptAlpha, ""));
Properties.Add(new HBProperty("TheaterTek Title Path", "TheaterTek Title Path", false, "", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptAlpha, ""));
Properties.Add(new HBProperty("TheaterTek Title Number", "TheaterTek Title Number", false, "", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptNumeric, ""));
Properties.Add(new HBProperty("TheaterTek IP Address", "TheaterTek IP Address", false, "", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptAlpha, "1:Enter the IP Address used for the TheaterTek server"));
Properties.Add(new HBProperty("TheaterTek IP Port", "TheaterTek IP Port", false, "2663", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptNumeric, "2:Enter the IP Port used by the TheaterTek server (typically 2663)"));
Properties.Add(new HBProperty("TheaterTek Autokiller IP Port", "TheaterTek Autokiller IP Port", false, "2664", eIOType.ioInputAndOutput, true, true, true, false, ePropertyType.ptNumeric, "3:Enter the Autokiller IP Port used by the TheaterTek server (typically 2664)"));
Code: Select all
HBModule.CreateDevicePropertyValue("TheaterTek Command", "Next");
HBModule.CreateDevicePropertyValue("TheaterTek Command", "Previous");
HBModule.CreateDevicePropertyValue("TheaterTek Command", "DVD Menu");
-- Dave