Please login or register.

Login with username, password and session length

Author Topic: Multiple programs accessing ActiveHome  (Read 7730 times)

John_MacX10

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 5
Multiple programs accessing ActiveHome
« on: March 18, 2010, 10:41:15 PM »

I have a VB 2008 program that sends X10 commands and monitors commands that runs continuously on my server.  I also have an ASP.NET webpage that resides on the same server that can send X10 commands.  Each works fine when run separately.  Once I have run the webpage, the VB program stops detecting X10 commands.  But can still send them.  The standard ActiveHome interface where you setup modules, macros and timers, will also hang.

I'm guessing you can't have multiple programs access ActiveHome library at once?

I would dispose of it once done then reopen, but not sure how to do that.

Anyone run into this problem?

Thanks

Added:  I just saw that I had posted this a while back, but never got a notify of the response.  It is at:
http://forums.x10.com/index.php?topic=14898.0

So I guess my question is how to dispose of ActiveHome?  ActiveHomeObj.dispose() ?
In the VB program that runs continuously, I can only declare " Dim WithEvents ActiveHomeObj As ActiveHome" outside of a subroutine, so don't see how to dispose of it in the program, then reopen it when needed again.

Perhaps the problem is disposing of it in the webpage that reloads many times.  I should try that.
« Last Edit: March 18, 2010, 11:04:44 PM by John_MacX10 »
Logged

-Bill- (of wgjohns.com)

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 81
  • Posts: 1340
  • He's just this guy. You know?
    • wgjohns.com
Re: Multiple programs accessing ActiveHome
« Reply #1 on: March 20, 2010, 02:33:07 AM »

My BVC software is written in VB 2008, and I haven't noticed any issues with BVC receiving X10 signals when AHP is running.

Reading your other post, and my reply in it, I still think your ASP.NET web page isn't correctly releasing the ActiveHome Scripting object and that is somehow crapping up the connection to other programs that are referencing it.

Your VB references sound correct, and I don't explicitly destroy the "ActiveHomeObj" (I named mine "X10Obj") when BVC closes.

I wouldn't suggest creating and destroying the  "ActiveHomeObj" repeatedly within a program.  I instantiate it once at program start up as a "global" and then reference it throughout the program.

Hope that gives you some insight into your problem.  Not sure it will, but we can always hope.

 >!
Logged
-Bill- (of wgjohns.com)
bill@wgjohns.com

In the real world, the only constant is change.

When I'm online you can find me in the Home Automation Chat Room!

John_MacX10

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 5
Re: Multiple programs accessing ActiveHome
« Reply #2 on: March 26, 2010, 04:04:27 PM »

Hi Bill

Thanks for the thoughtful reply.  I don't have a lot of experience in unmanaged code and COMs, but also think my problem is how the webpage is using and releasing AHP.  Let me give a little more detail.

Again, I have a resident program on the server that is always running.  It is interfaced to a CM15a computer interface.  This program "connects" to the interface by creating an object with:

ActiveHomeObj = CreateObject("X10.ActiveHome")

as you saw in the code.  It can send X10 commands from within the program with the:

ActiveHomeObj.SendAction("sendplc", "m1 on") for example

and it works fine.  I can also detect if an X10 module like a motion detector or a remote handheld has sent an X10 command with the:

Sub ActiveHome_RecvAction(ByVal bszRecv As Object _
                            , ByVal v1 As Object _
                            , ByVal v2 As Object _
                            , ByVal v3 As Object _
                            , ByVal v4 As Object _
                            , ByVal v5 As Object _
                            , ByVal vRes As Object) Handles ActiveHomeObj.RecvAction

since I have declared:

Dim WithEvents ActiveHomeObj As ActiveHome

in the resident program to detect events (basically an interrupt).

Inside this sub I look at what command was sent and decide on appropriate action.

This all works perfectly for the resident program.

The problem is when I attempt to have a webpage on the same server set X10 commands from the page.  The VB "code behind" is basically the same as the resident program except I don't use the ActiveHome_RecvAction to detect X10 commands...only send them.

In the Webpage, I create the same AHP object and I have radio buttons that when clicked do the ActiveHomeObj.SendAction function.  It is set up so that the button does an AutoPostBack.  This also works fine for the Webpage.

But once the Webpage is run, the resident program does not see X10 events and the ActiveHome_RecvAction subroutine is never called.  And as you say, things get crapped up.

Since there can be many postbacks and reloading of the webpage in a session (one per button click at least), I figured I was creating many X10 objects and not releasing them.  I tied ActiveHomeObj.Dispose(), but that is not supported by AHP.  There may be other ways to release the AHP resources, but I do not know how.

The only way to clear the problem is to reboot.  So I have to fix it properly.

Hope this gives a little better picture of what I'm trying to do.

Best,
John



Logged

-Bill- (of wgjohns.com)

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 81
  • Posts: 1340
  • He's just this guy. You know?
    • wgjohns.com
Re: Multiple programs accessing ActiveHome
« Reply #3 on: March 27, 2010, 12:55:58 AM »

Not sure it will make any difference, but in my VB program, I instantiate the X10 Active Home object as follows:

ActiveHomeObj = New ActiveHome

As opposed to your:

ActiveHomeObj = CreateObject("X10.ActiveHome")

Logged
-Bill- (of wgjohns.com)
bill@wgjohns.com

In the real world, the only constant is change.

When I'm online you can find me in the Home Automation Chat Room!
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.