Multiple Device Instances

HouseBot Plugin Development Discussions.
Post Reply
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Multiple Device Instances

Post by Osler »

Scott:

Is there anything special that I have to do to allow multiple instances of the same device in HB. I had created a plugin for a thermostat and it worked great. I just installed a second thermostat of the same type and created a new device using my plugin in HB. Now only one of the devices works. The other will go through the steps of initialize, enable, call run, device run completed....but nothing else happens. What am I missing?

Osler
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Multiple Device Instances

Post by ScottBot »

Architecturally, there's nothing special that you have to do. However, if you developed a 'software' device that communicates with some hardware in your PC, then creating a second instance of that device will probably have issues since they can not both concurrently access the physical hardware (e.g. you can only have one open connection to a COM port). That's where the hardware interface comes into play by allowing multiple 'hardware' devices to connect to it and manage the interface.

If that's not the issue, then can you give me some additional details on the device? When you said 'device run complete', that makes it sound like the device is returning from the HBDeviceRun() function. This function should only be returned from when HouseBot is terminated (hTerminate event is set).
Scott
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Multiple Device Instances

Post by Osler »

I am using the HBDotNetBridge to write these plugins, so there is some abstraction of the actual C++ code for sure.

I don't actually have an HBDeviceRun() Function within my plugin...I presume this is handled within the HBDotNetBridge but am unsure.

The device is fairly simple and uses a timer as well as a webclient to periodically poll an IP thermostat and then parse the returned data. In addition, changes in device properties are uploaded to the IP thermostat as they come in. There is no use of outside hardware other than the socket that is required to communicate with the thermostat.

Osler
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Multiple Device Instances

Post by ScottBot »

I wouldn't think that there would be an issue with having multiple socket connections, especially if they are going to different devices.

I didn't write the .net code, so maybe there is an issue with having duplicates that is specific to the .net stuff.
Scott
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Multiple Device Instances

Post by Osler »

I will continue to play around with it and try to come up with more specific questions for you. Thanks.

Osler
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Multiple Device Instances

Post by Osler »

Well, this is a real problem. It's almost as if devices created from the same dll using the hbdotnet bridge are attempting to use the same resources. If I create a separate dll using the exact same code for each device all works fine. This is going to severely limit the ability of others to use any of the plugins I write. With the way things are, I won't be able to write a Sonos plugin, my current SageTV plugin is pretty much hosed since you will have to have a seperate device for each and every extender, the proliphix thermostat plugin may be workable since most people will have a max of 1-3 of these tstats in an install, and the gnuplot graphing plugin will be severely limited in functionality since you won't be able to have a graph device for each data item you want to graph. I am a bit bummed by all of this. Sorry about this folks....I am going to take a break from coding for a while as all of my efforts do not appear to be as extensible as I once thought.

Osler
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Multiple Device Instances

Post by roussell »

Hmm, this is sad news as it had crossed my mind when reading this thread. Most of what I've done thus far has been geared toward a single device so I never ran into the problem. However I had some stuff on the horizon that would definitely need to have multiples. I had wondered early on whether the .NET plugin would allow multiple instances of the same dll but never tried it. Perhaps we can get the source or persuade the developer to take another look at it. There's always C++ I suppose... :wink:

Terry
Post Reply